如何获取成交均价?
使用保留字(Reserve Word)不能直接获得成交均价字段。 使用OrderTicket发送的委托可以通过Order对象获得其平均成交价格。 具体用法见示例。
示例1:使用Order获得成交均价
using guosen;
using elsystem;
using tsdata.common;
using tsdata.marketdata;
vars:
guosen.OrderTicket otk1(null),
guosen.Order ord(null),
string accID("410038122059");
method void AnalysisTechnique_Initialized( elsystem.Object sender, elsystem.InitializedEventArgs args )
begin
otk1 = new guosen.OrderTicket;
otk1.Symbol = "000002.SZ";
otk1.Quantity = 100;
otk1.Account = accID;
otk1.Action = OrderAction.Buy;
otk1.SymbolType = tsdata.common.SecurityType.Stock;
otk1.Type = tsdata.trading.OrderType.Limit;
otk1.Duration="GFD";
otk1.LimitPrice = 26.28;
ord = otk1.Send();
ord.Updated += ord_Updated;
end;
Method void ord_Updated(elsystem.Object sender,guosen.OrderUpdatedEventArgs args)
Begin
print(DateTime.Now.ToString()+ "," +args.OrderID.ToString()+","+
args.State.ToString()+",成交均价:"+numtostr(args.Order.AvgFilledPrice,2));
End;
//打印语句输出栏结果示例:
//2016/12/5 16:42:32,,sending,成交均价:0.00
//2016/12/5 16:42:32,0-_410-0381-2205-9_20-1612-05_1-0403-6257,queued,成交均价:0.00
//2016/12/5 16:42:32,0-_410-0381-2205-9_20-1612-05_1-0403-6257,received,成交均价:0.00
//2016/12/5 16:42:32,0-_410-0381-2205-9_20-1612-05_1-0403-6257,partiallyfilled,成交均价:26.28
//2016/12/5 16:42:32,0-_410-0381-2205-9_20-1612-05_1-0403-6257,filled,成交均价:26.28