public void CTP_RegMD() { MdApi.CTP_RegOnRtnDepthMarketData_Tick(OnRtnDepthMarketData_Tick_2); MdApi.CTP_RegOnRtnDepthMarketData_KLine(OnRtnDepthMarketData_KLine_2); MdApi.CTP_RegOnHistory_Tick(OnHistoryTick_2); MdApi.CTP_RegOnHistory_KLine(OnHistoryKLine_2); MdApi.CTP_RegOnRtnForQuoteRsp(OnRtnForQuoteRsp_2); CommApi.CTP_RegMDOnConnect(OnConnect_2); CommApi.CTP_RegMDOnDisconnect(OnDisconnect_2); CommApi.CTP_RegMDOnRspError(OnRspError_2); }
//建立行情 private void Connect_MD() { lock (_lockMd) { if (_bWantMdConnect && (null == m_pMdApi || IntPtr.Zero == m_pMdApi)) { m_pMdApi = MdApi.MD_CreateMdApi(); MdApi.CTP_RegOnRtnDepthMarketData(m_pMsgQueue, _fnOnRtnDepthMarketData_Holder); MdApi.CTP_RegOnRtnForQuoteRsp(m_pMsgQueue, _fnOnRtnForQuoteRsp_Holder); MdApi.MD_RegMsgQueue2MdApi(m_pMdApi, m_pMsgQueue); MdApi.MD_Connect(m_pMdApi, _newTempPath, string.Join(";", server.MarketData.ToArray()), server.BrokerID, account.InvestorId, account.Password); //向单例对象中注入操作用句柄 CTPAPI.GetInstance().__RegMdApi(m_pMdApi); } } }