Administrator
2024-04-24 ddd7de518a8d108b080a599968a99887af973204
L2添加耗时日志
2个文件已修改
48 ■■■■ 已修改文件
huaxin_client/command_manager.py 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/data_export_util.py 45 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
huaxin_client/command_manager.py
@@ -131,8 +131,7 @@
                            async_log_util.info(logger_local_huaxin_contact_debug, f"接受到信息: {val}")
                        cls.process_command(_type, None, val)
                except Exception as e:
                    async_log_util.exception(logger_local_huaxin_trade_debug, e)
                    logging.exception(e)
                    logger_local_huaxin_trade_debug.exception(e)
        except Exception as e:
            async_log_util.exception(logger_local_huaxin_trade_debug, e)
utils/data_export_util.py
@@ -39,7 +39,7 @@
            local_today_datas = __l2_data_cache.get(date)
        else:
            local_today_datas = log_export.load_l2_from_log(date)
            __l2_data_cache[code] = local_today_datas
            __l2_data_cache[date] = local_today_datas
        datas = local_today_datas.get(code)
    if not datas:
        datas = []
@@ -94,17 +94,20 @@
            if trade_indexs[i][1] == index:
                return trade_indexs[i]
        return None
    logger_debug.info("准备加载L2Map数据-----")
    # 数据预处理
    num_operate_map = {}
    l2.l2_data_util.load_num_operate_map(num_operate_map, code, datas)
    logger_debug.info("load_num_operate_map")
    buy_no_map = {}
    sell_no_map = {}
    l2.l2_data_util.load_buy_no_map(buy_no_map, code, datas)
    logger_debug.info("load_buy_no_map")
    l2.l2_data_util.load_sell_no_map(sell_no_map, code, datas)
    logger_debug.info("load_sell_no_map")
    l2.l2_data_util.load_canceled_buy_no_map(l2.l2_data_util.local_today_canceled_buyno_map, code, datas)
    logger_debug.info("load_canceled_buy_no_map")
    # num_dict = {}
    # for data in datas:
    #     if data["val"]["num"] not in num_dict:
@@ -227,39 +230,7 @@
        format_data.append(cancel_order_info)
        format_data.append(data["val"].get("orderNo"))
        fdatas.append((style_int, trade_info, format_data))
    # 将订单号索引
    order_no_index_map = {}
    for i in range(len(fdatas)):
        d = fdatas[i][2]
        if d[6].find('撤') >= 0:
            continue
        order_no_index_map[int(d[10])] = i
    order_no_indexes = [(k, order_no_index_map[k]) for k in order_no_index_map]
    order_no_indexes.sort(key=lambda x: x[0])
    # 不添加主动卖数据
    # if sell_nos:
    #     for sell_info in sell_nos:
    #         if sell_info[1] * sell_info[2] < 50 * 10000:
    #             continue
    #         for i in range(len(order_no_indexes) - 1):
    #             if order_no_indexes[i][0] < sell_info[0] < order_no_indexes[i + 1][0]:
    #                 item = []
    #                 item.append(order_no_indexes[i + 1][1])
    #                 item.append(l2_huaxin_util.convert_time(sell_info[3][0], with_ms=True))
    #                 item.append("")
    #                 item.append(
    #                     "{}万".format(round(sell_info[1] * sell_info[2] / 10000, 1)))
    #                 item.append(sell_info[2])
    #                 item.append(sell_info[1] // 100)
    #                 item.append("主动卖")
    #                 item.append(1)
    #                 item.append(l2_huaxin_util.convert_time(sell_info[4][0], with_ms=True))
    #                 item.append(None)
    #                 item.append(sell_info[0])
    #                 fdatas.insert(order_no_indexes[i + 1][1], (0, None, item))
    #                 break
    logger_debug.info("循环组装数据完成")
    return fdatas