Administrator
2025-05-28 c62187f349fdb90fc3f525522a512af5a0a83a54
data_parser/transaction_big_order_parser.py
@@ -194,7 +194,21 @@
    ))
def extract_big_order_of_code(dir_path, code=None):
__combined_df_cache = {}
def extract_big_order_of_all(dir_path):
    combined_path = os.path.join(dir_path, 'combined.csv')
    if not os.path.exists(combined_path):
        print("拼接数据不存在")
        return
    codes = extract_big_order_codes(dir_path)
    print("总代码数量:", len(codes))
    for code in codes:
        extract_big_order_of_code(dir_path, code)
def extract_big_order_of_code(dir_path, code):
    """
    提取代码的大单
    @param dir_path: 数据目录
@@ -223,7 +237,14 @@
    if not os.path.exists(combined_path):
        print("拼接数据不存在")
        return
    df = pd.read_csv(combined_path)
    output_path = os.path.join(dir_path, f"big_buy_{code}.csv")
    if os.path.exists(output_path):
        print("路径已存在:", output_path)
        return
    df = __combined_df_cache.get(combined_path, None)
    if df is None:
        df = pd.read_csv(combined_path)
        __combined_df_cache[combined_path] = df
    df_copy = df.copy()
    if code:
        df_copy = df_copy[df_copy["SecurityID"] == int(code)]
@@ -237,11 +258,8 @@
    grouped_result = grouped_result[grouped_result["TotalAmount"] > 500000]
    # print(grouped_result)
    # 遍历内容
    if code:
        grouped_result.to_csv(os.path.join(dir_path, f"big_buy_{code}.csv"), index=False)
    else:
        grouped_result.to_csv(os.path.join(dir_path, f"big_buy.csv"), index=False)
    print("保存成功")
    grouped_result.to_csv(output_path, index=False)
    print(f"保存成功,路径:{output_path}")
def extract_big_order_codes(dir_path):
@@ -251,16 +269,6 @@
    @param code:
    @return:
    """
    def first_last(group):
        """
            获取第一条数据与最后一条
            @param group:
            @return:
            """
        return pd.Series({
        })
    combined_path = os.path.join(dir_path, 'combined.csv')
    if not os.path.exists(combined_path):
        print("拼接数据不存在")