| | |
| | | import concurrent.futures |
| | | import json |
| | | import logging |
| | | import multiprocessing |
| | | import os |
| | | import threading |
| | | import time |
| | |
| | | # 采用的是socket通信 |
| | | sk.sendall(socket_util.load_header(data.encode('utf-8'))) |
| | | else: |
| | | strategy_pipe.send(data) |
| | | queue_strategy_trade_write.put_nowait(data) |
| | | |
| | | |
| | | # 交易反馈回调 |
| | |
| | | |
| | | addr, port = constant.SERVER_IP, constant.SERVER_PORT |
| | | |
| | | def run(trade_response_: TradeResponse = None, pipe_l2=None, pipe_strategy=None, queue_strategy_trade=None): |
| | | |
| | | def run(trade_response_: TradeResponse = None, pipe_l2=None, queue_strategy_trade_write_=None, |
| | | queue_strategy_trade_read=None): |
| | | try: |
| | | logger_system.info("交易进程ID:{}", os.getpid()) |
| | | logger_system.info(f"trade 线程ID:{tool.get_thread_id()}") |
| | |
| | | global l2pipe |
| | | l2pipe = pipe_l2 |
| | | |
| | | global strategy_pipe |
| | | strategy_pipe = pipe_strategy |
| | | global queue_strategy_trade_write |
| | | queue_strategy_trade_write = queue_strategy_trade_write_ |
| | | |
| | | global trade_response |
| | | trade_response = trade_response_ |
| | |
| | | |
| | | global tradeCommandManager |
| | | tradeCommandManager = command_manager.TradeCommandManager() |
| | | tradeCommandManager.init(MyTradeActionCallback(), l2pipe, pipe_strategy, queue_strategy_trade) |
| | | tradeCommandManager.init(MyTradeActionCallback(), l2pipe, queue_strategy_trade_read) |
| | | logger_system.info("华鑫交易服务启动") |
| | | tradeCommandManager.run() |
| | | except Exception as e: |