| | |
| | | |
| | | @classmethod |
| | | def process_command(cls, _type, client_id, result_json, sk=None): |
| | | # 查看是否是设置L2的代码 |
| | | if _type == CLIENT_TYPE_CMD_L2: |
| | | cls.pipe_l2.send( |
| | | json.dumps({"type": "set_l2_codes", "data": result_json["data"]})) |
| | | return |
| | | |
| | | try: |
| | | data = result_json["data"] |
| | | print("接收内容", result_json) |
| | |
| | | val = json.loads(val) |
| | | print("run_process_command", val) |
| | | _type = val["type"] |
| | | _data = val["data"] |
| | | # 查看是否是设置L2的代码 |
| | | if _type == CLIENT_TYPE_CMD_L2: |
| | | cls.pipe_l2.send( |
| | | json.dumps({"type": "set_l2_codes", "data": _data})) |
| | | else: |
| | | threading.Thread(target=lambda: cls.process_command(_type, None, val), daemon=True).start() |
| | | except Exception as e: |
| | | logger_local_huaxin_trade_debug.exception(e) |
| | |
| | | from log_module import async_log_util |
| | | from log_module.log import hx_logger_l2_upload, hx_logger_contact_debug, hx_logger_trade_callback, \ |
| | | hx_logger_l2_orderdetail, hx_logger_l2_transaction, hx_logger_l2_market_data, logger_l2_trade_buy_queue, \ |
| | | logger_l2_g_cancel |
| | | logger_l2_g_cancel, logger_debug |
| | | from third_data import block_info, kpl_api, kpl_data_manager |
| | | from third_data.code_plate_key_manager import KPLCodeJXBlockManager, CodePlateKeyBuyManager |
| | | from third_data.history_k_data_util import JueJinApi, HistoryKDatasUtils |
| | |
| | | is_normal = l2_data_util.load_l2_data(code, load_latest=False) |
| | | volume_rate = code_volumn_manager.get_volume_rate(code) |
| | | volume_rate_index = code_volumn_manager.get_volume_rate_index(volume_rate) |
| | | m_val = L2PlaceOrderParamsManager(code, True, volume_rate, volume_rate_index, None).get_m_val()[ |
| | | m_val = \ |
| | | L2PlaceOrderParamsManager(code, True, volume_rate, volume_rate_index, None).get_m_val()[ |
| | | 0] |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | m_val_num = int(m_val / (float(limit_up_price) * 100)) |
| | |
| | | accountID = data["accountID"] |
| | | orderSysID = data["orderSysID"] |
| | | sinfo = data["sinfo"] |
| | | if orderSysID: |
| | | result = huaxin_trade_api.cancel_order(direction, accountID, orderSysID, sinfo=sinfo, |
| | | blocking=True, request_id=request_id) |
| | | self.send_response({"code": 0, "data": result}, client_id, request_id) |
| | | elif code: |
| | | l2_data_manager_new.L2TradeDataProcessor.cancel_buy(code, "手动撤单") |
| | | self.send_response({"code": 0, "data": {"code": 0}}, client_id, request_id) |
| | | |
| | | |
| | | except Exception as e: |
| | | self.send_response({"code": 1, "msg": str(e)}, client_id, request_id) |
| | | |
| | |
| | | |
| | | # 同步L2订阅代码 |
| | | def OnSyncL2SubscriptCodes(self, client_id, request_id): |
| | | logger_debug.debug("OnSyncL2SubscriptCodes") |
| | | try: |
| | | codes_sh, codes_sz = l1_subscript_codes_manager.request_l1_subscript_target_codes() |
| | | if codes_sh and codes_sz: |
| | | l1_subscript_codes_manager.save_codes(codes_sh, codes_sz) |
| | | result = {"code": 0, "data": {"codes_sh": len(codes_sh), "codes_sz": len(codes_sz)}} |
| | | self.send_response(result, client_id, request_id) |
| | | except Exception as e: |
| | | logger_debug.error(e) |
| | | |
| | | |
| | | def run(pipe_trade, pipe_l1): |