| | |
| | | |
| | | |
| | | def __receive_from_pipe_trade(pipe): |
| | | logger_system.info(f"l2_client __receive_from_pipe_trade 线程ID:{tool.get_thread_id()}") |
| | | while True: |
| | | try: |
| | | value = pipe.recv() |
| | |
| | | |
| | | |
| | | def __receive_from_pipe_strategy(pipe_): |
| | | logger_system.info(f"l2_client __receive_from_pipe_strategy 线程ID:{tool.get_thread_id()}") |
| | | while True: |
| | | # print("__receive_from_pipe_strategy") |
| | | try: |
| | |
| | | from huaxin_client.l2_data_transform_protocol import L2DataCallBack |
| | | from log_module import log_export, async_log_util |
| | | from log_module.log import logger_local_huaxin_l2_error, logger_local_huaxin_l2_upload, logger_local_huaxin_l2_buy_no, \ |
| | | logger_local_huaxin_g_cancel, hx_logger_contact_debug |
| | | logger_local_huaxin_g_cancel, hx_logger_contact_debug, logger_system |
| | | from utils import tool |
| | | |
| | | order_detail_upload_active_time_dict = {} |
| | | transaction_upload_active_time_dict = {} |
| | |
| | | |
| | | def __run_upload_common(l2_data_callback: L2DataCallBack): |
| | | print("__run_upload_common") |
| | | logger_system.info(f"l2_client __run_upload_common 线程ID:{tool.get_thread_id()}") |
| | | while True: |
| | | try: |
| | | while not common_queue.empty(): |
| | |
| | | |
| | | def __run_upload_trading_canceled(l2_data_callback: L2DataCallBack): |
| | | print("__run_upload_trading_canceled") |
| | | logger_system.info(f"l2_client __run_upload_trading_canceled 线程ID:{tool.get_thread_id()}") |
| | | while True: |
| | | try: |
| | | temp = trading_canceled_queue.get() |
| | |
| | | |
| | | def __run_log(): |
| | | print("__run_log") |
| | | logger_system.info(f"l2_client __run_log 线程ID:{tool.get_thread_id()}") |
| | | while True: |
| | | try: |
| | | temp = log_buy_no_queue.get() |
| | |
| | | # 运行守护线程 |
| | | def run_upload_daemon(_l2_data_callback): |
| | | def upload_daemon(): |
| | | logger_system.info(f"l2_client upload_daemon 线程ID:{tool.get_thread_id()}") |
| | | while True: |
| | | try: |
| | | for code in target_codes_add_time: |
| | |
| | | import queue |
| | | import time |
| | | |
| | | from log_module.log import logger_debug |
| | | from log_module.log import logger_debug, logger_system |
| | | from utils import tool |
| | | |
| | | |
| | |
| | | |
| | | # 运行同步日志 |
| | | def run_sync(self): |
| | | logger_system.info(f"run_sync 线程ID:{tool.get_thread_id()}") |
| | | while True: |
| | | try: |
| | | val = self.__log_queue.get() |
| | |
| | | |
| | | # 运行同步日志 |
| | | def run_sync(): |
| | | logger_system.info(f"async_log 线程ID:{tool.get_thread_id()}") |
| | | while True: |
| | | try: |
| | | val = log_queue.get() |
| | |
| | | # 心跳信息 |
| | | from huaxin_client import socket_util |
| | | from huaxin_client.client_network import SendResponseSkManager |
| | | from log_module.log import logger_debug |
| | | from utils import middle_api_protocol |
| | | from log_module.log import logger_debug, logger_system |
| | | from utils import middle_api_protocol, tool |
| | | |
| | | MSG_TYPE_HEART = "heart" |
| | | # 命令信息 |
| | |
| | | |
| | | @classmethod |
| | | def __maintain_client(cls): |
| | | logger_system.info(f"outside_api __maintain_client 线程ID:{tool.get_thread_id()}") |
| | | while True: |
| | | try: |
| | | if len(cls.trade_client_dict) < cls.trade_client_count: |
| | |
| | | |
| | | from huaxin_client.trade_transform_protocol import TradeRequest |
| | | 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 log_module.log import hx_logger_trade_debug, hx_logger_trade_loop, hx_logger_trade_callback, logger_trade, \ |
| | | logger_system |
| | | from trade.huaxin import huaxin_trade_data_update |
| | | from trade.huaxin.huaxin_trade_record_manager import TradeOrderIdManager |
| | | from utils import socket_util, huaxin_util |
| | | from utils import socket_util, huaxin_util, tool |
| | | |
| | | # 外部传入的交易队列 |
| | | pipe_trade = None |
| | | |
| | | |
| | | def __run_recv_pipe_trade(): |
| | | logger_system.info(f"huaxin_trade_api __run_recv_pipe_trade 线程ID:{tool.get_thread_id()}") |
| | | |
| | | # 设置结果 |
| | | def __set_response(data_json): |
| | | if 'request_id' not in data_json: |
| | |
| | | |
| | | |
| | | def clear_invalid_client(): |
| | | logger_system.info(f"trade_server clear_invalid_client 线程ID:{tool.get_thread_id()}") |
| | | while True: |
| | | try: |
| | | huaxin_trade_api.ClientSocketManager.del_invalid_clients() |
| | |
| | | |
| | | |
| | | def __recv_pipe_l1(pipe_l1): |
| | | logger_system.info(f"trade_server __recv_pipe_l1 线程ID:{tool.get_thread_id()}") |
| | | if pipe_l1 is not None: |
| | | while True: |
| | | try: |
| | |
| | | order_status = data["orderStatus"] |
| | | huaxin_trade_record_manager.DelegateRecordManager.add([data]) |
| | | if huaxin_util.is_deal(order_status): |
| | | if int(str(data["direction"])) == huaxin_util.TORA_TSTP_D_Buy: |
| | | l2_trade_util.forbidden_trade(data["securityID"],msg="已成交") |
| | | # 成交,更新成交列表与资金列表 |
| | | huaxin_trade_data_update.add_deal_list() |
| | |
| | | # 禁止代码交易 |
| | | def forbidden_trade(code, msg=None): |
| | | add_to_forbidden_trade_codes(code) |
| | | async_log_util.warning(logger_trade, f"加入黑名单原因:{msg}") |
| | | async_log_util.warning(logger_trade, f"{code}加入黑名单原因:{msg}") |
| | | # l2_data_manager.remove_from_l2_fixed_codes(code) |
| | | # l2_code_operate.L2CodeOperate.get_instance().remove_l2_listen(code, "禁止代码交易") |
| | | |