From 4dc63db71c1f59dd7c6eccdf6fff347c752e4ee3 Mon Sep 17 00:00:00 2001 From: nanoric Date: Mon, 18 Feb 2019 03:12:20 -0400 Subject: [PATCH 1/2] =?UTF-8?q?[Add]=20TaskQueue=E5=A2=9E=E5=8A=A0terminat?= =?UTF-8?q?e()=EF=BC=8C=E5=8F=AF=E4=BB=A5=E7=BB=88=E6=AD=A2pop=E7=9A=84?= =?UTF-8?q?=E7=AD=89=E5=BE=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/api/ctp/vnctp/vnctp.h | 18 +- vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.cpp | 142 +-- vnpy/api/ctp/vnctp/vnctptd/vnctptd.cpp | 1448 ++++++++++++------------ 3 files changed, 815 insertions(+), 793 deletions(-) diff --git a/vnpy/api/ctp/vnctp/vnctp.h b/vnpy/api/ctp/vnctp/vnctp.h index 23050d51..236e9c82 100644 --- a/vnpy/api/ctp/vnctp/vnctp.h +++ b/vnpy/api/ctp/vnctp/vnctp.h @@ -25,6 +25,8 @@ struct Task bool task_last; //是否为最后返回 }; +class TerminatedError : std::exception +{}; class TaskQueue { @@ -33,6 +35,8 @@ private: mutex mutex_; //互斥锁 condition_variable cond_; //条件变量 + bool _terminate = false; + public: //存入新的任务 @@ -48,15 +52,21 @@ public: Task pop() { unique_lock mlock(mutex_); - while (queue_.empty()) //当队列为空时 - { - cond_.wait(mlock); //等待条件变量通知 - } + cond_.wait(mlock, [&]() { + return !queue_.empty() || _terminate; + }); //等待条件变量通知 + if (_terminate) + throw TerminatedError(); Task task = queue_.front(); //获取队列中的最后一个任务 queue_.pop(); //删除该任务 return task; //返回该任务 } + void terminate() + { + _terminate = true; + cond_.notify_all(); //通知正在阻塞等待的线程 + } }; diff --git a/vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.cpp b/vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.cpp index d85494b3..a8398879 100644 --- a/vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.cpp +++ b/vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.cpp @@ -206,85 +206,91 @@ void MdApi::OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) void MdApi::processTask() { - while (this->active) - { - Task task = this->task_queue.pop(); - - switch (task.task_name) - { - case ONFRONTCONNECTED: - { - this->processFrontConnected(&task); - break; - } + try + { + while (this->active) + { + Task task = this->task_queue.pop(); + + switch (task.task_name) + { + case ONFRONTCONNECTED: + { + this->processFrontConnected(&task); + break; + } - case ONFRONTDISCONNECTED: - { - this->processFrontDisconnected(&task); - break; - } + case ONFRONTDISCONNECTED: + { + this->processFrontDisconnected(&task); + break; + } - case ONHEARTBEATWARNING: - { - this->processHeartBeatWarning(&task); - break; - } + case ONHEARTBEATWARNING: + { + this->processHeartBeatWarning(&task); + break; + } - case ONRSPUSERLOGIN: - { - this->processRspUserLogin(&task); - break; - } + case ONRSPUSERLOGIN: + { + this->processRspUserLogin(&task); + break; + } - case ONRSPUSERLOGOUT: - { - this->processRspUserLogout(&task); - break; - } + case ONRSPUSERLOGOUT: + { + this->processRspUserLogout(&task); + break; + } - case ONRSPERROR: - { - this->processRspError(&task); - break; - } + case ONRSPERROR: + { + this->processRspError(&task); + break; + } - case ONRSPSUBMARKETDATA: - { - this->processRspSubMarketData(&task); - break; - } + case ONRSPSUBMARKETDATA: + { + this->processRspSubMarketData(&task); + break; + } - case ONRSPUNSUBMARKETDATA: - { - this->processRspUnSubMarketData(&task); - break; - } + case ONRSPUNSUBMARKETDATA: + { + this->processRspUnSubMarketData(&task); + break; + } - case ONRSPSUBFORQUOTERSP: - { - this->processRspSubForQuoteRsp(&task); - break; - } + case ONRSPSUBFORQUOTERSP: + { + this->processRspSubForQuoteRsp(&task); + break; + } - case ONRSPUNSUBFORQUOTERSP: - { - this->processRspUnSubForQuoteRsp(&task); - break; - } + case ONRSPUNSUBFORQUOTERSP: + { + this->processRspUnSubForQuoteRsp(&task); + break; + } - case ONRTNDEPTHMARKETDATA: - { - this->processRtnDepthMarketData(&task); - break; - } + case ONRTNDEPTHMARKETDATA: + { + this->processRtnDepthMarketData(&task); + break; + } - case ONRTNFORQUOTERSP: - { - this->processRtnForQuoteRsp(&task); - break; - } - }; - } + case ONRTNFORQUOTERSP: + { + this->processRtnForQuoteRsp(&task); + break; + } + }; + } + } + catch (const TerminatedError&) + { + } }; void MdApi::processFrontConnected(Task *task) diff --git a/vnpy/api/ctp/vnctp/vnctptd/vnctptd.cpp b/vnpy/api/ctp/vnctp/vnctptd/vnctptd.cpp index 5d0ea59e..7f8d9ed4 100644 --- a/vnpy/api/ctp/vnctp/vnctptd/vnctptd.cpp +++ b/vnpy/api/ctp/vnctp/vnctptd/vnctptd.cpp @@ -2228,727 +2228,733 @@ void TdApi::OnRtnChangeAccountByBank(CThostFtdcChangeAccountField *pChangeAccoun void TdApi::processTask() { - while (this->active) - { - Task task = this->task_queue.pop(); - - switch (task.task_name) - { - case ONFRONTCONNECTED: - { - this->processFrontConnected(&task); - break; - } - - case ONFRONTDISCONNECTED: - { - this->processFrontDisconnected(&task); - break; - } - - case ONHEARTBEATWARNING: - { - this->processHeartBeatWarning(&task); - break; - } - - case ONRSPAUTHENTICATE: - { - this->processRspAuthenticate(&task); - break; - } - - case ONRSPUSERLOGIN: - { - this->processRspUserLogin(&task); - break; - } - - case ONRSPUSERLOGOUT: - { - this->processRspUserLogout(&task); - break; - } - - case ONRSPUSERPASSWORDUPDATE: - { - this->processRspUserPasswordUpdate(&task); - break; - } - - case ONRSPTRADINGACCOUNTPASSWORDUPDATE: - { - this->processRspTradingAccountPasswordUpdate(&task); - break; - } - - case ONRSPORDERINSERT: - { - this->processRspOrderInsert(&task); - break; - } - - case ONRSPPARKEDORDERINSERT: - { - this->processRspParkedOrderInsert(&task); - break; - } - - case ONRSPPARKEDORDERACTION: - { - this->processRspParkedOrderAction(&task); - break; - } - - case ONRSPORDERACTION: - { - this->processRspOrderAction(&task); - break; - } - - case ONRSPQUERYMAXORDERVOLUME: - { - this->processRspQueryMaxOrderVolume(&task); - break; - } - - case ONRSPSETTLEMENTINFOCONFIRM: - { - this->processRspSettlementInfoConfirm(&task); - break; - } - - case ONRSPREMOVEPARKEDORDER: - { - this->processRspRemoveParkedOrder(&task); - break; - } - - case ONRSPREMOVEPARKEDORDERACTION: - { - this->processRspRemoveParkedOrderAction(&task); - break; - } - - case ONRSPEXECORDERINSERT: - { - this->processRspExecOrderInsert(&task); - break; - } - - case ONRSPEXECORDERACTION: - { - this->processRspExecOrderAction(&task); - break; - } - - case ONRSPFORQUOTEINSERT: - { - this->processRspForQuoteInsert(&task); - break; - } - - case ONRSPQUOTEINSERT: - { - this->processRspQuoteInsert(&task); - break; - } - - case ONRSPQUOTEACTION: - { - this->processRspQuoteAction(&task); - break; - } - - case ONRSPBATCHORDERACTION: - { - this->processRspBatchOrderAction(&task); - break; - } - - case ONRSPOPTIONSELFCLOSEINSERT: - { - this->processRspOptionSelfCloseInsert(&task); - break; - } - - case ONRSPOPTIONSELFCLOSEACTION: - { - this->processRspOptionSelfCloseAction(&task); - break; - } - - case ONRSPCOMBACTIONINSERT: - { - this->processRspCombActionInsert(&task); - break; - } - - case ONRSPQRYORDER: - { - this->processRspQryOrder(&task); - break; - } - - case ONRSPQRYTRADE: - { - this->processRspQryTrade(&task); - break; - } - - case ONRSPQRYINVESTORPOSITION: - { - this->processRspQryInvestorPosition(&task); - break; - } - - case ONRSPQRYTRADINGACCOUNT: - { - this->processRspQryTradingAccount(&task); - break; - } - - case ONRSPQRYINVESTOR: - { - this->processRspQryInvestor(&task); - break; - } - - case ONRSPQRYTRADINGCODE: - { - this->processRspQryTradingCode(&task); - break; - } - - case ONRSPQRYINSTRUMENTMARGINRATE: - { - this->processRspQryInstrumentMarginRate(&task); - break; - } - - case ONRSPQRYINSTRUMENTCOMMISSIONRATE: - { - this->processRspQryInstrumentCommissionRate(&task); - break; - } - - case ONRSPQRYEXCHANGE: - { - this->processRspQryExchange(&task); - break; - } - - case ONRSPQRYPRODUCT: - { - this->processRspQryProduct(&task); - break; - } - - case ONRSPQRYINSTRUMENT: - { - this->processRspQryInstrument(&task); - break; - } - - case ONRSPQRYDEPTHMARKETDATA: - { - this->processRspQryDepthMarketData(&task); - break; - } - - case ONRSPQRYSETTLEMENTINFO: - { - this->processRspQrySettlementInfo(&task); - break; - } - - case ONRSPQRYTRANSFERBANK: - { - this->processRspQryTransferBank(&task); - break; - } - - case ONRSPQRYINVESTORPOSITIONDETAIL: - { - this->processRspQryInvestorPositionDetail(&task); - break; - } - - case ONRSPQRYNOTICE: - { - this->processRspQryNotice(&task); - break; - } - - case ONRSPQRYSETTLEMENTINFOCONFIRM: - { - this->processRspQrySettlementInfoConfirm(&task); - break; - } - - case ONRSPQRYINVESTORPOSITIONCOMBINEDETAIL: - { - this->processRspQryInvestorPositionCombineDetail(&task); - break; - } - - case ONRSPQRYCFMMCTRADINGACCOUNTKEY: - { - this->processRspQryCFMMCTradingAccountKey(&task); - break; - } - - case ONRSPQRYEWARRANTOFFSET: - { - this->processRspQryEWarrantOffset(&task); - break; - } - - case ONRSPQRYINVESTORPRODUCTGROUPMARGIN: - { - this->processRspQryInvestorProductGroupMargin(&task); - break; - } - - case ONRSPQRYEXCHANGEMARGINRATE: - { - this->processRspQryExchangeMarginRate(&task); - break; - } - - case ONRSPQRYEXCHANGEMARGINRATEADJUST: - { - this->processRspQryExchangeMarginRateAdjust(&task); - break; - } - - case ONRSPQRYEXCHANGERATE: - { - this->processRspQryExchangeRate(&task); - break; - } - - case ONRSPQRYSECAGENTACIDMAP: - { - this->processRspQrySecAgentACIDMap(&task); - break; - } - - case ONRSPQRYPRODUCTEXCHRATE: - { - this->processRspQryProductExchRate(&task); - break; - } - - case ONRSPQRYPRODUCTGROUP: - { - this->processRspQryProductGroup(&task); - break; - } - - case ONRSPQRYMMINSTRUMENTCOMMISSIONRATE: - { - this->processRspQryMMInstrumentCommissionRate(&task); - break; - } - - case ONRSPQRYMMOPTIONINSTRCOMMRATE: - { - this->processRspQryMMOptionInstrCommRate(&task); - break; - } - - case ONRSPQRYINSTRUMENTORDERCOMMRATE: - { - this->processRspQryInstrumentOrderCommRate(&task); - break; - } - - case ONRSPQRYOPTIONINSTRTRADECOST: - { - this->processRspQryOptionInstrTradeCost(&task); - break; - } - - case ONRSPQRYOPTIONINSTRCOMMRATE: - { - this->processRspQryOptionInstrCommRate(&task); - break; - } - - case ONRSPQRYEXECORDER: - { - this->processRspQryExecOrder(&task); - break; - } - - case ONRSPQRYFORQUOTE: - { - this->processRspQryForQuote(&task); - break; - } - - case ONRSPQRYQUOTE: - { - this->processRspQryQuote(&task); - break; - } - - case ONRSPQRYOPTIONSELFCLOSE: - { - this->processRspQryOptionSelfClose(&task); - break; - } - - case ONRSPQRYINVESTUNIT: - { - this->processRspQryInvestUnit(&task); - break; - } - - case ONRSPQRYCOMBINSTRUMENTGUARD: - { - this->processRspQryCombInstrumentGuard(&task); - break; - } - - case ONRSPQRYCOMBACTION: - { - this->processRspQryCombAction(&task); - break; - } - - case ONRSPQRYTRANSFERSERIAL: - { - this->processRspQryTransferSerial(&task); - break; - } - - case ONRSPQRYACCOUNTREGISTER: - { - this->processRspQryAccountregister(&task); - break; - } - - case ONRSPERROR: - { - this->processRspError(&task); - break; - } - - case ONRTNORDER: - { - this->processRtnOrder(&task); - break; - } - - case ONRTNTRADE: - { - this->processRtnTrade(&task); - break; - } - - case ONERRRTNORDERINSERT: - { - this->processErrRtnOrderInsert(&task); - break; - } - - case ONERRRTNORDERACTION: - { - this->processErrRtnOrderAction(&task); - break; - } - - case ONRTNINSTRUMENTSTATUS: - { - this->processRtnInstrumentStatus(&task); - break; - } - - case ONRTNBULLETIN: - { - this->processRtnBulletin(&task); - break; - } - - case ONRTNTRADINGNOTICE: - { - this->processRtnTradingNotice(&task); - break; - } - - case ONRTNERRORCONDITIONALORDER: - { - this->processRtnErrorConditionalOrder(&task); - break; - } - - case ONRTNEXECORDER: - { - this->processRtnExecOrder(&task); - break; - } - - case ONERRRTNEXECORDERINSERT: - { - this->processErrRtnExecOrderInsert(&task); - break; - } - - case ONERRRTNEXECORDERACTION: - { - this->processErrRtnExecOrderAction(&task); - break; - } - - case ONERRRTNFORQUOTEINSERT: - { - this->processErrRtnForQuoteInsert(&task); - break; - } - - case ONRTNQUOTE: - { - this->processRtnQuote(&task); - break; - } - - case ONERRRTNQUOTEINSERT: - { - this->processErrRtnQuoteInsert(&task); - break; - } - - case ONERRRTNQUOTEACTION: - { - this->processErrRtnQuoteAction(&task); - break; - } - - case ONRTNFORQUOTERSP: - { - this->processRtnForQuoteRsp(&task); - break; - } - - case ONRTNCFMMCTRADINGACCOUNTTOKEN: - { - this->processRtnCFMMCTradingAccountToken(&task); - break; - } - - case ONERRRTNBATCHORDERACTION: - { - this->processErrRtnBatchOrderAction(&task); - break; - } - - case ONRTNOPTIONSELFCLOSE: - { - this->processRtnOptionSelfClose(&task); - break; - } - - case ONERRRTNOPTIONSELFCLOSEINSERT: - { - this->processErrRtnOptionSelfCloseInsert(&task); - break; - } - - case ONERRRTNOPTIONSELFCLOSEACTION: - { - this->processErrRtnOptionSelfCloseAction(&task); - break; - } - - case ONRTNCOMBACTION: - { - this->processRtnCombAction(&task); - break; - } - - case ONERRRTNCOMBACTIONINSERT: - { - this->processErrRtnCombActionInsert(&task); - break; - } - - case ONRSPQRYCONTRACTBANK: - { - this->processRspQryContractBank(&task); - break; - } - - case ONRSPQRYPARKEDORDER: - { - this->processRspQryParkedOrder(&task); - break; - } - - case ONRSPQRYPARKEDORDERACTION: - { - this->processRspQryParkedOrderAction(&task); - break; - } - - case ONRSPQRYTRADINGNOTICE: - { - this->processRspQryTradingNotice(&task); - break; - } - - case ONRSPQRYBROKERTRADINGPARAMS: - { - this->processRspQryBrokerTradingParams(&task); - break; - } - - case ONRSPQRYBROKERTRADINGALGOS: - { - this->processRspQryBrokerTradingAlgos(&task); - break; - } - - case ONRSPQUERYCFMMCTRADINGACCOUNTTOKEN: - { - this->processRspQueryCFMMCTradingAccountToken(&task); - break; - } - - case ONRTNFROMBANKTOFUTUREBYBANK: - { - this->processRtnFromBankToFutureByBank(&task); - break; - } - - case ONRTNFROMFUTURETOBANKBYBANK: - { - this->processRtnFromFutureToBankByBank(&task); - break; - } - - case ONRTNREPEALFROMBANKTOFUTUREBYBANK: - { - this->processRtnRepealFromBankToFutureByBank(&task); - break; - } - - case ONRTNREPEALFROMFUTURETOBANKBYBANK: - { - this->processRtnRepealFromFutureToBankByBank(&task); - break; - } - - case ONRTNFROMBANKTOFUTUREBYFUTURE: - { - this->processRtnFromBankToFutureByFuture(&task); - break; - } - - case ONRTNFROMFUTURETOBANKBYFUTURE: - { - this->processRtnFromFutureToBankByFuture(&task); - break; - } - - case ONRTNREPEALFROMBANKTOFUTUREBYFUTUREMANUAL: - { - this->processRtnRepealFromBankToFutureByFutureManual(&task); - break; - } - - case ONRTNREPEALFROMFUTURETOBANKBYFUTUREMANUAL: - { - this->processRtnRepealFromFutureToBankByFutureManual(&task); - break; - } - - case ONRTNQUERYBANKBALANCEBYFUTURE: - { - this->processRtnQueryBankBalanceByFuture(&task); - break; - } - - case ONERRRTNBANKTOFUTUREBYFUTURE: - { - this->processErrRtnBankToFutureByFuture(&task); - break; - } - - case ONERRRTNFUTURETOBANKBYFUTURE: - { - this->processErrRtnFutureToBankByFuture(&task); - break; - } - - case ONERRRTNREPEALBANKTOFUTUREBYFUTUREMANUAL: - { - this->processErrRtnRepealBankToFutureByFutureManual(&task); - break; - } - - case ONERRRTNREPEALFUTURETOBANKBYFUTUREMANUAL: - { - this->processErrRtnRepealFutureToBankByFutureManual(&task); - break; - } - - case ONERRRTNQUERYBANKBALANCEBYFUTURE: - { - this->processErrRtnQueryBankBalanceByFuture(&task); - break; - } - - case ONRTNREPEALFROMBANKTOFUTUREBYFUTURE: - { - this->processRtnRepealFromBankToFutureByFuture(&task); - break; - } - - case ONRTNREPEALFROMFUTURETOBANKBYFUTURE: - { - this->processRtnRepealFromFutureToBankByFuture(&task); - break; - } - - case ONRSPFROMBANKTOFUTUREBYFUTURE: - { - this->processRspFromBankToFutureByFuture(&task); - break; - } - - case ONRSPFROMFUTURETOBANKBYFUTURE: - { - this->processRspFromFutureToBankByFuture(&task); - break; - } - - case ONRSPQUERYBANKACCOUNTMONEYBYFUTURE: - { - this->processRspQueryBankAccountMoneyByFuture(&task); - break; - } - - case ONRTNOPENACCOUNTBYBANK: - { - this->processRtnOpenAccountByBank(&task); - break; - } - - case ONRTNCANCELACCOUNTBYBANK: - { - this->processRtnCancelAccountByBank(&task); - break; - } - - case ONRTNCHANGEACCOUNTBYBANK: - { - this->processRtnChangeAccountByBank(&task); - break; - } - }; - } + try + { + while (this->active) + { + Task task = this->task_queue.pop(); + + switch (task.task_name) + { + case ONFRONTCONNECTED: + { + this->processFrontConnected(&task); + break; + } + + case ONFRONTDISCONNECTED: + { + this->processFrontDisconnected(&task); + break; + } + + case ONHEARTBEATWARNING: + { + this->processHeartBeatWarning(&task); + break; + } + + case ONRSPAUTHENTICATE: + { + this->processRspAuthenticate(&task); + break; + } + + case ONRSPUSERLOGIN: + { + this->processRspUserLogin(&task); + break; + } + + case ONRSPUSERLOGOUT: + { + this->processRspUserLogout(&task); + break; + } + + case ONRSPUSERPASSWORDUPDATE: + { + this->processRspUserPasswordUpdate(&task); + break; + } + + case ONRSPTRADINGACCOUNTPASSWORDUPDATE: + { + this->processRspTradingAccountPasswordUpdate(&task); + break; + } + + case ONRSPORDERINSERT: + { + this->processRspOrderInsert(&task); + break; + } + + case ONRSPPARKEDORDERINSERT: + { + this->processRspParkedOrderInsert(&task); + break; + } + + case ONRSPPARKEDORDERACTION: + { + this->processRspParkedOrderAction(&task); + break; + } + + case ONRSPORDERACTION: + { + this->processRspOrderAction(&task); + break; + } + + case ONRSPQUERYMAXORDERVOLUME: + { + this->processRspQueryMaxOrderVolume(&task); + break; + } + + case ONRSPSETTLEMENTINFOCONFIRM: + { + this->processRspSettlementInfoConfirm(&task); + break; + } + + case ONRSPREMOVEPARKEDORDER: + { + this->processRspRemoveParkedOrder(&task); + break; + } + + case ONRSPREMOVEPARKEDORDERACTION: + { + this->processRspRemoveParkedOrderAction(&task); + break; + } + + case ONRSPEXECORDERINSERT: + { + this->processRspExecOrderInsert(&task); + break; + } + + case ONRSPEXECORDERACTION: + { + this->processRspExecOrderAction(&task); + break; + } + + case ONRSPFORQUOTEINSERT: + { + this->processRspForQuoteInsert(&task); + break; + } + + case ONRSPQUOTEINSERT: + { + this->processRspQuoteInsert(&task); + break; + } + + case ONRSPQUOTEACTION: + { + this->processRspQuoteAction(&task); + break; + } + + case ONRSPBATCHORDERACTION: + { + this->processRspBatchOrderAction(&task); + break; + } + + case ONRSPOPTIONSELFCLOSEINSERT: + { + this->processRspOptionSelfCloseInsert(&task); + break; + } + + case ONRSPOPTIONSELFCLOSEACTION: + { + this->processRspOptionSelfCloseAction(&task); + break; + } + + case ONRSPCOMBACTIONINSERT: + { + this->processRspCombActionInsert(&task); + break; + } + + case ONRSPQRYORDER: + { + this->processRspQryOrder(&task); + break; + } + + case ONRSPQRYTRADE: + { + this->processRspQryTrade(&task); + break; + } + + case ONRSPQRYINVESTORPOSITION: + { + this->processRspQryInvestorPosition(&task); + break; + } + + case ONRSPQRYTRADINGACCOUNT: + { + this->processRspQryTradingAccount(&task); + break; + } + + case ONRSPQRYINVESTOR: + { + this->processRspQryInvestor(&task); + break; + } + + case ONRSPQRYTRADINGCODE: + { + this->processRspQryTradingCode(&task); + break; + } + + case ONRSPQRYINSTRUMENTMARGINRATE: + { + this->processRspQryInstrumentMarginRate(&task); + break; + } + + case ONRSPQRYINSTRUMENTCOMMISSIONRATE: + { + this->processRspQryInstrumentCommissionRate(&task); + break; + } + + case ONRSPQRYEXCHANGE: + { + this->processRspQryExchange(&task); + break; + } + + case ONRSPQRYPRODUCT: + { + this->processRspQryProduct(&task); + break; + } + + case ONRSPQRYINSTRUMENT: + { + this->processRspQryInstrument(&task); + break; + } + + case ONRSPQRYDEPTHMARKETDATA: + { + this->processRspQryDepthMarketData(&task); + break; + } + + case ONRSPQRYSETTLEMENTINFO: + { + this->processRspQrySettlementInfo(&task); + break; + } + + case ONRSPQRYTRANSFERBANK: + { + this->processRspQryTransferBank(&task); + break; + } + + case ONRSPQRYINVESTORPOSITIONDETAIL: + { + this->processRspQryInvestorPositionDetail(&task); + break; + } + + case ONRSPQRYNOTICE: + { + this->processRspQryNotice(&task); + break; + } + + case ONRSPQRYSETTLEMENTINFOCONFIRM: + { + this->processRspQrySettlementInfoConfirm(&task); + break; + } + + case ONRSPQRYINVESTORPOSITIONCOMBINEDETAIL: + { + this->processRspQryInvestorPositionCombineDetail(&task); + break; + } + + case ONRSPQRYCFMMCTRADINGACCOUNTKEY: + { + this->processRspQryCFMMCTradingAccountKey(&task); + break; + } + + case ONRSPQRYEWARRANTOFFSET: + { + this->processRspQryEWarrantOffset(&task); + break; + } + + case ONRSPQRYINVESTORPRODUCTGROUPMARGIN: + { + this->processRspQryInvestorProductGroupMargin(&task); + break; + } + + case ONRSPQRYEXCHANGEMARGINRATE: + { + this->processRspQryExchangeMarginRate(&task); + break; + } + + case ONRSPQRYEXCHANGEMARGINRATEADJUST: + { + this->processRspQryExchangeMarginRateAdjust(&task); + break; + } + + case ONRSPQRYEXCHANGERATE: + { + this->processRspQryExchangeRate(&task); + break; + } + + case ONRSPQRYSECAGENTACIDMAP: + { + this->processRspQrySecAgentACIDMap(&task); + break; + } + + case ONRSPQRYPRODUCTEXCHRATE: + { + this->processRspQryProductExchRate(&task); + break; + } + + case ONRSPQRYPRODUCTGROUP: + { + this->processRspQryProductGroup(&task); + break; + } + + case ONRSPQRYMMINSTRUMENTCOMMISSIONRATE: + { + this->processRspQryMMInstrumentCommissionRate(&task); + break; + } + + case ONRSPQRYMMOPTIONINSTRCOMMRATE: + { + this->processRspQryMMOptionInstrCommRate(&task); + break; + } + + case ONRSPQRYINSTRUMENTORDERCOMMRATE: + { + this->processRspQryInstrumentOrderCommRate(&task); + break; + } + + case ONRSPQRYOPTIONINSTRTRADECOST: + { + this->processRspQryOptionInstrTradeCost(&task); + break; + } + + case ONRSPQRYOPTIONINSTRCOMMRATE: + { + this->processRspQryOptionInstrCommRate(&task); + break; + } + + case ONRSPQRYEXECORDER: + { + this->processRspQryExecOrder(&task); + break; + } + + case ONRSPQRYFORQUOTE: + { + this->processRspQryForQuote(&task); + break; + } + + case ONRSPQRYQUOTE: + { + this->processRspQryQuote(&task); + break; + } + + case ONRSPQRYOPTIONSELFCLOSE: + { + this->processRspQryOptionSelfClose(&task); + break; + } + + case ONRSPQRYINVESTUNIT: + { + this->processRspQryInvestUnit(&task); + break; + } + + case ONRSPQRYCOMBINSTRUMENTGUARD: + { + this->processRspQryCombInstrumentGuard(&task); + break; + } + + case ONRSPQRYCOMBACTION: + { + this->processRspQryCombAction(&task); + break; + } + + case ONRSPQRYTRANSFERSERIAL: + { + this->processRspQryTransferSerial(&task); + break; + } + + case ONRSPQRYACCOUNTREGISTER: + { + this->processRspQryAccountregister(&task); + break; + } + + case ONRSPERROR: + { + this->processRspError(&task); + break; + } + + case ONRTNORDER: + { + this->processRtnOrder(&task); + break; + } + + case ONRTNTRADE: + { + this->processRtnTrade(&task); + break; + } + + case ONERRRTNORDERINSERT: + { + this->processErrRtnOrderInsert(&task); + break; + } + + case ONERRRTNORDERACTION: + { + this->processErrRtnOrderAction(&task); + break; + } + + case ONRTNINSTRUMENTSTATUS: + { + this->processRtnInstrumentStatus(&task); + break; + } + + case ONRTNBULLETIN: + { + this->processRtnBulletin(&task); + break; + } + + case ONRTNTRADINGNOTICE: + { + this->processRtnTradingNotice(&task); + break; + } + + case ONRTNERRORCONDITIONALORDER: + { + this->processRtnErrorConditionalOrder(&task); + break; + } + + case ONRTNEXECORDER: + { + this->processRtnExecOrder(&task); + break; + } + + case ONERRRTNEXECORDERINSERT: + { + this->processErrRtnExecOrderInsert(&task); + break; + } + + case ONERRRTNEXECORDERACTION: + { + this->processErrRtnExecOrderAction(&task); + break; + } + + case ONERRRTNFORQUOTEINSERT: + { + this->processErrRtnForQuoteInsert(&task); + break; + } + + case ONRTNQUOTE: + { + this->processRtnQuote(&task); + break; + } + + case ONERRRTNQUOTEINSERT: + { + this->processErrRtnQuoteInsert(&task); + break; + } + + case ONERRRTNQUOTEACTION: + { + this->processErrRtnQuoteAction(&task); + break; + } + + case ONRTNFORQUOTERSP: + { + this->processRtnForQuoteRsp(&task); + break; + } + + case ONRTNCFMMCTRADINGACCOUNTTOKEN: + { + this->processRtnCFMMCTradingAccountToken(&task); + break; + } + + case ONERRRTNBATCHORDERACTION: + { + this->processErrRtnBatchOrderAction(&task); + break; + } + + case ONRTNOPTIONSELFCLOSE: + { + this->processRtnOptionSelfClose(&task); + break; + } + + case ONERRRTNOPTIONSELFCLOSEINSERT: + { + this->processErrRtnOptionSelfCloseInsert(&task); + break; + } + + case ONERRRTNOPTIONSELFCLOSEACTION: + { + this->processErrRtnOptionSelfCloseAction(&task); + break; + } + + case ONRTNCOMBACTION: + { + this->processRtnCombAction(&task); + break; + } + + case ONERRRTNCOMBACTIONINSERT: + { + this->processErrRtnCombActionInsert(&task); + break; + } + + case ONRSPQRYCONTRACTBANK: + { + this->processRspQryContractBank(&task); + break; + } + + case ONRSPQRYPARKEDORDER: + { + this->processRspQryParkedOrder(&task); + break; + } + + case ONRSPQRYPARKEDORDERACTION: + { + this->processRspQryParkedOrderAction(&task); + break; + } + + case ONRSPQRYTRADINGNOTICE: + { + this->processRspQryTradingNotice(&task); + break; + } + + case ONRSPQRYBROKERTRADINGPARAMS: + { + this->processRspQryBrokerTradingParams(&task); + break; + } + + case ONRSPQRYBROKERTRADINGALGOS: + { + this->processRspQryBrokerTradingAlgos(&task); + break; + } + + case ONRSPQUERYCFMMCTRADINGACCOUNTTOKEN: + { + this->processRspQueryCFMMCTradingAccountToken(&task); + break; + } + + case ONRTNFROMBANKTOFUTUREBYBANK: + { + this->processRtnFromBankToFutureByBank(&task); + break; + } + + case ONRTNFROMFUTURETOBANKBYBANK: + { + this->processRtnFromFutureToBankByBank(&task); + break; + } + + case ONRTNREPEALFROMBANKTOFUTUREBYBANK: + { + this->processRtnRepealFromBankToFutureByBank(&task); + break; + } + + case ONRTNREPEALFROMFUTURETOBANKBYBANK: + { + this->processRtnRepealFromFutureToBankByBank(&task); + break; + } + + case ONRTNFROMBANKTOFUTUREBYFUTURE: + { + this->processRtnFromBankToFutureByFuture(&task); + break; + } + + case ONRTNFROMFUTURETOBANKBYFUTURE: + { + this->processRtnFromFutureToBankByFuture(&task); + break; + } + + case ONRTNREPEALFROMBANKTOFUTUREBYFUTUREMANUAL: + { + this->processRtnRepealFromBankToFutureByFutureManual(&task); + break; + } + + case ONRTNREPEALFROMFUTURETOBANKBYFUTUREMANUAL: + { + this->processRtnRepealFromFutureToBankByFutureManual(&task); + break; + } + + case ONRTNQUERYBANKBALANCEBYFUTURE: + { + this->processRtnQueryBankBalanceByFuture(&task); + break; + } + + case ONERRRTNBANKTOFUTUREBYFUTURE: + { + this->processErrRtnBankToFutureByFuture(&task); + break; + } + + case ONERRRTNFUTURETOBANKBYFUTURE: + { + this->processErrRtnFutureToBankByFuture(&task); + break; + } + + case ONERRRTNREPEALBANKTOFUTUREBYFUTUREMANUAL: + { + this->processErrRtnRepealBankToFutureByFutureManual(&task); + break; + } + + case ONERRRTNREPEALFUTURETOBANKBYFUTUREMANUAL: + { + this->processErrRtnRepealFutureToBankByFutureManual(&task); + break; + } + + case ONERRRTNQUERYBANKBALANCEBYFUTURE: + { + this->processErrRtnQueryBankBalanceByFuture(&task); + break; + } + + case ONRTNREPEALFROMBANKTOFUTUREBYFUTURE: + { + this->processRtnRepealFromBankToFutureByFuture(&task); + break; + } + + case ONRTNREPEALFROMFUTURETOBANKBYFUTURE: + { + this->processRtnRepealFromFutureToBankByFuture(&task); + break; + } + + case ONRSPFROMBANKTOFUTUREBYFUTURE: + { + this->processRspFromBankToFutureByFuture(&task); + break; + } + + case ONRSPFROMFUTURETOBANKBYFUTURE: + { + this->processRspFromFutureToBankByFuture(&task); + break; + } + + case ONRSPQUERYBANKACCOUNTMONEYBYFUTURE: + { + this->processRspQueryBankAccountMoneyByFuture(&task); + break; + } + + case ONRTNOPENACCOUNTBYBANK: + { + this->processRtnOpenAccountByBank(&task); + break; + } + + case ONRTNCANCELACCOUNTBYBANK: + { + this->processRtnCancelAccountByBank(&task); + break; + } + + case ONRTNCHANGEACCOUNTBYBANK: + { + this->processRtnChangeAccountByBank(&task); + break; + } + }; + } + } + catch (const TerminatedError&) + { + } }; void TdApi::processFrontConnected(Task *task) From 3080101ba026f0888b6f3e4f2c206c9b407c2d89 Mon Sep 17 00:00:00 2001 From: nanoric Date: Mon, 18 Feb 2019 03:41:16 -0400 Subject: [PATCH 2/2] =?UTF-8?q?[Mod]=20Include=E7=9A=84=E7=9B=B8=E5=AF=B9?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E6=94=B9=E4=B8=BA=E7=BB=9D=E5=AF=B9=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=EF=BC=88Python=E9=99=A4=E5=A4=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/api/ctp/vnctp/vnctp.h | 3 -- vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.vcxproj | 39 ++++++++++++++-------- vnpy/api/ctp/vnctp/vnctptd/vnctptd.vcxproj | 38 +++++++++++++++------ 3 files changed, 53 insertions(+), 27 deletions(-) diff --git a/vnpy/api/ctp/vnctp/vnctp.h b/vnpy/api/ctp/vnctp/vnctp.h index 236e9c82..d70bfd78 100644 --- a/vnpy/api/ctp/vnctp/vnctp.h +++ b/vnpy/api/ctp/vnctp/vnctp.h @@ -1,6 +1,3 @@ -#define NOMINMAX -#define _CRT_SECURE_NO_WARNINGS - #include #include #include diff --git a/vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.vcxproj b/vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.vcxproj index 7a830fb8..d5c4473c 100644 --- a/vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.vcxproj +++ b/vnpy/api/ctp/vnctp/vnctpmd/vnctpmd.vcxproj @@ -23,7 +23,7 @@ {F00054FF-282F-4826-848E-D58BFB9E9D9F} Win32Proj vnctpmd - 10.0.17134.0 + 10.0.17763.0 @@ -72,21 +72,29 @@ true + C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath) + C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath) + .pyd true + C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath) + C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath) + .pyd false .pyd - C:\GitHub\vnpy\vnpy\api\ctp\pybind11;C:\GitHub\vnpy\vnpy\api\ctp\ctpapi;$(IncludePath) + C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath) C:\GitHub\vnpy\vnpy\api\ctp\ctpapi;$(ReferencePath) + C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath) false - $(IncludePath) + C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath) $(ReferencePath) .pyd + C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath) @@ -94,11 +102,12 @@ Level3 Disabled true - WIN32;_DEBUG;VNCTPMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + NOMINMAX;_CRT_SECURE_NO_WARNINGS;NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;VNCTPMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true + stdafx.h - Windows + Console true @@ -108,11 +117,12 @@ Level3 Disabled true - _DEBUG;VNCTPMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + NOMINMAX;_CRT_SECURE_NO_WARNINGS;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_DEBUG;VNCTPMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true + stdafx.h - Windows + Console true @@ -124,11 +134,12 @@ true true true - WIN32;NDEBUG;VNCTPMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + NOMINMAX;_CRT_SECURE_NO_WARNINGS;NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;VNCTPMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true + stdafx.h - Windows + Console true true true @@ -136,18 +147,20 @@ - NotUsing + Use Level3 MaxSpeed true true true - NDEBUG;VNCTPMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + NOMINMAX;_CRT_SECURE_NO_WARNINGS;NDEBUG;VNCTPMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - C:\GitHub\vnpy\vnpy\api\ctp\vnctp;C:\Miniconda3\include;C:\GitHub\vnpy\vnpy\api\ctp\include;%(AdditionalIncludeDirectories) + + + stdafx.h - Windows + Console true true true diff --git a/vnpy/api/ctp/vnctp/vnctptd/vnctptd.vcxproj b/vnpy/api/ctp/vnctp/vnctptd/vnctptd.vcxproj index d0acf4ac..625a5bb9 100644 --- a/vnpy/api/ctp/vnctp/vnctptd/vnctptd.vcxproj +++ b/vnpy/api/ctp/vnctp/vnctptd/vnctptd.vcxproj @@ -23,7 +23,7 @@ {016732E6-5789-4F7C-9A1C-C46A249080CF} Win32Proj vnctptd - 10.0.17134.0 + 10.0.17763.0 @@ -72,16 +72,27 @@ true + C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath) + C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath) + .pyd true + C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath) + C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath) + .pyd false + C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath) + C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath) + .pyd false .pyd + C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath) + C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath) @@ -89,11 +100,12 @@ Level3 Disabled true - WIN32;_DEBUG;VNCTPTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;VNCTPTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true + stdafx.h - Windows + Console true @@ -103,11 +115,12 @@ Level3 Disabled true - _DEBUG;VNCTPTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + NOMINMAX;_CRT_SECURE_NO_WARNINGS;_DEBUG;VNCTPTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true + stdafx.h - Windows + Console true @@ -119,11 +132,12 @@ true true true - WIN32;NDEBUG;VNCTPTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;VNCTPTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true + stdafx.h - Windows + Console true true true @@ -131,18 +145,20 @@ - NotUsing + Use Level3 MaxSpeed true true true - NDEBUG;VNCTPTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + NOMINMAX;_CRT_SECURE_NO_WARNINGS;NDEBUG;VNCTPTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - C:\Miniconda3\include;C:\GitHub\vnpy\vnpy\api\ctp\include;C:\GitHub\vnpy\vnpy\api\ctp\vnctp;%(AdditionalIncludeDirectories) + + + stdafx.h - Windows + Console true true true