| | |
| | | CLIENT_TYPE_POSITION_LIST = "position_list" |
| | | CLIENT_TYPE_MONEY = "money" |
| | | CLIENT_TYPE_DEAL = "deal" |
| | | CLIENT_TYPE_ORDER_FOUND_DETAIL = "order_found_detail" |
| | | |
| | | CLIENT_TYPE_CMD_L2 = "l2_cmd" |
| | | |
| | |
| | | |
| | | # 测试 |
| | | def OnTest(self, client_id, request_id, data, sk): |
| | | pass |
| | | |
| | | def OnOrderFoundDetail(self, client_id, request_id, sk, data): |
| | | pass |
| | | |
| | | |
| | |
| | | cls.action_callback.OnDelegateList(client_id, request_id, sk, can_cancel) |
| | | elif _type == CLIENT_TYPE_POSITION_LIST: |
| | | cls.action_callback.OnPositionList(client_id, request_id, sk) |
| | | |
| | | elif _type == CLIENT_TYPE_POSITION_LIST: |
| | | cls.action_callback.OnOrderFoundDetail(client_id, request_id, sk, data) |
| | | |
| | | |
| | | elif _type == "test": |
| | | cls.action_callback.OnTest(client_id, request_id, data, sk) |
| | | except Exception as e: |
| | |
| | | TYPE_LIST_MONEY = 5 |
| | | # 成交 |
| | | TYPE_DEAL = 6 |
| | | # 订单费率 |
| | | TYPE_LIST_ORDER_FOUND = 7 |
| | | |
| | | ENABLE_ORDER = True |
| | | |
| | |
| | | raise Exception('ReqQryTradingAccount fail, ret[%d]' % ret) |
| | | return req_id |
| | | |
| | | def queryOrderFoundDetail(self, code, orderSysID): |
| | | """ |
| | | 查询订单单资金明细 |
| | | :param code: |
| | | :param orderSysID: |
| | | :return: |
| | | """ |
| | | self.req_id += 1 |
| | | req_id = self.req_id |
| | | req_field = traderapi.CTORATstpQryOrderFundDetailField() |
| | | if tool.is_sz_code(code): |
| | | req_field.ExchangeID = traderapi.TORA_TSTP_EXD_SZSE |
| | | elif tool.is_sh_code(code): |
| | | req_field.ExchangeID = traderapi.TORA_TSTP_EXD_SSE |
| | | req_field.InvestorID = InvestorID |
| | | req_field.SecurityID = code |
| | | req_field.OrderSysID = orderSysID |
| | | ret = api.ReqQryOrderFundDetail(req_field, req_id) |
| | | if ret != 0: |
| | | raise Exception('ReqQryOrderFundDetail fail, ret[%d]' % ret) |
| | | return req_id |
| | | |
| | | def login(self): |
| | | # 请求登录 |
| | | login_req = traderapi.CTORATstpReqUserLoginField() |
| | |
| | | self.__temp_order_list_dict = {} |
| | | self.__temp_position_list_dict = {} |
| | | self.__temp_money_account_list_dict = {} |
| | | self.__temp_order_found_list_dict = {} |
| | | self.call_back_thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=10) |
| | | |
| | | def OnFrontConnected(self) -> "void": |
| | |
| | | % (pTradeField.TradeID, pTradeField.InvestorID, pTradeField.SecurityID, |
| | | pTradeField.OrderRef, pTradeField.OrderLocalID, pTradeField.Price, |
| | | pTradeField.Volume)) |
| | | except: |
| | | pass |
| | | |
| | | def OnRspQryOrderFundDetail(self, pOrderFundDetailField: "CTORATstpOrderFundDetailField", |
| | | pRspInfoField: "CTORATstpRspInfoField", nRequestID: "int", bIsLast: "bool") -> "void": |
| | | logging.info(f"佣金费用响应:{pRspInfoField.ErrorID}-{pRspInfoField.ErrorMsg}-{bIsLast}") |
| | | try: |
| | | if nRequestID not in self.__temp_order_found_list_dict: |
| | | self.__temp_order_found_list_dict[nRequestID] = [] |
| | | if bIsLast != 1: |
| | | data = {"orderLocalID": pOrderFundDetailField.OrderLocalID, |
| | | "orderSysID": pOrderFundDetailField.OrderSysID, |
| | | "securityID": pOrderFundDetailField.SecurityID, |
| | | "orderAmount": pOrderFundDetailField.OrderAmount, "turnover": pOrderFundDetailField.Turnover, |
| | | "stampTaxFee": pOrderFundDetailField.StampTaxFee, |
| | | "handlingFee": pOrderFundDetailField.HandlingFee, |
| | | "brokerageFee": pOrderFundDetailField.BrokerageFee, "totalFee": pOrderFundDetailField.TotalFee} |
| | | self.__temp_order_found_list_dict[nRequestID].append(data) |
| | | else: |
| | | results = self.__temp_order_found_list_dict.pop(nRequestID) |
| | | self.call_back_thread_pool.submit(self.__data_callback, TYPE_LIST_ORDER_FOUND, nRequestID, results) |
| | | except: |
| | | pass |
| | | |
| | |
| | | send_response(json.dumps({"code": 1, "msg": str(e)}), "common", client_id, |
| | | request_id) |
| | | |
| | | def OnOrderFoundDetail(self, client_id, request_id, sk, data): |
| | | async_log_util.info(logger_local_huaxin_trade_debug, f"请求订单资金明细:client_id-{client_id} request_id-{request_id}") |
| | | try: |
| | | code, orderSysID = data.get("code"), data.get("orderSysID") |
| | | req_id = self.__tradeSimpleApi.queryOrderFoundDetail(code, orderSysID) |
| | | req_rid_dict[req_id] = (client_id, request_id, sk) |
| | | except Exception as e: |
| | | send_response(json.dumps({"code": 1, "msg": str(e)}), "common", client_id, |
| | | request_id) |
| | | |
| | | def OnTest(self, client_id, request_id, data, sk): |
| | | send_response( |
| | | json.dumps({"type": "response", "data": {"code": 0, "data": data}, "client_id": client_id, |
| | |
| | | GUI管理 |
| | | """ |
| | | import math |
| | | import time |
| | | |
| | | import psutil |
| | | |
| | |
| | | from task import task_manager |
| | | from third_data import hx_qc_value_util |
| | | from third_data.code_plate_key_manager import KPLPlateForbiddenManager |
| | | from trade.huaxin import huaxin_trade_api |
| | | from utils import shared_memery_util |
| | | |
| | | logger_system.info("程序启动Pre:{}", os.getpid()) |
| | |
| | | args=(sub_single_queue, data_callback_queue, channels, i, )) |
| | | l2_process.start() |
| | | |
| | | l2_subscript_manager.process_manager = l2_subscript_manager.TargetCodeProcessManager(sub_single_queue_list, channel_count_list) |
| | | l2_subscript_manager.process_manager = l2_subscript_manager.TargetCodeProcessManager(sub_single_queue_list, |
| | | channel_count_list) |
| | | # 监听L2市场行情数据 |
| | | huaxin_trade_server.run_l2_market_info_reciever(data_callback_queue_list) |
| | | # 启动ZMQserver,针对委托队列与成交队列进行监听 |
| | |
| | | # 运行华鑫增值服务进程 |
| | | threading.Thread(target=hx_qc_value_util.run, daemon=True).start() |
| | | |
| | | |
| | | def test(): |
| | | time.sleep(180) |
| | | huaxin_trade_api.query_order_found_detail("603716", "110010190007896") |
| | | |
| | | |
| | | threading.Thread(target=test, daemon=True).start() |
| | | |
| | | # 绑核运行 |
| | | # psutil.Process(l1Process.pid).cpu_affinity([20]) |
| | | # psutil.Process(tradeProcess.pid).cpu_affinity([21, 22]) |
| | |
| | | CLIENT_TYPE_MONEY = "money" |
| | | CLIENT_TYPE_DEAL = "deal" |
| | | CLIENT_TYPE_CMD_L2 = "l2_cmd" |
| | | CLIENT_TYPE_ORDER_FOUND_DETAIL = "order_found_detail" |
| | | socket_client_dict = {} |
| | | socket_client_lock_dict = {} |
| | | active_client_dict = {} |
| | |
| | | return __read_response(request_id, blocking) |
| | | |
| | | |
| | | def query_order_found_detail(code, orderSysID): |
| | | """ |
| | | 查询订单资金明细 |
| | | :param code: |
| | | :param orderSysID: |
| | | :return: |
| | | """ |
| | | request_id = __get_request_id(ClientSocketManager.CLIENT_TYPE_ORDER_FOUND_DETAIL) |
| | | for i in range(1): |
| | | request_id = __request(ClientSocketManager.CLIENT_TYPE_ORDER_FOUND_DETAIL, |
| | | {"type": ClientSocketManager.CLIENT_TYPE_ORDER_FOUND_DETAIL, |
| | | "code": code, |
| | | "orderSysID": orderSysID}, |
| | | request_id=request_id, |
| | | is_trade=True) |
| | | try: |
| | | res = __read_response(request_id, True) |
| | | async_log_util.info(hx_logger_trade_debug, f"资金明细结果:{res}") |
| | | return res |
| | | finally: |
| | | pass |
| | | |
| | | |
| | | # 设置L2订阅数据 |
| | | def __test_trade_channel(sid): |
| | | request_id = __request("test", |