Пример #1
0
        //撤销订单
        private void cancelOrder(SubOrder subOrder)
        {
            //
            if (subOrder.OrderID.Equals(string.Empty))
            {
                LogUtils.EnginLog($"撤单错误|未找到订单编号:{subOrder.InstrumentID}|{subOrder.Direction}|{subOrder.Offset}|{subOrder.LimitPrice}|{subOrder.Volume}|{subOrder.CustomID}");
                return;
            }
            //
            if (subOrder.Status == OrderStatus.Canceled ||
                subOrder.Status == OrderStatus.Error ||
                subOrder.Status == OrderStatus.Filled)
            {
                return;
            }
            //
            int rtn;

            rtn = mTrader.ReqOrderAction(subOrder.OrderID);

            //这种情况多是盘后未撤订单,按撤单处理
            if (rtn == -1)
            {
                subOrder.Status     = OrderStatus.Canceled;
                subOrder.VolumeLeft = 0;
                activeOrders.Remove(subOrder);
                subOrder.Refresh();
            }

            LogUtils.EnginLog($"撤单:{rtn}|{subOrder.InstrumentID}|{subOrder.Direction}|{subOrder.Offset}|{subOrder.LimitPrice}|{subOrder.Volume}|{subOrder.CustomID}|{subOrder.OrderID}");
        }
Пример #2
0
        //同步订单
        private void syncOrder(OrderField o, SubOrder s)
        {
            //更新编号
            s.OrderID = o.OrderID;
            //只有正常和部成,才响应订单事件
            if (s.Status == OrderStatus.Normal || s.Status == OrderStatus.Partial)
            {
                switch (o.Status)
                {
                case HaiFeng.OrderStatus.Canceled:
                    s.VolumeLeft = 0;
                    s.Status     = OrderStatus.Canceled;
                    activeOrders.Remove(s);
                    break;

                case HaiFeng.OrderStatus.Filled:
                    s.VolumeLeft   = 0;
                    s.Status       = OrderStatus.Filled;
                    s.VolumeTraded = s.Volume;
                    activeOrders.Remove(s);
                    break;

                case HaiFeng.OrderStatus.Error:
                    s.VolumeLeft = 0;
                    s.Status     = OrderStatus.Error;
                    activeOrders.Remove(s);
                    break;

                case HaiFeng.OrderStatus.Partial:
                    s.VolumeLeft   = o.VolumeLeft;
                    s.VolumeTraded = s.Volume - s.VolumeLeft;
                    s.Status       = OrderStatus.Partial;
                    break;
                }
            }
            s.Refresh();
        }