# Path: kquant_data/config.py
# __CONFIG_TDAYS_SSE_FILE__ = os.path.join(__CONFIG_H5_STK_DIR__, 'tdays', 'SSE.csv')
# 
# __CONFIG_H5_STK_SECTOR_DIR__ = os.path.join(__CONFIG_H5_STK_DIR__, 'sectorconstituent')
# 
# Path: kquant_data/wind_resume/wset.py
# def download_sectors_list(
#         w,
#         root_path,
#         sector_name="中信证券一级行业指数"):
#     """
#     下载行业分类列表
#     :param w:
#     :param sector_name:
#     :param root_path:
#     :return:
#     """
#     date_str = datetime.today().strftime('%Y-%m-%d')
# 
#     df = download_sectorconstituent(w, date_str, sector_name, None, 'wind_code')
#     df['ID'] = list(range(0, df.shape[0]))
#     df['ID'] += 1001
# 
#     path = os.path.join(root_path, '%s.csv' % sector_name)
#     df.to_csv(path, encoding='utf-8-sig', date_format='%Y-%m-%d', index=None)
#     return df
# 
# Path: kquant_data/wind_resume/tdays.py
# def resume_download_tdays(w, enddate, path):
#     """
#     增量下载
#     :return:
#     """
#     df_old = read_tdays(path)
#     if df_old is None:
#         startdate = '1991-01-01'
#     else:
#         startdate = df_old.index[-1]
#     df_new = download_tdays(w, startdate, enddate, option="")
#     df = pd.concat([df_old, df_new])
# 
#     # 可能要‘去重’，也可能None不能参与合并
#     write_tdays(path, df)


import sys
from WindPy import w
from kquant_data.config import __CONFIG_TDAYS_SSE_FILE__, __CONFIG_H5_STK_SECTOR_DIR__
from kquant_data.wind_resume.wset import download_sectors_list
from kquant_data.wind_resume.tdays import resume_download_tdays
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
执行次数很早的算法
比如下载行业分类列表，下载
"""



# 解决Python 3.6的pandas不支持中文路径的问题
print(sys.getfilesystemencoding())  # 查看修改前的
try:
    sys._enablelegacywindowsfsencoding()  # 修改
    print(sys.getfilesystemencoding())  # 查看修改后的
except:
    pass


if __name__ == '__main__':
    w.start()
    # 因为只用下载一次，所以都用False先关闭

    # 下载行业分类列表，只用下载一次即可
    if False:
        download_sectors_list(w,
                              sector_name="中信证券一级行业指数",

# Path: kquant_data/config.py
# __CONFIG_TDAYS_SSE_FILE__ = os.path.join(__CONFIG_H5_STK_DIR__, 'tdays', 'SSE.csv')
# 
# __CONFIG_H5_STK_SECTOR_DIR__ = os.path.join(__CONFIG_H5_STK_DIR__, 'sectorconstituent')
# 
# Path: kquant_data/wind_resume/wset.py
# def download_sectors_list(
#         w,
#         root_path,
#         sector_name="中信证券一级行业指数"):
#     """
#     下载行业分类列表
#     :param w:
#     :param sector_name:
#     :param root_path:
#     :return:
#     """
#     date_str = datetime.today().strftime('%Y-%m-%d')
# 
#     df = download_sectorconstituent(w, date_str, sector_name, None, 'wind_code')
#     df['ID'] = list(range(0, df.shape[0]))
#     df['ID'] += 1001
# 
#     path = os.path.join(root_path, '%s.csv' % sector_name)
#     df.to_csv(path, encoding='utf-8-sig', date_format='%Y-%m-%d', index=None)
#     return df
# 
# Path: kquant_data/wind_resume/tdays.py
# def resume_download_tdays(w, enddate, path):
#     """
#     增量下载
#     :return:
#     """
#     df_old = read_tdays(path)
#     if df_old is None:
#         startdate = '1991-01-01'
#     else:
#         startdate = df_old.index[-1]
#     df_new = download_tdays(w, startdate, enddate, option="")
#     df = pd.concat([df_old, df_new])
# 
#     # 可能要‘去重’，也可能None不能参与合并
#     write_tdays(path, df)


# Path: demo_stock/A_1day/A01_tdays_sectors.py
import sys
from WindPy import w
from kquant_data.config import __CONFIG_TDAYS_SSE_FILE__, __CONFIG_H5_STK_SECTOR_DIR__
from kquant_data.wind_resume.wset import download_sectors_list
from kquant_data.wind_resume.tdays import resume_download_tdays

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
执行次数很早的算法
比如下载行业分类列表，下载
"""



# 解决Python 3.6的pandas不支持中文路径的问题
print(sys.getfilesystemencoding())  # 查看修改前的
try:
    sys._enablelegacywindowsfsencoding()  # 修改
    print(sys.getfilesystemencoding())  # 查看修改后的
except:
    pass


if __name__ == '__main__':
    w.start()
    # 因为只用下载一次，所以都用False先关闭

    # 下载行业分类列表，只用下载一次即可
    if False:
        download_sectors_list(w,
                              sector_name="中信证券一级行业指数",

                              root_path=__CONFIG_H5_STK_SECTOR_DIR__)