Пример #1
0
def classify_detail(classify_list):
    """
    获取类别数据
    """
    f = h5py.File(conf.HDF5_FILE_CLASSIFY, 'a')
    for ctype in classify_list:
        console.write_head(conf.HDF5_OPERATE_GET, conf.HDF5_RESOURCE_TUSHARE,
                           ctype)
        cpath = '/' + ctype
        if f.get(cpath) is None:
            f.create_group(cpath)

        if ctype == conf.HDF5_CLASSIFY_INDUSTRY:
            # 获取工业分类
            classify.get_industry_classified(f[cpath])
        elif ctype == conf.HDF5_CLASSIFY_CONCEPT:
            # 获取概念分类
            classify.get_concept_classified(f[cpath])
        elif ctype == conf.HDF5_CLASSIFY_HOT:
            # 获取热门分类
            classify.get_hot_classified(f[cpath])
        count.show_result()
        console.write_tail()
    f.close()
    return
Пример #2
0
def margin(reset_flag=False):
    """
    获取沪市融资融券
    """
    # 初始化文件
    f = h5py.File(conf.HDF5_FILE_FUNDAMENTAL, 'a')
    console.write_head(conf.HDF5_OPERATE_GET, conf.HDF5_RESOURCE_TUSHARE,
                       conf.HDF5_FUNDAMENTAL_SH_MARGINS)
    path = '/' + conf.HDF5_FUNDAMENTAL_SH_MARGINS
    if f.get(path) is None:
        f.create_group(path)
    fundamental.get_sh_margins(f[path], reset_flag)
    count.show_result()
    console.write_tail()

    # 获取深市融资融券
    console.write_head(conf.HDF5_OPERATE_GET, conf.HDF5_RESOURCE_TUSHARE,
                       conf.HDF5_FUNDAMENTAL_SZ_MARGINS)
    path = '/' + conf.HDF5_FUNDAMENTAL_SZ_MARGINS
    if f.get(path) is None:
        f.create_group(path)
    fundamental.get_sz_margins(f[path], reset_flag)
    count.show_result()
    console.write_tail()
    f.close()
    return
Пример #3
0
def all_share(omit_list):
    """
    根据类别获取所有share数据
    """
    console.write_head(conf.HDF5_OPERATE_GET, conf.HDF5_RESOURCE_TUSHARE,
                       conf.HDF5_RESOURCE_TUSHARE)
    # 初始化相关文件
    f_classify = h5py.File(conf.HDF5_FILE_CLASSIFY, 'a')
    code_list = []
    classify_list = [
        conf.HDF5_CLASSIFY_CONCEPT,
        conf.HDF5_CLASSIFY_INDUSTRY,
        conf.HDF5_CLASSIFY_HOT,
    ]
    for ctype in classify_list:
        # 获取概念下具体类别名称
        for classify_name in f_classify[ctype]:
            # 如果不存在code list,则跳过
            if f_classify[ctype][classify_name].get(
                    conf.HDF5_CLASSIFY_DS_CODE) is None:
                continue
            # 获取单个分类(code的list)下的share数据
            for row in f_classify[ctype][classify_name][
                    conf.HDF5_CLASSIFY_DS_CODE]:
                code = row[0].astype(str)
                if code not in code_list:
                    code_list.append(code)
    f_classify.close()

    f = h5py.File(conf.HDF5_FILE_SHARE, 'a')
    # 初始化error记录
    error.init_batch(conf.HDF5_ERROR_SHARE_GET)
    for code in code_list:
        code_prefix = code[0:3]
        if code_prefix in omit_list:
            continue
        # TODO, 筛选错误数据
        # history = error.get_file()
        # error_history = list()
        # if history is not None:
        #     history["ktype"] = history["ktype"].str.decode("utf-8")
        #     history["code"] = history["code"].str.decode("utf-8")
        #     error_history = history.values
        code_share(f, code)
    # 记录错误内容
    error.write_batch()
    # 输出获取情况
    count.show_result()
    f.close()
    console.write_tail()
    return
Пример #4
0
def ipo(reset_flag=False):
    """
    获取ipo数据
    """
    # 初始化文件
    f = h5py.File(conf.HDF5_FILE_FUNDAMENTAL, 'a')
    console.write_head(conf.HDF5_OPERATE_GET, conf.HDF5_RESOURCE_TUSHARE,
                       conf.HDF5_FUNDAMENTAL_IPO)
    path = '/' + conf.HDF5_FUNDAMENTAL_IPO
    if f.get(path) is None:
        f.create_group(path)
    fundamental.get_ipo(f[path], reset_flag)
    count.show_result()
    console.write_tail()
    f.close()
    return
Пример #5
0
def xsg():
    """
    获取限售股解禁数据
    """
    # 初始化文件
    f = h5py.File(conf.HDF5_FILE_FUNDAMENTAL, 'a')
    console.write_head(conf.HDF5_OPERATE_GET, conf.HDF5_RESOURCE_TUSHARE,
                       conf.HDF5_FUNDAMENTAL_XSG)
    path = '/' + conf.HDF5_FUNDAMENTAL_XSG
    if f.get(path) is None:
        f.create_group(path)
    fundamental.get_xsg(f[path])
    count.show_result()
    console.write_tail()
    f.close()
    return
Пример #6
0
def basic_environment(start_date):
    """
    获取基本面数据
    """
    # 初始化文件
    f = h5py.File(conf.HDF5_FILE_BASIC, 'a')
    # 初始化error记录
    error.init_batch(conf.HDF5_ERROR_DETAIL_GET)
    # 初始化打点记录
    console.write_head(conf.HDF5_OPERATE_GET, conf.HDF5_RESOURCE_TUSHARE,
                       conf.HDF5_BASIC_DETAIL)
    path = '/' + conf.HDF5_BASIC_DETAIL
    if f.get(path) is None:
        f.create_group(path)
    basic.get_detail(f[path], start_date)

    # 记录错误内容
    error.merge_batch()
    # 展示打点结果
    count.show_result()
    console.write_tail()
    f.close()
    return