{"description":"实验创建于2022/4/8","graph":{"edges":[{"to_node_id":"-161:input_data","from_node_id":"-505:data"},{"to_node_id":"-760:input","from_node_id":"-505:data"},{"to_node_id":"-645:input_1","from_node_id":"-512:data"},{"to_node_id":"-1953:input_1","from_node_id":"-519:data"},{"to_node_id":"-161:features","from_node_id":"-666:data"},{"to_node_id":"-549:input_1","from_node_id":"-161:data"},{"to_node_id":"-7412:instruments","from_node_id":"-760:instrument_list"},{"to_node_id":"-519:data2","from_node_id":"-645:data_1"},{"to_node_id":"-519:data1","from_node_id":"-549:data_1"},{"to_node_id":"-7412:options_data","from_node_id":"-1953:data_1"}],"nodes":[{"node_id":"-505","module_id":"BigQuantSpace.use_datasource.use_datasource-v1","parameters":[{"name":"datasource_id","value":"market_performance_CN_CONBOND","type":"Literal","bound_global_parameter":null},{"name":"start_date","value":"2018-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2020-12-31","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-505"},{"name":"features","node_id":"-505"}],"output_ports":[{"name":"data","node_id":"-505"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-512","module_id":"BigQuantSpace.use_datasource.use_datasource-v1","parameters":[{"name":"datasource_id","value":"basic_info_CN_CONBOND","type":"Literal","bound_global_parameter":null},{"name":"start_date","value":"2018-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2020-12-31","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-512"},{"name":"features","node_id":"-512"}],"output_ports":[{"name":"data","node_id":"-512"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-519","module_id":"BigQuantSpace.join.join-v3","parameters":[{"name":"on","value":"instrument","type":"Literal","bound_global_parameter":null},{"name":"how","value":"inner","type":"Literal","bound_global_parameter":null},{"name":"sort","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"data1","node_id":"-519"},{"name":"data2","node_id":"-519"}],"output_ports":[{"name":"data","node_id":"-519"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-666","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\ndouble_low = close + bond_prem_ratio\nremain_size > 1.5\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-666"}],"output_ports":[{"name":"data","node_id":"-666"}],"cacheable":true,"seq_num":6,"comment":"","comment_collapsed":true},{"node_id":"-161","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":"{}","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-161"},{"name":"features","node_id":"-161"}],"output_ports":[{"name":"data","node_id":"-161"}],"cacheable":true,"seq_num":7,"comment":"","comment_collapsed":true},{"node_id":"-760","module_id":"BigQuantSpace.trade_data_generation.trade_data_generation-v1","parameters":[{"name":"category","value":"CN_STOCK","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input","node_id":"-760"}],"output_ports":[{"name":"history_data","node_id":"-760"},{"name":"instrument_list","node_id":"-760"},{"name":"calendar","node_id":"-760"}],"cacheable":false,"seq_num":9,"comment":"","comment_collapsed":true},{"node_id":"-7412","module_id":"BigQuantSpace.hftrade.hftrade-v2","parameters":[{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"initialize","value":"# 交易引擎:初始化函数,只执行一次\ndef bigquant_run(context):\n print(\"initializing\")\n # 加载股票指标数据,数据继承自m6模块\n context.indicator_data = context.options['data'].read_df()\n\n # 系统已经设置了默认的交易手续费和滑点,要修改手续费可使用如下函数\n context.set_commission(PerOrder(buy_cost=0.0003, sell_cost=0.0013, min_cost=5))\n \n # 设置股票数量\n context.stock_num = 20\n \n # 调仓天数,22个交易日大概就是一个月。可以理解为一个月换仓一次\n context.rebalance_days = 22\n \n # 如果策略运行中,需要将数据进行保存,可以借用extension这个对象,类型为dict\n # 比如当前运行的k线的索引,比如个股持仓天数、买入均价\n try:\n print(f\"check idx: {context.extension.idx}\")\n except AttributeError as e:\n context.extension.idx = 0\n ","type":"Literal","bound_global_parameter":null},{"name":"before_trading_start","value":"# 交易引擎:每个单位时间开盘前调用一次。\ndef bigquant_run(context, data):\n context.subscribe(context.instruments)\n pass","type":"Literal","bound_global_parameter":null},{"name":"handle_tick","value":"# 交易引擎:tick数据处理函数,每个tick执行一次\ndef bigquant_run(context, data):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"handle_data","value":"# 回测引擎:每日数据处理函数,每天执行一次\ndef bigquant_run(context, data):\n \n context.extension.idx += 1\n # 不在换仓日就return,相当于后面的代码只会一个月运行一次,买入的股票会持有1个月\n if context.extension.idx % context.rebalance_days != 0:\n return\n \n # 当前的日期\n date = data.current_dt.strftime('%Y-%m-%d')\n cur_data = context.indicator_data[context.indicator_data['date'] == date]\n \n #建仓条件判断:市场双低均值达到170可进行建仓\n if cur_data['double_low'].mean() > 170:\n print(date,':该调仓日市场双低均值为',cur_data['double_low'].mean(),\",无需建仓\")\n return\n \n \n # 设定股票池\n # 条件1:上市超过1个月\n stock_can_buy = cur_data[cur_data['can_buy'] == 1]\n # 条件2:剩余期限小于180个自然日\n stock_to_clean = cur_data[cur_data['to_clean'] == 1]\n \n symbols = list(set(stock_can_buy['instrument'].values).difference(set(stock_to_clean['instrument'].values)))\n cur_data = cur_data.set_index('instrument').loc[symbols,:].reset_index().sort_values('double_low')\n stock_to_buy = list(cur_data.instrument[:context.stock_num])\n \n # 通过positions对象,使用列表生成式的方法获取目前持仓的股票列表\n stock_hold_now = [equity for equity in context.portfolio.positions]\n # 继续持有的股票:调仓时,如果买入的股票已经存在于目前的持仓里,那么应继续持有\n no_need_to_sell = [i for i in stock_hold_now if i in stock_to_buy]\n # 需要卖出的股票\n stock_to_sell = [i for i in stock_hold_now if i not in no_need_to_sell] \n \n # 卖出\n for stock in stock_to_sell:\n context.order_target_percent(stock, 0)\n \n # 如果当天没有买入的股票,就返回\n if len(stock_to_buy) == 0:\n print(date,'当天没有买入的股票')\n return\n\n # 等权重买入 \n weight = 1 / len(stock_to_buy)\n \n # 买入\n for stock in stock_to_buy:\n context.order_target_percent(stock, weight)\n ","type":"Literal","bound_global_parameter":null},{"name":"handle_trade","value":"# 交易引擎:成交回报处理函数,每个成交发生时执行一次\ndef bigquant_run(context, data):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"handle_order","value":"# 交易引擎:委托回报处理函数,每个委托变化时执行一次\ndef bigquant_run(context, data):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"after_trading","value":"# 交易引擎:盘后处理函数,每日盘后执行一次\ndef bigquant_run(context, data):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"capital_base","value":"1000001","type":"Literal","bound_global_parameter":null},{"name":"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":"before_start_days","value":"0","type":"Literal","bound_global_parameter":null},{"name":"volume_limit","value":1,"type":"Literal","bound_global_parameter":null},{"name":"order_price_field_buy","value":"close","type":"Literal","bound_global_parameter":null},{"name":"order_price_field_sell","value":"close","type":"Literal","bound_global_parameter":null},{"name":"benchmark","value":"000300.HIX","type":"Literal","bound_global_parameter":null},{"name":"plot_charts","value":"True","type":"Literal","bound_global_parameter":null},{"name":"disable_cache","value":"False","type":"Literal","bound_global_parameter":null},{"name":"replay_bdb","value":"False","type":"Literal","bound_global_parameter":null},{"name":"show_debug_info","value":"False","type":"Literal","bound_global_parameter":null},{"name":"backtest_only","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-7412"},{"name":"options_data","node_id":"-7412"},{"name":"history_ds","node_id":"-7412"},{"name":"benchmark_ds","node_id":"-7412"}],"output_ports":[{"name":"raw_perf","node_id":"-7412"}],"cacheable":false,"seq_num":8,"comment":"","comment_collapsed":true},{"node_id":"-645","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 = input_1.read()\n df['list_date'] = df['list_date'].astype(str)\n df['delist_date'] = df['delist_date'].astype(str)\n df = df.loc[:,['instrument','list_date','delist_date']]\n \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":"-645"},{"name":"input_2","node_id":"-645"},{"name":"input_3","node_id":"-645"}],"output_ports":[{"name":"data_1","node_id":"-645"},{"name":"data_2","node_id":"-645"},{"name":"data_3","node_id":"-645"}],"cacheable":true,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"-549","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 = input_1.read()\n \n df = df.loc[:,['date','instrument','close','bond_prem_ratio','double_low','remain_size']]\n \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":"-549"},{"name":"input_2","node_id":"-549"},{"name":"input_3","node_id":"-549"}],"output_ports":[{"name":"data_1","node_id":"-549"},{"name":"data_2","node_id":"-549"},{"name":"data_3","node_id":"-549"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true},{"node_id":"-1953","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 = input_1.read()\n \n df['date'] = pd.to_datetime(df['date'])\n df['list_date'] = pd.to_datetime(df['list_date'])\n df['delist_date'] = pd.to_datetime(df['delist_date'])\n \n #买入规则:上市满30天才能买入\n df['can_buy'] = df['date'] > (df['list_date'] + datetime.timedelta(days=30))\n\n #卖出规则:离退市日期差6个月时清仓\n df['to_clean'] = (df['date'] + datetime.timedelta(days=180)) > df['delist_date']\n \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":"-1953"},{"name":"input_2","node_id":"-1953"},{"name":"input_3","node_id":"-1953"}],"output_ports":[{"name":"data_1","node_id":"-1953"},{"name":"data_2","node_id":"-1953"},{"name":"data_3","node_id":"-1953"}],"cacheable":true,"seq_num":10,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-505' Position='139,-159,200,200'/><node_position Node='-512' Position='623,-44,200,200'/><node_position Node='-519' Position='423,176,200,200'/><node_position Node='-666' Position='445,-164,200,200'/><node_position Node='-161' Position='322,-49,200,200'/><node_position Node='-760' Position='6.2948455810546875,48,200,200'/><node_position Node='-7412' Position='361.29486083984375,400,200,200'/><node_position Node='-645' Position='603,50,200,200'/><node_position Node='-549' Position='302,50,200,200'/><node_position Node='-1953' Position='405,279,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
[2023-04-19 10:22:11.417124] INFO: moduleinvoker: use_datasource.v1 开始运行..
[2023-04-19 10:22:11.425519] INFO: moduleinvoker: 命中缓存
[2023-04-19 10:22:11.428400] INFO: moduleinvoker: use_datasource.v1 运行完成[0.011304s].
[2023-04-19 10:22:11.441191] INFO: moduleinvoker: trade_data_generation.v1 开始运行..
[2023-04-19 10:22:13.738273] INFO: moduleinvoker: trade_data_generation.v1 运行完成[2.297065s].
[2023-04-19 10:22:13.749200] INFO: moduleinvoker: use_datasource.v1 开始运行..
[2023-04-19 10:22:13.758557] INFO: moduleinvoker: 命中缓存
[2023-04-19 10:22:13.761271] INFO: moduleinvoker: use_datasource.v1 运行完成[0.012087s].
[2023-04-19 10:22:13.778782] INFO: moduleinvoker: cached.v3 开始运行..
[2023-04-19 10:22:13.790187] INFO: moduleinvoker: 命中缓存
[2023-04-19 10:22:13.795542] INFO: moduleinvoker: cached.v3 运行完成[0.016779s].
[2023-04-19 10:22:13.804820] INFO: moduleinvoker: input_features.v1 开始运行..
[2023-04-19 10:22:13.813496] INFO: moduleinvoker: 命中缓存
[2023-04-19 10:22:13.816225] INFO: moduleinvoker: input_features.v1 运行完成[0.011416s].
[2023-04-19 10:22:13.833533] INFO: moduleinvoker: derived_feature_extractor.v3 开始运行..
[2023-04-19 10:22:13.841141] INFO: moduleinvoker: 命中缓存
[2023-04-19 10:22:13.845231] INFO: moduleinvoker: derived_feature_extractor.v3 运行完成[0.011641s].
[2023-04-19 10:22:13.879721] INFO: moduleinvoker: cached.v3 开始运行..
[2023-04-19 10:22:13.890041] INFO: moduleinvoker: 命中缓存
[2023-04-19 10:22:13.893451] INFO: moduleinvoker: cached.v3 运行完成[0.013734s].
[2023-04-19 10:22:13.908498] INFO: moduleinvoker: join.v3 开始运行..
[2023-04-19 10:22:13.920612] INFO: moduleinvoker: 命中缓存
[2023-04-19 10:22:13.926757] INFO: moduleinvoker: join.v3 运行完成[0.01824s].
[2023-04-19 10:22:13.947445] INFO: moduleinvoker: cached.v3 开始运行..
[2023-04-19 10:22:13.959323] INFO: moduleinvoker: 命中缓存
[2023-04-19 10:22:13.962111] INFO: moduleinvoker: cached.v3 运行完成[0.014701s].
[2023-04-19 10:22:14.016740] INFO: moduleinvoker: hfbacktest.v1 开始运行..
[2023-04-19 10:22:14.023134] INFO: hfbacktest: biglearning V1.4.21
[2023-04-19 10:22:14.025220] INFO: hfbacktest: bigtrader v1.10.1 2023-04-12
[2023-04-19 10:22:14.056266] INFO: moduleinvoker: cached.v2 开始运行..
[2023-04-19 10:22:14.066388] INFO: moduleinvoker: 命中缓存
[2023-04-19 10:22:14.068689] INFO: moduleinvoker: cached.v2 运行完成[0.012438s].
[2023-04-19 10:22:14.154023] INFO: moduleinvoker: cached.v2 开始运行..
[2023-04-19 10:22:14.161863] INFO: moduleinvoker: 命中缓存
[2023-04-19 10:22:14.170366] INFO: moduleinvoker: cached.v2 运行完成[0.016358s].
[2023-04-19 10:23:07.075481] INFO: hfbacktest: backtest done, raw_perf_ds:DataSource(db2e77413340405f9fac0808f9bed2e1T)
[2023-04-19 10:23:30.575700] INFO: moduleinvoker: hfbacktest.v1 运行完成[76.558953s].
[2023-04-19 10:23:30.587292] INFO: moduleinvoker: hftrade.v2 运行完成[76.598787s].
- 收益率36.93%
- 年化收益率10.98%
- 基准收益率27.5%
- 阿尔法0.06
- 贝塔0.38
- 夏普比率0.67
- 胜率0.55
- 盈亏比2.56
- 收益波动率12.96%
- 信息比率0.0
- 最大回撤14.77%
bigcharts-data-start/{"__type":"tabs","__id":"bigchart-c4760e911465417fbe09c277a5be3371"}/bigcharts-data-end