# Path: kquant_data/config.py
# __CONFIG_H5_FUT_DATA_DIR__ = os.path.join(__CONFIG_H5_FUT_DIR__, 'data')


import os
import pandas as pd
from kquant_data.config import __CONFIG_H5_FUT_DATA_DIR__

def process2(input_path, output_path, folder_name):
    for dirpath, dirnames, filenames in os.walk(input_path):
        dfs_long = None
        dfs_short = None
        for filename in filenames:
            path = os.path.join(dirpath, filename)
            df = pd.read_csv(path, encoding='utf-8-sig', parse_dates=['date'])
            df.index = df['date']
            col_name = filename[:-4]

            col_long = df['long_position_increase']
            col_long.name = col_name
            dfs_long = pd.concat([dfs_long, col_long], axis=1)

            col_short = df['short_position_increase']
            col_short.name = col_name
            dfs_short = pd.concat([dfs_short, col_short], axis=1)

        path2 = os.path.join(output_path, '%s_long_position_increase.csv' % folder_name)
        dfs_long.to_csv(path2, encoding='utf-8-sig', date_format='%Y-%m-%d')

        path2 = os.path.join(output_path, '%s_short_position_increase.csv' % folder_name)
        dfs_short.to_csv(path2, encoding='utf-8-sig', date_format='%Y-%m-%d')


if __name__ == '__main__':

    member_name = '前二十名合计'
    folder_name = 'top20'

# Path: kquant_data/config.py
# __CONFIG_H5_FUT_DATA_DIR__ = os.path.join(__CONFIG_H5_FUT_DIR__, 'data')


# Path: demo_future/A03_merge_futureoir.py
import os
import pandas as pd
from kquant_data.config import __CONFIG_H5_FUT_DATA_DIR__


def process2(input_path, output_path, folder_name):
    for dirpath, dirnames, filenames in os.walk(input_path):
        dfs_long = None
        dfs_short = None
        for filename in filenames:
            path = os.path.join(dirpath, filename)
            df = pd.read_csv(path, encoding='utf-8-sig', parse_dates=['date'])
            df.index = df['date']
            col_name = filename[:-4]

            col_long = df['long_position_increase']
            col_long.name = col_name
            dfs_long = pd.concat([dfs_long, col_long], axis=1)

            col_short = df['short_position_increase']
            col_short.name = col_name
            dfs_short = pd.concat([dfs_short, col_short], axis=1)

        path2 = os.path.join(output_path, '%s_long_position_increase.csv' % folder_name)
        dfs_long.to_csv(path2, encoding='utf-8-sig', date_format='%Y-%m-%d')

        path2 = os.path.join(output_path, '%s_short_position_increase.csv' % folder_name)
        dfs_short.to_csv(path2, encoding='utf-8-sig', date_format='%Y-%m-%d')


if __name__ == '__main__':

    member_name = '前二十名合计'
    folder_name = 'top20'

    input_path = os.path.join(__CONFIG_H5_FUT_DATA_DIR__, "futureoir")