#2_获取需要的数据 index_cons ; daily_index_cons
#step1_指数成分
from jaqs_fxdayu.util import dp
start = 20120104
end = 20171222
id_cons = dp.index_cons(api, "000300.SH", start,
                        end)  #可以得到各个股票进出沪深300的时间,out_date=999999表示现在仍在
#以下为一个小实验,统计出沪深300成分的数量:
k = id_cons.iloc[:, 2]
i = 0  #统计沪深300成分的数量
for s in k:
    if s == 99999999:
        i = i + 1

id_member = dp.daily_index_cons(
    api, "000300.SH", start,
    end)  #与id_cons类似,这里输出的是更为详细的数据,精确到每一天,每一支股票,true表示这一天在沪深300中
mask = ~id_member  #true变为false,false变为true
print(mask.tail())

#step2_行业分类信息 daily_sec_industry
symbol_id = dp.index_cons(api, "000300.SH", start,
                          end)["symbol"].dropna()  #得到沪深300全部的股票代码
symbols = ",".join(symbol_id)  #将Series做成str形式,并用豆号隔开,得到一串股票代码symbols

group = dp.daily_sec_industry(api,
                              symbols,
                              start,
                              end,
                              source='sw',
                              value="industry1_name")
Beispiel #2
0
# In[4]:

dv.append_df(GetResidual(), 'R')
dv.append_df(alpha32_.run_formula(dv), 'alpha32_')
dv.append_df(alpha42_.run_formula(dv), 'alpha42_')
dv.append_df(alpha56_.run_formula(dv), 'alpha56_')
dv.append_df(alpha62_.run_formula(dv), 'alpha62_')
dv.append_df(alpha64_.run_formula(dv), 'alpha64_')
dv.append_df(alpha194.run_formula(dv), 'alpha194')
dv.append_df(alpha195.run_formula(dv), 'alpha195')
dv.append_df(alpha197.run_formula(dv), 'alpha197')
dv.append_df(Beta3.run_formula(dv), 'Beta3')

# In[6]:

id_zz500 = dp.daily_index_cons(api, "000300.SH", start, end)
id_hs300 = dp.daily_index_cons(api, "000905.SH", start, end)

columns_500 = list(set(id_zz500.columns) - set(id_hs300.columns))


def limit_up_down():
    trade_status = dv.get_ts('trade_status').fillna(0)
    mask_sus = trade_status == 0
    # 涨停
    up_limit = dv.add_formula(
        'up_limit',
        '(close - Delay(close, 1)) / Delay(close, 1) > 0.095',
        is_quarterly=False)
    # 跌停
    down_limit = dv.add_formula(
Beispiel #3
0
def cal_obj(signal, name, period=5, quantile=5):
    obj = SignalDigger()
    obj.process_signal_before_analysis(
        signal,
        price=price,
        n_quantiles=quantile,
        period=period,
        can_enter=can_enter,
        can_exit=can_exit,
        mask=mask,
    )
    obj.create_full_report()
    return obj


id_member = dp.daily_index_cons(ds, "000906.SH", start, end)
mask = id_member == 0

can_enter, can_exit = limit_up_down()

from jaqs_fxdayu.research.signaldigger import multi_factor

period_list = [20]
factor_list = ['Factor1', 'Factor7', 'Factor9']
ic = dict()
factors_dict = {signal: dv.get_ts(signal) for signal in factor_list}
for period in period_list:
    ic[period] = multi_factor.get_factors_ic_df(
        factors_dict,
        price=dv.get_ts("close_adj"),
        high=dv.get_ts("high_adj"),  # 可为空
def mask_index_member():
    id_member = dp.daily_index_cons(api, "000906.SH", start, end)
    mask = id_member==0
    return mask