Example #1
0
 //建立行情
 private void Connect_TD()
 {
     lock (_lockTd)
     {
         if (null == m_pTdApi || IntPtr.Zero == m_pTdApi)
         {
             m_pTdApi = TraderApi.TD_CreateTdApi();
             TraderApi.CTP_RegOnErrRtnOrderAction(m_pMsgQueue, _fnOnErrRtnOrderAction_Holder);
             TraderApi.CTP_RegOnErrRtnOrderInsert(m_pMsgQueue, _fnOnErrRtnOrderInsert_Holder);
             TraderApi.CTP_RegOnRspOrderAction(m_pMsgQueue, _fnOnRspOrderAction_Holder);
             TraderApi.CTP_RegOnRspOrderInsert(m_pMsgQueue, _fnOnRspOrderInsert_Holder);
             TraderApi.CTP_RegOnRspQryDepthMarketData(m_pMsgQueue, _fnOnRspQryDepthMarketData_Holder);
             TraderApi.CTP_RegOnRspQryInstrument(m_pMsgQueue, _fnOnRspQryInstrument_Holder);
             TraderApi.CTP_RegOnRspQryInstrumentCommissionRate(m_pMsgQueue, _fnOnRspQryInstrumentCommissionRate_Holder);
             TraderApi.CTP_RegOnRspQryInstrumentMarginRate(m_pMsgQueue, _fnOnRspQryInstrumentMarginRate_Holder);
             TraderApi.CTP_RegOnRspQryInvestorPosition(m_pMsgQueue, _fnOnRspQryInvestorPosition_Holder);
             TraderApi.CTP_RegOnRspQryOrder(m_pMsgQueue, _fnOnRspQryOrder_Holder);
             TraderApi.CTP_RegOnRspQryTrade(m_pMsgQueue, _fnOnRspQryTrade_Holder);
             TraderApi.CTP_RegOnRspQryTradingAccount(m_pMsgQueue, _fnOnRspQryTradingAccount_Holder);
             TraderApi.CTP_RegOnRtnInstrumentStatus(m_pMsgQueue, _fnOnRtnInstrumentStatus_Holder);
             TraderApi.CTP_RegOnRtnOrder(m_pMsgQueue, _fnOnRtnOrder_Holder);
             TraderApi.CTP_RegOnRtnTrade(m_pMsgQueue, _fnOnRtnTrade_Holder);
             TraderApi.TD_RegMsgQueue2TdApi(m_pTdApi, m_pMsgQueue);
             TraderApi.TD_Connect(m_pTdApi, szPath, szAddresses,
                                  szBrokerId, szInvestorId, szPassword,
                                  nResumeType,
                                  szUserProductInfo, szAuthCode);
         }
     }
 }
Example #2
0
 private void Disconnect_TD()
 {
     lock (_lockTd)
     {
         if (null != m_pTdApi && IntPtr.Zero != m_pTdApi)
         {
             TraderApi.TD_RegMsgQueue2TdApi(m_pTdApi, IntPtr.Zero);
             TraderApi.TD_ReleaseTdApi(m_pTdApi);
             m_pTdApi = IntPtr.Zero;
         }
         _bTdConnected = false;
     }
 }