Administrator
2023-08-02 bfbcb5aefb4eb7b235628728d150dfd7ade50442
redis缓存加入内存缓存
1个文件已修改
22 ■■■■■ 已修改文件
l2/l2_data_manager_new.py 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
l2/l2_data_manager_new.py
@@ -235,7 +235,7 @@
            _start_index = 0
            total_datas = local_today_datas.get(code)
            if total_datas:
                _start_index =total_datas[-1]["index"] + 1
                _start_index = total_datas[-1]["index"] + 1
            datas = l2_huaxin_util.get_format_l2_datas(code, origin_datas,
                                                       gpcode_manager.get_limit_up_price(code), _start_index)
            # 获取下单位置
@@ -294,7 +294,7 @@
        if len(add_datas) > 0:
            # 是否为首板代码
            is_first_code = True #gpcode_manager.FirstCodeManager.is_in_first_record(code)
            is_first_code = True  # gpcode_manager.FirstCodeManager.is_in_first_record(code)
            # 计算量
            volume_rate = code_volumn_manager.get_volume_rate(code)
            volume_rate_index = code_volumn_manager.get_volume_rate_index(volume_rate)
@@ -324,7 +324,7 @@
                end_index = len(total_datas) - 1
                if state == trade_manager.TRADE_STATE_BUY_DELEGATED or state == trade_manager.TRADE_STATE_BUY_PLACE_ORDER or state == trade_manager.TRADE_STATE_BUY_SUCCESS:
                    # 已挂单
                    if True: #len(add_datas) < 10:
                    if True:  # len(add_datas) < 10:
                        cls.__process_order(code, start_index, end_index, capture_timestamp, is_first_code)
                    else:
                        pass
@@ -342,9 +342,7 @@
                else:
                    # 未挂单,时间相差不大才能挂单
                    if l2.l2_data_util.L2DataUtil.is_same_time(now_time_str, latest_time):
                        cls.__process_not_order(code, start_index, end_index, capture_timestamp, is_first_code)
            logger_l2_process.info("code:{} 处理数据范围: {}-{} 处理时间:{} 截图时间戳:{}", code, add_datas[0]["index"],
                                   add_datas[-1]["index"], round(t.time() * 1000) - __start_time,
@@ -361,7 +359,7 @@
        if round(t.time() * 1000) - __start_time > 10:
            __start_time = l2_data_log.l2_time(code, round(t.time() * 1000) - __start_time,
                                               "获取m值数据耗时")
        if True: #end_index - start_index < 10:
        if True:  # end_index - start_index < 10:
            cls.__start_compute_buy(code, start_index, end_index, threshold_money, capture_time, is_first_code)
        else:
            pass
@@ -575,7 +573,17 @@
        if not is_first_code:
            can, need_clear_data, reason = cls.__can_buy(code)
        else:
            can, need_clear_data, reason = cls.__can_buy_first(code)
            # can, need_clear_data, reason = cls.__can_buy_first(code)
            lp = LineProfiler()
            lp.enable()
            lp_wrap = lp(cls.__can_buy_first)
            can, need_clear_data, reason = lp_wrap(code)
            output = io.StringIO()
            lp.print_stats(stream=output)
            lp.disable()
            with open(f"/home/logs/profile/{code}_can_buy_first.txt", 'w') as f:
                f.write(output.getvalue())
        __start_time = l2_data_log.l2_time(code, tool.get_now_timestamp() - __start_time, "最后判断是否能下单", force=True)
        # 删除虚拟下单
        if code in cls.unreal_buy_dict: