{"description":"实验创建于2021/9/1","graph":{"edges":[{"to_node_id":"-149:instruments","from_node_id":"-136:data"},{"to_node_id":"-149:features","from_node_id":"-144:data"},{"to_node_id":"-160:input_data","from_node_id":"-149:data"},{"to_node_id":"-160:features","from_node_id":"-155:data"}],"nodes":[{"node_id":"-136","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2017-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2018-01-01","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"600000.SHA\n600004.SHA\n600010.SHA\n600012.SHA\n000012.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":"-136"}],"output_ports":[{"name":"data","node_id":"-136"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-144","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nreturn_5\nclose_0\nmf_net_amount_10\nmarket_cap_float_0\nclose_0/close_5 - 1","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-144"}],"output_ports":[{"name":"data","node_id":"-144"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-149","module_id":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v7","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}],"input_ports":[{"name":"instruments","node_id":"-149"},{"name":"features","node_id":"-149"}],"output_ports":[{"name":"data","node_id":"-149"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-155","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nrelative_ret(close_0)","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-155"}],"output_ports":[{"name":"data","node_id":"-155"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-160","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":"{\n 'relative_ret': relative_ret\n}\n\ndef relative_ret(df, close_0):\n return df.groupby('instrument', group_keys=False).apply(calcu_relative_ret)\n\ndef calcu_relative_ret(df):\n # 先获取中证800指数数据\n start_date = min(m7.data.read_df().date).strftime('%Y-%m-%d')\n end_date = max(m7.data.read_df().date).strftime('%Y-%m-%d')\n hs800_df = D.history_data(\n '000906.SHA',\n start_date=(pd.to_datetime(start_date) - datetime.timedelta(days=10)).strftime('%Y-%m-%d'), # 多取几天的数据\n end_date=end_date)[['date', 'close']].rename(columns={'close': 'hs800_close'})\n \n # 与个股数据合并\n df = df[['date', 'close_0']].reset_index().merge(hs800_df, on='date', how='left').set_index('index')\n \n # 返回超额收益率\n return df['close_0'].pct_change() - df['hs800_close'].pct_change()","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-160"},{"name":"features","node_id":"-160"}],"output_ports":[{"name":"data","node_id":"-160"}],"cacheable":true,"seq_num":5,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-136' Position='443.2216796875,34.53517532348633,200,200'/><node_position Node='-144' Position='771.0216064453125,34.53517532348633,200,200'/><node_position Node='-149' Position='509.22161865234375,163.2351837158203,200,200'/><node_position Node='-155' Position='841.2579956054688,157.9261016845703,200,200'/><node_position Node='-160' Position='688.4116821289062,275.6260986328125,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
[2021-09-01 11:28:49.666037] INFO: moduleinvoker: instruments.v2 开始运行..
[2021-09-01 11:28:49.836143] INFO: moduleinvoker: 命中缓存
[2021-09-01 11:28:49.837944] INFO: moduleinvoker: instruments.v2 运行完成[0.171914s].
[2021-09-01 11:28:49.845615] INFO: moduleinvoker: input_features.v1 开始运行..
[2021-09-01 11:28:49.851801] INFO: moduleinvoker: 命中缓存
[2021-09-01 11:28:49.853381] INFO: moduleinvoker: input_features.v1 运行完成[0.007797s].
[2021-09-01 11:28:49.869410] INFO: moduleinvoker: general_feature_extractor.v7 开始运行..
[2021-09-01 11:28:49.877277] INFO: moduleinvoker: 命中缓存
[2021-09-01 11:28:49.878971] INFO: moduleinvoker: general_feature_extractor.v7 运行完成[0.009581s].
[2021-09-01 11:28:49.888048] INFO: moduleinvoker: input_features.v1 开始运行..
[2021-09-01 11:28:49.925847] INFO: moduleinvoker: input_features.v1 运行完成[0.037792s].
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-44-2544e875d2da> in <module>
49 remove_extra_columns=False,
50 user_functions= {
---> 51 'relative_ret': relative_ret
52 }
53
NameError: name 'relative_ret' is not defined