Esempio n. 1
0
def GQ_fetch_index_min(symbol, frequence, path='cache', verbose=False):
    if (isinstance(symbol, list)):
        symbol = symbol[0]

    mkdirs(os.path.join(path, 'index'))
    res = pd.read_hdf(os.path.join(path, 'index',
                                   '{}_{}_kline.hdf'.format(symbol,
                                                            frequence)),
                      key='df',
                      mode='r')
    return res
Esempio n. 2
0
    #                                   'username', 
    #                                   'password'])
    # 用上面的代码保存密码到用户配置 .GolemQ 目录下面
    password = load_settings('password.hdf5')
    auth(password.username[0], password.password[0]) #ID是申请时所填写的手机号;Password为聚宽官网登录密码,新申请用户默认为手机号后6位
    asset = u'000001.XSHE'
    is_auth = is_auth()

    # 查询当日剩余可调用条数
    print(get_query_count())
    print(is_auth)
    codelist = ['000876']
    code = codelist[0]

    # 创建数据下载目录
    index_path = mkdirs(os.path.join(mkdirs('datastore'), 'kline', 'index'))
    print(index_path)

    for year in range(2005, 2017):
        start_date = '{}-01-01'
        end_date = '{}-01-02'
        for code in indexlist:

        #his = jqapi.get_price(asset, start_date, end_date, frequency='60m')
        data_day = QA.QA_fetch_stock_min_adv(codelist,
            start='2019-01-01',
            end='2020-08-28',
            frequence='60min')
        his = data_day.data
        export_metadata_to_pickle(index_path, u'{}_{}'.format(asset, year), metadata=his)
        print()
        '399384',
        '510810',
        '399987',
        '159905',
        '399396',
        '399997',
        '159919',
        '159941',
        '159920',
    ]
    indexlist = jqapi.normalize_code(indexlist)
    code = indexlist[0]

    # 创建数据下载目录
    frequence = '60min'
    index_path = mkdirs(
        os.path.join(mkdirs('datastore'), 'kline', 'index', frequence))
    print(index_path)

    for year in range(2017, 2005, -1):
        start_date = '{}-01-01'.format(year)
        end_date = '{}-01-02'.format(year + 1)
        for asset in indexlist:
            print(
                asset,
                start_date,
                end_date,
            )
            indexfile = os.path.join(
                index_path, u'{}_{}_{}.pickle'.format(asset, year, frequence))
            if os.path.isfile(indexfile):
                print('文件已经存在,跳过 ', indexfile)