Administrator
2023-08-31 b217ca6db84c273f0d1c24eed3fae6bec2431dbe
添加系统日志
6个文件已修改
38 ■■■■ 已修改文件
huaxin_client/l2_client.py 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/trade_client.py 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.py 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_record_manager.py 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/trade_server.py 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/l2_client.py
@@ -575,6 +575,7 @@
def run(pipe_trade, _pipe_strategy, _l2_data_callback: l2_data_transform_protocol.L2DataCallBack)->None:
    logger_system.info("L2进程ID:{}", os.getpid())
    try:
    log.close_print()
    if pipe_trade is not None:
        t1 = threading.Thread(target=lambda: __receive_from_pipe_trade(pipe_trade), daemon=True)
@@ -596,6 +597,8 @@
    l2CommandManager = command_manager.L2CommandManager()
    l2CommandManager.init(MyL2ActionCallback())
    logger_system.info("L2订阅服务启动成功")
    except Exception as e:
        logger_system.exception(e)
    while True:
        time.sleep(2)
huaxin_client/trade_client.py
@@ -1028,6 +1028,7 @@
def run(trade_response_: TradeResponse, pipe_l2=None, pipe_strategy=None):
    try:
    logger_system.info("交易进程ID:{}", os.getpid())
    __init_trade_data_server()
    global l2pipe
@@ -1046,6 +1047,8 @@
    tradeCommandManager = command_manager.TradeCommandManager()
    tradeCommandManager.init(MyTradeActionCallback(), l2pipe, pipe_strategy)
    logger_system.info("华鑫交易服务启动")
    except Exception as e:
        logger_system.exception(e)
    # 不需要运行命令解析
    # tradeCommandManager.run()
    while True:
l2/cancel_buy_strategy.py
@@ -1195,7 +1195,9 @@
                        if left_count > 0:
                            buy_nums += left_count * data["val"]["num"]
                            if buy_nums > threshold_num:
                                l2_log.l_cancel_debug(code, f"LX阻断L撤撤单:{buy_nums}/{threshold_num}")
                                return False, "LX阻断L撤撤单"
                l2_log.l_cancel_debug(code, f"LX尚未阻断L撤撤单:{buy_nums}/{threshold_num}")
                return can_cancel, cancel_data
            except Exception as e:
                l2_log.l_cancel_debug(code, f"LX撤单计算异常:{str(e)}")
main.py
@@ -42,11 +42,13 @@
    t1.start()
    # 启动L2订阅服务
    t1 = threading.Thread(target=huaxin_client.l2_client.run, args=(ptl2_l2, psl2_l2, trade_server.my_l2_data_callback), daemon=True)
    t1 = threading.Thread(target=huaxin_client.l2_client.run, args=(ptl2_l2, psl2_l2, trade_server.my_l2_data_callback),
                          daemon=True)
    t1.start()
    # 启动华鑫交易服务
    t1 = threading.Thread(target=huaxin_client.trade_client.run, args=(trade_server.my_trade_response, ptl2_trade, pst_trade),
    t1 = threading.Thread(target=huaxin_client.trade_client.run,
                          args=(trade_server.my_trade_response, ptl2_trade, pst_trade),
                          daemon=True)
    t1.start()
@@ -78,6 +80,7 @@
if __name__ == '__main__':
    try:
    logger_l2_trade.info("启动程序")
    logger_system.info("启动程序--------")
    log.close_print()
@@ -98,11 +101,14 @@
    # serverProcess.start()
    logger_system.info("主进程ID:{}", os.getpid())
    tradeServerProcess = multiprocessing.Process(target=createTradeServer,
                                                 args=(pss_strategy, pst_strategy, pl1t_strategy, psl2_strategy,ptl2_l2, psl2_l2,ptl2_trade,pst_trade))
    tradeServerProcess.start()
    # L1订阅数据
    huaxin_client.l1_client.run(pl1t_l1)
        l1Process = multiprocessing.Process(target=huaxin_client.l1_client.run, args=(pl1t_l1,))
        l1Process.start()
        # 主进程
        createTradeServer(pss_strategy, pst_strategy, pl1t_strategy, psl2_strategy, ptl2_l2, psl2_l2, ptl2_trade, pst_trade)
    # 将tradeServer作为主进程
    tradeServerProcess.join()
        l1Process.join()
    except Exception as e:
        logger_system.exception(e)
trade/huaxin/huaxin_trade_record_manager.py
@@ -393,5 +393,8 @@
if __name__ == "__main__":
    results = DelegateRecordManager.list_by_day('20230704', '1970-01-01')
    update_time = None
    results, update_time = DelegateRecordManager.list_by_day(
        tool.get_now_date_str("%Y%m%d"), update_time)
    print(results)
trade/huaxin/trade_server.py
@@ -798,6 +798,7 @@
def run(pipe_trade, pipe_l1, pipe_l2, trade_cmd_callback):
    try:
    # 执行一些初始化数据
    block_info.init()
@@ -830,6 +831,8 @@
    except Exception as e:
        logger_system.exception(e)
        logger_system.error(f"端口服务器:{laddr[1]} 启动失败")
    except Exception as e:
        logger_system.exception(e)
if __name__ == "__main__":