| | |
| | | import huaxin_client.trade_client |
| | | import huaxin_client.l2_client |
| | | import huaxin_client.l1_client |
| | | import huaxin_client.l1_client_for_trade |
| | | from huaxin_client import l2_market_client |
| | | |
| | | |
| | |
| | | l1Process = multiprocessing.Process(target=huaxin_client.l1_client.run, |
| | | args=(queue_l1_w_strategy_r, queue_l1_r_strategy_w,)) |
| | | l1Process.start() |
| | | |
| | | l1TradeProcess = multiprocessing.Process(target=huaxin_client.l1_client_for_trade.run, |
| | | args=(queue_l1_trade_w_strategy_r, queue_l1_trade_r_strategy_w,)) |
| | | l1TradeProcess.start() |
| | | |
| | | l2MarketProcess = multiprocessing.Process(target=l2_market_client.run, |
| | | args=(queue_l1_w_strategy_r,)) |
| | |
| | | import threading |
| | | import time |
| | | |
| | | from huaxin_client import l1_client_for_trade |
| | | |
| | | if __name__ == "__main__": |
| | | def test_sub(): |
| | | time.sleep(10) |
| | |
| | | queue_l1_trade_w_strategy_r, queue_l1_trade_r_strategy_w = multiprocessing.Queue(), multiprocessing.Queue() |
| | | threading.Thread(target=test_sub, daemon=True).start() |
| | | threading.Thread(target=read_data, daemon=True).start() |
| | | l1_client_for_trade.run(queue_l1_trade_w_strategy_r, queue_l1_trade_r_strategy_w) |
| | |
| | | if dataJSON["code"] == 0: |
| | | datas = dataJSON["data"] |
| | | huaxin_trade_record_manager.PositionManager.cache(datas) |
| | | # 获取持仓股的涨停价 |
| | | position_codes = set() |
| | | for d in datas: |
| | | limit_up_price = gpcode_manager.get_limit_up_price(d["securityID"]) |
| | | if not limit_up_price: |
| | | init_data_util.re_set_price_pre(d["securityID"], force=True) |
| | | if d["prePosition"] > 0: |
| | | position_codes.add(d["securityID"]) |
| | | queue_l1_trade_r_strategy_w.put_nowait( |
| | | {"type": "set_target_codes", "data": list(position_codes)}) |
| | | # 9点25之前需要订阅持仓票 |
| | | if position_codes and tool.trade_time_sub(tool.get_now_time_str(), "09:25:00") < 0: |
| | | try: |
| | | # 如果有持仓票 |
| | | l2_subscript_datas = [] |
| | | for code in position_codes: |
| | | l2_subscript_datas.append( |
| | | (code, float(gpcode_manager.get_limit_up_price(code)), 10, 0, time.time())) |
| | | # 在9:25之前订阅持仓票的L2 |
| | | root_data = {"type": "l2_cmd", |
| | | "data": l2_subscript_datas} |
| | | queue_other_w_l2_r.put_nowait(json.dumps(root_data)) |
| | | except Exception as e: |
| | | raise e |
| | | __process_thread_pool.submit(huaxin_trade_record_manager.PositionManager.add, datas) |
| | | async_log_util.info(hx_logger_trade_debug, f"获取交易数据成功:{type_}") |
| | | except Exception as e1: |