Administrator
2024-01-31 0c3fb1e666ce81b6cb9ec995095a938a21f92cfe
L前撤单比例修改/挂太远主动撤单/L2数据早上数据卡顿处理
3个文件已修改
69 ■■■■■ 已修改文件
constant.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_server.py 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constant.py
@@ -119,7 +119,7 @@
# 撤单比例
L_CANCEL_RATE = 0.6
# L上撤单比例
L_CANCEL_RATE_UP = 0.7
L_CANCEL_RATE_UP = 0.79
# 大金额
L_CANCEL_BIG_MONEY = 100
# 小金额
l2/l2_data_manager_new.py
@@ -436,7 +436,7 @@
                    cls.__process_order(code, start_index, end_index, capture_timestamp, is_first_code)
                else:
                    # 未挂单,时间相差不大才能挂单
                    if l2.l2_data_util.L2DataUtil.is_same_time(now_time_str, latest_time):
                    if l2.l2_data_util.L2DataUtil.is_same_time(now_time_str, latest_time) or int(now_time_str.replace(":","")) < int("093200"):
                        cls.__process_not_order(code, start_index, end_index, capture_timestamp, is_first_code)
            async_log_util.info(logger_l2_process, "code:{} 处理数据范围: {}-{} 处理时间:{} 截图时间戳:{}", code,
@@ -862,7 +862,7 @@
        # ---------均价约束-------------
        average_rate = cls.__Buy1PriceManager.get_average_rate(code)
        if average_rate and average_rate <= 0.01:
        if average_rate and average_rate <= 0.01 and tool.trade_time_sub(tool.get_now_time_str(),"10:30:00") >= 0:
            return False, True, f"均价涨幅({average_rate})小于1%"
        total_data = local_today_datas.get(code)
trade/huaxin/huaxin_trade_server.py
@@ -518,6 +518,62 @@
                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:
@@ -1107,7 +1163,8 @@
            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:
@@ -1452,6 +1509,10 @@
        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()