如何使用OrderTicket发送港股通委托?

使用OrderTicket发送港股通委托,具体用法见示例一:

示例1:使用OrderTicket发送港股通委托

using guosen;
using tsdata.marketdata;
using tsdata.common;

vars:
    OrderTicket otk(null),
    Order ord(null),
    SymbolAttributesProvider SAP(null),
    string sym("00001.HG"); //深港通为SG结尾,沪港通为HG结尾//
method void AnalysisTechnique_Initialized( elsystem.Object sender, elsystem.InitializedEventArgs args ) 
begin
    SAP = new SymbolAttributesProvider;
    SAP.Symbol = sym;
    SAP.StateChanged += SAP_StateChanged;
    SAP.Load = TRUE;
end;

Method void SAP_StateChanged(elsystem.object sender,tsdata.common.StateChangedEventArgs args)
Begin
    if(args.NewState = DataState.loaded)then
    Begin
        sendOrder(SAP.Symbol,SAP.UnitsOfTrade); //发送数量为最小的交易单位//
    End;
End;

Method void sendOrder(string sym,double quantity)
Begin
    otk = new guosen.OrderTicket;  
    otk.Symbol = sym;
    otk.Quantity = quantity;
    otk.BypassClientValidation = True;//跳过客户端验证,若下单采用高级限价单,请设置为False//
    otk.Account = getCashAccount();
    otk.Action = OrderAction.Buy;
    otk.SymbolType = tsdata.common.SecurityType.Stock;
    otk.Type = tsdata.trading.OrderType.Limit;//港股通支持限价单,不支持市价单//
    otk.LimitPrice = 91.95;
    otk.Duration="ELO";//自动选择期限,港股通支持为ALO(竞价限价),ELO(增强限价),或采用AUT(自动)//
    otk.ExtendedProperties.SetItem("OrderName", "customOrderIDxxxxxxxx");//自定义的OrderName//
    ord = otk.Send();//发送委托//
End;

//获取股票账户//
Method string getCashAccount()
vars:string acct, int loop, int count;
Begin
    count = getnumaccounts();
    For loop = 1 to count
    Begin
        acct = getaccount(loop);
        if(Getaccounttype(acct) = 1)then
        Begin
            Return acct;
        End;
    End;
    Return "";    
End;
Copyright © 1998-2018 国信证券股份有限公司 版权所有发布时间: 2018-05-14 14:58:15

results matching ""

    No results matching ""