Administrator
2023-08-15 457f3d4ca0c33ea41055de2e45c4218e3f541d02
trade/huaxin/trade_api_server.py
@@ -22,6 +22,7 @@
from trade.huaxin import huaxin_trade_api, huaxin_trade_record_manager, \
    huaxin_trade_data_update
from trade.huaxin.huaxin_trade_api import ClientSocketManager
from trade.trade_manager import TradeTargetCodeModeManager
from utils import socket_util, tool, huaxin_util, data_export_util
@@ -433,8 +434,12 @@
                    codes = [d[0] for d in datas]
                    for code in codes:
                        block_info.init_code(code)
                    result = huaxin_trade_api.set_l2_codes_data(datas)
                    print("设置L2代码结果:", result)
                    root_data = {"type": ClientSocketManager.CLIENT_TYPE_CMD_L2,
                                 "data": datas,
                                 "request_id": f"{ ClientSocketManager.CLIENT_TYPE_CMD_L2}_{round(time.time()*1000)}"}
                    root_data = socket_util.encryp_client_params_sign(root_data)
                    pipe_l2.send(json.dumps(root_data))
                    print("设置L2代码结束")
        except Exception as e:
            logging.exception(e)
        finally:
@@ -486,7 +491,10 @@
            time.sleep(1)
def run(pipe):
def run(pipe_server, pipe_l2_):
    global pipe_l2
    pipe_l2 = pipe_l2_
    print("create TradeApiServer")
    # 拉取交易信息
    huaxin_trade_data_update.run()
@@ -494,7 +502,7 @@
    t1 = threading.Thread(target=lambda: __set_target_codes(), daemon=True)
    t1.start()
    t1 = threading.Thread(target=lambda: __read_sync_task(pipe), daemon=True)
    t1 = threading.Thread(target=lambda: __read_sync_task(pipe_server), daemon=True)
    t1.start()
    laddr = "0.0.0.0", 10009