コード例 #1
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)  # 保存数据文件到指定路径,方便下次直接加载
コード例 #2
0
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)  # 保存数据文件到指定路径,方便下次直接加载
コード例 #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)
コード例 #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')
コード例 #5
0
ファイル: test_wxt.py プロジェクト: optimuse/8Factors
def get_dv(start=20170101, end=20180101):
    import jaqs_fxdayu
    jaqs_fxdayu.patch_all()
    from jaqs_fxdayu.data import DataView
    from jaqs_fxdayu.data.dataservice import LocalDataService

    import warnings
    warnings.filterwarnings("ignore")

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

    #define
    factor_list = ['fcffps', 'lt_borrow', 'st_borrow', 'LCAP', 'end_bal_cash']
    check_factor = ','.join(factor_list)

    dataview_folder = r'D:/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()

    # total market value
    data_config = {
        "remote.data.address":
        "tcp://data.tushare.org:8910",
        "remote.data.username":
        "******",
        "remote.data.password":
        "******"
    }
    from jaqs_fxdayu.data.dataservice import RemoteDataService
    ds1 = RemoteDataService()
    ds1.init_from_config(data_config)
    dv.add_field('total_mv', ds1)
    dv.add_field('ncf_oper_ttm', ds1)

    return dv
コード例 #6
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)
コード例 #7
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)
コード例 #8
0
def get_dv(start=20170101, end=20180101):
    #import jaqs_fxdayu
    #jaqs_fxdayu.patch_all()
    from jaqs_fxdayu.data import DataView
    from jaqs_fxdayu.data.dataservice import LocalDataService

    import warnings
    warnings.filterwarnings("ignore")

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

    #define
    factor_list = [
        'BBI', 'EPS', 'PE', 'PS', 'ACCA', 'CTOP', 'MA10RegressCoeff12', 'AR',
        'BR', 'ARBR', 'np_parent_comp_ttm', 'total_share', 'bps', 'volume'
    ]
    check_factor = ','.join(factor_list)

    dataview_folder = r'../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()
    return dv
コード例 #9
0
dataview_folder = 'E:/data/data'
dv = DataView()
ds = LocalDataService(fp=dataview_folder)


factor_list = ['volume']
check_factor = ','.join(factor_list)

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

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

for name in FactorList:
    dv.add_field(name)

import numpy as np

def mask_index_member():
    id_member = dp.daily_index_cons(api, "000906.SH", start, end)
    mask = id_member==0
    return mask

def limit_up_down():
    # 定义可买卖条件——未停牌、未涨跌停
    trade_status = dv.get_ts('trade_status')
    mask_sus = trade_status != 1