Administrator
2024-03-21 492d4e72ff94d36ff385d3f958f7150f571f1b16
S撤调整
6个文件已修改
30 ■■■■ 已修改文件
l2/cancel_buy_strategy.py 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/code_price_manager.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
log_module/log_export.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
test/l2_trade_test.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/huaxin_trade_server.py 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/trade_data_manager.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/cancel_buy_strategy.py
@@ -36,7 +36,7 @@
def set_real_place_position(code, index, buy_single_index=None, is_default=True):
    # DCancelBigNumComputer().set_real_order_index(code, index)
    SCancelBigNumComputer().set_real_place_order_index(code, index,is_default)
    SCancelBigNumComputer().set_real_place_order_index(code, index, is_default)
    LCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index=buy_single_index,
                                                       is_default=is_default)
    HourCancelBigNumComputer().set_real_place_order_index(code, index, buy_single_index)
@@ -50,6 +50,7 @@
    __sCancelParamsManager = l2_trade_factor.SCancelParamsManager
    __s_cancel_real_place_order_index_cache = {}
    __s_down_watch_indexes_dict = {}
    __recompute_l_down_time_dict = {}
    __instance = None
@@ -167,9 +168,16 @@
                if int(val['orderNo']) < start_order_no:
                    continue
                real_trade_index = i
                break
            if real_trade_index is None:
                l2_log.s_cancel_debug(code, f"没找到真实的成交进度:start_order_no-{start_order_no} 卖单-{big_sell_order_info}")
                return False, ""
            # 间隔1S以上才能重新囊括
            if code in self.__recompute_l_down_time_dict and tool.trade_time_sub_with_ms(latest_deal_time_ms,
                                                                                         self.__recompute_l_down_time_dict[
                                                                                             code]) < 1000:
                return False, ""
            self.__recompute_l_down_time_dict[code] = latest_deal_time_ms
            # 重新囊括L后
            # 撤单时间比早成交时间大就需要计算在里面
            LCancelBigNumComputer().re_compute_l_down_watch_indexes(code, big_sell_info=(
l2/code_price_manager.py
@@ -64,6 +64,8 @@
                val = RedisUtils.get(redis_, key)
                val = round(float(val), 2)
                tool.CodeDataCacheUtil.set_cache(cls.__open_limit_up_lowest_price_cache, code, val)
        except Exception as e:
            pass
        finally:
            RedisUtils.realse(redis_)
log_module/log_export.py
@@ -79,7 +79,7 @@
def load_l2_from_log(date=None):
    today_data = {}
    if date is None:
        date = datetime.datetime.now().strftime("%Y-%m-%d")
        date = tool.get_now_date_str()
    try:
        with open("{}/logs/gp/l2/l2_data.{}.log".format(constant.get_path_prefix(), date), mode='r') as f:
            while True:
test/l2_trade_test.py
@@ -206,7 +206,7 @@
        code = "603363"
        l2.l2_data_util.load_l2_data(code)
        l2.l2_data_util.local_today_datas[code] = l2.l2_data_util.local_today_datas[code][:222]
        l2.cancel_buy_strategy.SCancelBigNumComputer().set_real_place_order_index(code, 153,False)
        l2.cancel_buy_strategy.SCancelBigNumComputer().set_real_place_order_index(code, 153, False)
        TradeBuyQueue.get_traded_index = mock.Mock(return_value=(117, False))
        order_begin_pos = l2_data_manager.OrderBeginPosInfo(buy_single_index=117, buy_exec_index=122)
trade/huaxin/huaxin_trade_server.py
@@ -30,7 +30,7 @@
from huaxin_client.client_network import SendResponseSkManager
from huaxin_client.trade_transform_protocol import TradeResponse
from l2 import l2_data_manager_new, l2_log, code_price_manager, l2_data_util, l2_data_manager, transaction_progress, \
    l2_data_source_util, cancel_buy_strategy
    l2_data_source_util, cancel_buy_strategy, l2_data_log
from l2.cancel_buy_strategy import LCancelBigNumComputer, GCancelBigNumComputer, SCancelBigNumComputer, \
    LCancelRateManager, DCancelBigNumComputer
from l2.code_price_manager import Buy1PriceManager
@@ -382,7 +382,8 @@
    @classmethod
    def l2_order(cls, code, _datas, timestamp):
        use_time = int((time.time() - timestamp) * 1000)
        now_time = time.time()
        use_time = int((now_time - timestamp) * 1000)
        thread_id = random.randint(0, 100000)
        l2_log.threadIds[code] = thread_id
        l2_log.info(code, hx_logger_l2_orderdetail,
@@ -392,9 +393,10 @@
        try:
            l2_data_manager_new.L2TradeDataProcessor.process_huaxin(code, _datas)
        finally:
            pass
            # l2_data_log.l2_time_log(code,
            #                         f"处理L2逐笔委托结束:处理数据数量: {len(_datas)} 最终处理时间:{round(time.time() * 1000) - now_timestamp}")
            use_time = time.time() - now_time
            if use_time > 0.01:
                l2_data_log.l2_time_log(code,
                                    f"处理L2逐笔委托结束:处理数据数量: {len(_datas)} 最终处理时间:{round(use_time*1000,2)}ms")
    @classmethod
    def l2_transaction(cls, code, datas):
trade/trade_data_manager.py
@@ -223,6 +223,8 @@
                code = k.split("-")[-1]
                val = RedisUtils.get(__redis, k)
                tool.CodeDataCacheUtil.set_cache(cls.__code_current_rate_cache, code, float(val))
        except Exception as e:
            pass
        finally:
            RedisUtils.realse(__redis)