trade/huaxin/huaxin_trade_api.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
trade/huaxin/huaxin_trade_data_update.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
trade/huaxin/huaxin_trade_api.py
@@ -45,9 +45,15 @@ type_ = data_json["type"] if type_ == "response": # 主动触发的响应 request_id = data_json['request_id'] async_log_util.info(hx_logger_trade_callback, f"response:request_id-{data_json['request_id']}") f"response:request_id-{request_id}") __response_thread_pool.submit(__set_response, data_json) if request_id.find("trade") > 0: data = data_json["data"].get("data") if data: __response_thread_pool.submit(huaxin_trade_record_manager.DelegateRecordManager.add_one, data) elif type_ == "trade_callback": try: # 交易回调 @@ -84,12 +90,14 @@ try: TradeResultProcessor.process_order(order) finally: try: for j in range(2): # 加入2次,增大加入成功率 huaxin_trade_record_manager.DelegateRecordManager.add_one(data) __response_thread_pool.submit( huaxin_trade_record_manager.DelegateRecordManager.add_one, data) except Exception as e: hx_logger_trade_debug.exception(e) if not is_shadow_order: # 订单相关回调 # 重新请求委托列表与资金 trade/huaxin/huaxin_trade_data_update.py
@@ -14,9 +14,10 @@ from trade.huaxin import huaxin_trade_api, huaxin_trade_record_manager from trade.huaxin.huaxin_trade_order_processor import HuaxinOrderEntity, TradeResultProcessor from utils import huaxin_util, tool import concurrent.futures trade_data_request_queue = queue.Queue() __process_thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=5) # 主动更新数据 def __read_update_task_queue(): @@ -33,10 +34,9 @@ try: if type_ == "delegate_list": dataJSON = huaxin_trade_api.get_delegate_list(can_cancel=False, timeout=10) print("获取委托列表", dataJSON) if dataJSON["code"] == 0: data = dataJSON["data"] huaxin_trade_record_manager.DelegateRecordManager.add(data) __process_thread_pool.submit(huaxin_trade_record_manager.DelegateRecordManager.add, data) # 是否可以撤单 if data: codes = [] @@ -74,6 +74,7 @@ trade_manager.process_trade_delegate_data([{"code": c} for c in codes]) except Exception as e: logging.exception(e) elif type_ == "money": dataJSON = huaxin_trade_api.get_money() if dataJSON["code"] == 0: