# Path: kquant_data/config.py
# __CONFIG_H5_FUT_FACTOR_DIR__ = os.path.join(__CONFIG_H5_FUT_DIR__, 'factor')
# 
# Path: kquant_data/xio/csv.py
# def read_data_dataframe(path, sep=','):
#     """
#     读取季报的公告日
#     注意：有些股票多个季度一起发，一般是公司出问题了，特别是600878，四个报告同一天发布
#     年报与一季报很有可能一起发
#     :param path:
#     :param sep:
#     :return:
#     """
#     try:
#         df = pd.read_csv(path, index_col=0, parse_dates=True, encoding='utf-8-sig', sep=sep)
#     except (FileNotFoundError, OSError):
#         return None
# 
#     return df
# 
# def write_data_dataframe(path, df, date_format='%Y-%m-%d'):
#     """
#     写入数据
#     :param path:
#     :param df:
#     :return:
#     """
#     df.to_csv(path, date_format=date_format, encoding='utf-8-sig')
# 
# Path: kquant_data/future/symbol.py
# def wind_code_2_InstrumentID(df, field):
#     sym_ex = df[field].str.split('.')
#     sym_ex = list(sym_ex)
#     sym_ex_df = pd.DataFrame(sym_ex, index=df.index)
#     sym_ex_df.columns = ['InstrumentID', 'exchange']
#     df = pd.concat([df, sym_ex_df], axis=1)
#     df['lower'] = (df['exchange'] == 'SHF') | (df['exchange'] == 'DCE') | (df['exchange'] == 'INE')
#     df['InstrumentID'][df['lower']] = df['InstrumentID'].str.lower()
#     return df


import os
import pandas as pd
from kquant_data.config import __CONFIG_H5_FUT_FACTOR_DIR__
from kquant_data.xio.csv import read_data_dataframe, write_data_dataframe
from kquant_data.future.symbol import wind_code_2_InstrumentID
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
已经下载到了每个合约的最新主力信息
现在对数据进一步整理成表单
"""


if __name__ == '__main__':
    input_path = os.path.join(__CONFIG_H5_FUT_FACTOR_DIR__, 'trade_hiscode')

# Path: kquant_data/config.py
# __CONFIG_H5_FUT_FACTOR_DIR__ = os.path.join(__CONFIG_H5_FUT_DIR__, 'factor')
# 
# Path: kquant_data/xio/csv.py
# def read_data_dataframe(path, sep=','):
#     """
#     读取季报的公告日
#     注意：有些股票多个季度一起发，一般是公司出问题了，特别是600878，四个报告同一天发布
#     年报与一季报很有可能一起发
#     :param path:
#     :param sep:
#     :return:
#     """
#     try:
#         df = pd.read_csv(path, index_col=0, parse_dates=True, encoding='utf-8-sig', sep=sep)
#     except (FileNotFoundError, OSError):
#         return None
# 
#     return df
# 
# def write_data_dataframe(path, df, date_format='%Y-%m-%d'):
#     """
#     写入数据
#     :param path:
#     :param df:
#     :return:
#     """
#     df.to_csv(path, date_format=date_format, encoding='utf-8-sig')
# 
# Path: kquant_data/future/symbol.py
# def wind_code_2_InstrumentID(df, field):
#     sym_ex = df[field].str.split('.')
#     sym_ex = list(sym_ex)
#     sym_ex_df = pd.DataFrame(sym_ex, index=df.index)
#     sym_ex_df.columns = ['InstrumentID', 'exchange']
#     df = pd.concat([df, sym_ex_df], axis=1)
#     df['lower'] = (df['exchange'] == 'SHF') | (df['exchange'] == 'DCE') | (df['exchange'] == 'INE')
#     df['InstrumentID'][df['lower']] = df['InstrumentID'].str.lower()
#     return df


# Path: demo_future/B03_update_trade_hiscode.py
import os
import pandas as pd
from kquant_data.config import __CONFIG_H5_FUT_FACTOR_DIR__
from kquant_data.xio.csv import read_data_dataframe, write_data_dataframe
from kquant_data.future.symbol import wind_code_2_InstrumentID

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
已经下载到了每个合约的最新主力信息
现在对数据进一步整理成表单
"""


if __name__ == '__main__':
    input_path = os.path.join(__CONFIG_H5_FUT_FACTOR_DIR__, 'trade_hiscode')

    output_path = os.path.join(__CONFIG_H5_FUT_FACTOR_DIR__, 'trade_hiscode.csv')