复制链接
克隆策略

    {"description":"实验创建于2022/5/12","graph":{"edges":[{"to_node_id":"-280:input_1","from_node_id":"-1878:data"},{"to_node_id":"-280:input_2","from_node_id":"-1890:data_1"},{"to_node_id":"-902:input_ds","from_node_id":"-960:data_1"},{"to_node_id":"-921:input_2","from_node_id":"-902:data"},{"to_node_id":"-268:input_1","from_node_id":"-3631:data"},{"to_node_id":"-157:input_2","from_node_id":"-3631:data"},{"to_node_id":"-268:input_2","from_node_id":"-4795:data_1"},{"to_node_id":"-3672:input_ds","from_node_id":"-3663:data_1"},{"to_node_id":"-921:input_3","from_node_id":"-3672:data"},{"to_node_id":"-592:input_1","from_node_id":"-921:data_1"},{"to_node_id":"-483:input_1","from_node_id":"-592:data_1"},{"to_node_id":"-489:input_data","from_node_id":"-483:data"},{"to_node_id":"-585:input_data","from_node_id":"-489:data_1"},{"to_node_id":"-500:input_1","from_node_id":"-585:data"},{"to_node_id":"-577:input_1","from_node_id":"-500:data_1"},{"to_node_id":"-157:input_1","from_node_id":"-577:data_1"},{"to_node_id":"-236:input_1","from_node_id":"-577:data_2"},{"to_node_id":"-3663:input_1","from_node_id":"-268:data_1"},{"to_node_id":"-960:input_1","from_node_id":"-280:data_1"},{"to_node_id":"-181:instruments","from_node_id":"-157:data_1"},{"to_node_id":"-2555:input_1","from_node_id":"-157:data_1"},{"to_node_id":"-169:input_1","from_node_id":"-157:data_2"},{"to_node_id":"-220:input_ds","from_node_id":"-169:data_1"},{"to_node_id":"-214:input_ds","from_node_id":"-2555:data_1"},{"to_node_id":"-229:input_1","from_node_id":"-214:data"},{"to_node_id":"-229:input_2","from_node_id":"-220:data"},{"to_node_id":"-181:options_data","from_node_id":"-229:data_1"},{"to_node_id":"-181:history_ds","from_node_id":"-229:data_1"},{"to_node_id":"-224:input_data","from_node_id":"-229:data_2"}],"nodes":[{"node_id":"-1878","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2019-10-11","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-10-11","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_FUND","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"#159919.ZOF","type":"Literal","bound_global_parameter":null},{"name":"max_count","value":0,"type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"rolling_conf","node_id":"-1878"}],"output_ports":[{"name":"data","node_id":"-1878"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-1890","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, start_date,end_date):\n # 示例代码如下。在这里编写您的代码\n #from datetime import datetime\n #ins=input_1.read_pickle()['instruments']\n #start_date=input_1.read_pickle()['start_date']\n #end_date=input_1.read_pickle()['end_date']\n #start_date_dt = datetime.strptime(start_date, '%Y-%m-%d')\n #end_date_dt = datetime.strptime(end_date, '%Y-%m-%d')\n \n fund_info = DataSource('basic_info_CN_FUND').read()\n #fund_info_0 = fund_info[fund_info['type'] == 'ETF']\n\n data_1 = DataSource.write_df(fund_info)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-1890"},{"name":"input_2","node_id":"-1890"},{"name":"input_3","node_id":"-1890"}],"output_ports":[{"name":"data_1","node_id":"-1890"},{"name":"data_2","node_id":"-1890"},{"name":"data_3","node_id":"-1890"}],"cacheable":true,"seq_num":2,"comment":"读出场内基金信息","comment_collapsed":false},{"node_id":"-960","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3):\n # 示例代码如下。在这里编写您的代码\n df = DataSource.read_df(input_1)\n df['close'] = df['close'] * df['adjust_factor']\n df = df.sort_values(['instrument', 'date'])\n first_instrument = df.iloc[0]['instrument']\n for key, group in df.groupby('instrument'):\n group['return_0'] = group['close'] / group['close'].shift(1) - 1\n if key == first_instrument:\n group_all = group\n else:\n group_all = pd.concat([group_all, group])\n group_all = group_all.dropna()\n #df['cum_return'] = (df['return_0'] + 1).cumprod() - 1\n data_1 = DataSource.write_df(group_all)\n #data_2 = DataSource.write_pickle(df)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-960"},{"name":"input_2","node_id":"-960"},{"name":"input_3","node_id":"-960"}],"output_ports":[{"name":"data_1","node_id":"-960"},{"name":"data_2","node_id":"-960"},{"name":"data_3","node_id":"-960"}],"cacheable":true,"seq_num":3,"comment":"计算日收益率","comment_collapsed":false},{"node_id":"-902","module_id":"BigQuantSpace.select_columns.select_columns-v3","parameters":[{"name":"columns","value":"date,instrument,return_0,close","type":"Literal","bound_global_parameter":null},{"name":"reverse_select","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_ds","node_id":"-902"},{"name":"columns_ds","node_id":"-902"}],"output_ports":[{"name":"data","node_id":"-902"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-3631","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2019-10-11","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-10-11","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_MUTFUND","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"#000395.OFCN","type":"Literal","bound_global_parameter":null},{"name":"max_count","value":0,"type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"rolling_conf","node_id":"-3631"}],"output_ports":[{"name":"data","node_id":"-3631"}],"cacheable":true,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"-4795","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1):\n # 示例代码如下。在这里编写您的代码\n #from datetime import datetime\n #ins=input_1.read_pickle()['instruments']\n #start_date=input_1.read_pickle()['start_date']\n #end_date=input_1.read_pickle()['end_date']\n #start_date_dt = datetime.strptime(start_date, '%Y-%m-%d')\n #end_date_dt = datetime.strptime(end_date, '%Y-%m-%d')\n \n #if len(ins) == 0:\n fund_info = DataSource('basic_info_CN_MUTFUND').read()\n #fund_info_0 = fund_info[fund_info['etf_lof'] == 'ETF']\n data_1 = DataSource.write_df(fund_info)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-4795"},{"name":"input_2","node_id":"-4795"},{"name":"input_3","node_id":"-4795"}],"output_ports":[{"name":"data_1","node_id":"-4795"},{"name":"data_2","node_id":"-4795"},{"name":"data_3","node_id":"-4795"}],"cacheable":true,"seq_num":6,"comment":"读出场外公募基金信息","comment_collapsed":false},{"node_id":"-3663","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3):\n # 示例代码如下。在这里编写您的代码\n df = DataSource.read_df(input_1)\n df = df.rename({'adjust_nav': 'close'}, axis = 1)\n df['return_0'] = df['adj_nav_chg_pct'] / 100\n '''\n df = df.sort_values(['instrument', 'date'])\n first_instrument = df.iloc[0]['instrument']\n for key, group in df.groupby('instrument'):\n group['cum_return'] = (group['return_0'] + 1).cumprod() - 1\n if key == first_instrument:\n group_all = group\n else:\n group_all = pd.concat([group_all, group])\n ''' \n data_1 = DataSource.write_df(df)\n #data_2 = DataSource.write_pickle(df)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-3663"},{"name":"input_2","node_id":"-3663"},{"name":"input_3","node_id":"-3663"}],"output_ports":[{"name":"data_1","node_id":"-3663"},{"name":"data_2","node_id":"-3663"},{"name":"data_3","node_id":"-3663"}],"cacheable":true,"seq_num":28,"comment":"计算日收益率","comment_collapsed":false},{"node_id":"-3672","module_id":"BigQuantSpace.select_columns.select_columns-v3","parameters":[{"name":"columns","value":"date,instrument,return_0,close","type":"Literal","bound_global_parameter":null},{"name":"reverse_select","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_ds","node_id":"-3672"},{"name":"columns_ds","node_id":"-3672"}],"output_ports":[{"name":"data","node_id":"-3672"}],"cacheable":true,"seq_num":29,"comment":"","comment_collapsed":true},{"node_id":"-921","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3):\n # 示例代码如下。在这里编写您的代码\n #df1 = DataSource.read_df(input_1)\n df2 = DataSource.read_df(input_2)\n df3 = DataSource.read_df(input_3)\n df = pd.concat([df2, df3])\n data_1 = DataSource.write_df(df)\n #data_2 = DataSource.write_pickle(df)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-921"},{"name":"input_2","node_id":"-921"},{"name":"input_3","node_id":"-921"}],"output_ports":[{"name":"data_1","node_id":"-921"},{"name":"data_2","node_id":"-921"},{"name":"data_3","node_id":"-921"}],"cacheable":true,"seq_num":30,"comment":"纵向合并2个表","comment_collapsed":false},{"node_id":"-592","module_id":"BigQuantSpace.set_inf_to_nan.set_inf_to_nan-v1","parameters":[],"input_ports":[{"name":"input_1","node_id":"-592"}],"output_ports":[{"name":"data_1","node_id":"-592"}],"cacheable":true,"seq_num":31,"comment":"","comment_collapsed":true},{"node_id":"-483","module_id":"BigQuantSpace.pivot_fbfill_stack.pivot_fbfill_stack-v3","parameters":[{"name":"index_col","value":"date","type":"Literal","bound_global_parameter":null},{"name":"col_name","value":"instrument","type":"Literal","bound_global_parameter":null},{"name":"values_col","value":"return_0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-483"}],"output_ports":[{"name":"data","node_id":"-483"}],"cacheable":true,"seq_num":33,"comment":"","comment_collapsed":true},{"node_id":"-489","module_id":"BigQuantSpace.pandas_pivot_table.pandas_pivot_table-v1","parameters":[{"name":"index","value":"date","type":"Literal","bound_global_parameter":null},{"name":"columns","value":"instrument","type":"Literal","bound_global_parameter":null},{"name":"values","value":"return_0","type":"Literal","bound_global_parameter":null},{"name":"flat","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-489"}],"output_ports":[{"name":"data_1","node_id":"-489"}],"cacheable":true,"seq_num":34,"comment":"用日收益率形成透视表","comment_collapsed":false},{"node_id":"-585","module_id":"BigQuantSpace.dropnan.dropnan-v2","parameters":[],"input_ports":[{"name":"input_data","node_id":"-585"},{"name":"features","node_id":"-585"}],"output_ports":[{"name":"data","node_id":"-585"}],"cacheable":true,"seq_num":35,"comment":"","comment_collapsed":true},{"node_id":"-500","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3):\n # 示例代码如下。在这里编写您的代码\n df = DataSource.read_df(input_1)\n df = df.loc[ :,(\"return_0\", )]\n data_1 = DataSource.write_df(df)\n #data_2 = DataSource.write_pickle(df)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-500"},{"name":"input_2","node_id":"-500"},{"name":"input_3","node_id":"-500"}],"output_ports":[{"name":"data_1","node_id":"-500"},{"name":"data_2","node_id":"-500"},{"name":"data_3","node_id":"-500"}],"cacheable":true,"seq_num":36,"comment":"修改列索引","comment_collapsed":false},{"node_id":"-577","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3):\n # 示例代码如下。在这里编写您的代码\n df = DataSource.read_df(input_1)\n df_columns = df.columns.to_list()\n hs300_corr = pd.DataFrame(0, index = df_columns, columns = ['hs300_corr'])\n for label, item in df.iteritems():\n hs300_corr.loc[label, 'hs300_corr'] = df['159919.ZOF'].corr(item)\n hs300_corr = hs300_corr.sort_values(by = ['hs300_corr'])\n hs300_corr1 = hs300_corr[(hs300_corr['hs300_corr'] <= 0.01) & (hs300_corr['hs300_corr'] >= - 0.01)]\n hs300_corr1_ins = hs300_corr1.index.to_list()\n hs300_corr1_ins.append('159919.ZOF')\n hs300_corr_df = df[hs300_corr1_ins]\n corr_high = hs300_corr_df.corr().applymap(lambda x: np.nan if x > 0.1 else x).isnull()\n col_all = corr_high.columns.tolist()\n del_col = []\n i = 0\n while i < len(col_all) - 1:\n ex_index = corr_high.iloc[:,i][i+1:].index[np.where(corr_high.iloc[:,i][i+1:])].tolist()\n for var in ex_index:\n col_all.remove(var)\n corr_high = corr_high.loc[col_all, col_all]\n i += 1\n col_all_corr = hs300_corr_df[col_all].corr()\n hs300_nocorr_df = hs300_corr_df[col_all]\n #print(\"下表为无相关性的基金的两两的相关系数,接近0表示相关性弱,接近1表示相关性强。\")\n #print(col_all_corr)\n ins = hs300_nocorr_df.columns.to_list()\n df2 = DataSource(\"basic_info_CN_FUND\").read()\n df4 = DataSource(\"basic_info_CN_MUTFUND\").read()\n name = []\n for value in ins:\n is_named = False\n for index1, row1 in df4.iterrows():\n if value == row1['instrument']:\n name.append(row1['sec_short_name'])\n is_named = True\n break\n if not is_named:\n for index2, row2 in df2.iterrows():\n if value == row2['instrument']:\n name.append(row2['name'])\n is_named = True\n break\n hs300_nocorr_df.columns = name\n data_1 = DataSource.write_df(col_all_corr)\n data_2 = DataSource.write_df(hs300_nocorr_df)\n return Outputs(data_1=data_1, data_2=data_2, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-577"},{"name":"input_2","node_id":"-577"},{"name":"input_3","node_id":"-577"}],"output_ports":[{"name":"data_1","node_id":"-577"},{"name":"data_2","node_id":"-577"},{"name":"data_3","node_id":"-577"}],"cacheable":true,"seq_num":37,"comment":"筛选出与沪深300指数基金相关性低的基金","comment_collapsed":false},{"node_id":"-268","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2):\n # 示例代码如下。在这里编写您的代码\n from datetime import datetime\n ins=input_1.read_pickle()['instruments']\n start_date=input_1.read_pickle()['start_date']\n end_date=input_1.read_pickle()['end_date']\n start_date_dt = datetime.strptime(start_date, '%Y-%m-%d')\n end_date_dt = datetime.strptime(end_date, '%Y-%m-%d')\n fund_info_0 = DataSource.read_df(input_2)\n \n fund_info_delist_date = fund_info_0[fund_info_0['delist_date'].notnull()]\n fund_info_delist_date1 = fund_info_delist_date[(fund_info_delist_date['delist_date'] >= end_date_dt) & (fund_info_delist_date['list_date'] <= start_date_dt)]\n ins_delist_date1 = fund_info_delist_date1['instrument'].to_list()\n fund_info_delist_date2 = fund_info_0[fund_info_0['delist_date'].isnull() & (fund_info_0['list_date'] <= start_date_dt)]\n ins_delist_date2 = fund_info_delist_date2['instrument'].to_list()\n fund_info_expire_date = fund_info_0[fund_info_0['expire_date'].notnull()]\n fund_info_expire_date1 = fund_info_expire_date[(fund_info_expire_date['expire_date'] >= end_date_dt) & (fund_info_expire_date['establish_date'] <= start_date_dt)]\n ins_expire_date1 = fund_info_expire_date1['instrument'].to_list()\n fund_info_expire_date2 = fund_info_0[fund_info_0['expire_date'].isnull() & (fund_info_0['establish_date'] <= start_date_dt)]\n ins_expire_date2 = fund_info_expire_date2['instrument'].to_list()\n ins1 = ins_delist_date1 + ins_delist_date2 + ins_expire_date1 + ins_expire_date2 \n df=DataSource('history_nav_CN_MUTFUND').read(ins1,start_date=start_date,end_date=end_date)\n data_1 = DataSource.write_df(df)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-268"},{"name":"input_2","node_id":"-268"},{"name":"input_3","node_id":"-268"}],"output_ports":[{"name":"data_1","node_id":"-268"},{"name":"data_2","node_id":"-268"},{"name":"data_3","node_id":"-268"}],"cacheable":true,"seq_num":19,"comment":"读取场外公募基金行情","comment_collapsed":false},{"node_id":"-280","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2):\n # 示例代码如下。在这里编写您的代码\n from datetime import datetime\n ins=input_1.read_pickle()['instruments']\n start_date=input_1.read_pickle()['start_date']\n end_date=input_1.read_pickle()['end_date']\n start_date_dt = datetime.strptime(start_date, '%Y-%m-%d')\n end_date_dt = datetime.strptime(end_date, '%Y-%m-%d')\n \n fund_info_0 = DataSource.read_df(input_2)\n fund_info1 = fund_info_0[(fund_info_0['delist_date'] >= end_date_dt) & (fund_info_0['list_date'] <= start_date_dt)]\n fund_info2 = fund_info_0[fund_info_0['delist_date'].isnull() & (fund_info_0['list_date'] <= start_date_dt)]\n ins1 = fund_info1['instrument'].to_list() \n ins2 = fund_info2['instrument'].to_list() \n ins1.extend(ins2)\n df=DataSource('bar1d_CN_FUND').read(ins1,start_date=start_date,end_date=end_date)\n data_1 = DataSource.write_df(df)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-280"},{"name":"input_2","node_id":"-280"},{"name":"input_3","node_id":"-280"}],"output_ports":[{"name":"data_1","node_id":"-280"},{"name":"data_2","node_id":"-280"},{"name":"data_3","node_id":"-280"}],"cacheable":true,"seq_num":20,"comment":"读取场内基金行情","comment_collapsed":false},{"node_id":"-157","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3):\n # 示例代码如下。在这里编写您的代码\n df = DataSource.read_df(input_1)\n dict = DataSource.read_pickle(input_2)\n dict2 = dict.copy()\n list = df.index.to_list()\n trade_mutfund_list = []\n trade_fund_list = []\n \n for item in list:\n item_split = item.split(\".\")\n if item_split[1] == 'OFCN' or item_split[1] == 'OFCN2':\n trade_mutfund_list.append(item)\n elif item_split[1] == 'ZOF' or item_split[1] == 'HOF':\n trade_fund_list.append(item)\n \n dict['instruments'] = trade_mutfund_list\n dict2['instruments'] = trade_fund_list\n dict2['market'] = 'CN_FUND'\n #print(dict)\n data_1 = DataSource.write_pickle(dict2)\n data_2 = DataSource.write_pickle(dict)\n return Outputs(data_1=data_1, data_2=data_2, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-157"},{"name":"input_2","node_id":"-157"},{"name":"input_3","node_id":"-157"}],"output_ports":[{"name":"data_1","node_id":"-157"},{"name":"data_2","node_id":"-157"},{"name":"data_3","node_id":"-157"}],"cacheable":true,"seq_num":8,"comment":"合并产生代码列表","comment_collapsed":false},{"node_id":"-169","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2):\n # 示例代码如下。在这里编写您的代码\n from datetime import datetime\n ins=input_1.read_pickle()['instruments']\n start_date=input_1.read_pickle()['start_date']\n end_date=input_1.read_pickle()['end_date']\n df=DataSource('history_nav_CN_MUTFUND').read(ins,start_date=start_date,end_date=end_date)\n df['open'] = df['nav']\n df['high'] = df['nav']\n df['low'] = df['nav']\n df['close'] = df['nav']\n df['adjust_factor'] = df['adjust_nav'] / df['nav']\n df['volume'] = 1000000\n data_1 = DataSource.write_df(df)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-169"},{"name":"input_2","node_id":"-169"},{"name":"input_3","node_id":"-169"}],"output_ports":[{"name":"data_1","node_id":"-169"},{"name":"data_2","node_id":"-169"},{"name":"data_3","node_id":"-169"}],"cacheable":true,"seq_num":9,"comment":"读取场外公募基金行情","comment_collapsed":false},{"node_id":"-181","module_id":"BigQuantSpace.trade.trade-v4","parameters":[{"name":"start_date","value":"2019-10-11","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2022-10-11","type":"Literal","bound_global_parameter":null},{"name":"initialize","value":"# 回测引擎:初始化函数,只执行一次\ndef bigquant_run(context):\n # 加载预测数据\n context.ranker_prediction = context.options['data'].read_df()\n\n # 系统已经设置了默认的交易手续费和滑点,要修改手续费可使用如下函数\n context.set_commission(PerOrder(buy_cost=0.0003, sell_cost=0.0013, min_cost=5))\n # 预测数据,通过options传入进来,使用 read_df 函数,加载到内存 (DataFrame)\n # 设置买入的股票数量,这里买入预测股票列表排名靠前的5只\n #stock_count = 5\n # 每只的股票的权重,如下的权重分配会使得靠前的股票分配多一点的资金,[0.339160, 0.213986, 0.169580, ..]\n #context.stock_weights = T.norm([1 / math.log(i + 2) for i in range(0, stock_count)])\n # 设置每只股票占用的最大资金比例\n #context.max_cash_per_instrument = 0.2\n #context.hold_days = 5\n \n #周期为22个交易日\n context.rebalance_days = 22\n\n # 如果策略运行中,需要将数据进行保存,可以借用extension这个对象,类型为dict\n # 比如当前运行的k线的索引,比如个股持仓天数、买入均价\n if 'index' not in context.extension:\n context.extension['index'] = 0\n","type":"Literal","bound_global_parameter":null},{"name":"handle_data","value":"# 回测引擎:每日数据处理函数,每天执行一次\ndef bigquant_run(context, data):\n # 不在换仓日就return,相当于后面的代码只会一个月运行一次,买入的股票会持有1个月\n if context.extension['index'] % context.rebalance_days != 0:\n context.extension['index'] += 1\n return \n \n # 按日期过滤得到今日的预测数据\n date = data.current_dt.strftime('%Y-%m-%d')\n ranker_prediction = context.ranker_prediction[\n context.ranker_prediction.date == date]\n fund_amount = len(ranker_prediction)\n instrument_open = {}\n instrument_weight = {}\n \n for index, row in ranker_prediction.iterrows():\n instrument_open[row['instrument']] = row['open']\n instrument_weight[row['instrument']] = row['weight']\n \n #print('date: ', date, 'fund_amount: ', str(fund_amount))\n \n # 1. 资金分配\n # 平均持仓时间是hold_days,每日都将买入股票,每日预期使用 1/hold_days 的资金\n # 实际操作中,会存在一定的买入误差,所以在前hold_days天,等量使用资金;之后,尽量使用剩余资金(这里设置最多用等量的1.5倍)\n #is_staging = context.trading_day_index < context.hold_days # 是否在建仓期间(前 hold_days 天)\n #cash_avg = context.portfolio.portfolio_value / context.hold_days\n portfolio_value = context.portfolio.portfolio_value\n #cash_for_sell = cash_avg - (context.portfolio.cash - cash_for_buy)\n positions = {e.symbol: p.amount\n for e, p in context.perf_tracker.position_tracker.positions.items()}\n '''\n # 2. 生成卖出订单:hold_days天之后才开始卖出;对持仓的股票,按StockRanker预测的排序末位淘汰\n if not is_staging and cash_for_sell > 0:\n equities = {e.symbol: e for e, p in context.perf_tracker.position_tracker.positions.items()}\n instruments = list(reversed(list(ranker_prediction.instrument[ranker_prediction.instrument.apply(\n lambda x: x in equities and not context.has_unfinished_sell_order(equities[x]))])))\n # print('rank order for sell %s' % instruments)\n for instrument in instruments:\n context.order_target(context.symbol(instrument), 0)\n cash_for_sell -= positions[instrument]\n if cash_for_sell <= 0:\n break\n '''\n # 3. 生成买入订单:按StockRanker预测的排序,买入前面的stock_count只股票\n if fund_amount > 0:\n weight = 1 / fund_amount\n #print('date: ', date, 'index: ', str(context.extension['index']), ' portfolio_value: ', str(portfolio_value), ' weight: ', str(weight))\n buy_instruments = list(ranker_prediction.instrument)\n #cash = cash_for_buy * buy_cash_weights\n #max_cash_per_instrument = context.portfolio.portfolio_value * context.max_cash_per_instrument\n for instrument, amount in positions.items():\n if instrument not in buy_instruments:\n context.order(context.symbol(instrument), - amount)\n \n for i, instrument in enumerate(buy_instruments):\n #if cash > max_cash_per_instrument - positions.get(instrument, 0):\n # 确保股票持仓量不会超过每次股票最大的占用资金量\n # cash = max_cash_per_instrument - positions.get(instrument, 0)\n #hold_amount = positions.get(instrument, 0)\n #open_price = instrument_open[instrument]\n #trade_amount = int((portfolio_value * weight - hold_amount * open_price) / open_price)\n #print('instrument: ', instrument, ' open_price: ', str(open_price), ' hold_amount: ', 'trade_amount: ', str(trade_amount))\n #if trade_amount > 100 or trade_amount < 0:\n context.order_target_percent(context.symbol(instrument), weight)\n context.extension['index'] += 1\n","type":"Literal","bound_global_parameter":null},{"name":"prepare","value":"# 回测引擎:准备数据,只执行一次\ndef bigquant_run(context):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"before_trading_start","value":"# 回测引擎:每个单位时间开始前调用一次,即每日开盘前调用一次。\ndef bigquant_run(context, data):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"volume_limit","value":"0.025","type":"Literal","bound_global_parameter":null},{"name":"order_price_field_buy","value":"open","type":"Literal","bound_global_parameter":null},{"name":"order_price_field_sell","value":"open","type":"Literal","bound_global_parameter":null},{"name":"capital_base","value":"100000","type":"Literal","bound_global_parameter":null},{"name":"auto_cancel_non_tradable_orders","value":"True","type":"Literal","bound_global_parameter":null},{"name":"data_frequency","value":"daily","type":"Literal","bound_global_parameter":null},{"name":"price_type","value":"后复权","type":"Literal","bound_global_parameter":null},{"name":"product_type","value":"股票","type":"Literal","bound_global_parameter":null},{"name":"plot_charts","value":"True","type":"Literal","bound_global_parameter":null},{"name":"backtest_only","value":"False","type":"Literal","bound_global_parameter":null},{"name":"benchmark","value":"000300.HIX","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-181"},{"name":"options_data","node_id":"-181"},{"name":"history_ds","node_id":"-181"},{"name":"benchmark_ds","node_id":"-181"},{"name":"trading_calendar","node_id":"-181"}],"output_ports":[{"name":"raw_perf","node_id":"-181"}],"cacheable":false,"seq_num":10,"comment":"","comment_collapsed":true},{"node_id":"-2555","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2):\n # 示例代码如下。在这里编写您的代码\n #from datetime import datetime\n ins=input_1.read_pickle()['instruments']\n start_date=input_1.read_pickle()['start_date']\n end_date=input_1.read_pickle()['end_date']\n df=DataSource('bar1d_CN_FUND').read(ins,start_date=start_date,end_date=end_date)\n data_1 = DataSource.write_df(df)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-2555"},{"name":"input_2","node_id":"-2555"},{"name":"input_3","node_id":"-2555"}],"output_ports":[{"name":"data_1","node_id":"-2555"},{"name":"data_2","node_id":"-2555"},{"name":"data_3","node_id":"-2555"}],"cacheable":true,"seq_num":7,"comment":"读取场内基金行情","comment_collapsed":false},{"node_id":"-214","module_id":"BigQuantSpace.select_columns.select_columns-v3","parameters":[{"name":"columns","value":"date,instrument,open,high,low,close,adjust_factor,volume","type":"Literal","bound_global_parameter":null},{"name":"reverse_select","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_ds","node_id":"-214"},{"name":"columns_ds","node_id":"-214"}],"output_ports":[{"name":"data","node_id":"-214"}],"cacheable":true,"seq_num":12,"comment":"","comment_collapsed":true},{"node_id":"-220","module_id":"BigQuantSpace.select_columns.select_columns-v3","parameters":[{"name":"columns","value":"date,instrument,open,high,low,close,adjust_factor,volume","type":"Literal","bound_global_parameter":null},{"name":"reverse_select","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_ds","node_id":"-220"},{"name":"columns_ds","node_id":"-220"}],"output_ports":[{"name":"data","node_id":"-220"}],"cacheable":true,"seq_num":13,"comment":"","comment_collapsed":true},{"node_id":"-229","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"name":"run","value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3):\n # 示例代码如下。在这里编写您的代码\n df1 = DataSource.read_df(input_1)\n df2 = DataSource.read_df(input_2)\n #df3 = DataSource.read_df(input_3)\n df3 = pd.concat([df1, df2])\n #df4 = df3.reset_index()\n df5 = df3.sort_values(by = 'date')\n df5.index = range(len(df5))\n i = 0\n for name, group in df5.groupby(df5['date']):\n fund_numbers = len(group)\n weight = 1 / fund_numbers\n group['weight'] = weight\n group['date'] = name\n \n if i == 0:\n group_all = group.copy()\n first_date = name\n else:\n group_all = pd.concat([group_all, group])\n i += 1\n #group_all1 = group_all.sort_values(by = 'date')\n instrument_weight = group_all[group_all['date'] == first_date]\n instrument_weight = instrument_weight[['instrument', 'weight']]\n instrument_weight1 = instrument_weight.reset_index(drop = True)\n instrument_weight2 = instrument_weight1.set_index('instrument')\n ins = instrument_weight2.index.to_list()\n df6 = DataSource(\"basic_info_CN_FUND\").read()\n df7 = DataSource(\"basic_info_CN_MUTFUND\").read()\n name = []\n for value in ins:\n is_named = False\n for index1, row1 in df7.iterrows():\n if value == row1['instrument']:\n name.append(row1['sec_short_name'])\n is_named = True\n break\n if not is_named:\n for index2, row2 in df6.iterrows():\n if value == row2['instrument']:\n name.append(row2['name'])\n is_named = True\n break\n instrument_weight2.index = name \n data_1 = DataSource.write_df(group_all)\n data_2 = DataSource.write_df(instrument_weight2)\n return Outputs(data_1=data_1, data_2=data_2, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-229"},{"name":"input_2","node_id":"-229"},{"name":"input_3","node_id":"-229"}],"output_ports":[{"name":"data_1","node_id":"-229"},{"name":"data_2","node_id":"-229"},{"name":"data_3","node_id":"-229"}],"cacheable":false,"seq_num":11,"comment":"纵向合并2个表","comment_collapsed":false},{"node_id":"-236","module_id":"BigQuantSpace.df_stastic1.df_stastic1-v1","parameters":[{"name":"type_num","value":1,"type":"Literal","bound_global_parameter":null},{"name":"columns","value":"[\"PassengerId\"]","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-236"}],"output_ports":[],"cacheable":true,"seq_num":14,"comment":"","comment_collapsed":true},{"node_id":"-224","module_id":"BigQuantSpace.plot_dataframe.plot_dataframe-v1","parameters":[{"name":"title","value":"无相关性基金权重图","type":"Literal","bound_global_parameter":null},{"name":"chart_type","value":"pie","type":"Literal","bound_global_parameter":null},{"name":"x","value":"","type":"Literal","bound_global_parameter":null},{"name":"y","value":"","type":"Literal","bound_global_parameter":null},{"name":"options","value":"{\n 'chart': {\n 'height': 400\n }\n}","type":"Literal","bound_global_parameter":null},{"name":"candlestick","value":"False","type":"Literal","bound_global_parameter":null},{"name":"pane_1","value":"","type":"Literal","bound_global_parameter":null},{"name":"pane_2","value":"","type":"Literal","bound_global_parameter":null},{"name":"pane_3","value":"","type":"Literal","bound_global_parameter":null},{"name":"pane_4","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-224"}],"output_ports":[],"cacheable":false,"seq_num":15,"comment":"绘制无相关性基金权重图","comment_collapsed":false}],"node_layout":"<node_postions><node_position Node='-1878' Position='-170,187,200,200'/><node_position Node='-1890' Position='124,166,200,200'/><node_position Node='-960' Position='107,382,200,200'/><node_position Node='-902' Position='83,471,200,200'/><node_position Node='-3631' Position='406,174,200,200'/><node_position Node='-4795' Position='696,170,200,200'/><node_position Node='-3663' Position='423,374,200,200'/><node_position Node='-3672' Position='409,475,200,200'/><node_position Node='-921' Position='80,541,200,200'/><node_position Node='-592' Position='70,643,200,200'/><node_position Node='-483' Position='-108,721,200,200'/><node_position Node='-489' Position='-114,799,200,200'/><node_position Node='-585' Position='-99,901,200,200'/><node_position Node='-500' Position='-82,973,200,200'/><node_position Node='-577' Position='-78,1054,200,200'/><node_position Node='-268' Position='394,278,200,200'/><node_position Node='-280' Position='90,265,200,200'/><node_position Node='-157' Position='411.08282470703125,747.4878540039062,200,200'/><node_position Node='-169' Position='727.2751770019531,841.2954711914062,200,200'/><node_position Node='-181' Position='223.27517700195312,1121.2954711914062,200,200'/><node_position Node='-2555' Position='417.08282470703125,845.4878540039062,200,200'/><node_position Node='-214' Position='407.2751770019531,940.2954711914062,200,200'/><node_position Node='-220' Position='720.2751770019531,940.2954711914062,200,200'/><node_position Node='-229' Position='523.2751770019531,1012.2954711914062,200,200'/><node_position Node='-236' Position='-79.35111618041992,1166.7039794921875,200,200'/><node_position Node='-224' Position='691.2751770019531,1119.2954711914062,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [ ]:
    # 本代码由可视化策略环境自动生成 2022年11月3日 17:56
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m2_run_bigquant_run(input_1, start_date,end_date):
        # 示例代码如下。在这里编写您的代码
        #from datetime import datetime
        #ins=input_1.read_pickle()['instruments']
        #start_date=input_1.read_pickle()['start_date']
        #end_date=input_1.read_pickle()['end_date']
        #start_date_dt = datetime.strptime(start_date, '%Y-%m-%d')
        #end_date_dt = datetime.strptime(end_date, '%Y-%m-%d')
        
        fund_info = DataSource('basic_info_CN_FUND').read()
        #fund_info_0 = fund_info[fund_info['type'] == 'ETF']
    
        data_1 = DataSource.write_df(fund_info)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m2_post_run_bigquant_run(outputs):
        return outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m20_run_bigquant_run(input_1, input_2):
        # 示例代码如下。在这里编写您的代码
        from datetime import datetime
        ins=input_1.read_pickle()['instruments']
        start_date=input_1.read_pickle()['start_date']
        end_date=input_1.read_pickle()['end_date']
        start_date_dt = datetime.strptime(start_date, '%Y-%m-%d')
        end_date_dt = datetime.strptime(end_date, '%Y-%m-%d')
        
        fund_info_0 = DataSource.read_df(input_2)
        fund_info1 = fund_info_0[(fund_info_0['delist_date'] >= end_date_dt) & (fund_info_0['list_date'] <= start_date_dt)]
        fund_info2 = fund_info_0[fund_info_0['delist_date'].isnull() & (fund_info_0['list_date'] <= start_date_dt)]
        ins1 = fund_info1['instrument'].to_list()       
        ins2 = fund_info2['instrument'].to_list()       
        ins1.extend(ins2)
        df=DataSource('bar1d_CN_FUND').read(ins1,start_date=start_date,end_date=end_date)
        data_1 = DataSource.write_df(df)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m20_post_run_bigquant_run(outputs):
        return outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m3_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        df = DataSource.read_df(input_1)
        df['close'] = df['close'] * df['adjust_factor']
        df = df.sort_values(['instrument', 'date'])
        first_instrument = df.iloc[0]['instrument']
        for key, group in df.groupby('instrument'):
            group['return_0'] = group['close'] / group['close'].shift(1) - 1
            if key == first_instrument:
                group_all = group
            else:
                group_all = pd.concat([group_all, group])
        group_all = group_all.dropna()
        #df['cum_return'] = (df['return_0'] + 1).cumprod() - 1
        data_1 = DataSource.write_df(group_all)
        #data_2 = DataSource.write_pickle(df)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m3_post_run_bigquant_run(outputs):
        return outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m6_run_bigquant_run(input_1):
        # 示例代码如下。在这里编写您的代码
        #from datetime import datetime
        #ins=input_1.read_pickle()['instruments']
        #start_date=input_1.read_pickle()['start_date']
        #end_date=input_1.read_pickle()['end_date']
        #start_date_dt = datetime.strptime(start_date, '%Y-%m-%d')
        #end_date_dt = datetime.strptime(end_date, '%Y-%m-%d')
        
        #if len(ins) == 0:
        fund_info = DataSource('basic_info_CN_MUTFUND').read()
            #fund_info_0 = fund_info[fund_info['etf_lof'] == 'ETF']
        data_1 = DataSource.write_df(fund_info)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m6_post_run_bigquant_run(outputs):
        return outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m19_run_bigquant_run(input_1, input_2):
        # 示例代码如下。在这里编写您的代码
        from datetime import datetime
        ins=input_1.read_pickle()['instruments']
        start_date=input_1.read_pickle()['start_date']
        end_date=input_1.read_pickle()['end_date']
        start_date_dt = datetime.strptime(start_date, '%Y-%m-%d')
        end_date_dt = datetime.strptime(end_date, '%Y-%m-%d')
        fund_info_0 = DataSource.read_df(input_2)
        
        fund_info_delist_date = fund_info_0[fund_info_0['delist_date'].notnull()]
        fund_info_delist_date1 = fund_info_delist_date[(fund_info_delist_date['delist_date'] >= end_date_dt) & (fund_info_delist_date['list_date'] <= start_date_dt)]
        ins_delist_date1 = fund_info_delist_date1['instrument'].to_list()
        fund_info_delist_date2 = fund_info_0[fund_info_0['delist_date'].isnull() & (fund_info_0['list_date'] <= start_date_dt)]
        ins_delist_date2 = fund_info_delist_date2['instrument'].to_list()
        fund_info_expire_date = fund_info_0[fund_info_0['expire_date'].notnull()]
        fund_info_expire_date1 = fund_info_expire_date[(fund_info_expire_date['expire_date'] >= end_date_dt) & (fund_info_expire_date['establish_date'] <= start_date_dt)]
        ins_expire_date1 = fund_info_expire_date1['instrument'].to_list()
        fund_info_expire_date2 = fund_info_0[fund_info_0['expire_date'].isnull() & (fund_info_0['establish_date'] <= start_date_dt)]
        ins_expire_date2 = fund_info_expire_date2['instrument'].to_list()
        ins1 = ins_delist_date1 + ins_delist_date2 + ins_expire_date1 + ins_expire_date2        
        df=DataSource('history_nav_CN_MUTFUND').read(ins1,start_date=start_date,end_date=end_date)
        data_1 = DataSource.write_df(df)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m19_post_run_bigquant_run(outputs):
        return outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m28_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        df = DataSource.read_df(input_1)
        df = df.rename({'adjust_nav': 'close'}, axis = 1)
        df['return_0'] = df['adj_nav_chg_pct'] / 100
        '''
        df = df.sort_values(['instrument', 'date'])
        first_instrument = df.iloc[0]['instrument']
        for key, group in df.groupby('instrument'):
            group['cum_return'] = (group['return_0'] + 1).cumprod() - 1
            if key == first_instrument:
                group_all = group
            else:
                group_all = pd.concat([group_all, group])
        '''        
        data_1 = DataSource.write_df(df)
        #data_2 = DataSource.write_pickle(df)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m28_post_run_bigquant_run(outputs):
        return outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m30_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        #df1 = DataSource.read_df(input_1)
        df2 = DataSource.read_df(input_2)
        df3 = DataSource.read_df(input_3)
        df = pd.concat([df2, df3])
        data_1 = DataSource.write_df(df)
        #data_2 = DataSource.write_pickle(df)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m30_post_run_bigquant_run(outputs):
        return outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m36_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        df = DataSource.read_df(input_1)
        df = df.loc[ :,("return_0", )]
        data_1 = DataSource.write_df(df)
        #data_2 = DataSource.write_pickle(df)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m36_post_run_bigquant_run(outputs):
        return outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m37_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        df = DataSource.read_df(input_1)
        df_columns = df.columns.to_list()
        hs300_corr = pd.DataFrame(0, index = df_columns, columns = ['hs300_corr'])
        for label, item in df.iteritems():
            hs300_corr.loc[label, 'hs300_corr'] = df['159919.ZOF'].corr(item)
        hs300_corr = hs300_corr.sort_values(by = ['hs300_corr'])
        hs300_corr1 = hs300_corr[(hs300_corr['hs300_corr'] <= 0.01) & (hs300_corr['hs300_corr'] >= - 0.01)]
        hs300_corr1_ins = hs300_corr1.index.to_list()
        hs300_corr1_ins.append('159919.ZOF')
        hs300_corr_df = df[hs300_corr1_ins]
        corr_high = hs300_corr_df.corr().applymap(lambda x: np.nan if x > 0.1 else x).isnull()
        col_all = corr_high.columns.tolist()
        del_col = []
        i = 0
        while i < len(col_all) - 1:
            ex_index = corr_high.iloc[:,i][i+1:].index[np.where(corr_high.iloc[:,i][i+1:])].tolist()
            for var in ex_index:
                col_all.remove(var)
            corr_high = corr_high.loc[col_all, col_all]
            i += 1
        col_all_corr = hs300_corr_df[col_all].corr()
        hs300_nocorr_df = hs300_corr_df[col_all]
        #print("下表为无相关性的基金的两两的相关系数,接近0表示相关性弱,接近1表示相关性强。")
        #print(col_all_corr)
        ins = hs300_nocorr_df.columns.to_list()
        df2 = DataSource("basic_info_CN_FUND").read()
        df4 = DataSource("basic_info_CN_MUTFUND").read()
        name = []
        for value in ins:
            is_named = False
            for index1, row1 in df4.iterrows():
                if value == row1['instrument']:
                    name.append(row1['sec_short_name'])
                    is_named = True
                    break
            if not is_named:
                for index2, row2 in df2.iterrows():
                    if value == row2['instrument']:
                        name.append(row2['name'])
                        is_named = True
                        break
        hs300_nocorr_df.columns = name
        data_1 = DataSource.write_df(col_all_corr)
        data_2 = DataSource.write_df(hs300_nocorr_df)
        return Outputs(data_1=data_1, data_2=data_2, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m37_post_run_bigquant_run(outputs):
        return outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m8_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        df = DataSource.read_df(input_1)
        dict = DataSource.read_pickle(input_2)
        dict2 = dict.copy()
        list = df.index.to_list()
        trade_mutfund_list = []
        trade_fund_list = []
        
        for item in list:
            item_split = item.split(".")
            if item_split[1] == 'OFCN' or item_split[1] == 'OFCN2':
                trade_mutfund_list.append(item)
            elif item_split[1] == 'ZOF' or item_split[1] == 'HOF':
                trade_fund_list.append(item)
                
        dict['instruments'] = trade_mutfund_list
        dict2['instruments'] = trade_fund_list
        dict2['market'] = 'CN_FUND'
        #print(dict)
        data_1 = DataSource.write_pickle(dict2)
        data_2 = DataSource.write_pickle(dict)
        return Outputs(data_1=data_1, data_2=data_2, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m8_post_run_bigquant_run(outputs):
        return outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m7_run_bigquant_run(input_1, input_2):
        # 示例代码如下。在这里编写您的代码
        #from datetime import datetime
        ins=input_1.read_pickle()['instruments']
        start_date=input_1.read_pickle()['start_date']
        end_date=input_1.read_pickle()['end_date']
        df=DataSource('bar1d_CN_FUND').read(ins,start_date=start_date,end_date=end_date)
        data_1 = DataSource.write_df(df)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m7_post_run_bigquant_run(outputs):
        return outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m9_run_bigquant_run(input_1, input_2):
        # 示例代码如下。在这里编写您的代码
        from datetime import datetime
        ins=input_1.read_pickle()['instruments']
        start_date=input_1.read_pickle()['start_date']
        end_date=input_1.read_pickle()['end_date']
        df=DataSource('history_nav_CN_MUTFUND').read(ins,start_date=start_date,end_date=end_date)
        df['open'] = df['nav']
        df['high'] = df['nav']
        df['low'] = df['nav']
        df['close'] = df['nav']
        df['adjust_factor'] = df['adjust_nav'] / df['nav']
        df['volume'] = 1000000
        data_1 = DataSource.write_df(df)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m9_post_run_bigquant_run(outputs):
        return outputs
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m11_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        df1 = DataSource.read_df(input_1)
        df2 = DataSource.read_df(input_2)
        #df3 = DataSource.read_df(input_3)
        df3 = pd.concat([df1, df2])
        #df4 = df3.reset_index()
        df5 = df3.sort_values(by = 'date')
        df5.index = range(len(df5))
        i = 0
        for name, group in df5.groupby(df5['date']):
            fund_numbers = len(group)
            weight = 1 / fund_numbers
            group['weight'] = weight
            group['date'] = name
            
            if i == 0:
                group_all = group.copy()
                first_date = name
            else:
                group_all = pd.concat([group_all, group])
            i += 1
        #group_all1 = group_all.sort_values(by = 'date')
        instrument_weight = group_all[group_all['date'] == first_date]
        instrument_weight = instrument_weight[['instrument', 'weight']]
        instrument_weight1 = instrument_weight.reset_index(drop = True)
        instrument_weight2 = instrument_weight1.set_index('instrument')
        ins = instrument_weight2.index.to_list()
        df6 = DataSource("basic_info_CN_FUND").read()
        df7 = DataSource("basic_info_CN_MUTFUND").read()
        name = []
        for value in ins:
            is_named = False
            for index1, row1 in df7.iterrows():
                if value == row1['instrument']:
                    name.append(row1['sec_short_name'])
                    is_named = True
                    break
            if not is_named:
                for index2, row2 in df6.iterrows():
                    if value == row2['instrument']:
                        name.append(row2['name'])
                        is_named = True
                        break
        instrument_weight2.index = name    
        data_1 = DataSource.write_df(group_all)
        data_2 = DataSource.write_df(instrument_weight2)
        return Outputs(data_1=data_1, data_2=data_2, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m11_post_run_bigquant_run(outputs):
        return outputs
    
    # 回测引擎:初始化函数,只执行一次
    def m10_initialize_bigquant_run(context):
        # 加载预测数据
        context.ranker_prediction = context.options['data'].read_df()
    
        # 系统已经设置了默认的交易手续费和滑点,要修改手续费可使用如下函数
        context.set_commission(PerOrder(buy_cost=0.0003, sell_cost=0.0013, min_cost=5))
        # 预测数据,通过options传入进来,使用 read_df 函数,加载到内存 (DataFrame)
        # 设置买入的股票数量,这里买入预测股票列表排名靠前的5只
        #stock_count = 5
        # 每只的股票的权重,如下的权重分配会使得靠前的股票分配多一点的资金,[0.339160, 0.213986, 0.169580, ..]
        #context.stock_weights = T.norm([1 / math.log(i + 2) for i in range(0, stock_count)])
        # 设置每只股票占用的最大资金比例
        #context.max_cash_per_instrument = 0.2
        #context.hold_days = 5
        
        #周期为22个交易日
        context.rebalance_days = 22
    
        # 如果策略运行中,需要将数据进行保存,可以借用extension这个对象,类型为dict
        # 比如当前运行的k线的索引,比如个股持仓天数、买入均价
        if 'index' not in context.extension:
            context.extension['index'] = 0
    
    # 回测引擎:每日数据处理函数,每天执行一次
    def m10_handle_data_bigquant_run(context, data):
        # 不在换仓日就return,相当于后面的代码只会一个月运行一次,买入的股票会持有1个月
        if  context.extension['index'] % context.rebalance_days != 0:
            context.extension['index'] += 1
            return 
        
        # 按日期过滤得到今日的预测数据
        date = data.current_dt.strftime('%Y-%m-%d')
        ranker_prediction = context.ranker_prediction[
            context.ranker_prediction.date == date]
        fund_amount = len(ranker_prediction)
        instrument_open = {}
        instrument_weight = {}
        
        for index, row in ranker_prediction.iterrows():
            instrument_open[row['instrument']] = row['open']
            instrument_weight[row['instrument']] = row['weight']
            
        #print('date: ', date, 'fund_amount: ', str(fund_amount))
        
        # 1. 资金分配
        # 平均持仓时间是hold_days,每日都将买入股票,每日预期使用 1/hold_days 的资金
        # 实际操作中,会存在一定的买入误差,所以在前hold_days天,等量使用资金;之后,尽量使用剩余资金(这里设置最多用等量的1.5倍)
        #is_staging = context.trading_day_index < context.hold_days # 是否在建仓期间(前 hold_days 天)
        #cash_avg = context.portfolio.portfolio_value / context.hold_days
        portfolio_value = context.portfolio.portfolio_value
        #cash_for_sell = cash_avg - (context.portfolio.cash - cash_for_buy)
        positions = {e.symbol: p.amount
                     for e, p in context.perf_tracker.position_tracker.positions.items()}
        '''
        # 2. 生成卖出订单:hold_days天之后才开始卖出;对持仓的股票,按StockRanker预测的排序末位淘汰
        if not is_staging and cash_for_sell > 0:
            equities = {e.symbol: e for e, p in context.perf_tracker.position_tracker.positions.items()}
            instruments = list(reversed(list(ranker_prediction.instrument[ranker_prediction.instrument.apply(
                    lambda x: x in equities and not context.has_unfinished_sell_order(equities[x]))])))
            # print('rank order for sell %s' % instruments)
            for instrument in instruments:
                context.order_target(context.symbol(instrument), 0)
                cash_for_sell -= positions[instrument]
                if cash_for_sell <= 0:
                    break
        '''
        # 3. 生成买入订单:按StockRanker预测的排序,买入前面的stock_count只股票
        if fund_amount > 0:
            weight = 1 / fund_amount
            #print('date: ', date, 'index: ', str(context.extension['index']), ' portfolio_value: ', str(portfolio_value), ' weight: ', str(weight))
            buy_instruments = list(ranker_prediction.instrument)
            #cash = cash_for_buy * buy_cash_weights
            #max_cash_per_instrument = context.portfolio.portfolio_value * context.max_cash_per_instrument
            for instrument, amount in positions.items():
                if instrument not in buy_instruments:
                    context.order(context.symbol(instrument), - amount)
                            
            for i, instrument in enumerate(buy_instruments):
                #if cash > max_cash_per_instrument - positions.get(instrument, 0):
                # 确保股票持仓量不会超过每次股票最大的占用资金量
                #    cash = max_cash_per_instrument - positions.get(instrument, 0)
                #hold_amount = positions.get(instrument, 0)
                #open_price = instrument_open[instrument]
                #trade_amount = int((portfolio_value * weight - hold_amount * open_price) / open_price)
                #print('instrument: ', instrument, ' open_price: ', str(open_price), ' hold_amount: ', 'trade_amount: ', str(trade_amount))
                #if trade_amount > 100 or trade_amount < 0:
                context.order_target_percent(context.symbol(instrument), weight)
        context.extension['index'] += 1
    
    # 回测引擎:准备数据,只执行一次
    def m10_prepare_bigquant_run(context):
        pass
    
    # 回测引擎:每个单位时间开始前调用一次,即每日开盘前调用一次。
    def m10_before_trading_start_bigquant_run(context, data):
        pass
    
    
    m1 = M.instruments.v2(
        start_date='2019-10-11',
        end_date='2022-10-11',
        market='CN_FUND',
        instrument_list='#159919.ZOF',
        max_count=0
    )
    
    m2 = M.cached.v3(
        run=m2_run_bigquant_run,
        post_run=m2_post_run_bigquant_run,
        input_ports='',
        params='',
        output_ports=''
    )
    
    m20 = M.cached.v3(
        input_1=m1.data,
        input_2=m2.data_1,
        run=m20_run_bigquant_run,
        post_run=m20_post_run_bigquant_run,
        input_ports='',
        params='',
        output_ports=''
    )
    
    m3 = M.cached.v3(
        input_1=m20.data_1,
        run=m3_run_bigquant_run,
        post_run=m3_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    m4 = M.select_columns.v3(
        input_ds=m3.data_1,
        columns='date,instrument,return_0,close',
        reverse_select=False
    )
    
    m5 = M.instruments.v2(
        start_date='2019-10-11',
        end_date='2022-10-11',
        market='CN_MUTFUND',
        instrument_list='#000395.OFCN',
        max_count=0
    )
    
    m6 = M.cached.v3(
        run=m6_run_bigquant_run,
        post_run=m6_post_run_bigquant_run,
        input_ports='',
        params='',
        output_ports=''
    )
    
    m19 = M.cached.v3(
        input_1=m5.data,
        input_2=m6.data_1,
        run=m19_run_bigquant_run,
        post_run=m19_post_run_bigquant_run,
        input_ports='',
        params='',
        output_ports=''
    )
    
    m28 = M.cached.v3(
        input_1=m19.data_1,
        run=m28_run_bigquant_run,
        post_run=m28_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    m29 = M.select_columns.v3(
        input_ds=m28.data_1,
        columns='date,instrument,return_0,close',
        reverse_select=False
    )
    
    m30 = M.cached.v3(
        input_2=m4.data,
        input_3=m29.data,
        run=m30_run_bigquant_run,
        post_run=m30_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    m31 = M.set_inf_to_nan.v1(
        input_1=m30.data_1
    )
    
    m33 = M.pivot_fbfill_stack.v3(
        input_1=m31.data_1,
        index_col='date',
        col_name='instrument',
        values_col='return_0'
    )
    
    m34 = M.pandas_pivot_table.v1(
        input_data=m33.data,
        index='date',
        columns='instrument',
        values='return_0',
        flat=False
    )
    
    m35 = M.dropnan.v2(
        input_data=m34.data_1
    )
    
    m36 = M.cached.v3(
        input_1=m35.data,
        run=m36_run_bigquant_run,
        post_run=m36_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    m37 = M.cached.v3(
        input_1=m36.data_1,
        run=m37_run_bigquant_run,
        post_run=m37_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    m8 = M.cached.v3(
        input_1=m37.data_1,
        input_2=m5.data,
        run=m8_run_bigquant_run,
        post_run=m8_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    m7 = M.cached.v3(
        input_1=m8.data_1,
        run=m7_run_bigquant_run,
        post_run=m7_post_run_bigquant_run,
        input_ports='',
        params='',
        output_ports=''
    )
    
    m12 = M.select_columns.v3(
        input_ds=m7.data_1,
        columns='date,instrument,open,high,low,close,adjust_factor,volume',
        reverse_select=False
    )
    
    m9 = M.cached.v3(
        input_1=m8.data_2,
        run=m9_run_bigquant_run,
        post_run=m9_post_run_bigquant_run,
        input_ports='',
        params='',
        output_ports=''
    )
    
    m13 = M.select_columns.v3(
        input_ds=m9.data_1,
        columns='date,instrument,open,high,low,close,adjust_factor,volume',
        reverse_select=False
    )
    
    m11 = M.cached.v3(
        input_1=m12.data,
        input_2=m13.data,
        run=m11_run_bigquant_run,
        post_run=m11_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports='',
        m_cached=False
    )
    
    m10 = M.trade.v4(
        instruments=m8.data_1,
        options_data=m11.data_1,
        history_ds=m11.data_1,
        start_date='2019-10-11',
        end_date='2022-10-11',
        initialize=m10_initialize_bigquant_run,
        handle_data=m10_handle_data_bigquant_run,
        prepare=m10_prepare_bigquant_run,
        before_trading_start=m10_before_trading_start_bigquant_run,
        volume_limit=0.025,
        order_price_field_buy='open',
        order_price_field_sell='open',
        capital_base=100000,
        auto_cancel_non_tradable_orders=True,
        data_frequency='daily',
        price_type='后复权',
        product_type='股票',
        plot_charts=True,
        backtest_only=False,
        benchmark='000300.HIX'
    )
    
    m15 = M.plot_dataframe.v1(
        input_data=m11.data_2,
        title='无相关性基金权重图',
        chart_type='pie',
        x='',
        y='',
        options={
        'chart': {
            'height': 400
        }
    },
        candlestick=False,
        pane_1='',
        pane_2='',
        pane_3='',
        pane_4=''
    )
    
    m14 = M.df_stastic1.v1(
        input_1=m37.data_2,
        type_num=1,
        columns=["PassengerId"]
    )
    
    列: ['date', 'instrument', 'return_0', 'close']
    /data: 83564
    
    列: ['date', 'instrument', 'return_0', 'close']
    /data: 4533009