Administrator
2023-08-10 d534b71782e55c0d5d63da74fe3a3719faf86987
main.py
@@ -12,9 +12,10 @@
# 交易服务
from third_data import data_server
from trade.huaxin import trade_server, trade_api_server
import huaxin
def createTradeServer(pipe):
def createTradeServer(pipe_server, pipe_trade, pipe_l1):
    # 初始化参数
    global_data_loader.init()
@@ -23,15 +24,15 @@
    t1.start()
    # 交易接口服务
    t1 = threading.Thread(target=trade_api_server.run, args=(pipe,), daemon=True)
    t1 = threading.Thread(target=trade_api_server.run, args=(pipe_server,), daemon=True)
    t1.start()
    # redis后台服务
    t1 = threading.Thread(target=redis_manager.RedisUtils.run_loop,  daemon=True)
    t1 = threading.Thread(target=redis_manager.RedisUtils.run_loop, daemon=True)
    t1.start()
    # 交易服务
    trade_server.run()
    trade_server.run(pipe_trade, pipe_l1)
# 主服务
@@ -50,9 +51,23 @@
if __name__ == '__main__':
    pipe_server, pipe_trade = multiprocessing.Pipe()
    # 策略与server间的通信
    pss_server, pss_strategy = multiprocessing.Pipe()
    # 策略与交易间的通信
    pst_trade, pst_strategy = multiprocessing.Pipe()
    # 交易与l2之间的通信
    ptl2_trade, ptl2_l2 = multiprocessing.Pipe()
    # l1与trade间的通信
    pl1t_l1, pl1t_trade = multiprocessing.Pipe()
    logger_l2_process_time.info("测试123")
    serverProcess = multiprocessing.Process(target=createServer, args=(pipe_server,))
    serverProcess = multiprocessing.Process(target=createServer, args=(pss_server,))
    serverProcess.start()
    # 将tradeServer作为主进程
    createTradeServer(pipe_trade)
    createTradeServer(pss_strategy, pst_strategy, pl1t_trade)
    tradeProcess = multiprocessing.Process(target=huaxin.trade_client.run, args=(ptl2_trade, pst_trade))
    l2Process = multiprocessing.Process(target=huaxin.l2_client.run, args=(ptl2_l2,))
    tradeProcess.start()
    l2Process.start()
    huaxin.l1_client.run_async(pl1t_l1)