| | |
| | | |
| | | def __receive_from_pipe_strategy(pipe_): |
| | | while True: |
| | | print("__receive_from_pipe_strategy") |
| | | # print("__receive_from_pipe_strategy") |
| | | try: |
| | | val = pipe_.recv() |
| | | if val: |
| | |
| | | |
| | | |
| | | def run(pipe_trade, pipe_strategy): |
| | | __init_l2() |
| | | if pipe_trade is not None: |
| | | t1 = threading.Thread(target=lambda: __receive_from_pipe_trade(pipe_trade), daemon=True) |
| | | t1.start() |
| | | if pipe_strategy is not None: |
| | | t1 = threading.Thread(target=lambda: __receive_from_pipe_strategy(pipe_strategy), daemon=True) |
| | | t1 = threading.Thread(target=__receive_from_pipe_strategy, args=(pipe_strategy,), daemon=True) |
| | | t1.start() |
| | | __init_l2() |
| | | l2_data_manager.run_upload_common() |
| | | global l2CommandManager |
| | | l2CommandManager = command_manager.L2CommandManager() |
| | | l2CommandManager.init(MyL2ActionCallback()) |
| | | |
| | | print("l2_client启动成功") |
| | | while True: |
| | | time.sleep(2) |
| | | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | run(None,None) |
| | | run(None, None) |
| | | # spi.set_codes_data([("000333", 12000)]) |
| | | input() |
| | |
| | | tradeCommandManager.init(MyTradeActionCallback(), l2pipe, pipe_strategy) |
| | | tradeCommandManager.run() |
| | | print("trade_client启动成功") |
| | | while True: |
| | | time.sleep(2) |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | |
| | | tradeServerProcess.start() |
| | | |
| | | # 交易进程与L2进程 |
| | | tradeProcess = multiprocessing.Process(target=lambda: huaxin_api.trade_client.run(ptl2_trade, pst_trade)) |
| | | l2Process = multiprocessing.Process(target=lambda: huaxin_api.l2_client.run(ptl2_l2, psl2_l2)) |
| | | tradeProcess.start() |
| | | |
| | | l2Process = multiprocessing.Process(target=huaxin_api.l2_client.run, args=(ptl2_l2, psl2_l2,)) |
| | | l2Process.start() |
| | | # |
| | | tradeProcess = multiprocessing.Process(target=huaxin_api.trade_client.run,args=(ptl2_trade, pst_trade,)) |
| | | tradeProcess.start() |
| | | # L1订阅数据 |
| | | huaxin_api.l1_client.run_async(pl1t_l1) |
| | | # 将tradeServer作为主进程 |
| | | input() |
| | | tradeServerProcess.join() |
| | | tradeProcess.join() |
| | | l2Process.join() |