| | |
| | | nRequestID: "int") -> "void": |
| | | try: |
| | | if pRspInfoField.ErrorID == 0: |
| | | logger.info('[%d] OnRspOrderInsert: OK! [%d]' % (round(time.time() * 1000), nRequestID)) |
| | | # logger.info('[%d] OnRspOrderInsert: OK! [%d]' % (round(time.time() * 1000), nRequestID)) |
| | | pass |
| | | else: |
| | | logger.info('OnRspOrderInsert: Error! [%d] [%d] [%s]' |
| | | % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | # logger.info('OnRspOrderInsert: Error! [%d] [%d] [%s]' |
| | | # % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | threading.Thread(target=lambda: self.__data_callback(TYPE_ORDER, nRequestID, |
| | | {"sinfo": pInputOrderField.SInfo, |
| | | "orderStatus": -1, |
| | |
| | | pRspInfoField.ErrorID, |
| | | pRspInfoField.ErrorMsg)) |
| | | except: |
| | | logger_local_huaxin_trade_debug.info("OnErrRtnOrderAction: 撤单出错") |
| | | async_log_util.info(logger_local_huaxin_trade_debug, "OnErrRtnOrderAction: 撤单出错") |
| | | |
| | | def OnRspInquiryJZFund(self, pRspInquiryJZFundField: "CTORATstpRspInquiryJZFundField", |
| | | pRspInfoField: "CTORATstpRspInfoField", nRequestID: "int") -> "void": |
| | | try: |
| | | if pRspInfoField.ErrorID == 0: |
| | | logger.info('OnRspInquiryJZFund: OK! [%d] [%.2f] [%.2f]' |
| | | % (nRequestID, pRspInquiryJZFundField.UsefulMoney, pRspInquiryJZFundField.FetchLimit)) |
| | | else: |
| | | logger.info('OnRspInquiryJZFund: Error! [%d] [%d] [%s]' |
| | | % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | except: |
| | | # try: |
| | | # if pRspInfoField.ErrorID == 0: |
| | | # logger.info('OnRspInquiryJZFund: OK! [%d] [%.2f] [%.2f]' |
| | | # % (nRequestID, pRspInquiryJZFundField.UsefulMoney, pRspInquiryJZFundField.FetchLimit)) |
| | | # else: |
| | | # logger.info('OnRspInquiryJZFund: Error! [%d] [%d] [%s]' |
| | | # % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | # except: |
| | | # pass |
| | | pass |
| | | |
| | | def OnRspTransferFund(self, pInputTransferFundField: "CTORATstpInputTransferFundField", |
| | | pRspInfoField: "CTORATstpRspInfoField", nRequestID: "int") -> "void": |
| | | try: |
| | | if pRspInfoField.ErrorID == 0: |
| | | logger.info('OnRspTransferFund: OK! [%d]' % nRequestID) |
| | | else: |
| | | logger.info('OnRspTransferFund: Error! [%d] [%d] [%s]' |
| | | % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | except: |
| | | # try: |
| | | # if pRspInfoField.ErrorID == 0: |
| | | # logger.info('OnRspTransferFund: OK! [%d]' % nRequestID) |
| | | # else: |
| | | # logger.info('OnRspTransferFund: Error! [%d] [%d] [%s]' |
| | | # % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | # except: |
| | | # pass |
| | | pass |
| | | |
| | | def OnRtnOrder(self, pOrderField: "CTORATstpOrderField") -> "void": |
| | |
| | | threading.Thread(target=lambda: self.__data_callback(TYPE_ORDER, 0, order_data), |
| | | daemon=True).start() |
| | | except Exception as e: |
| | | logger_local_huaxin_trade_debug.exception(e) |
| | | logger_local_huaxin_trade_debug.error("OnRtnOrder 出错") |
| | | async_log_util.error(logger_local_huaxin_trade_debug, "OnRtnOrder 出错") |
| | | except: |
| | | logger_local_huaxin_trade_debug.error("OnRtnOrder 出错") |
| | | async_log_util.error(logger_local_huaxin_trade_debug, "OnRtnOrder 出错") |
| | | |
| | | def OnRtnTrade(self, pTradeField: "CTORATstpTradeField") -> "void": |
| | | try: |
| | |
| | | "frozenCash": round(pTradingAccountField.FrozenCash, 2), |
| | | "fetchLimit": round(pTradingAccountField.FetchLimit, 2), |
| | | "preDeposit": round(pTradingAccountField.PreDeposit, 2)}) |
| | | logger.info( |
| | | 'OnRspQryTradingAccount[%d]: DepartmentID[%s] InvestorID[%s] AccountID[%s] CurrencyID[%s] UsefulMoney[%.2f] FetchLimit[%.2f]' |
| | | % (nRequestID, pTradingAccountField.DepartmentID, pTradingAccountField.InvestorID, |
| | | pTradingAccountField.AccountID, pTradingAccountField.CurrencyID, |
| | | pTradingAccountField.UsefulMoney, pTradingAccountField.FetchLimit)) |
| | | # logger.info( |
| | | # 'OnRspQryTradingAccount[%d]: DepartmentID[%s] InvestorID[%s] AccountID[%s] CurrencyID[%s] UsefulMoney[%.2f] FetchLimit[%.2f]' |
| | | # % (nRequestID, pTradingAccountField.DepartmentID, pTradingAccountField.InvestorID, |
| | | # pTradingAccountField.AccountID, pTradingAccountField.CurrencyID, |
| | | # pTradingAccountField.UsefulMoney, pTradingAccountField.FetchLimit)) |
| | | else: |
| | | results = self.__temp_money_account_list_dict.pop(nRequestID) |
| | | threading.Thread(target=lambda: self.__data_callback(TYPE_LIST_MONEY, nRequestID, results), |
| | | daemon=True).start() |
| | | logger.info('查询资金账号结束[%d] ErrorID[%d] ErrorMsg[%s]' |
| | | % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | # logger.info('查询资金账号结束[%d] ErrorID[%d] ErrorMsg[%s]' |
| | | # % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | except: |
| | | pass |
| | | |
| | |
| | | if nRequestID not in self.__temp_order_list_dict: |
| | | self.__temp_order_list_dict[nRequestID] = [] |
| | | if not bIsLast: |
| | | logger.info( |
| | | 'OnRspQryOrder[%d]: SecurityID[%s] OrderLocalID[%s] Direction[%s] OrderRef[%d] OrderSysID[%s] VolumeTraded[%d] OrderStatus[%s] OrderSubmitStatus[%s], StatusMsg[%s]' |
| | | % (nRequestID, pOrderField.SecurityID, pOrderField.OrderLocalID, pOrderField.Direction, |
| | | pOrderField.OrderRef, pOrderField.OrderSysID, |
| | | pOrderField.VolumeTraded, pOrderField.OrderStatus, pOrderField.OrderSubmitStatus, |
| | | pOrderField.StatusMsg)) |
| | | # logger.info( |
| | | # 'OnRspQryOrder[%d]: SecurityID[%s] OrderLocalID[%s] Direction[%s] OrderRef[%d] OrderSysID[%s] VolumeTraded[%d] OrderStatus[%s] OrderSubmitStatus[%s], StatusMsg[%s]' |
| | | # % (nRequestID, pOrderField.SecurityID, pOrderField.OrderLocalID, pOrderField.Direction, |
| | | # pOrderField.OrderRef, pOrderField.OrderSysID, |
| | | # pOrderField.VolumeTraded, pOrderField.OrderStatus, pOrderField.OrderSubmitStatus, |
| | | # pOrderField.StatusMsg)) |
| | | self.__temp_order_list_dict[nRequestID].append( |
| | | {"securityID": pOrderField.SecurityID, "orderLocalID": pOrderField.OrderLocalID, |
| | | "direction": pOrderField.Direction, "orderSysID": pOrderField.OrderSysID, |
| | |
| | | "volume": pOrderField.VolumeTotalOriginal, |
| | | "volumeTraded": pOrderField.VolumeTraded, "orderStatus": pOrderField.OrderStatus, |
| | | "orderSubmitStatus": pOrderField.OrderSubmitStatus, "statusMsg": pOrderField.StatusMsg}) |
| | | |
| | | else: |
| | | logger.info('查询报单结束[%d] ErrorID[%d] ErrorMsg[%s]' |
| | | % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | # logger.info('查询报单结束[%d] ErrorID[%d] ErrorMsg[%s]' |
| | | # % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | threading.Thread(target=lambda: self.__data_callback(TYPE_LIST_DELEGATE, nRequestID, |
| | | self.__temp_order_list_dict[nRequestID]), |
| | | daemon=True).start() |
| | |
| | | "todayTotalBuyAmount": pPositionField.TodayTotalBuyAmount, |
| | | "todayTotalSellAmount": pPositionField.TodayTotalSellAmount}) |
| | | else: |
| | | logger.info('查询持仓结束[%d] ErrorID[%d] ErrorMsg[%s]' |
| | | % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | # logger.info('查询持仓结束[%d] ErrorID[%d] ErrorMsg[%s]' |
| | | # % (nRequestID, pRspInfoField.ErrorID, pRspInfoField.ErrorMsg)) |
| | | threading.Thread(target=lambda: self.__data_callback(TYPE_LIST_POSITION, nRequestID, |
| | | self.__temp_position_list_dict[nRequestID]), |
| | | daemon=True).start() |
| | |
| | | |
| | | # 成交回报,参数pTradeField是一个CTORATstpTradeField类对象 |
| | | def OnRtnTrade(self, pTradeField: "CTORATstpTradeField") -> "void": |
| | | logger.info("OnRtnTrade") |
| | | pass |
| | | # logger.info("OnRtnTrade") |
| | | |
| | | # 查询成交响应,参数pTradeField是一个CTORATstpTradeField类对象 |
| | | def OnRspQryTrade(self, pTradeField: "CTORATstpTradeField", pRspInfoField: "CTORATstpRspInfoField", |
| | | nRequestID: "int", bIsLast: "bool") -> "void": |
| | | try: |
| | | logger.info("查询成交响应") |
| | | # logger.info("查询成交响应") |
| | | pass |
| | | if nRequestID not in self.__temp_order_list_dict: |
| | | self.__temp_order_list_dict[nRequestID] = [] |
| | | if not bIsLast: |
| | |
| | | else: |
| | | strategy_pipe.send(data) |
| | | |
| | | |
| | | # 交易反馈回调 |
| | | def __traderapi_callback(type, req_id, data): |
| | | async_log_util.info(logger_local_huaxin_trade_debug, "回调:type-{} req_id-{}", type, req_id) |