Пример #1
0
 public OnRspOrderActionArgs(ref CThostFtdcInputOrderActionField pInputOrderAction, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     this.pInputOrderAction = pInputOrderAction;
     this.pRspInfo          = pRspInfo;
     this.nRequestID        = nRequestID;
     this.bIsLast           = bIsLast;
 }
Пример #2
0
 private void OnRspOrderAction_callback(object sender, ref CThostFtdcInputOrderActionField pInputOrderAction, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (null != OnRspOrderAction)
     {
         OnRspOrderAction(this, new OnRspOrderActionArgs(ref pInputOrderAction, ref pRspInfo, nRequestID, bIsLast));
     }
 }
Пример #3
0
        /// <summary>
        /// 撤普通单错误时回报
        /// </summary>
        private void CTradeApi_OnRspOrderAction(ref CThostFtdcInputOrderActionField pInputOrderAction, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            OrderField of = new OrderField();

            of.StatusMsg    = string.Format("{0}:{1}", pRspInfo.ErrorID, pRspInfo.ErrorMsg);
            of.InstrumentID = pInputOrderAction.InstrumentID;
            of.OrderRef     = pInputOrderAction.OrderRef;
            of.LimitPrice   = pInputOrderAction.LimitPrice;
            of.OrderSysID   = pInputOrderAction.OrderSysID;
            of.SessionID    = pInputOrderAction.SessionID;
            of.FrontID      = pInputOrderAction.FrontID;
            of.InvestorID   = pInputOrderAction.InvestorID;
            of.BrokerID     = pInputOrderAction.BrokerID;
            this._OnErrorOrder?.Invoke(of);
        }
Пример #4
0
        private void CTPOnRspOrderAction(ref CThostFtdcInputOrderActionField pInputOrderAction, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            if (pRspInfo.ErrorID == 0)
            {
                return;
            }

            string     id = string.Format("{0}|{1}|{2}", pInputOrderAction.SessionID, pInputOrderAction.FrontID, pInputOrderAction.OrderRef);
            OrderField of;

            if (IsLogin && DicOrderField.TryGetValue(id, out of))
            {
                _OnRtnErrCancel?.Invoke(this, new ErrOrderArgs {
                    ErrorID = pRspInfo.ErrorID, ErrorMsg = pRspInfo.ErrorMsg, Value = of
                });
            }
        }
Пример #5
0
        private void OnRspOrderAction(IntPtr pTraderApi, ref CThostFtdcInputOrderActionField pInputOrderAction, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            SingleOrder order;

            if (_OrderRef2Order.TryGetValue(string.Format("{0}:{1}:{2}", _RspUserLogin.FrontID, _RspUserLogin.SessionID, pInputOrderAction.OrderRef), out order))
            {
                if (OutputLog)
                {
                    Console.WriteLine("CTP回应:{0},价{1},变化量{2},引用{3},{4}",
                                      pInputOrderAction.InstrumentID, pInputOrderAction.LimitPrice, pInputOrderAction.VolumeChange, pInputOrderAction.OrderRef,
                                      pRspInfo.ErrorMsg);
                }

                order.Text = string.Format("{0} {1}", order.Text, pRspInfo.ErrorMsg);
                EmitCancelReject(order, order.Text);
            }
        }
Пример #6
0
        private void OnRspOrderAction(IntPtr pTraderApi, ref CThostFtdcInputOrderActionField pInputOrderAction, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            tdlog.Error("CTP回应:{0},价{1},变化量{2},前置{3},会话{4},引用{5},{6}#{7}",
                        pInputOrderAction.InstrumentID, pInputOrderAction.LimitPrice,
                        pInputOrderAction.VolumeChange,
                        pInputOrderAction.FrontID, pInputOrderAction.SessionID, pInputOrderAction.OrderRef,
                        pRspInfo.ErrorID, pRspInfo.ErrorMsg);

            GenericOrderItem item;
            string           strKey = string.Format("{0}:{1}:{2}", pInputOrderAction.FrontID, pInputOrderAction.SessionID, pInputOrderAction.OrderRef);

            if (orderMap.TryGetValue(strKey, out item))
            {
                EmitCancelReject(item, pRspInfo.ErrorID, pRspInfo.ErrorMsg);
                EmitCancelLastStatus(item);
            }
        }
Пример #7
0
        private void OnRspOrderAction(IntPtr pTraderApi, ref CThostFtdcInputOrderActionField pInputOrderAction, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            SingleOrder order;
            string      strKey = string.Format("{0}:{1}:{2}", pInputOrderAction.FrontID, pInputOrderAction.SessionID, pInputOrderAction.OrderRef);

            if (_OrderRef2Order.TryGetValue(strKey, out order))
            {
                tdlog.Error("CTP回应:{0},价{1},变化量{2},前置{3},会话{4},引用{5},{6}#{7}",
                            pInputOrderAction.InstrumentID, pInputOrderAction.LimitPrice,
                            pInputOrderAction.VolumeChange,
                            pInputOrderAction.FrontID, pInputOrderAction.SessionID, pInputOrderAction.OrderRef,
                            pRspInfo.ErrorID, pRspInfo.ErrorMsg);

                order.Text = string.Format("{0}|{1}#{2}", order.Text.Substring(0, Math.Min(order.Text.Length, 64)), pRspInfo.ErrorID, pRspInfo.ErrorMsg);

                EmitCancelReject(order, order.OrdStatus, order.Text);
            }
        }
Пример #8
0
 private void OnRspOrderAction_callback(IntPtr pTraderApi, ref CThostFtdcInputOrderActionField pInputOrderAction, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (null != OnRspOrderAction)
     {
         OnRspOrderAction(this, new OnRspOrderActionArgs(pTraderApi, ref pInputOrderAction, ref pRspInfo, nRequestID, bIsLast));
     }
 }
Пример #9
0
        public void TestOrderAction()
        {
            _api.OnRspOrderAction += new TradeApi.RspOrderAction((ref CThostFtdcInputOrderActionField pInputOrderAction,
                                                                  ref CThostFtdcRspInfoField pRspInfo, int nRequestID, byte bIsLast) =>
            {
                if (pRspInfo.ErrorID != 0)
                {
                    Console.WriteLine(pRspInfo.ErrorMsg);
                    Assert.IsTrue(pRspInfo.ErrorID == 0);
                }
            });
            _api.OnRtnOrder += new TradeApi.RtnOrder((ref CThostFtdcOrderField pOrder) =>
            {
                if (pOrder.OrderStatus == TThostFtdcOrderStatusType.Canceled)
                {
                    Console.WriteLine("撤单成功, BrokerID: {0}, OrderSysID: {1}", pOrder.BrokerID, pOrder.OrderSysID);
                }
                else
                {
                    Console.WriteLine("下单成功, BrokerID: {0}, OrderSysID: {1}", pOrder.BrokerID, pOrder.OrderSysID);
                    CThostFtdcInputOrderActionField field = new CThostFtdcInputOrderActionField();
                    field.ActionFlag   = TThostFtdcActionFlagType.Delete;
                    field.BrokerID     = _brokerID;
                    field.InvestorID   = _investorID;
                    field.InstrumentID = "TF1809";
                    if (pOrder.FrontID != 0)
                    {
                        field.FrontID = pOrder.FrontID;
                    }
                    if (pOrder.SessionID != 0)
                    {
                        field.SessionID = pOrder.SessionID;
                    }
                    if (pOrder.OrderRef != "")
                    {
                        field.OrderRef = pOrder.OrderRef;
                    }
                    field.ExchangeID = pOrder.ExchangeID;
                    if (pOrder.OrderSysID != null)
                    {
                        field.OrderSysID = new string('\0', 21 - pOrder.OrderSysID.Length) + pOrder.OrderSysID;
                    }
                    _api.OrderAction(1, field);
                    Thread.Sleep(50);
                }
                Thread.Sleep(50);
            });
            _api.OnRspOrderInsert += new TradeApi.RspOrderInsert((ref CThostFtdcInputOrderField pInputOrder, ref CThostFtdcRspInfoField pRspInfo,
                                                                  int nRequestID, byte bIsLast) =>
            {
                if (pRspInfo.ErrorID != 0)
                {
                    Console.WriteLine(pRspInfo.ErrorMsg);
                    Assert.IsTrue(pRspInfo.ErrorID == 0);
                }
            });
            CThostFtdcInputOrderField order = new CThostFtdcInputOrderField();

            order.BrokerID            = _brokerID;
            order.InvestorID          = _investorID;
            order.InstrumentID        = "TF1809";
            order.OrderRef            = "1";
            order.UserID              = _investorID;
            order.OrderPriceType      = TThostFtdcOrderPriceTypeType.LimitPrice;
            order.Direction           = TThostFtdcDirectionType.Buy;
            order.CombOffsetFlag      = TThostFtdcOffsetFlagType.Open;
            order.CombHedgeFlag       = TThostFtdcHedgeFlagType.Speculation;
            order.LimitPrice          = 97.150;
            order.VolumeTotalOriginal = 1;
            order.TimeCondition       = TThostFtdcTimeConditionType.GFD;
            order.VolumeCondition     = TThostFtdcVolumeConditionType.AV;
            order.MinVolume           = 1;
            order.ContingentCondition = TThostFtdcContingentConditionType.Immediately;
            order.ForceCloseReason    = TThostFtdcForceCloseReasonType.NotForceClose;
            order.IsAutoSuspend       = (int)TThostFtdcBoolType.No;
            order.BusinessUnit        = null;
            order.UserForceClose      = (int)TThostFtdcBoolType.No;
            _api.OrderInsert(1, order);
            Thread.Sleep(500);
        }
Пример #10
0
    public virtual int ReqOrderAction(CThostFtdcInputOrderActionField pInputOrderAction, int nRequestID)
    {
        int ret = thosttradeapiPINVOKE.CThostFtdcTraderApi_ReqOrderAction(swigCPtr, CThostFtdcInputOrderActionField.getCPtr(pInputOrderAction), nRequestID);

        return(ret);
    }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CThostFtdcInputOrderActionField obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Пример #12
0
 private void OnRspOrderAction_3(ref CThostFtdcInputOrderActionField pInputOrderAction, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     OnRspOrderAction_1(this, ref pInputOrderAction, ref pRspInfo, nRequestID, bIsLast);
 }
Пример #13
0
 private void OnRspOrderAction_3(IntPtr pTraderApi, ref CThostFtdcInputOrderActionField pInputOrderAction, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     OnRspOrderAction_1(this, pTraderApi, ref pInputOrderAction, ref pRspInfo, nRequestID, bIsLast);
 }
Пример #14
0
 public int ReqOrderAction(CThostFtdcInputOrderActionField pInputOrderAction, int nRequestID)
 {
     return(_traderApi.ReqOrderAction(pInputOrderAction, nRequestID));
 }
 ///报单操作请求响应
 public void OnRspOrderAction(CThostFtdcInputOrderActionField pInputOrderAction, CThostFtdcRspInfoField pRspInfo,
                              int nRequestID, bool bIsLast)
 {
     Console.WriteLine("OnRspOrderAction");
 }
 public override void OnRspOrderAction(CThostFtdcInputOrderActionField pInputOrderAction, CThostFtdcRspInfoField pRspInfo,
                                       int nRequestID, bool bIsLast)
 {
     _callbackApi.OnRspOrderAction(pInputOrderAction, pRspInfo, nRequestID, bIsLast);
 }
Пример #17
0
 public OnRspOrderActionArgs(IntPtr pTraderApi, ref CThostFtdcInputOrderActionField pInputOrderAction, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     this.pTraderApi = pTraderApi;
     this.pInputOrderAction = pInputOrderAction;
     this.pRspInfo = pRspInfo;
     this.nRequestID = nRequestID;
     this.bIsLast = bIsLast;
 }