在API中添加了安全退出函数exit
This commit is contained in:
parent
f1321bdf19
commit
3b83f326bb
@ -433,6 +433,15 @@ int MdApi::join()
|
||||
return i;
|
||||
};
|
||||
|
||||
int MdApi::exit()
|
||||
{
|
||||
//该函数在原生API里没有,用于安全退出API用,原生的join似乎不太稳定
|
||||
this->api->RegisterSpi(NULL);
|
||||
this->api->Release();
|
||||
this->api = NULL;
|
||||
return 1;
|
||||
};
|
||||
|
||||
string MdApi::getTradingDay()
|
||||
{
|
||||
string day = this->api->GetTradingDay();
|
||||
@ -642,6 +651,7 @@ BOOST_PYTHON_MODULE(vnltsmd)
|
||||
.def("release", &MdApiWrap::release)
|
||||
.def("init", &MdApiWrap::init)
|
||||
.def("join", &MdApiWrap::join)
|
||||
.def("exit", &MdApiWrap::exit)
|
||||
.def("getTradingDay", &MdApiWrap::getTradingDay)
|
||||
.def("registerFront", &MdApiWrap::registerFront)
|
||||
.def("subscribeMarketData", &MdApiWrap::subscribeMarketData)
|
||||
|
@ -258,6 +258,8 @@ public:
|
||||
|
||||
int join();
|
||||
|
||||
int exit();
|
||||
|
||||
string getTradingDay();
|
||||
|
||||
void registerFront(string pszFrontAddress);
|
||||
|
@ -128,16 +128,19 @@ def main():
|
||||
#i = api.reqUserLogout({}, 1)
|
||||
#sleep(0.5)
|
||||
|
||||
## 安全退出,测试通过
|
||||
#i = api.exit()
|
||||
|
||||
# 获取交易日,目前输出为空
|
||||
#day = api.getTradingDay()
|
||||
#print 'Trading Day is:' + str(day)
|
||||
#sleep(0.5)
|
||||
|
||||
# 订阅合约
|
||||
subReq = {}
|
||||
subReq['InstrumentID'] = '11000061'
|
||||
subReq['ExchangeID'] = 'SSE'
|
||||
i = api.subscribeMarketData(subReq)
|
||||
## 订阅合约
|
||||
#subReq = {}
|
||||
#subReq['InstrumentID'] = '11000061'
|
||||
#subReq['ExchangeID'] = 'SSE'
|
||||
#i = api.subscribeMarketData(subReq)
|
||||
|
||||
## 退订合约
|
||||
#i = api.unSubscribeMarketData(subReq)
|
||||
|
Binary file not shown.
@ -2127,6 +2127,15 @@ int TdApi::join()
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::exit()
|
||||
{
|
||||
//该函数在原生API里没有,用于安全退出API用,原生的join似乎不太稳定
|
||||
this->api->RegisterSpi(NULL);
|
||||
this->api->Release();
|
||||
this->api = NULL;
|
||||
return 1;
|
||||
};
|
||||
|
||||
string TdApi::getTradingDay()
|
||||
{
|
||||
string day = this->api->GetTradingDay();
|
||||
@ -3129,6 +3138,7 @@ BOOST_PYTHON_MODULE(vnltstd)
|
||||
.def("release", &TdApiWrap::release)
|
||||
.def("init", &TdApiWrap::init)
|
||||
.def("join", &TdApiWrap::join)
|
||||
.def("exit", &TdApiWrap::exit)
|
||||
.def("getTradingDay", &TdApiWrap::getTradingDay)
|
||||
.def("registerFront", &TdApiWrap::registerFront)
|
||||
.def("subscribePrivateTopic", &TdApiWrap::subscribePrivateTopic)
|
||||
|
@ -496,6 +496,8 @@ public:
|
||||
|
||||
int join();
|
||||
|
||||
int exit();
|
||||
|
||||
string getTradingDay();
|
||||
|
||||
void registerFront(string pszFrontAddress);
|
||||
|
@ -345,6 +345,9 @@ def main():
|
||||
#i = api.reqUserLogout({}, 1)
|
||||
#sleep(0.5)
|
||||
|
||||
## 安全退出,测试通过
|
||||
#i = api.exit()
|
||||
|
||||
## 获取交易日,目前输出为空,测试通过
|
||||
#day = api.getTradingDay()
|
||||
#print 'Trading Day is:' + str(day)
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user