| | |
| | | logging.exception(e) |
| | | |
| | | |
| | | # 排得太远撤单 |
| | | def __cancel_buy_for_too_far(): |
| | | while True: |
| | | try: |
| | | current_delegates = huaxin_trade_record_manager.DelegateRecordManager().list_current_delegates() |
| | | for c in current_delegates: |
| | | if int(c["direction"]) != huaxin_util.TORA_TSTP_D_Buy: |
| | | continue |
| | | code = c["securityID"] |
| | | # 获取下单位置信息 |
| | | order_begin_pos = TradePointManager().get_buy_compute_start_data_cache(code) |
| | | if order_begin_pos is None or order_begin_pos.buy_single_index is None: |
| | | continue |
| | | total_datas = l2_data_util.local_today_datas.get(code) |
| | | if not total_datas: |
| | | continue |
| | | if order_begin_pos.buy_exec_index < 0: |
| | | continue |
| | | if tool.trade_time_sub(tool.get_now_time_str(), |
| | | total_datas[order_begin_pos.buy_exec_index]["val"]["time"]) < 60: |
| | | continue |
| | | trade_index, is_default = transaction_progress.TradeBuyQueue().get_traded_index(code) |
| | | # 下单位置 |
| | | place_order_index = SecondCancelBigNumComputer().get_real_place_order_index_cache(code) |
| | | |
| | | # 获取剩下的笔数 |
| | | total_left_num = 0 |
| | | for i in range(trade_index + 1, place_order_index): |
| | | data = total_datas[i] |
| | | val = data["val"] |
| | | if not L2DataUtil.is_limit_up_price_buy(val): |
| | | continue |
| | | if val["num"] * float(val["price"]) < 5000: |
| | | continue |
| | | left_count = l2_data_source_util.L2DataSourceUtils.get_limit_up_buy_no_canceled_count_v2(code, |
| | | i, |
| | | total_datas, |
| | | l2_data_util.local_today_canceled_buyno_map.get( |
| | | code)) |
| | | if left_count > 0: |
| | | total_left_num += val["num"] * left_count |
| | | # 获取封单额 |
| | | limit_up_price = gpcode_manager.get_limit_up_price(code) |
| | | buy1_money = Buy1PriceManager().get_latest_buy1_money(code) |
| | | if buy1_money is None: |
| | | buy1_money = 0 |
| | | if buy1_money > 0: |
| | | total_left_money = total_left_num * 100 * float(limit_up_price) |
| | | if total_left_money > buy1_money * 2 / 3: |
| | | l2_data_manager_new.L2TradeDataProcessor.cancel_buy(code, "下单距离太远") |
| | | except Exception as e: |
| | | logger_debug.exception(e) |
| | | finally: |
| | | time.sleep(3) |
| | | |
| | | |
| | | def __recv_pipe_l1_trade(queue_l1_trade_w_strategy_r: multiprocessing.Queue): |
| | | logger_system.info(f"trade_server __recv_pipe_l1_trade 线程ID:{tool.get_thread_id()}") |
| | | if queue_l1_trade_w_strategy_r is not None: |
| | |
| | | positions = PositionManager.latest_positions |
| | | sell_rules_count = len(SellRuleManager().list_can_excut_rules_cache()) |
| | | |
| | | fdata = {"code": code, "total": 0, "available": 0, "sell_orders": [], "sell_rules_count": sell_rules_count,"cost_price":0, |
| | | fdata = {"code": code, "total": 0, "available": 0, "sell_orders": [], "sell_rules_count": sell_rules_count, |
| | | "cost_price": 0, |
| | | "code_info": (code, code_name), "desc": "".join(desc_list)} |
| | | if positions: |
| | | for d in positions: |
| | |
| | | t1 = threading.Thread(target=lambda: __recv_pipe_l1_trade(queue_l1_trade_w_strategy_r), daemon=True) |
| | | t1.start() |
| | | |
| | | # 下单距离太远取消订单 |
| | | t1 = threading.Thread(target=lambda: __cancel_buy_for_too_far(), daemon=True) |
| | | t1.start() |
| | | |
| | | # 同步异步日志 |
| | | t1 = threading.Thread(target=lambda: async_log_util.run_sync(), daemon=True) |
| | | t1.start() |