# Path: kquant_data/processing/merge.py
# def merge_report(rule, field, dataset_name):
#     path = os.path.join(__CONFIG_H5_STK_DIR__, rule, 'Symbol.csv')
#     symbols = all_instruments(path)
# 
#     path = os.path.join(__CONFIG_H5_STK_DIR__, rule, 'DateTime.csv')
#     DateTime = get_datetime(path)
# 
#     tic()
#     path = os.path.join(__CONFIG_H5_STK_FACTOR_DIR__, field)
#     df = None
#     cnt = 0
#     for dirpath, dirnames, filenames in os.walk(path):
#         # 只处理目录
#         for filename in filenames:
#             print(filename)
#             filepath = os.path.join(dirpath, filename)
#             df_ = read_data_dataframe(filepath)
#             df_tmp = df_.stack()
#             if df is None:
#                 df = df_tmp
#             else:
#                 df = pd.concat([df, df_tmp])
#             cnt += 1
#             # if cnt > 10:
#             #    break
# 
#     df = df.unstack()
#     df.fillna(method='ffill', inplace=True)
#     print("数据加载完成")
#     toc()
# 
#     df = expand_dataframe_according_to(df, DateTime.index, symbols['wind_code'])
#     #
#     path = os.path.join(__CONFIG_H5_STK_DIR__, rule, "%s.h5" % dataset_name)
#     write_dataframe_set_dtype_remove_head(path, df, None, field)


from kquant_data.processing.merge import merge_report
﻿#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
合并财务数据
"""

if __name__ == '__main__':
    rule = '1day'
    field = 'total_shares'

# Path: kquant_data/processing/merge.py
# def merge_report(rule, field, dataset_name):
#     path = os.path.join(__CONFIG_H5_STK_DIR__, rule, 'Symbol.csv')
#     symbols = all_instruments(path)
# 
#     path = os.path.join(__CONFIG_H5_STK_DIR__, rule, 'DateTime.csv')
#     DateTime = get_datetime(path)
# 
#     tic()
#     path = os.path.join(__CONFIG_H5_STK_FACTOR_DIR__, field)
#     df = None
#     cnt = 0
#     for dirpath, dirnames, filenames in os.walk(path):
#         # 只处理目录
#         for filename in filenames:
#             print(filename)
#             filepath = os.path.join(dirpath, filename)
#             df_ = read_data_dataframe(filepath)
#             df_tmp = df_.stack()
#             if df is None:
#                 df = df_tmp
#             else:
#                 df = pd.concat([df, df_tmp])
#             cnt += 1
#             # if cnt > 10:
#             #    break
# 
#     df = df.unstack()
#     df.fillna(method='ffill', inplace=True)
#     print("数据加载完成")
#     toc()
# 
#     df = expand_dataframe_according_to(df, DateTime.index, symbols['wind_code'])
#     #
#     path = os.path.join(__CONFIG_H5_STK_DIR__, rule, "%s.h5" % dataset_name)
#     write_dataframe_set_dtype_remove_head(path, df, None, field)


# Path: demo_stock/A_1day/D02_merge_total_shares.py
from kquant_data.processing.merge import merge_report

﻿#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
合并财务数据
"""

if __name__ == '__main__':
    rule = '1day'
    field = 'total_shares'

    merge_report(rule, field, field)