| | |
| | | class TraderSpi(traderapi.CTORATstpTraderSpi): |
| | | def __init__(self, api, callback): |
| | | traderapi.CTORATstpTraderSpi.__init__(self) |
| | | self.__api= api |
| | | self.__api = api |
| | | self.__front_id = 0 |
| | | self.__session_id = 0 |
| | | self.__data_callback = callback |
| | |
| | | |
| | | ret = self.__api.ReqGetConnectionInfo(TradeSimpleApi.req_id) |
| | | if ret != 0: |
| | | logger_info.info('ReqGetConnectionInfo fail, ret[%d]' % ret) |
| | | printlog('ReqGetConnectionInfo fail, ret[%d]' % ret) |
| | | |
| | | def OnFrontDisconnected(self, nReason: "int") -> "void": |
| | | logger_info.info('OnFrontDisconnected: [%d]' % nReason) |
| | | printlog('OnFrontDisconnected: [%d]' % nReason) |
| | | |
| | | def OnRspGetConnectionInfo(self, pConnectionInfoField: "CTORATstpConnectionInfoField", |
| | | pRspInfoField: "CTORATstpRspInfoField", nRequestID: "int") -> "void": |
| | |
| | | # login_req.OuterIPAddress = '58.246.43.50' |
| | | |
| | | TradeSimpleApi.req_id += 1 |
| | | ret = self.__api.ReqUserLogin(login_req, TradeSimpleApi.req_id) |
| | | ret = self.__api.ReqUserLogin(login_req, TradeSimpleApi.req_id) |
| | | if ret != 0: |
| | | logger.info('ReqUserLogin fail, ret[%d]' % ret) |
| | | printlog('ReqUserLogin fail, ret[%d]' % ret) |
| | | else: |
| | | logger_info.info('GetConnectionInfo fail, [%d] [%d] [%s]!!!' % ( |
| | | printlog('GetConnectionInfo fail, [%d] [%d] [%s]!!!' % ( |
| | | nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | |
| | | def OnRspUserLogin(self, pRspUserLoginField: "CTORATstpRspUserLoginField", pRspInfoField: "CTORATstpRspInfoField", |
| | | nRequestID: "int") -> "void": |
| | | if pRspInfoField.ErrorID == 0: |
| | | logger_info.info('Login success! [%d]' % nRequestID) |
| | | printlog('Login success! [%d]' % nRequestID) |
| | | self.__front_id = pRspUserLoginField.FrontID |
| | | self.__session_id = pRspUserLoginField.SessionID |
| | | # TradeSimpleApi.set_login_info(self.__session_id, self.__front_id) |
| | |
| | | def OnRspUserPasswordUpdate(self, pUserPasswordUpdateField: "CTORATstpUserPasswordUpdateField", |
| | | pRspInfoField: "CTORATstpRspInfoField", nRequestID: "int") -> "void": |
| | | if pRspInfoField.ErrorID == 0: |
| | | logger.info('OnRspUserPasswordUpdate: OK! [%d]' % nRequestID) |
| | | printlog('OnRspUserPasswordUpdate: OK! [%d]' % nRequestID) |
| | | else: |
| | | logger.info('OnRspUserPasswordUpdate: Error! [%d] [%d] [%s]' |
| | | % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | printlog('OnRspUserPasswordUpdate: Error! [%d] [%d] [%s]' |
| | | % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | |
| | | def OnRspOrderInsert(self, pInputOrderField: "CTORATstpInputOrderField", pRspInfoField: "CTORATstpRspInfoField", |
| | | nRequestID: "int") -> "void": |