예제 #1
0
파일: EventArgs.cs 프로젝트: kandsy/CTPZQ
 public OnRspErrorArgs(IntPtr pApi, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     this.pApi = pApi;
     this.pRspInfo = pRspInfo;
     this.nRequestID = nRequestID;
     this.bIsLast = bIsLast;
 }
예제 #2
0
 private void OnErrRtnOrderAction_callback(IntPtr pTraderApi, ref CZQThostFtdcOrderActionField pOrderAction, ref CZQThostFtdcRspInfoField pRspInfo)
 {
     if (null != OnErrRtnOrderAction)
     {
         OnErrRtnOrderAction(this, new OnErrRtnOrderActionArgs(pTraderApi, ref pOrderAction, ref pRspInfo));
     }
 }
예제 #3
0
파일: EventArgs.cs 프로젝트: kandsy/CTPZQ
 public OnErrRtnOrderInsertArgs(IntPtr pTraderApi, ref CZQThostFtdcInputOrderField pInputOrder, ref CZQThostFtdcRspInfoField pRspInfo)
 {
     this.pTraderApi = pTraderApi;
     this.pInputOrder = pInputOrder;
     this.pRspInfo = pRspInfo;
 }
예제 #4
0
파일: EventArgs.cs 프로젝트: kandsy/CTPZQ
 public OnRspQryInvestorPositionDetailArgs(IntPtr pTraderApi, ref CZQThostFtdcInvestorPositionDetailField pInvestorPositionDetail, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     this.pTraderApi = pTraderApi;
     this.pInvestorPositionDetail = pInvestorPositionDetail;
     this.pRspInfo = pRspInfo;
     this.nRequestID = nRequestID;
     this.bIsLast = bIsLast;
 }
예제 #5
0
파일: EventArgs.cs 프로젝트: kandsy/CTPZQ
 public OnDisconnectArgs(IntPtr pApi, ref CZQThostFtdcRspInfoField pRspInfo, ConnectionStatus step)
 {
     this.pApi = pApi;
     this.pRspInfo = pRspInfo;
     this.step = step;
 }
예제 #6
0
 private void OnDisconnect_callback(IntPtr pApi, ref CZQThostFtdcRspInfoField pRspInfo, ConnectionStatus step)
 {
     if (null != OnDisconnect)
     {
         OnDisconnect(this, new OnDisconnectArgs(pApi, ref pRspInfo, step));
     }
 }
예제 #7
0
파일: EventArgs.cs 프로젝트: kandsy/CTPZQ
 public OnRspQryDepthMarketDataArgs(IntPtr pTraderApi, ref CZQThostFtdcDepthMarketDataField pDepthMarketData, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     this.pTraderApi = pTraderApi;
     this.pDepthMarketData = pDepthMarketData;
     this.pRspInfo = pRspInfo;
     this.nRequestID = nRequestID;
     this.bIsLast = bIsLast;
 }
예제 #8
0
 private void OnRspQryOrder_callback(IntPtr pTraderApi, ref CZQThostFtdcOrderField pOrder, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (null != OnRspQryOrder)
     {
         OnRspQryOrder(this, new OnRspQryOrderArgs(pTraderApi, ref pOrder, ref pRspInfo, nRequestID, bIsLast));
     }
 }
예제 #9
0
 private void OnRspQryTradingAccount_callback(IntPtr pTraderApi, ref CZQThostFtdcTradingAccountField pTradingAccount, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (null != OnRspQryTradingAccount)
     {
         OnRspQryTradingAccount(this, new OnRspQryTradingAccountArgs(pTraderApi, ref pTradingAccount, ref pRspInfo, nRequestID, bIsLast));
     }
 }
예제 #10
0
 private void OnRspQryInstrumentCommissionRate_callback(IntPtr pTraderApi, ref CZQThostFtdcInstrumentCommissionRateField pInstrumentCommissionRate, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (null != OnRspQryInstrumentCommissionRate)
     {
         OnRspQryInstrumentCommissionRate(this, new OnRspQryInstrumentCommissionRateArgs(pTraderApi, ref pInstrumentCommissionRate, ref pRspInfo, nRequestID, bIsLast));
     }
 }
예제 #11
0
 //private void OnRspQryInstrumentMarginRate_callback(IntPtr pTraderApi, ref CZQThostFtdcInstrumentMarginRateField pInstrumentMarginRate, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 //{
 //    if (null != OnRspQryInstrumentMarginRate)
 //    {
 //        OnRspQryInstrumentMarginRate(this, new OnRspQryInstrumentMarginRateArgs(pTraderApi, ref pInstrumentMarginRate, ref pRspInfo, nRequestID, bIsLast));
 //    }
 //}
 private void OnRspQryInvestorPosition_callback(IntPtr pTraderApi, ref CZQThostFtdcInvestorPositionField pInvestorPosition, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (null != OnRspQryInvestorPosition)
     {
         OnRspQryInvestorPosition(this, new OnRspQryInvestorPositionArgs(pTraderApi, ref pInvestorPosition, ref pRspInfo, nRequestID, bIsLast));
     }
 }
예제 #12
0
 private void OnRspQryDepthMarketData_callback(IntPtr pTraderApi, ref CZQThostFtdcDepthMarketDataField pDepthMarketData, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (null != OnRspQryDepthMarketData)
     {
         OnRspQryDepthMarketData(this, new OnRspQryDepthMarketDataArgs(pTraderApi, ref pDepthMarketData, ref pRspInfo, nRequestID, bIsLast));
     }
 }
예제 #13
0
 private void OnRspOrderInsert_callback(IntPtr pTraderApi, ref CZQThostFtdcInputOrderField pInputOrder, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (null != OnRspOrderInsert)
     {
         OnRspOrderInsert(this, new OnRspOrderInsertArgs(pTraderApi, ref pInputOrder, ref pRspInfo, nRequestID, bIsLast));
     }
 }
예제 #14
0
 private void OnErrRtnOrderInsert_callback(IntPtr pTraderApi, ref CZQThostFtdcInputOrderField pInputOrder, ref CZQThostFtdcRspInfoField pRspInfo)
 {
     if (null != OnErrRtnOrderInsert)
     {
         OnErrRtnOrderInsert(this, new OnErrRtnOrderInsertArgs(pTraderApi, ref pInputOrder, ref pRspInfo));
     }
 }
예제 #15
0
 private void OnRspQryInvestorPosition(IntPtr pTraderApi, ref CZQThostFtdcInvestorPositionField pInvestorPosition, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (0 == pRspInfo.ErrorID)
     {
         _dbInMemInvestorPosition.InsertOrReplace(
             pInvestorPosition.InstrumentID,
             pInvestorPosition.PosiDirection,
             pInvestorPosition.HedgeFlag,
             pInvestorPosition.PositionDate,
             pInvestorPosition.Position,
             pInvestorPosition.LongFrozen,
             pInvestorPosition.ShortFrozen);
         timerPonstion.Enabled = false;
         timerPonstion.Enabled = true;
     }
     else
         EmitError(nRequestID, pRspInfo.ErrorID, "OnRspQryInvestorPosition:" + pRspInfo.ErrorMsg);
 }
예제 #16
0
 public void OnRspQryDepthMarketData(IntPtr pTraderApi, ref CZQThostFtdcDepthMarketDataField pDepthMarketData, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (0 == pRspInfo.ErrorID)
     {
         CZQThostFtdcDepthMarketDataField DepthMarket;
         if (!_dictDepthMarketData.TryGetValue(pDepthMarketData.InstrumentID, out DepthMarket))
         {
             //没找到此元素,保存一下
             _dictDepthMarketData[pDepthMarketData.InstrumentID] = pDepthMarketData;
         }
         Console.WriteLine("TdApi:{0},已经接收查询深度行情 {1}",
                 Clock.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                 pDepthMarketData.InstrumentID);
         //通知单例
         CTPZQAPI.GetInstance().FireOnRspQryDepthMarketData(pDepthMarketData);
     }
     else
         EmitError(nRequestID, pRspInfo.ErrorID, "OnRspQryDepthMarketData:" + pRspInfo.ErrorMsg);
 }
예제 #17
0
 private void OnRspQryTradingAccount(IntPtr pTraderApi, ref CZQThostFtdcTradingAccountField pTradingAccount, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLastt)
 {
     if (0 == pRspInfo.ErrorID)
     {
         m_TradingAccount = pTradingAccount;
         //有资金信息过来了,重新计时
         timerAccount.Enabled = false;
         timerAccount.Enabled = true;
     }
     else
         EmitError(nRequestID, pRspInfo.ErrorID, "OnRspQryTradingAccount:" + pRspInfo.ErrorMsg);
 }
예제 #18
0
 private void OnDisconnect(IntPtr pApi, ref CZQThostFtdcRspInfoField pRspInfo, ConnectionStatus step)
 {
     if (m_pMdApi == pApi)//行情
     {
         Disconnect_MD();
         if (isConnected)
         {
             EmitError((int)step, pRspInfo.ErrorID, "MdApi:" + pRspInfo.ErrorMsg + " 等待定时重试连接");
         }
         else
         {
             EmitError((int)step, pRspInfo.ErrorID, "MdApi:" + pRspInfo.ErrorMsg);
             if (OutputLogToConsole)
             {
                 Console.WriteLine("MdApi:{0},{1},{2}", Clock.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), pRspInfo.ErrorID, pRspInfo.ErrorMsg);
             }
         }
     }
     else if (m_pTdApi == pApi)//交易
     {
         Disconnect_TD();
         if (isConnected)//如果以前连成功,表示密码没有错,只是初始化失败,可以重试
         {
             EmitError((int)step, pRspInfo.ErrorID, "TdApi:" + pRspInfo.ErrorMsg + " 等待定时重试连接");
         }
         else
         {
             EmitError((int)step, pRspInfo.ErrorID, "TdApi:" + pRspInfo.ErrorMsg);
             if (OutputLogToConsole)
             {
                 Console.WriteLine("TdApi:{0},{1},{2}", Clock.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), pRspInfo.ErrorID, pRspInfo.ErrorMsg);
             }
         }
     }
     if (!isConnected)//从来没有连接成功过,可能是密码错误,直接退出
     {
         _Disconnect(true);
     }
     else
     {
         ChangeStatus(ProviderStatus.Connecting);
         EmitDisconnectedEvent();
     }
 }
예제 #19
0
 private void OnRspError_callback(IntPtr pApi, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (null != OnRspError)
     {
         OnRspError(this, new OnRspErrorArgs(pApi, ref pRspInfo, nRequestID, bIsLast));
     }
 }
예제 #20
0
 private void OnRspError(IntPtr pApi, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     EmitError(nRequestID, pRspInfo.ErrorID, pRspInfo.ErrorMsg);
 }
예제 #21
0
파일: EventArgs.cs 프로젝트: kandsy/CTPZQ
 public OnRspQryInstrumentMarginRateArgs(IntPtr pTraderApi, ref CZQThostFtdcInstrumentMarginRateField pInstrumentMarginRate, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     this.pTraderApi = pTraderApi;
     this.pInstrumentMarginRate = pInstrumentMarginRate;
     this.pRspInfo = pRspInfo;
     this.nRequestID = nRequestID;
     this.bIsLast = bIsLast;
 }
예제 #22
0
        private void OnRspOrderAction(IntPtr pTraderApi, ref CZQThostFtdcInputOrderActionField pInputOrderAction, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            SingleOrder order;
            if (_OrderRef2Order.TryGetValue(string.Format("{0}:{1}:{2}", _RspUserLogin.FrontID, _RspUserLogin.SessionID, pInputOrderAction.OrderRef), out order))
            {
                if (OutputLogToConsole)
                {
                    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);
            }
        }
예제 #23
0
파일: EventArgs.cs 프로젝트: kandsy/CTPZQ
 public OnRspQryOrderArgs(IntPtr pTraderApi, ref CZQThostFtdcOrderField pOrder, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     this.pTraderApi = pTraderApi;
     this.pOrder = pOrder;
     this.pRspInfo = pRspInfo;
     this.nRequestID = nRequestID;
     this.bIsLast = bIsLast;
 }
예제 #24
0
 private void OnRspOrderInsert(IntPtr pTraderApi, ref CZQThostFtdcInputOrderField pInputOrder, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     SingleOrder order;
     string strKey = string.Format("{0}:{1}:{2}", _RspUserLogin.FrontID, _RspUserLogin.SessionID, pInputOrder.OrderRef);
     if (_OrderRef2Order.TryGetValue(strKey, out order))
     {
         if (OutputLogToConsole)
         {
             Console.WriteLine("CTP回应:{0},{1},开平{2},价{3},原量{4},引用{5},{6}",
                 pInputOrder.InstrumentID, pInputOrder.Direction, pInputOrder.CombOffsetFlag, pInputOrder.LimitPrice,
                 pInputOrder.VolumeTotalOriginal,
                 pInputOrder.OrderRef, pRspInfo.ErrorMsg);
         }
         order.Text = string.Format("{0}|{1}", order.Text, pRspInfo.ErrorMsg);
         EmitRejected(order, order.Text);
         //这些地方没法处理混合报单
         //没得办法,这样全撤了状态就唯一了
         //但由于不知道在错单时是否会有报单回报,所以在这查一次,以防重复撤单出错
         //找到对应的报单回应
         Dictionary<string, CZQThostFtdcOrderField> _Ref2Action;
         if (_Orders4Cancel.TryGetValue(order, out _Ref2Action))
         {
             lock (_Ref2Action)
             {
                 _Ref2Action.Remove(strKey);
                 if (0 == _Ref2Action.Count())
                 {
                     _Orders4Cancel.Remove(order);
                     return;
                 }
                 Cancel(order);
             }
         }
     }
 }
예제 #25
0
파일: EventArgs.cs 프로젝트: kandsy/CTPZQ
 public OnRspQryTradingAccountArgs(IntPtr pTraderApi, ref CZQThostFtdcTradingAccountField pTradingAccount, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     this.pTraderApi = pTraderApi;
     this.pTradingAccount = pTradingAccount;
     this.pRspInfo = pRspInfo;
     this.nRequestID = nRequestID;
     this.bIsLast = bIsLast;
 }
예제 #26
0
        private void OnRspQryInstrument(IntPtr pTraderApi, ref CZQThostFtdcInstrumentField pInstrument, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            if (0 == pRspInfo.ErrorID)
            {
                //比较无语,测试平台上会显示很多无效数据,有关期货的还会把正确的数据给覆盖,所以临时这样处理
                if (pInstrument.ProductClass != TZQThostFtdcProductClassType.Futures)
                {
                    _dictInstruments[pInstrument.InstrumentID] = pInstrument;
                }

                if (bIsLast)
                {
                    Console.WriteLine("TdApi:{0},合约列表已经接收完成",
                        Clock.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                }
            }
            else
                EmitError(nRequestID, pRspInfo.ErrorID, "OnRspQryInstrument:" + pRspInfo.ErrorMsg);
        }
예제 #27
0
파일: EventArgs.cs 프로젝트: kandsy/CTPZQ
 public OnErrRtnOrderActionArgs(IntPtr pTraderApi, ref CZQThostFtdcOrderActionField pOrderAction, ref CZQThostFtdcRspInfoField pRspInfo)
 {
     this.pTraderApi = pTraderApi;
     this.pOrderAction = pOrderAction;
     this.pRspInfo = pRspInfo;
 }
예제 #28
0
        private void OnRspQryInstrumentCommissionRate(IntPtr pTraderApi, ref CZQThostFtdcInstrumentCommissionRateField pInstrumentCommissionRate, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            if (0 == pRspInfo.ErrorID)
            {
                _dictCommissionRate[pInstrumentCommissionRate.InstrumentID] = pInstrumentCommissionRate;
                Console.WriteLine("TdApi:{0},已经接收手续费率 {1}",
                        Clock.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                        pInstrumentCommissionRate.InstrumentID);

                //通知单例
                CTPZQAPI.GetInstance().FireOnRspQryInstrumentCommissionRate(pInstrumentCommissionRate);
            }
            else
                EmitError(nRequestID, pRspInfo.ErrorID, "OnRspQryInstrumentCommissionRate:" + pRspInfo.ErrorMsg);
        }
예제 #29
0
파일: EventArgs.cs 프로젝트: kandsy/CTPZQ
 public OnRspOrderActionArgs(IntPtr pTraderApi, ref CZQThostFtdcInputOrderActionField pInputOrderAction, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     this.pTraderApi = pTraderApi;
     this.pInputOrderAction = pInputOrderAction;
     this.pRspInfo = pRspInfo;
     this.nRequestID = nRequestID;
     this.bIsLast = bIsLast;
 }
예제 #30
0
        private void OnDisconnect_callback(IntPtr pApi, ref CZQThostFtdcRspInfoField pRspInfo, ConnectionStatus step)
        {
            if (isConnected)
            {
                if (7 == pRspInfo.ErrorID//综合交易平台:还没有初始化
                    || 8 == pRspInfo.ErrorID)//综合交易平台:前置不活跃
                {
                    Disconnect_TD();
                    Connect_TD();
                }
            }

            if (null != OnDisconnect)
            {
                OnDisconnect(this, new OnDisconnectArgs(pApi, ref pRspInfo, step));
            }
        }