Administrator
2024-03-17 15199f8e93fe48e6261c99eadf6673d788db3a80
l2/l2_data_manager_new.py
@@ -29,11 +29,13 @@
    local_latest_datas, local_today_canceled_buyno_map
import l2.l2_data_util
from log_module.log import logger_l2_trade_buy, logger_l2_process, logger_l2_error, logger_debug, \
    logger_l2_not_buy_reasons
    logger_l2_not_buy_reasons, logger_real_place_order_position
from trade.trade_data_manager import CodeActualPriceProcessor, PlaceOrderCountManager
from trade.trade_manager import TradeTargetCodeModeManager, AccountAvailableMoneyManager, MarketSituationManager
import concurrent.futures
class L2DataManager:
@@ -242,6 +244,7 @@
    __PlaceOrderCountManager = PlaceOrderCountManager()
    __CodeNatureRecordManager = code_nature_analyse.CodeNatureRecordManager()
    __MarketSituationManager = MarketSituationManager()
    __re_compute_threading_pool = concurrent.futures.ThreadPoolExecutor(max_workers=10)
    # 获取代码评分
    @classmethod
@@ -334,6 +337,19 @@
            origin_datas.clear()
    @classmethod
    def __recompute_real_order_index(cls, code, pre_real_order_index, order_info):
        real_order_index = huaxin_delegate_postion_manager.recompute_for_slow_time(code, order_info,
                                                                                   pre_real_order_index)
        if real_order_index:
            exec_data = order_info[2]
            order_begin_pos = cls.__get_order_begin_pos(
                code)
            if order_begin_pos and order_begin_pos.buy_exec_index == exec_data["index"]:
                cls.set_real_place_order_index(code, real_order_index, order_begin_pos)
                async_log_util.info(logger_real_place_order_position,
                                    f"真实下单位矫正:{code}-{real_order_index}  下单数据:{order_info}")
    @classmethod
    def process_add_datas(cls, code, add_datas, capture_timestamp, __start_time):
        now_time_str = tool.get_now_time_str()
        if len(add_datas) > 0:
@@ -355,12 +371,18 @@
                        #     cls.set_real_place_order_index(code, place_order_index, order_begin_pos.buy_single_index)
                    else:
                        # 获取下单位置
                        place_order_index = huaxin_delegate_postion_manager.get_l2_place_order_position(code, float(
                            gpcode_manager.get_limit_up_price(code)), add_datas)
                        place_order_index, order_info = huaxin_delegate_postion_manager.get_l2_place_order_position(
                            code, float(
                                gpcode_manager.get_limit_up_price(code)), add_datas)
                        if place_order_index:
                            order_begin_pos = cls.__get_order_begin_pos(
                                code)
                            cls.set_real_place_order_index(code, place_order_index, order_begin_pos)
                            try:
                                cls.__re_compute_threading_pool.submit(
                                    cls.__recompute_real_order_index, code, place_order_index, order_info)
                            except:
                                pass
                            async_log_util.info(logger_l2_process, "code:{} 获取到下单真实位置:{}", code, place_order_index)
                except:
                    async_log_util.error(logger_l2_error, f"{code} 处理真实下单位置出错")
@@ -847,11 +869,11 @@
        if cls.__PauseBuyCodesManager.is_in_cache(code):
            return False, True, f"该代码被暂停交易"
        if int(tool.get_now_time_str().replace(":", "")) >= 145700:
        now_time_int = int(tool.get_now_time_str().replace(":", ""))
        if  now_time_int>= 145700:
            return False, True, f"14:57后不能交易"
        if  130100>=now_time_int>= 112900:
            return False, True, f"11:29:00-13:01:00不能交易"
        limit_up_price = gpcode_manager.get_limit_up_price(code)
@@ -868,8 +890,6 @@
        average_rate = cls.__Buy1PriceManager.get_average_rate(code)
        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)
        order_begin_pos = cls.__get_order_begin_pos(
@@ -1641,10 +1661,10 @@
                threshold_num = int(sell_data[1] / (limit_up_price * 100)) // 2
                threshold_max_num = 1
            #  信号为之前有待成交的大单(不是正在成交)
            trade_index,is_default = cls.__TradeBuyQueue.get_traded_index(code)
            trade_index, is_default = cls.__TradeBuyQueue.get_traded_index(code)
            if not is_default and trade_index is not None:
                temp_big_num = int(30000/limit_up_price)
                for i in range(trade_index+1, buy_single_index):
                temp_big_num = int(30000 / limit_up_price)
                for i in range(trade_index + 1, buy_single_index):
                    data = total_datas[i]
                    val = data['val']
                    if not L2DataUtil.is_limit_up_price_buy(val):
@@ -1662,10 +1682,8 @@
                    if left_count > 0:
                        # 安全笔数与囊括时间范围修改
                        threshold_count = 3
                        max_space_time_ms = 9*1000
                        max_space_time_ms = 9 * 1000
                        break
        if not threshold_num:
            # 目标手数
@@ -1675,12 +1693,10 @@
        # place_order_count = trade_data_manager.PlaceOrderCountManager().get_place_order_count(code)
        # buy_single_time_seconds = L2DataUtil.get_time_as_second(total_datas[buy_single_index]["val"]["time"])
        # 可以触发买,当有涨停买信号时才会触发买
        trigger_buy = True
        # 如果大单含有率大于50%,则时间囊括范围提高到3s
        if max_num_set and origin_count: