在API中添加了安全退出函数exit

This commit is contained in:
WOLF 2015-03-06 09:47:31 +08:00
parent f1321bdf19
commit 3b83f326bb
8 changed files with 35 additions and 5 deletions

View File

@ -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)

View File

@ -258,6 +258,8 @@ public:
int join();
int exit();
string getTradingDay();
void registerFront(string pszFrontAddress);

View File

@ -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.

View File

@ -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)

View File

@ -496,6 +496,8 @@ public:
int join();
int exit();
string getTradingDay();
void registerFront(string pszFrontAddress);

View File

@ -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.