| | |
| | | def concat_pre_transactions(dir_path): |
| | | __concat_pre_datas(dir_path) |
| | | |
| | | |
| | | def concat_pre_ngtsticks(dir_path): |
| | | __concat_pre_datas(dir_path) |
| | | |
| | | |
| | | def process_combined_transaction(dir_path): |
| | | """ |
| | | 处理拼接起来的数据 |
| | | @param dir_path: |
| | | @return: |
| | | """ |
| | | combined_path = os.path.join(dir_path, 'combined.csv') |
| | | if not os.path.exists(combined_path): |
| | | print("拼接数据不存在") |
| | | return |
| | | df = pd.read_csv(combined_path) |
| | | df_copy = df.copy() |
| | | grouped = df_copy.groupby(["SecurityID"]) |
| | | # 应用聚合函数 |
| | | chunk_result = grouped.apply(pd.Series({})) |
| | | # chunk_result["SecurityID"] = chunk_result["SecurityID"].apply(BigOrderDealParser.code_format) |
| | | print(chunk_result.to_string( |
| | | index=False, # 不显示索引 |
| | | justify='left', # 左对齐 |
| | | float_format='%.3f' # 浮点数格式 |
| | | )) |
| | | |
| | | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | pre_process_transactions("E:/测试数据/Transaction_Test.csv") |
| | | # pre_process_transactions("E:/测试数据/Transaction_Test.csv") |
| | | # pre_process_ngtsticks("E:/测试数据/NGTSTick_Test.csv") |
| | | concat_pre_transactions("E:/测试数据/Transaction_Test") |
| | | # concat_pre_transactions("E:/测试数据/Transaction_Test") |
| | | process_combined_transaction("E:/测试数据/Transaction_Test") |