{"description":"实验创建于2017/8/26","graph":{"edges":[{"to_node_id":"-43:instruments","from_node_id":"-143:data"},{"to_node_id":"-43:features","from_node_id":"-151:data"},{"to_node_id":"-43:user_functions","from_node_id":"-52:functions"},{"to_node_id":"-145:features","from_node_id":"-62:data"},{"to_node_id":"-145:input_data","from_node_id":"-43:data"}],"nodes":[{"node_id":"-143","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2020-06-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2020-12-31","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"000001.SZA\n000002.SZA\n000005.SZA","type":"Literal","bound_global_parameter":null},{"name":"max_count","value":"0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"rolling_conf","node_id":"-143"}],"output_ports":[{"name":"data","node_id":"-143"}],"cacheable":true,"seq_num":20,"comment":"","comment_collapsed":true},{"node_id":"-151","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"# 支持 np=numpy, pd=pandas, ta=talib, math 库,支持 pandas series 内建函数\n# _ 开始的表示中间变量,不会出现在最终结果中,可以用于中间复用计算结果,加快速度\n# 自定义表达式\n\n\n\n\nret5m = close.loc[145700] / close.loc[145200] -1 \n\n\n\nclose_ = close.loc[145700]\n\n\n\n(close*volume).sum()/volume.sum()\nvwap(close,volume)\nmean_4 = close.loc[103000]+close.loc[113000]+ close.loc[140000]+close.loc[145700] \n_ret = close.pct_change().fillna(close.iloc[0]/open.iloc[0])\n\n# 分钟收益率的各阶矩\t\nskew = _ret.skew()\nkurt = _ret.kurt()\ninday_ret = close.loc[145700]/close.loc[95900] - 1 # 日内涨跌幅累积\nlow_volume_cov = low.cov(volume) #日内成交量最低价的协方差\n \nsome_rsi = ta.RSI(close).loc[95900] # RSI技术指标\nsar = ta.SAR(high,low, 0.02, 0.2).loc[145700] # SAR抛物线转向\n\n_pvt = (_ret * volume).cumsum()\npvt = _pvt.iloc[-1] - _pvt.mean() # PVT量价趋势因子\n\n# 聪明钱指标\n_st = ((close / close.shift(1) - 1).abs() / volume.pow(0.5)).sort_values(ascending=False)\n_volume = volume[_st.index]\n_close = close[_st.index]\n_smart_money = (_volume.cumsum() / volume.sum()) >= 0.2\nsmart_money = ((_volume[_smart_money] * _close[_smart_money]).sum() / _volume[_smart_money].sum()) / ((volume * close).sum() / volume.sum())\n \n# 成交量个阶矩\nmean_v =volume.mean()\nstd_v = volume.std()\nskew_v = volume.skew()\nkurt_v =volume.kurt()\n\n# 日内最优动量\nmom1 = close.loc[103000]/close.loc[93100] - 1\nmom2 = close.loc[113000]/close.loc[103000] - 1\nmom3 = close.loc[140000]/close.loc[130100] - 1\nmom4 = close.loc[145700]/close.loc[140000] - 1\n\nopen_ = open.loc[93100]\nhigh_ = high.max() \nlow_ = low.min()\n \n# 人气指标 \n_mid = (high+low+close)/3\n_strong_sum = where(high>_mid.shift(1),high-_mid.shift(1),0).sum()\n_weak_sum = where(low<_mid.shift(1),_mid.shift(1)-low,0).sum()\ncr = _strong_sum / _weak_sum \n \n# MFI资金流向因子\n_mf = _mid * volume \n_mf_p = where(_mid>_mid.shift(1), _mf, 0)\n_mf_n = where(_mid<_mid.shift(1), -1*_mf, 0)\n_positive_mf = _mf_p.loc[100000:145700].sum()\n_negative_mf = _mf_n.loc[100000:145700].sum()\n_mr = _positive_mf/_negative_mf\nmfi = 100-(100/(1+_mr))\n\n# MACD指数平滑异同平均\n_dif = ta.EMA(close,12) - ta.EMA(close,26)\nmacd = _dif.loc[145700]\n\n# SRDM动向速度比率\n_dmz = where(high+low<high.shift(1)+low.shift(1),0,max(abs(high-high.shift(1)),abs(low-low.shift(1))))\n_dmf = where(high+low>=high.shift(1)+low.shift(1),0,max(abs(high-high.shift(1)),abs(low-low.shift(1))))\n_admz = mean(_dmz,10)\n_admf = mean(_dmf,10)\n_srdm = where(_admz>_admf,(_admz-_admf)/_admz,where(_admz==_admf,0,(_admz-_admf)/_admf))\nasrdm = mean(_srdm, 10).loc[145700]\n\n# 真正强度指数TSI\t\n_mom = close - close.shift(1)\n_mom_real = np.array(_mom,dtype='f8')\n_tsi_series = (ta.EMA(ta.EMA(_mom_real,25),13) / ta.EMA(ta.EMA(abs(_mom_real),25),13) )*100\ntsi = _tsi_series.loc[145700]\n\n# 日内大单流入\n_up_volumes = volume[_ret > 0]\nmy_mf_net_amount_l = _up_volumes.nlargest(math.floor(0.1 * len(_up_volumes))).sum()\n ","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-151"}],"output_ports":[{"name":"data","node_id":"-151"}],"cacheable":true,"seq_num":21,"comment":"","comment_collapsed":true},{"node_id":"-52","module_id":"BigQuantSpace.feature_extractor_user_function.feature_extractor_user_function-v1","parameters":[{"name":"name","value":"vwap","type":"Literal","bound_global_parameter":null},{"name":"func","value":"def bigquant_run(df, close, volume):\n vwap=(close*volume).sum()/volume.sum()\n return vwap\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_functions","node_id":"-52"}],"output_ports":[{"name":"functions","node_id":"-52"}],"cacheable":false,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-145","module_id":"BigQuantSpace.derived_feature_extractor.derived_feature_extractor-v3","parameters":[{"name":"date_col","value":"date","type":"Literal","bound_global_parameter":null},{"name":"instrument_col","value":"instrument","type":"Literal","bound_global_parameter":null},{"name":"drop_na","value":"False","type":"Literal","bound_global_parameter":null},{"name":"remove_extra_columns","value":"False","type":"Literal","bound_global_parameter":null},{"name":"user_functions","value":"def cal_m(df, amount_avg, price_chg, N):\n def get_m_rolling(s, df_1, N):\n _media_num = (N + 1)//2\n _temp = pd.Series(s).sort_values(ascending=False)\n _m_high = (df_1.iloc[_temp.iloc[:_media_num].index].price_chg + 1).cumprod().iloc[-1] - 1\n _m_low = (df_1.iloc[_temp.iloc[_media_num:].index].price_chg + 1).cumprod().iloc[-1] - 1\n return _m_high - _m_low\n return pd.rolling_apply(df.amount_avg, N, lambda x: get_m_rolling(x, df, N))\n\n# Series对象 rolling 分块求回归系数\ndef rolling_series(series, roll_period):\n series.index= range(1,len(series)+1)\n start_lst = list(series[:roll_period -1])\n rolllists = [series[1].copy()] * (roll_period - 1)\n for i in range(len(start_lst)):\n rolllists[i] = start_lst[i]\n \n for row in series.index:\n index = row\n values = series.ix[index]\n if index > roll_period - 1: # or -2 if zero-indexed\n res = []\n for i in range(index - roll_period, index):\n res.append(series.loc[i + 1]) # or i if 0-indexed\n rolllists.append(res)\n \n new_roll = []\n for li in rolllists:\n while isinstance(li[0], list):\n li = [item for sublist in li for item in sublist] # flatten nested list\n new_roll.append(li)\n return new_roll\n\ndef calcu_rnyd_ret(df, x_name, y_name, N):\n \n reg_df = pd.DataFrame({'x': rolling_series(x_name, N), 'y':rolling_series(y_name, N)})\n \n beta_lst = []\n \n for i in reg_df.index:\n \n x = pd.Series(reg_df.ix[i]['x']).fillna(0)\n y = pd.Series(reg_df.ix[i]['y']).fillna(0)\n \n from scipy import stats\n import statsmodels.api as sm\n \n beta, stockalpha, r_value, p_value, slope_std_error = stats.linregress( x, y)\n beta_lst.append(beta) \n return pd.Series(beta_lst)\n \nbigquant_run = {\n 'calcu_rnyd_ret': calcu_rnyd_ret,\n 'cal_m':cal_m\n}","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-145"},{"name":"features","node_id":"-145"}],"output_ports":[{"name":"data","node_id":"-145"}],"cacheable":true,"seq_num":2,"comment":"日频因子进行加工","comment_collapsed":false},{"node_id":"-62","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"mom0 = open_/close_.shift(1)\nma_mom1 = mean(mom1,22)\nma_mom2 = mean(mom2,22)\nma_mom3 = mean(mom3,22)\nma_mom4 = mean(mom4,22)\n \n ","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-62"}],"output_ports":[{"name":"data","node_id":"-62"}],"cacheable":false,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-43","module_id":"BigQuantSpace.feature_extractor_1m.feature_extractor_1m-v2","parameters":[{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"before_start_days","value":90,"type":"Literal","bound_global_parameter":null},{"name":"workers","value":2,"type":"Literal","bound_global_parameter":null},{"name":"parallel_mode","value":"测试","type":"Literal","bound_global_parameter":null},{"name":"table_1m","value":"降频分钟数据(股票)","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-43"},{"name":"features","node_id":"-43"},{"name":"user_functions","node_id":"-43"}],"output_ports":[{"name":"data","node_id":"-43"}],"cacheable":false,"seq_num":3,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-143' Position='-235,-681,200,200'/><node_position Node='-151' Position='80,-746,200,200'/><node_position Node='-52' Position='383,-687,200,200'/><node_position Node='-145' Position='246,-394,200,200'/><node_position Node='-62' Position='489,-572,200,200'/><node_position Node='-43' Position='74.93719100952148,-514.6241149902344,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
[2023-01-03 17:37:17.672242] INFO: moduleinvoker: instruments.v2 开始运行..
[2023-01-03 17:37:17.682472] INFO: moduleinvoker: 命中缓存
[2023-01-03 17:37:17.685599] INFO: moduleinvoker: instruments.v2 运行完成[0.013375s].
[2023-01-03 17:37:17.693669] INFO: moduleinvoker: input_features.v1 开始运行..
[2023-01-03 17:37:17.705684] INFO: moduleinvoker: 命中缓存
[2023-01-03 17:37:17.712058] INFO: moduleinvoker: input_features.v1 运行完成[0.018397s].
[2023-01-03 17:37:17.753502] INFO: moduleinvoker: feature_extractor_user_function.v1 运行完成[0.000255s].
[2023-01-03 17:37:17.807531] INFO: moduleinvoker: feature_extractor_1m.v2 开始运行..
[2023-01-03 17:37:18.108749] INFO: 高频特征抽取-分钟到日频: 测试模式运行, 选取证券代码:['000005.SZA', '000001.SZA', '000002.SZA']
[2023-01-03 17:37:18.114819] INFO: 高频特征抽取-分钟到日频: 【测试模式】, instruments:3, 并发数: 2
[2023-01-03 17:38:10.476273] INFO: 高频特征抽取-分钟到日频: extracted chunk 3/3 instruments, (618, 32).
[2023-01-03 17:38:10.480602] INFO: 高频特征抽取-分钟到日频: merge result .......
[2023-01-03 17:38:10.736287] INFO: 高频特征抽取-分钟到日频: extracted 3/3 instruments, (618, 32)
[2023-01-03 17:38:10.743249] INFO: moduleinvoker: feature_extractor_1m.v2 运行完成[52.935709s].
[2023-01-03 17:38:10.759360] INFO: moduleinvoker: input_features.v1 开始运行..
[2023-01-03 17:38:10.787420] INFO: moduleinvoker: input_features.v1 运行完成[0.028054s].
[2023-01-03 17:38:10.859064] INFO: moduleinvoker: derived_feature_extractor.v3 开始运行..
[2023-01-03 17:38:10.956802] INFO: derived_feature_extractor: 提取完成 mom0 = open_/close_.shift(1), 0.003s
[2023-01-03 17:38:10.967768] INFO: derived_feature_extractor: 提取完成 ma_mom1 = mean(mom1,22), 0.008s
[2023-01-03 17:38:10.981049] INFO: derived_feature_extractor: 提取完成 ma_mom2 = mean(mom2,22), 0.010s
[2023-01-03 17:38:10.992120] INFO: derived_feature_extractor: 提取完成 ma_mom3 = mean(mom3,22), 0.008s
[2023-01-03 17:38:11.002256] INFO: derived_feature_extractor: 提取完成 ma_mom4 = mean(mom4,22), 0.008s
[2023-01-03 17:38:11.095639] INFO: derived_feature_extractor: /data, 618
[2023-01-03 17:38:11.191241] INFO: moduleinvoker: derived_feature_extractor.v3 运行完成[0.332199s].