public void CTP_RegTD() { CommApi.CTP_RegTDOnConnect(OnConnect_2); CommApi.CTP_RegTDOnDisconnect(OnDisconnect_2); CommApi.CTP_RegTDOnRspError(OnRspError_2); TraderApi.CTP_RegOnErrRtnOrderAction(OnErrRtnOrderAction_2); TraderApi.CTP_RegOnErrRtnOrderInsert(OnErrRtnOrderInsert_2); TraderApi.CTP_RegOnErrRtnQuoteAction(OnErrRtnQuoteAction_2); TraderApi.CTP_RegOnErrRtnQuoteInsert(OnErrRtnQuoteInsert_2); TraderApi.CTP_RegOnRspOrderAction(OnRspOrderAction_2); TraderApi.CTP_RegOnRspOrderInsert(OnRspOrderInsert_2); TraderApi.CTP_RegOnRspQuoteAction(OnRspQuoteAction_2); TraderApi.CTP_RegOnRspQuoteInsert(OnRspQuoteInsert_2); TraderApi.CTP_RegOnRspQryDepthMarketData(OnRspQryDepthMarketData_2); TraderApi.CTP_RegOnRspQryInstrument(OnRspQryInstrument_2); TraderApi.CTP_RegOnRspQryInstrumentCommissionRate(OnRspQryInstrumentCommissionRate_2); TraderApi.CTP_RegOnRspQryInstrumentMarginRate(OnRspQryInstrumentMarginRate_2); TraderApi.CTP_RegOnRspQryInvestorPosition(OnRspQryInvestorPosition_2); TraderApi.CTP_RegOnRspQryInvestorPositionDetail(OnRspQryInvestorPositionDetail_2); TraderApi.CTP_RegOnRspQryOrder(OnRspQryOrder_2); TraderApi.CTP_RegOnRspQryTrade(OnRspQryTrade_2); TraderApi.CTP_RegOnRspQrySettlementInfo(OnRspQrySettlementInfo_2); TraderApi.CTP_RegOnRspQryTradingAccount(OnRspQryTradingAccount_2); TraderApi.CTP_RegOnRtnInstrumentStatus(OnRtnInstrumentStatus_2); TraderApi.CTP_RegOnRtnOrder(OnRtnOrder_2); TraderApi.CTP_RegOnRtnQuote(OnRtnQuote_2); TraderApi.CTP_RegOnRtnTrade(OnRtnTrade_2); }
//建立交易 private void Connect_TD() { lock (_lockTd) { if (_bWantTdConnect && (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_RegOnRspQryInvestorPosition(m_pMsgQueue, _fnOnRspQryInvestorPosition_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); #if CTP TraderApi.CTP_RegOnRspQryInstrumentMarginRate(m_pMsgQueue, _fnOnRspQryInstrumentMarginRate_Holder); #endif TraderApi.CTP_RegOnErrRtnQuoteAction(m_pMsgQueue, _fnOnErrRtnQuoteAction_Holder); TraderApi.CTP_RegOnErrRtnQuoteInsert(m_pMsgQueue, _fnOnErrRtnQuoteInsert_Holder); TraderApi.CTP_RegOnRspQuoteAction(m_pMsgQueue, _fnOnRspQuoteAction_Holder); TraderApi.CTP_RegOnRspQuoteInsert(m_pMsgQueue, _fnOnRspQuoteInsert_Holder); TraderApi.CTP_RegOnRtnQuote(m_pMsgQueue, _fnOnRtnQuote_Holder); TraderApi.TD_RegMsgQueue2TdApi(m_pTdApi, m_pMsgQueue); TraderApi.TD_Connect(m_pTdApi, _newTempPath, string.Join(";", server.Trading.ToArray()), server.BrokerID, account.InvestorId, account.Password, ResumeType, server.UserProductInfo, server.AuthCode); //向单例对象中注入操作用句柄 CTPAPI.GetInstance().__RegTdApi(m_pTdApi); } } }