| | |
| | | import random |
| | | import threading |
| | | import time |
| | | import concurrent.futures |
| | | |
| | | from log_module import async_log_util |
| | | from log_module.log import hx_logger_trade_debug, hx_logger_trade_loop, hx_logger_trade_callback, logger_trade, \ |
| | |
| | | from trade.huaxin.huaxin_trade_record_manager import TradeOrderIdManager |
| | | from trade.huaxin.huaxin_trade_order_processor import CancelOrderManager, HuaxinOrderEntity, TradeResultProcessor |
| | | from utils import socket_util, huaxin_util, tool |
| | | |
| | | __response_thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=15) |
| | | |
| | | |
| | | def __run_recv_queue_trade(queue: multiprocessing.Queue): |
| | |
| | | # 主动触发的响应 |
| | | async_log_util.info(hx_logger_trade_callback, |
| | | f"response:request_id-{data_json['request_id']}") |
| | | threading.Thread(target=lambda: __set_response(data_json), daemon=True).start() |
| | | __response_thread_pool.submit(__set_response, data_json) |
| | | elif type_ == "trade_callback": |
| | | try: |
| | | # 交易回调 |
| | |
| | | insertDate=data.get("insertDate") |
| | | |
| | | order = HuaxinOrderEntity(code, orderStatus, orderRef, accountID, orderSysID, |
| | | insertTime=insertTime, acceptTime=acceptTime, insertDate=insertDate) |
| | | insertTime=insertTime, acceptTime=acceptTime, |
| | | insertDate=insertDate) |
| | | TradeResultProcessor.process_order(order) |
| | | # 订单相关回调 |
| | | # 重新请求委托列表与资金 |
| | |
| | | t1.start() |
| | | t1 = threading.Thread(target=lambda: CancelOrderManager().run(cancel_order), daemon=True) |
| | | t1.start() |
| | | |
| | | |
| | | |
| | | |
| | | # 交易通道的错误次数 |