Ejemplo n.º 1
0
        private void OnRtnTrade(IntPtr pTraderApi, ref CThostFtdcTradeField pTrade)
        {
            tdlog.Info("时{0},合约{1},方向{2},开平{3},价{4},量{5},引用{6},成交编号{7}",
                       pTrade.TradeTime, pTrade.InstrumentID, pTrade.Direction, pTrade.OffsetFlag,
                       pTrade.Price, pTrade.Volume, pTrade.OrderRef, pTrade.TradeID);

            //找到自己发送的订单,标记成交
            string strSysID = string.Format("{0}:{1}", pTrade.ExchangeID, pTrade.OrderSysID);
            string strKey;

            if (!orderMap.TryGetValue(strSysID, out strKey))
            {
                return;
            }

            GenericOrderItem item;

            if (orderMap.TryGetValue(strKey, out item))
            {
                MultiOrderLeg leg   = item.GetLeg(CTPAPI.FromCTP(pTrade.Direction), pTrade.InstrumentID);
                SingleOrder   order = leg.Order;
#if CTP
                double Price = pTrade.Price;
#elif CTPZQ
                double Price = Convert.ToDouble(pTrade.Price);
#endif
                int Volume = pTrade.Volume;

                int LeavesQty = (int)order.LeavesQty - Volume;
                EmitFilled(order, Price, Volume, CommType.Absolute, 0);

                // 成交完成,清理数据
                OnRtnTradeLastStatus(item, pTrade, strSysID, strKey);
            }
        }
Ejemplo n.º 2
0
        public override void Add(SingleOrder order, TextCommon t)
        {
            if (Index >= GetLegNum())
            {
                return;
            }

            Leg[Index] = new MultiOrderLeg {
                Order = order, OpenClose = t.OpenClose
            };
            ++Index;
        }
Ejemplo n.º 3
0
 public override void Add(SingleOrder order, TextCommon t)
 {
     if (order.Side == Side.Buy)
     {
         Buy = new MultiOrderLeg()
         {
             Order = order, OpenClose = t.OpenClose
         };
     }
     else
     {
         Sell = new MultiOrderLeg()
         {
             Order = order, OpenClose = t.OpenClose
         };
     }
 }
Ejemplo n.º 4
0
 public override void Add(SingleOrder order, TextCommon t)
 {
     Leg = new MultiOrderLeg {
         Order = order, OpenClose = t.OpenClose
     };
 }
Ejemplo n.º 5
0
 public override void Init(TextCommon t)
 {
     base.Init(t);
     Leg = null;
 }