def save_dataview():
    data_config = {
        "remote.data.address":
        "tcp://data.tushare.org:8910",
        "remote.data.username":
        "******",
        "remote.data.password":
        "******"  #QuantOs API令牌
    }
    ds = RemoteDataService()
    ds.init_from_config(data_config)

    dv = DataView()
    props = {
        'start_date': 20140101,
        'end_date': 20180101,
        'universe': '000300.SH',  #'universe': '000300.SH'表示标的股票池取的是沪深300
        'fields':
        "pb,pe,ps,float_mv,sw1,roe",  #'fields'表示取的数据,pb,pe,ps分别表示市净率,市盈率,市销率;float_mv代表流通市值,sw1表示申万1级行业分类的数据
        'freq': 1
    }

    dv.init_from_config(props, ds)
    dv.prepare_data()
    dv.save_dataview(dataview_folder)  # 保存数据文件到指定路径,方便下次直接加载
Beispiel #2
0
def save_dataview():
    data_config = {
        "remote.data.address":
        "tcp://data.quantOS.org:8910",
        "remote.data.username":
        "******",
        "remote.data.password":
        "******"
    }
    ds = RemoteDataService()
    ds.init_from_config(data_config)

    dv = DataView()
    props = {
        'start_date': 20140101,
        'end_date': 20180101,
        'universe': '000300.SH',
        'fields': "volume,pb,pe,ps,roe,float_mv,sw1",
        'freq': 1,
        'timeout': 180
    }

    dv.init_from_config(props, ds)
    dv.prepare_data()
    dv.save_dataview(dataview_folder)  # 保存数据文件到指定路径,方便下次直接加载
Beispiel #3
0
def test_write():
    ds = RemoteDataService()
    ds.init_from_config(data_config)
    dv = DataView()

    secs = '600030.SH,000063.SZ,000001.SZ'
    props = {
        'start_date': 20160601,
        'end_date': 20170601,
        'symbol': secs,
        'fields': 'open,close,high,low,volume,pb,net_assets,pcf_ncf',
        'freq': 1
    }

    dv.init_from_config(props, data_api=ds)
    dv.prepare_data()
    assert dv.data_d.shape == (281, 48)
    assert dv.dates.shape == (281, )
    # TODO
    """
    PerformanceWarning:
    your performance may suffer as PyTables will pickle object types that it cannot
    map directly to c-types [inferred_type->mixed,key->block1_values] [items->[('000001.SZ', 'int_income'), ('000001.SZ', 'less_handling_chrg_comm_exp'), ('000001.SZ', 'net_int_income'), ('000001.SZ', 'oper_exp'), ('000001.SZ', 'symbol'), ('000063.SZ', 'int_income'), ('000063.SZ', 'less_handling_chrg_comm_exp'), ('000063.SZ', 'net_int_income'), ('000063.SZ', 'oper_exp'), ('000063.SZ', 'symbol'), ('600030.SH', 'int_income'), ('600030.SH', 'less_handling_chrg_comm_exp'), ('600030.SH', 'net_int_income'), ('600030.SH', 'oper_exp'), ('600030.SH', 'symbol')]]
    """

    dv.save_dataview(folder_path=daily_path)
Beispiel #4
0
def test_dataview_universe():
    ds = RemoteDataService()
    ds.init_from_config(data_config)
    dv = DataView()

    props = {
        'start_date':
        20170227,
        'end_date':
        20170327,
        'universe':
        '000016.SH',
        # 'symbol': 'rb1710.SHF,rb1801.SHF',
        'fields':
        ('open,high,low,close,vwap,volume,turnover,' + 'sw1,zz2,' +
         'roe,net_assets,' + 'total_oper_rev,oper_exp,tot_profit,int_income'),
        'freq':
        1
    }

    dv.init_from_config(props, ds)
    dv.prepare_data()

    data_bench = dv.data_benchmark.copy()
    dv.data_benchmark = data_bench

    try:
        dv.data_benchmark = data_bench.iloc[3:]
    except ValueError:
        pass

    dv.remove_field('roe,net_assets')
    dv.remove_field('close')
Beispiel #5
0
def test_add_field():
    dv = DataView()
    dv.load_dataview(folder_path=daily_path)
    nrows, ncols = dv.data_d.shape
    n_securities = len(dv.data_d.columns.levels[0])

    ds = RemoteDataService()
    ds.init_from_config(data_config)
    dv.add_field('total_share', ds)
    assert dv.data_d.shape == (nrows, ncols + 1 * n_securities)
Beispiel #6
0
def test_q_add_field():
    dv = DataView()
    dv.load_dataview(folder_path=quarterly_path)
    nrows, ncols = dv.data_q.shape
    n_securities = len(dv.data_d.columns.levels[0])

    ds = RemoteDataService()
    ds.init_from_config(data_config)
    dv.add_field("debttoassets", ds)
    assert dv.data_q.shape == (nrows, ncols + 1 * n_securities)
Beispiel #7
0
def get_dv(start=20170101, end=20180101):
    import jaqs_fxdayu
    jaqs_fxdayu.patch_all()
    from jaqs.data import DataView
    from jaqs_fxdayu.data.dataservice import LocalDataService

    import warnings
    warnings.filterwarnings("ignore")

    #--------------------------------------------------------

    #define
    factor_list = [
        'volume', 'tot_profit', 'plus_non_oper_rev', 'less_non_oper_exp',
        'net_cash_flows_oper_act', 'total_oper_rev', 'tot_oper_cost',
        'fin_exp', 'less_selling_dist_exp', 'less_gerl_admin_exp', 'oper_rev',
        'less_oper_cost', 'turnover'
    ]
    check_factor = ','.join(factor_list)

    dataview_folder = 'G:\GSICE\DATA\data'
    ds = LocalDataService(fp=dataview_folder)

    ZZ800_id = ds.query_index_member("000906.SH", start, end)
    stock_symbol = list(set(ZZ800_id))

    dv_props = {
        'start_date': start,
        'end_date': end,
        'symbol': ','.join(stock_symbol),
        'fields': check_factor,
        'freq': 1,
        "prepare_fields": True
    }

    dv = DataView()
    dv.init_from_config(dv_props, data_api=ds)
    dv.prepare_data()

    data_config = {
        "remote.data.address":
        "tcp://data.tushare.org:8910",
        "remote.data.username":
        "******",
        "remote.data.password":
        "******"
    }

    from jaqs_fxdayu.data import RemoteDataService
    Ds = RemoteDataService()
    Ds.init_from_config(data_config)
    dv.add_field('pe', Ds)

    return dv
Beispiel #8
0
def test_add_formula_directly():
    ds = RemoteDataService()
    ds.init_from_config(data_config)
    dv = DataView()

    secs = '600030.SH,000063.SZ,000001.SZ'
    props = {
        'start_date': 20160601,
        'end_date': 20170601,
        'symbol': secs,
        'fields': 'open,close',
        'freq': 1
    }
    dv.init_from_config(props, data_api=ds)
    dv.prepare_data()

    dv.add_formula("myfactor", 'close / open', is_quarterly=False)
    assert dv.data_d.shape == (281, 36)
Beispiel #9
0
def test_q():
    ds = RemoteDataService()
    ds.init_from_config(data_config)
    dv = DataView()

    secs = '600030.SH,000063.SZ,000001.SZ'
    props = {
        'start_date':
        20160609,
        'end_date':
        20170601,
        'symbol':
        secs,
        'fields':
        ('open,close,' + 'pb,net_assets,' + 'total_oper_rev,oper_exp,' +
         'cash_paid_invest,' + 'capital_stk,' + 'roe'),
        'freq':
        1
    }

    dv.init_from_config(props, data_api=ds)
    dv.prepare_data()
    dv.save_dataview(folder_path=quarterly_path)
Beispiel #10
0
import os
import numpy as np
import warnings
from jaqs_fxdayu.util import dp
warnings.filterwarnings("ignore")

data_config = {
    "remote.data.address":
    "tcp://data.tushare.org:8910",
    "remote.data.username":
    "******",
    "remote.data.password":
    "******"
}

ds = RemoteDataService()
ds.init_from_config(data_config)
DV = DataView()

start = 20100101
end = 20161231
stock_symbol = list(
    set(dp.index_cons(ds, "000906.SH", start, end).symbol.values))
zz800_props = {
    'start_date': start,
    'end_date': end,
    'symbol': ','.join(stock_symbol),
    'fields': 'pb,pe,ps,float_mv,sw1,volume',
    'freq': 1,
    "prepare_fields": True
}
import pandas as pd
factor=pd.read_excel('因子搜索.xlsx')
FactorList=list(factor.index[:10])

from jaqs_fxdayu.util import dp
from jaqs.data.dataapi import DataApi
from jaqs_fxdayu.data import RemoteDataService

data_config = {
    "remote.data.address": "tcp://data.tushare.org:8910",
    "remote.data.username": "******",
    "remote.data.password": "******"
}
ds = api = RemoteDataService()
ds.init_from_config(data_config)

start = 20160101
end = 20180327
stock_symbol = list(set(dp.index_cons(ds, "000906.SH", start, end).symbol.values))

factor_list = ['volume', 'pb', 'roe','pe','share_trans_ratio','sw1']
check_factor = ','.join(factor_list)

import jaqs_fxdayu
jaqs_fxdayu.patch_all()
from jaqs_fxdayu.data import DataView
from jaqs.data import RemoteDataService
from jaqs_fxdayu.data.dataservice import LocalDataService
import os
import numpy as np
import pandas as pd