思迷思: 需要的函数有点像酒,思路是酒量。 AB的函数我知道的不太多,帮助里都有,如果你感兴趣了,我再给你其他的。 AB是个非常开放的软件,对你来讲要开发点什么肯定也不是问题。 最近我在弄自动化,没有什么不得了的,也就是AB+http://www.amibroker.com/at/at1008beta.exe +tws 昨天我看了帮助上的一个自动化交易系统的例子,你看看再说,其实最要紧的是交易办法,没有好的妙法,其他再好也没有用,输起来也许更壮烈: // Param block TriggerOrder= ParamTrigger("Place order","Click here to place order"); Mode=ParamToggle("Mode","Modify existing|Always place new order"); ACT = ParamList("Action", "BUY|SELL|SSHORT"); OT = ParamList("Order Type", "MKT|LMT|STP"); TIF = ParamList("Time In Force", "DAY|GTC|IOC"); Ticker = ParamStr("Ticker",Name()); NumShares = Param("Number of Shares",10,10,100,10); LimitPrice = LastValue(C) + Param("Limit Price offset",0,-0.1,0.1,0.01); StopPrice = LastValue(C) + Param("Stop price offset",0,-0.1,0.1,0.01); Transmit = ParamToggle("Transmit","Do NOT transmit|Transmit",0); TriggerCancel = ParamTrigger("Cancel Order","Click here to Cancel order"); Msg = ""; // this variable stores error message text // create instance of trading interface ibc = GetTradingInterface("IB"); // retrieve orderID from previous run, will be empty if no order was placed before OrderID = StaticVarGetText("OrderID"+Ticker); if( TriggerOrder ) { // check if we are connected OK if( ibc.IsConnected() ) { if( Mode == 1 ) OrderID = ""; // if mode set to 'always new' then clear orderid // place orders only if we do not have already open position on this symbol // place or modify the order - don't transmit yet OrderID = ibc.ModifyOrder( OrderID, Ticker, ACT, NumShares, OT, LimitPrice, StopPrice, TIF, Transmit); // store orderID for next run so we know which order to modify StaticVarSetText("OrderID"+Ticker, OrderID); if( Mode == 1 ) Msg = "New order has been placed with ID = "; else Msg = "Order placed/modified with ID = "; Msg = Msg + OrderID + " on " + Now(); } else { Msg = "Placing order failed because of no connection to TWS"; } } if( TriggerCancel ) { if( OrderId != "" ) { if( ibc.CancelOrder( OrderId ) ) Msg = "Request to cancel order " + OrderID + " sent successfully"; else Msg = "Request to cancel order " + OrderID + " failed."; } else Msg = "Can not cancel order becase OrderID is empty"; } // monitoring code Title = Msg + "\nLast TWS message: "+ ibc.GetLastError(0) + "\nAvailable funds: " + ibc.GetAccountValue("AvailableFunds")+ " Gross Pos. Value: " + ibc.GetAccountValue("GrossPositionValue")+ "\nOrderID = "+OrderId+ "\nTicker = "+Ticker+ "\nAction = "+ACT+ "\nShares = "+NumToStr(NumShares,1.0)+ "\nOrderType = "+OT+ "\nLimitPrice = "+NumToStr(LimitPrice,1.3)+ "\nStopPrice = "+NumToStr(StopPrice,1.3)+ "\nTimeInForce= "+TIF+ "\nTransmit = "+NumToStr(Transmit,1.0)+"\n"+ "\nGetStatus = "+ibc.GetStatus( OrderID )+ "\nGetPositionSize = "+ibc.GetPositionSize( Ticker )+ "\nIsConnected = "+NumToStr(ibc.IsConnected(),1.0);