| | |
| | | |
| | | # 正式账号 |
| | | from log_module import async_log_util |
| | | from log_module.log import logger_local_huaxin_trade_debug, logger_system, logger_trade |
| | | from log_module.log import logger_local_huaxin_trade_debug as logger, logger_system, logger_trade, \ |
| | | logger_local_huaxin_trade_debug |
| | | from utils import tool, socket_util, middle_api_protocol |
| | | import logging as logger |
| | | |
| | | ########B类######## |
| | | UserID = '388000013349' |
| | |
| | | self.call_back_thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=10) |
| | | |
| | | def OnFrontConnected(self) -> "void": |
| | | logger.info('OnFrontConnected') |
| | | print('Trader OnFrontConnected') |
| | | |
| | | # 获取终端信息 |
| | | TradeSimpleApi.req_id += 1 |
| | | |
| | | ret = api.ReqGetConnectionInfo(TradeSimpleApi.req_id) |
| | | if ret != 0: |
| | | logger.info('ReqGetConnectionInfo fail, ret[%d]' % ret) |
| | | print('ReqGetConnectionInfo fail, ret[%d]' % ret) |
| | | |
| | | def OnFrontDisconnected(self, nReason: "int") -> "void": |
| | | logger.info('OnFrontDisconnected: [%d]' % nReason) |
| | | print('OnFrontDisconnected: [%d]' % nReason) |
| | | |
| | | def OnRspGetConnectionInfo(self, pConnectionInfoField: "CTORATstpConnectionInfoField", |
| | | pRspInfoField: "CTORATstpRspInfoField", nRequestID: "int") -> "void": |
| | |
| | | TradeSimpleApi.req_id += 1 |
| | | ret = api.ReqUserLogin(login_req, TradeSimpleApi.req_id) |
| | | if ret != 0: |
| | | logger.info('ReqUserLogin fail, ret[%d]' % ret) |
| | | print('ReqUserLogin fail, ret[%d]' % ret) |
| | | else: |
| | | logger.info('GetConnectionInfo fail, [%d] [%d] [%s]!!!' % ( |
| | | print('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_local_huaxin_trade_debug.info("交易登录成功") |
| | | logger.info('Login success! [%d]' % nRequestID) |
| | | print('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 __init_trade_data_server(): |
| | | logger.info("初始化交易服务器") |
| | | print("初始化交易服务器") |
| | | global api |
| | | api = traderapi.CTORATstpTraderApi.CreateTstpTraderApi('./flow', False) |
| | | # 创建回调对象 |