策略无法产生新的交易


(bonjovy) #1
克隆策略

    {"Description":"实验创建于2017/8/26","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-15:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"DestinationInputPortId":"-215:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data1","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-15:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"-215:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"-222:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"-231:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"-238:features","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:model","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43:model"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-84:input_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data"},{"DestinationInputPortId":"-250:options_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:predictions"},{"DestinationInputPortId":"-231:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"DestinationInputPortId":"-250:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43:training_ds","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-84:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:data","SourceOutputPortId":"-86:data"},{"DestinationInputPortId":"-222:input_data","SourceOutputPortId":"-215:data"},{"DestinationInputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data2","SourceOutputPortId":"-222:data"},{"DestinationInputPortId":"-238:input_data","SourceOutputPortId":"-231:data"},{"DestinationInputPortId":"-86:input_data","SourceOutputPortId":"-238:data"}],"ModuleNodes":[{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2016-03-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2019-11-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"market","Value":"CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_list","Value":"000001.SZA\n000002.SZA\n000009.SZA\n000021.SZA\n000027.SZA\n000028.SZA\n000031.SZA\n000039.SZA\n000043.SZA\n000046.SZA\n000060.SZA\n000062.SZA\n000063.SZA\n000066.SZA\n000069.SZA\n000088.SZA\n000089.SZA\n000100.SZA\n000166.SZA\n000333.SZA\n000338.SZA\n000401.SZA\n000402.SZA\n000413.SZA\n000423.SZA\n000429.SZA\n000623.SZA\n000627.SZA\n000629.SZA\n000630.SZA\n000636.SZA\n000661.SZA\n000671.SZA\n000672.SZA\n000681.SZA\n000686.SZA\n000688.SZA\n000690.SZA\n000703.SZA\n000709.SZA\n000712.SZA\n000723.SZA\n000728.SZA\n000729.SZA\n000732.SZA\n000738.SZA\n000739.SZA\n000761.SZA\n000768.SZA\n000776.SZA\n000778.SZA\n000783.SZA\n000786.SZA\n000792.SZA\n000799.SZA\n000800.SZA\n000807.SZA\n000810.SZA\n000813.SZA\n000826.SZA\n000830.SZA\n000831.SZA\n000839.SZA\n000860.SZA\n000869.SZA\n000876.SZA\n000878.SZA\n000883.SZA\n000898.SZA\n000918.SZA\n000932.SZA\n000938.SZA\n000960.SZA\n000961.SZA\n000963.SZA\n000977.SZA\n000983.SZA\n000987.SZA\n000988.SZA\n000997.SZA\n000998.SZA\n000999.SZA\n001979.SZA\n002001.SZA\n002007.SZA\n002008.SZA\n002010.SZA\n002013.SZA\n002019.SZA\n002024.SZA\n002027.SZA\n002032.SZA\n002036.SZA\n002038.SZA\n002044.SZA\n002049.SZA\n002074.SZA\n002078.SZA\n002080.SZA\n002081.SZA\n002092.SZA\n002099.SZA\n002100.SZA\n002110.SZA\n002120.SZA\n002123.SZA\n002124.SZA\n002127.SZA\n002128.SZA\n002129.SZA\n002131.SZA\n002138.SZA\n002142.SZA\n002146.SZA\n002174.SZA\n002179.SZA\n002180.SZA\n002191.SZA\n002202.SZA\n002203.SZA\n002212.SZA\n002217.SZA\n002221.SZA\n002223.SZA\n002230.SZA\n002233.SZA\n002236.SZA\n002237.SZA\n002241.SZA\n002242.SZA\n002244.SZA\n002262.SZA\n002268.SZA\n002271.SZA\n002273.SZA\n002281.SZA\n002287.SZA\n002294.SZA\n002299.SZA\n002302.SZA\n002304.SZA\n002311.SZA\n002340.SZA\n002368.SZA\n002371.SZA\n002372.SZA\n002373.SZA\n002384.SZA\n002387.SZA\n002396.SZA\n002399.SZA\n002408.SZA\n002410.SZA\n002411.SZA\n002414.SZA\n002419.SZA\n002422.SZA\n002429.SZA\n002430.SZA\n002439.SZA\n002440.SZA\n002444.SZA\n002460.SZA\n002461.SZA\n002463.SZA\n002466.SZA\n002493.SZA\n002600.SZA\n002601.SZA\n002602.SZA\n002603.SZA\n002607.SZA\n002624.SZA\n002626.SZA\n002643.SZA\n002648.SZA\n002670.SZA\n002673.SZA\n002678.SZA\n002690.SZA\n002701.SZA\n002714.SZA\n002736.SZA\n002739.SZA\n002773.SZA\n002797.SZA\n002812.SZA\n002821.SZA\n002916.SZA\n002926.SZA\n002938.SZA\n002939.SZA\n300001.SZA\n300003.SZA\n300009.SZA\n300012.SZA\n300014.SZA\n300017.SZA\n300024.SZA\n300027.SZA\n300033.SZA\n300070.SZA\n300072.SZA\n300078.SZA\n300088.SZA\n300113.SZA\n300122.SZA\n300124.SZA\n300134.SZA\n300136.SZA\n300142.SZA\n300144.SZA\n300146.SZA\n300168.SZA\n300207.SZA\n300212.SZA\n300226.SZA\n300271.SZA\n300274.SZA\n300294.SZA\n300296.SZA\n300308.SZA\n300316.SZA\n300326.SZA\n300339.SZA\n300347.SZA\n300369.SZA\n300383.SZA\n300408.SZA\n300413.SZA\n300433.SZA\n300463.SZA\n300476.SZA\n300482.SZA\n300496.SZA\n300498.SZA\n300601.SZA\n300661.SZA\n300676.SZA\n300699.SZA\n300748.SZA\n300760.SZA\n300782.SZA\n600000.SHA\n600004.SHA\n600007.SHA\n600008.SHA\n600009.SHA\n600010.SHA\n600011.SHA\n600016.SHA\n600018.SHA\n600019.SHA\n600021.SHA\n600022.SHA\n600023.SHA\n600026.SHA\n600027.SHA\n600028.SHA\n600029.SHA\n600030.SHA\n600031.SHA\n600036.SHA\n600037.SHA\n600038.SHA\n600039.SHA\n600048.SHA\n600060.SHA\n600061.SHA\n600062.SHA\n600064.SHA\n600066.SHA\n600068.SHA\n600072.SHA\n600079.SHA\n600089.SHA\n600093.SHA\n600094.SHA\n600098.SHA\n600100.SHA\n600104.SHA\n600109.SHA\n600111.SHA\n600118.SHA\n600126.SHA\n600132.SHA\n600143.SHA\n600160.SHA\n600161.SHA\n600166.SHA\n600167.SHA\n600170.SHA\n600176.SHA\n600177.SHA\n600183.SHA\n600188.SHA\n600196.SHA\n600201.SHA\n600208.SHA\n600216.SHA\n600219.SHA\n600221.SHA\n600233.SHA\n600236.SHA\n600260.SHA\n600266.SHA\n600267.SHA\n600271.SHA\n600273.SHA\n600276.SHA\n600277.SHA\n600282.SHA\n600297.SHA\n600298.SHA\n600299.SHA\n600307.SHA\n600309.SHA\n600317.SHA\n600320.SHA\n600323.SHA\n600332.SHA\n600340.SHA\n600346.SHA\n600348.SHA\n600362.SHA\n600369.SHA\n600372.SHA\n600373.SHA\n600376.SHA\n600377.SHA\n600380.SHA\n600383.SHA\n600388.SHA\n600392.SHA\n600398.SHA\n600406.SHA\n600409.SHA\n600410.SHA\n600426.SHA\n600436.SHA\n600438.SHA\n600446.SHA\n600460.SHA\n600466.SHA\n600482.SHA\n600483.SHA\n600486.SHA\n600487.SHA\n600489.SHA\n600491.SHA\n600497.SHA\n600498.SHA\n600600.SHA\n600604.SHA\n600606.SHA\n600612.SHA\n600623.SHA\n600633.SHA\n600637.SHA\n600639.SHA\n600641.SHA\n600642.SHA\n600643.SHA\n600648.SHA\n600649.SHA\n600660.SHA\n600663.SHA\n600667.SHA\n600673.SHA\n600674.SHA\n600682.SHA\n600688.SHA\n600690.SHA\n600699.SHA\n600702.SHA\n600703.SHA\n600704.SHA\n600717.SHA\n600718.SHA\n600728.SHA\n600729.SHA\n600737.SHA\n600739.SHA\n600741.SHA\n600748.SHA\n600760.SHA\n600763.SHA\n600776.SHA\n600779.SHA\n600782.SHA\n600787.SHA\n600797.SHA\n600801.SHA\n600803.SHA\n600808.SHA\n600809.SHA\n600811.SHA\n600812.SHA\n600816.SHA\n600820.SHA\n600823.SHA\n600827.SHA\n600837.SHA\n600839.SHA\n600848.SHA\n600862.SHA\n600863.SHA\n600864.SHA\n600867.SHA\n600869.SHA\n600871.SHA\n600872.SHA\n600873.SHA\n600879.SHA\n600884.SHA\n600886.SHA\n600887.SHA\n600893.SHA\n600900.SHA\n600901.SHA\n600909.SHA\n600917.SHA\n600919.SHA\n600926.SHA\n600970.SHA\n600977.SHA\n600998.SHA\n600999.SHA\n601000.SHA\n601003.SHA\n601006.SHA\n601009.SHA\n601012.SHA\n601018.SHA\n601021.SHA\n601066.SHA\n601088.SHA\n601098.SHA\n601099.SHA\n601100.SHA\n601106.SHA\n601108.SHA\n601111.SHA\n601117.SHA\n601118.SHA\n601127.SHA\n601128.SHA\n601138.SHA\n601139.SHA\n601162.SHA\n601163.SHA\n601166.SHA\n601168.SHA\n601169.SHA\n601179.SHA\n601186.SHA\n601198.SHA\n601211.SHA\n601216.SHA\n601229.SHA\n601231.SHA\n601233.SHA\n601238.SHA\n601288.SHA\n601318.SHA\n601319.SHA\n601328.SHA\n601333.SHA\n601336.SHA\n601369.SHA\n601377.SHA\n601390.SHA\n601398.SHA\n601600.SHA\n601601.SHA\n601607.SHA\n601608.SHA\n601611.SHA\n601618.SHA\n601628.SHA\n601633.SHA\n601636.SHA\n601668.SHA\n601669.SHA\n601688.SHA\n601689.SHA\n601699.SHA\n601718.SHA\n601727.SHA\n601766.SHA\n601788.SHA\n601799.SHA\n601800.SHA\n601801.SHA\n601808.SHA\n601818.SHA\n601838.SHA\n601866.SHA\n601872.SHA\n601877.SHA\n601878.SHA\n601880.SHA\n601881.SHA\n601888.SHA\n601898.SHA\n601899.SHA\n601901.SHA\n601919.SHA\n601928.SHA\n601933.SHA\n601939.SHA\n601966.SHA\n601969.SHA\n601988.SHA\n601989.SHA\n601990.SHA\n601991.SHA\n601992.SHA\n601997.SHA\n601998.SHA\n603000.SHA\n603012.SHA\n603019.SHA\n603027.SHA\n603077.SHA\n603160.SHA\n603198.SHA\n603222.SHA\n603260.SHA\n603288.SHA\n603328.SHA\n603338.SHA\n603369.SHA\n603377.SHA\n603444.SHA\n603609.SHA\n603707.SHA\n603737.SHA\n603799.SHA\n603806.SHA\n603816.SHA\n603866.SHA\n603868.SHA\n603882.SHA\n603883.SHA\n603888.SHA\n603899.SHA\n603939.SHA\n603986.SHA\n603993.SHA","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_count","Value":"0","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"rolling_conf","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-8"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-15","ModuleId":"BigQuantSpace.advanced_auto_labeler.advanced_auto_labeler-v2","ModuleParameters":[{"Name":"label_expr","Value":"# #号开始的表示注释\n# 0. 每行一个,顺序执行,从第二个开始,可以使用label字段\n# 1. 可用数据字段见 https://bigquant.com/docs/develop/datasource/deprecated/history_data.html\n# 添加benchmark_前缀,可使用对应的benchmark数据\n# 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/develop/bigexpr/usage.html>`_\n\n# 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)\nshift(close, -5) / shift(open, -1)\n\n# 极值处理:用1%和99%分位的值做clip\nclip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))\n\n# 将分数映射到分类,这里使用20个分类\nall_wbins(label, 20)\n\n# 过滤掉一字涨停的情况 (设置label为NaN,在后续处理和训练中会忽略NaN的label)\nwhere(shift(high, -1) == shift(low, -1), NaN, label)\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"start_date","Value":"2016-03-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2019-11-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"benchmark","Value":"000300.SHA","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"drop_na_label","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"cast_label_int","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_functions","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-15"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-15","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"# #号开始的表示注释\n# 多个特征,每行一个,可以包含基础特征和衍生特征\nreturn_5\nreturn_10\nreturn_20\navg_amount_0/avg_amount_5\navg_amount_5/avg_amount_10\navg_amount_0/avg_amount_10\nrank_avg_amount_0/rank_avg_amount_5\nrank_avg_amount_5/rank_avg_amount_10\nrank_avg_amount_0/rank_avg_amount_10\nrank_return_0\nrank_return_5\nrank_return_10\nrank_return_20\nrank_return_0/rank_return_5\nrank_return_5/rank_return_10\nrank_return_0/rank_return_10\npe_ttm_0\npe_lyr_0\npb_lf_0\n","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":3,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-43","ModuleId":"BigQuantSpace.stock_ranker_train.stock_ranker_train-v5","ModuleParameters":[{"Name":"learning_algorithm","Value":"排序","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"number_of_leaves","Value":"30","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"minimum_docs_per_leaf","Value":"1000","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"number_of_trees","Value":"20","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"learning_rate","Value":"0.1","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_bins","Value":"1023","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"feature_fraction","Value":1,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"m_lazy_run","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"training_ds","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"test_ds","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"base_model","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"}],"OutputPortsInternal":[{"Name":"model","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43","OutputType":null},{"Name":"feature_gains","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43","OutputType":null},{"Name":"m_lazy_run","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-43","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":6,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-53","ModuleId":"BigQuantSpace.join.join-v3","ModuleParameters":[{"Name":"on","Value":"date,instrument","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"how","Value":"inner","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"sort","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"data1","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"data2","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-53","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":7,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-60","ModuleId":"BigQuantSpace.stock_ranker_predict.stock_ranker_predict-v5","ModuleParameters":[{"Name":"m_lazy_run","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"model","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60"}],"OutputPortsInternal":[{"Name":"predictions","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60","OutputType":null},{"Name":"m_lazy_run","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-60","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":8,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2016-03-01","ValueType":"Literal","LinkedGlobalParameter":"交易日期"},{"Name":"end_date","Value":"2019-11-22","ValueType":"Literal","LinkedGlobalParameter":"交易日期"},{"Name":"market","Value":"CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_list","Value":"000050.SZA\n000156.SZA\n000157.SZA\n000158.SZA\n000415.SZA\n000425.SZA\n000503.SZA\n000513.SZA\n000538.SZA\n000539.SZA\n000540.SZA\n000547.SZA\n000555.SZA\n000559.SZA\n000563.SZA\n000568.SZA\n000581.SZA\n000596.SZA\n000598.SZA\n000625.SZA\n000651.SZA\n000656.SZA\n000725.SZA\n000735.SZA\n000750.SZA\n000825.SZA\n000858.SZA\n000895.SZA\n000935.SZA\n000951.SZA\n000959.SZA\n000975.SZA\n002025.SZA\n002050.SZA\n002051.SZA\n002056.SZA\n002065.SZA\n002075.SZA\n002085.SZA\n002152.SZA\n002153.SZA\n002156.SZA\n002157.SZA\n002185.SZA\n002195.SZA\n002250.SZA\n002252.SZA\n002352.SZA\n002353.SZA\n002385.SZA\n002405.SZA\n002415.SZA\n002450.SZA\n002456.SZA\n002458.SZA\n002465.SZA\n002475.SZA\n002500.SZA\n002506.SZA\n002507.SZA\n002508.SZA\n002511.SZA\n002531.SZA\n002537.SZA\n002555.SZA\n002557.SZA\n002558.SZA\n002563.SZA\n002572.SZA\n002594.SZA\n002597.SZA\n002653.SZA\n002675.SZA\n002705.SZA\n300015.SZA\n300058.SZA\n300059.SZA\n300115.SZA\n300251.SZA\n300253.SZA\n300285.SZA\n300315.SZA\n300357.SZA\n300450.SZA\n300454.SZA\n300529.SZA\n300558.SZA\n300595.SZA\n300750.SZA\n600015.SHA\n600025.SHA\n600050.SHA\n600056.SHA\n600085.SHA\n600115.SHA\n600150.SHA\n600153.SHA\n600155.SHA\n600157.SHA\n600185.SHA\n600195.SHA\n600252.SHA\n600256.SHA\n600258.SHA\n600305.SHA\n600315.SHA\n600325.SHA\n600350.SHA\n600352.SHA\n600415.SHA\n600435.SHA\n600500.SHA\n600507.SHA\n600516.SHA\n600518.SHA\n600519.SHA\n600521.SHA\n600522.SHA\n600528.SHA\n600529.SHA\n600535.SHA\n600536.SHA\n600546.SHA\n600547.SHA\n600548.SHA\n600549.SHA\n600566.SHA\n600567.SHA\n600570.SHA\n600572.SHA\n600575.SHA\n600578.SHA\n600580.SHA\n600582.SHA\n600583.SHA\n600584.SHA\n600585.SHA\n600588.SHA\n600597.SHA\n600598.SHA\n600635.SHA\n600655.SHA\n600675.SHA\n600685.SHA\n600705.SHA\n600745.SHA\n600754.SHA\n600755.SHA\n600795.SHA\n600835.SHA\n600845.SHA\n600850.SHA\n600875.SHA\n600885.SHA\n600895.SHA\n600958.SHA\n600959.SHA\n601005.SHA\n601155.SHA\n601158.SHA\n601225.SHA\n601519.SHA\n601555.SHA\n601857.SHA\n601958.SHA\n601985.SHA\n603156.SHA\n603259.SHA\n603456.SHA\n603501.SHA\n603515.SHA\n603517.SHA\n603568.SHA\n603589.SHA\n603658.SHA\n603659.SHA\n603858.SHA\n603885.SHA\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_count","Value":"0","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"rolling_conf","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":9,"IsPartOfPartialRun":null,"Comment":"预测数据,用于回测和模拟","CommentCollapsed":false},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-84","ModuleId":"BigQuantSpace.dropnan.dropnan-v1","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-84"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-84","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":13,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-86","ModuleId":"BigQuantSpace.dropnan.dropnan-v1","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-86"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-86","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":14,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-215","ModuleId":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v7","ModuleParameters":[{"Name":"start_date","Value":"2016-03-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2019-11-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"before_start_days","Value":"20","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-215"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-215"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-215","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":15,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-222","ModuleId":"BigQuantSpace.derived_feature_extractor.derived_feature_extractor-v3","ModuleParameters":[{"Name":"date_col","Value":"date","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_col","Value":"instrument","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"drop_na","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"remove_extra_columns","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_functions","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-222"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-222"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-222","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":16,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-231","ModuleId":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v7","ModuleParameters":[{"Name":"start_date","Value":"2016-03-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2019-11-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"before_start_days","Value":"20","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-231"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-231"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-231","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":17,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-238","ModuleId":"BigQuantSpace.derived_feature_extractor.derived_feature_extractor-v3","ModuleParameters":[{"Name":"date_col","Value":"date","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_col","Value":"instrument","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"drop_na","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"remove_extra_columns","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_functions","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-238"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-238"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-238","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":18,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-250","ModuleId":"BigQuantSpace.trade.trade-v4","ModuleParameters":[{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":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","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"handle_data","Value":"# 回测引擎:每日数据处理函数,每天执行一次\ndef bigquant_run(context, data):\n # 相隔几天(hold_days)进行一下换仓\n if context.trading_day_index % context.hold_days!= 0:\n return \n\n # 按日期过滤得到今日的预测数据\n ranker_prediction = context.ranker_prediction[\n context.ranker_prediction.date == data.current_dt.strftime('%Y-%m-%d')]\n\n # 目前持仓\n positions = {e.symbol: p.amount * p.last_sale_price\n for e, p in context.portfolio.positions.items()}\n # 权重\n buy_cash_weights = context.stock_weights\n # 今日买入股票列表\n stock_to_buy = list(ranker_prediction.instrument[:len(buy_cash_weights)])\n # 持仓上限\n max_cash_per_instrument = context.portfolio.portfolio_value * context.max_cash_per_instrument\n\n # 通过positions对象,使用列表生成式的方法获取目前持仓的股票列表\n stock_hold_now = [equity.symbol 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 # 如果该股票停牌,则没法成交。因此需要用can_trade方法检查下该股票的状态\n # 如果返回真值,则可以正常下单,否则会出错\n # 因为stock是字符串格式,我们用symbol方法将其转化成平台可以接受的形式:Equity格式\n if data.can_trade(context.symbol(stock)):\n # order_target_percent是平台的一个下单接口,表明下单使得该股票的权重为0,\n # 即卖出全部股票,可参考回测文档\n context.order_target_percent(context.symbol(stock), 0)\n \n # 如果当天没有买入的股票,就返回\n if len(stock_to_buy) == 0:\n return\n \n # 买入\n for i, instrument in enumerate(stock_to_buy):\n cash = context.portfolio.portfolio_value * buy_cash_weights[i]\n if cash > max_cash_per_instrument - positions.get(instrument, 0):\n # 确保股票持仓量不会超过每次股票最大的占用资金量\n cash = max_cash_per_instrument - positions.get(instrument, 0)\n if cash > 0:\n price = data.current(context.symbol(instrument), 'price') # 最新价格\n stock_num = np.floor(cash/price/100)*100 # 向下取整\n context.order(context.symbol(instrument), stock_num) # 整百下单\n ","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"prepare","Value":"# 回测引擎:准备数据,只执行一次\ndef bigquant_run(context):\n pass\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"before_trading_start","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"volume_limit","Value":0.025,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"order_price_field_buy","Value":"vwap_2","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"order_price_field_sell","Value":"open","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"capital_base","Value":1000000,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"auto_cancel_non_tradable_orders","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"data_frequency","Value":"daily","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"price_type","Value":"真实价格","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"product_type","Value":"股票","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"plot_charts","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"backtest_only","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"benchmark","Value":"00300.SHA","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-250"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"options_data","NodeId":"-250"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"history_ds","NodeId":"-250"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"benchmark_ds","NodeId":"-250"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"trading_calendar","NodeId":"-250"}],"OutputPortsInternal":[{"Name":"raw_perf","NodeId":"-250","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":19,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true}],"SerializedClientData":"<?xml version='1.0' encoding='utf-16'?><DataV1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Meta /><NodePositions><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-8' Position='211,64,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-15' Position='74,183,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-24' Position='766,21,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-43' Position='638,561,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-53' Position='247,375,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-60' Position='906,647,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-62' Position='1074,127,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-84' Position='376,467,200,200'/><NodePosition Node='-86' Position='1078,418,200,200'/><NodePosition Node='-215' Position='381,186,200,200'/><NodePosition Node='-222' Position='385,278,200,200'/><NodePosition Node='-231' Position='1079,236,200,200'/><NodePosition Node='-238' Position='1081,326,200,200'/><NodePosition Node='-250' Position='1033,755,200,200'/></NodePositions><NodeGroups /></DataV1>"},"IsDraft":true,"ParentExperimentId":null,"WebService":{"IsWebServiceExperiment":false,"Inputs":[],"Outputs":[],"Parameters":[{"Name":"交易日期","Value":"","ParameterDefinition":{"Name":"交易日期","FriendlyName":"交易日期","DefaultValue":"","ParameterType":"String","HasDefaultValue":true,"IsOptional":true,"ParameterRules":[],"HasRules":false,"MarkupType":0,"CredentialDescriptor":null}}],"WebServiceGroupId":null,"SerializedClientData":"<?xml version='1.0' encoding='utf-16'?><DataV1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Meta /><NodePositions></NodePositions><NodeGroups /></DataV1>"},"DisableNodesUpdate":false,"Category":"user","Tags":[],"IsPartialRun":true}
    In [15]:
    # 本代码由可视化策略环境自动生成 2019年11月25日 11:54
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # 回测引擎:初始化函数,只执行一次
    def m19_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
    
    # 回测引擎:每日数据处理函数,每天执行一次
    def m19_handle_data_bigquant_run(context, data):
         # 相隔几天(hold_days)进行一下换仓
        if context.trading_day_index % context.hold_days!= 0:
            return    
    
        # 按日期过滤得到今日的预测数据
        ranker_prediction = context.ranker_prediction[
            context.ranker_prediction.date == data.current_dt.strftime('%Y-%m-%d')]
    
       # 目前持仓
        positions = {e.symbol: p.amount * p.last_sale_price
                     for e, p in context.portfolio.positions.items()}
        # 权重
        buy_cash_weights = context.stock_weights
        # 今日买入股票列表
        stock_to_buy = list(ranker_prediction.instrument[:len(buy_cash_weights)])
        # 持仓上限
        max_cash_per_instrument = context.portfolio.portfolio_value * context.max_cash_per_instrument
    
        # 通过positions对象,使用列表生成式的方法获取目前持仓的股票列表
        stock_hold_now = [equity.symbol for equity in context.portfolio.positions ]
        # 继续持有的股票:调仓时,如果买入的股票已经存在于目前的持仓里,那么应继续持有
        no_need_to_sell = [i for i in stock_hold_now if i in stock_to_buy]
        # 需要卖出的股票
        stock_to_sell = [i for i in stock_hold_now if i not in no_need_to_sell]
      
        # 卖出
        for stock in stock_to_sell:
            # 如果该股票停牌,则没法成交。因此需要用can_trade方法检查下该股票的状态
            # 如果返回真值,则可以正常下单,否则会出错
            # 因为stock是字符串格式,我们用symbol方法将其转化成平台可以接受的形式:Equity格式
            if data.can_trade(context.symbol(stock)):
                # order_target_percent是平台的一个下单接口,表明下单使得该股票的权重为0,
                #   即卖出全部股票,可参考回测文档
                context.order_target_percent(context.symbol(stock), 0)
        
        # 如果当天没有买入的股票,就返回
        if len(stock_to_buy) == 0:
            return
        
        # 买入
        for i, instrument in enumerate(stock_to_buy):
            cash = context.portfolio.portfolio_value * buy_cash_weights[i]
            if cash > max_cash_per_instrument - positions.get(instrument, 0):
                # 确保股票持仓量不会超过每次股票最大的占用资金量
                cash = max_cash_per_instrument - positions.get(instrument, 0)
            if cash > 0:
                price = data.current(context.symbol(instrument), 'price')  # 最新价格
                stock_num = np.floor(cash/price/100)*100  # 向下取整
                context.order(context.symbol(instrument), stock_num) # 整百下单
      
    # 回测引擎:准备数据,只执行一次
    def m19_prepare_bigquant_run(context):
        pass
    
    
    m1 = M.instruments.v2(
        start_date='2016-03-01',
        end_date='2019-11-01',
        market='CN_STOCK_A',
        instrument_list="""000001.SZA
    000002.SZA
    000009.SZA
    000021.SZA
    000027.SZA
    000028.SZA
    000031.SZA
    000039.SZA
    000043.SZA
    000046.SZA
    000060.SZA
    000062.SZA
    000063.SZA
    000066.SZA
    000069.SZA
    000088.SZA
    000089.SZA
    000100.SZA
    000166.SZA
    000333.SZA
    000338.SZA
    000401.SZA
    000402.SZA
    000413.SZA
    000423.SZA
    000429.SZA
    000623.SZA
    000627.SZA
    000629.SZA
    000630.SZA
    000636.SZA
    000661.SZA
    000671.SZA
    000672.SZA
    000681.SZA
    000686.SZA
    000688.SZA
    000690.SZA
    000703.SZA
    000709.SZA
    000712.SZA
    000723.SZA
    000728.SZA
    000729.SZA
    000732.SZA
    000738.SZA
    000739.SZA
    000761.SZA
    000768.SZA
    000776.SZA
    000778.SZA
    000783.SZA
    000786.SZA
    000792.SZA
    000799.SZA
    000800.SZA
    000807.SZA
    000810.SZA
    000813.SZA
    000826.SZA
    000830.SZA
    000831.SZA
    000839.SZA
    000860.SZA
    000869.SZA
    000876.SZA
    000878.SZA
    000883.SZA
    000898.SZA
    000918.SZA
    000932.SZA
    000938.SZA
    000960.SZA
    000961.SZA
    000963.SZA
    000977.SZA
    000983.SZA
    000987.SZA
    000988.SZA
    000997.SZA
    000998.SZA
    000999.SZA
    001979.SZA
    002001.SZA
    002007.SZA
    002008.SZA
    002010.SZA
    002013.SZA
    002019.SZA
    002024.SZA
    002027.SZA
    002032.SZA
    002036.SZA
    002038.SZA
    002044.SZA
    002049.SZA
    002074.SZA
    002078.SZA
    002080.SZA
    002081.SZA
    002092.SZA
    002099.SZA
    002100.SZA
    002110.SZA
    002120.SZA
    002123.SZA
    002124.SZA
    002127.SZA
    002128.SZA
    002129.SZA
    002131.SZA
    002138.SZA
    002142.SZA
    002146.SZA
    002174.SZA
    002179.SZA
    002180.SZA
    002191.SZA
    002202.SZA
    002203.SZA
    002212.SZA
    002217.SZA
    002221.SZA
    002223.SZA
    002230.SZA
    002233.SZA
    002236.SZA
    002237.SZA
    002241.SZA
    002242.SZA
    002244.SZA
    002262.SZA
    002268.SZA
    002271.SZA
    002273.SZA
    002281.SZA
    002287.SZA
    002294.SZA
    002299.SZA
    002302.SZA
    002304.SZA
    002311.SZA
    002340.SZA
    002368.SZA
    002371.SZA
    002372.SZA
    002373.SZA
    002384.SZA
    002387.SZA
    002396.SZA
    002399.SZA
    002408.SZA
    002410.SZA
    002411.SZA
    002414.SZA
    002419.SZA
    002422.SZA
    002429.SZA
    002430.SZA
    002439.SZA
    002440.SZA
    002444.SZA
    002460.SZA
    002461.SZA
    002463.SZA
    002466.SZA
    002493.SZA
    002600.SZA
    002601.SZA
    002602.SZA
    002603.SZA
    002607.SZA
    002624.SZA
    002626.SZA
    002643.SZA
    002648.SZA
    002670.SZA
    002673.SZA
    002678.SZA
    002690.SZA
    002701.SZA
    002714.SZA
    002736.SZA
    002739.SZA
    002773.SZA
    002797.SZA
    002812.SZA
    002821.SZA
    002916.SZA
    002926.SZA
    002938.SZA
    002939.SZA
    300001.SZA
    300003.SZA
    300009.SZA
    300012.SZA
    300014.SZA
    300017.SZA
    300024.SZA
    300027.SZA
    300033.SZA
    300070.SZA
    300072.SZA
    300078.SZA
    300088.SZA
    300113.SZA
    300122.SZA
    300124.SZA
    300134.SZA
    300136.SZA
    300142.SZA
    300144.SZA
    300146.SZA
    300168.SZA
    300207.SZA
    300212.SZA
    300226.SZA
    300271.SZA
    300274.SZA
    300294.SZA
    300296.SZA
    300308.SZA
    300316.SZA
    300326.SZA
    300339.SZA
    300347.SZA
    300369.SZA
    300383.SZA
    300408.SZA
    300413.SZA
    300433.SZA
    300463.SZA
    300476.SZA
    300482.SZA
    300496.SZA
    300498.SZA
    300601.SZA
    300661.SZA
    300676.SZA
    300699.SZA
    300748.SZA
    300760.SZA
    300782.SZA
    600000.SHA
    600004.SHA
    600007.SHA
    600008.SHA
    600009.SHA
    600010.SHA
    600011.SHA
    600016.SHA
    600018.SHA
    600019.SHA
    600021.SHA
    600022.SHA
    600023.SHA
    600026.SHA
    600027.SHA
    600028.SHA
    600029.SHA
    600030.SHA
    600031.SHA
    600036.SHA
    600037.SHA
    600038.SHA
    600039.SHA
    600048.SHA
    600060.SHA
    600061.SHA
    600062.SHA
    600064.SHA
    600066.SHA
    600068.SHA
    600072.SHA
    600079.SHA
    600089.SHA
    600093.SHA
    600094.SHA
    600098.SHA
    600100.SHA
    600104.SHA
    600109.SHA
    600111.SHA
    600118.SHA
    600126.SHA
    600132.SHA
    600143.SHA
    600160.SHA
    600161.SHA
    600166.SHA
    600167.SHA
    600170.SHA
    600176.SHA
    600177.SHA
    600183.SHA
    600188.SHA
    600196.SHA
    600201.SHA
    600208.SHA
    600216.SHA
    600219.SHA
    600221.SHA
    600233.SHA
    600236.SHA
    600260.SHA
    600266.SHA
    600267.SHA
    600271.SHA
    600273.SHA
    600276.SHA
    600277.SHA
    600282.SHA
    600297.SHA
    600298.SHA
    600299.SHA
    600307.SHA
    600309.SHA
    600317.SHA
    600320.SHA
    600323.SHA
    600332.SHA
    600340.SHA
    600346.SHA
    600348.SHA
    600362.SHA
    600369.SHA
    600372.SHA
    600373.SHA
    600376.SHA
    600377.SHA
    600380.SHA
    600383.SHA
    600388.SHA
    600392.SHA
    600398.SHA
    600406.SHA
    600409.SHA
    600410.SHA
    600426.SHA
    600436.SHA
    600438.SHA
    600446.SHA
    600460.SHA
    600466.SHA
    600482.SHA
    600483.SHA
    600486.SHA
    600487.SHA
    600489.SHA
    600491.SHA
    600497.SHA
    600498.SHA
    600600.SHA
    600604.SHA
    600606.SHA
    600612.SHA
    600623.SHA
    600633.SHA
    600637.SHA
    600639.SHA
    600641.SHA
    600642.SHA
    600643.SHA
    600648.SHA
    600649.SHA
    600660.SHA
    600663.SHA
    600667.SHA
    600673.SHA
    600674.SHA
    600682.SHA
    600688.SHA
    600690.SHA
    600699.SHA
    600702.SHA
    600703.SHA
    600704.SHA
    600717.SHA
    600718.SHA
    600728.SHA
    600729.SHA
    600737.SHA
    600739.SHA
    600741.SHA
    600748.SHA
    600760.SHA
    600763.SHA
    600776.SHA
    600779.SHA
    600782.SHA
    600787.SHA
    600797.SHA
    600801.SHA
    600803.SHA
    600808.SHA
    600809.SHA
    600811.SHA
    600812.SHA
    600816.SHA
    600820.SHA
    600823.SHA
    600827.SHA
    600837.SHA
    600839.SHA
    600848.SHA
    600862.SHA
    600863.SHA
    600864.SHA
    600867.SHA
    600869.SHA
    600871.SHA
    600872.SHA
    600873.SHA
    600879.SHA
    600884.SHA
    600886.SHA
    600887.SHA
    600893.SHA
    600900.SHA
    600901.SHA
    600909.SHA
    600917.SHA
    600919.SHA
    600926.SHA
    600970.SHA
    600977.SHA
    600998.SHA
    600999.SHA
    601000.SHA
    601003.SHA
    601006.SHA
    601009.SHA
    601012.SHA
    601018.SHA
    601021.SHA
    601066.SHA
    601088.SHA
    601098.SHA
    601099.SHA
    601100.SHA
    601106.SHA
    601108.SHA
    601111.SHA
    601117.SHA
    601118.SHA
    601127.SHA
    601128.SHA
    601138.SHA
    601139.SHA
    601162.SHA
    601163.SHA
    601166.SHA
    601168.SHA
    601169.SHA
    601179.SHA
    601186.SHA
    601198.SHA
    601211.SHA
    601216.SHA
    601229.SHA
    601231.SHA
    601233.SHA
    601238.SHA
    601288.SHA
    601318.SHA
    601319.SHA
    601328.SHA
    601333.SHA
    601336.SHA
    601369.SHA
    601377.SHA
    601390.SHA
    601398.SHA
    601600.SHA
    601601.SHA
    601607.SHA
    601608.SHA
    601611.SHA
    601618.SHA
    601628.SHA
    601633.SHA
    601636.SHA
    601668.SHA
    601669.SHA
    601688.SHA
    601689.SHA
    601699.SHA
    601718.SHA
    601727.SHA
    601766.SHA
    601788.SHA
    601799.SHA
    601800.SHA
    601801.SHA
    601808.SHA
    601818.SHA
    601838.SHA
    601866.SHA
    601872.SHA
    601877.SHA
    601878.SHA
    601880.SHA
    601881.SHA
    601888.SHA
    601898.SHA
    601899.SHA
    601901.SHA
    601919.SHA
    601928.SHA
    601933.SHA
    601939.SHA
    601966.SHA
    601969.SHA
    601988.SHA
    601989.SHA
    601990.SHA
    601991.SHA
    601992.SHA
    601997.SHA
    601998.SHA
    603000.SHA
    603012.SHA
    603019.SHA
    603027.SHA
    603077.SHA
    603160.SHA
    603198.SHA
    603222.SHA
    603260.SHA
    603288.SHA
    603328.SHA
    603338.SHA
    603369.SHA
    603377.SHA
    603444.SHA
    603609.SHA
    603707.SHA
    603737.SHA
    603799.SHA
    603806.SHA
    603816.SHA
    603866.SHA
    603868.SHA
    603882.SHA
    603883.SHA
    603888.SHA
    603899.SHA
    603939.SHA
    603986.SHA
    603993.SHA""",
        max_count=0
    )
    
    m2 = M.advanced_auto_labeler.v2(
        instruments=m1.data,
        label_expr="""# #号开始的表示注释
    # 0. 每行一个,顺序执行,从第二个开始,可以使用label字段
    # 1. 可用数据字段见 https://bigquant.com/docs/develop/datasource/deprecated/history_data.html
    #   添加benchmark_前缀,可使用对应的benchmark数据
    # 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/develop/bigexpr/usage.html>`_
    
    # 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)
    shift(close, -5) / shift(open, -1)
    
    # 极值处理:用1%和99%分位的值做clip
    clip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))
    
    # 将分数映射到分类,这里使用20个分类
    all_wbins(label, 20)
    
    # 过滤掉一字涨停的情况 (设置label为NaN,在后续处理和训练中会忽略NaN的label)
    where(shift(high, -1) == shift(low, -1), NaN, label)
    """,
        start_date='2016-03-01',
        end_date='2019-11-01',
        benchmark='000300.SHA',
        drop_na_label=True,
        cast_label_int=True
    )
    
    m3 = M.input_features.v1(
        features="""# #号开始的表示注释
    # 多个特征,每行一个,可以包含基础特征和衍生特征
    return_5
    return_10
    return_20
    avg_amount_0/avg_amount_5
    avg_amount_5/avg_amount_10
    avg_amount_0/avg_amount_10
    rank_avg_amount_0/rank_avg_amount_5
    rank_avg_amount_5/rank_avg_amount_10
    rank_avg_amount_0/rank_avg_amount_10
    rank_return_0
    rank_return_5
    rank_return_10
    rank_return_20
    rank_return_0/rank_return_5
    rank_return_5/rank_return_10
    rank_return_0/rank_return_10
    pe_ttm_0
    pe_lyr_0
    pb_lf_0
    """
    )
    
    m15 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m3.data,
        start_date='2016-03-01',
        end_date='2019-11-01',
        before_start_days=20
    )
    
    m16 = M.derived_feature_extractor.v3(
        input_data=m15.data,
        features=m3.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=True,
        remove_extra_columns=True
    )
    
    m7 = M.join.v3(
        data1=m2.data,
        data2=m16.data,
        on='date,instrument',
        how='inner',
        sort=False
    )
    
    m13 = M.dropnan.v1(
        input_data=m7.data
    )
    
    m6 = M.stock_ranker_train.v5(
        training_ds=m13.data,
        features=m3.data,
        learning_algorithm='排序',
        number_of_leaves=30,
        minimum_docs_per_leaf=1000,
        number_of_trees=20,
        learning_rate=0.1,
        max_bins=1023,
        feature_fraction=1,
        m_lazy_run=False
    )
    
    m9 = M.instruments.v2(
        start_date=T.live_run_param('trading_date', '2016-03-01'),
        end_date=T.live_run_param('trading_date', '2019-11-22'),
        market='CN_STOCK_A',
        instrument_list="""000050.SZA
    000156.SZA
    000157.SZA
    000158.SZA
    000415.SZA
    000425.SZA
    000503.SZA
    000513.SZA
    000538.SZA
    000539.SZA
    000540.SZA
    000547.SZA
    000555.SZA
    000559.SZA
    000563.SZA
    000568.SZA
    000581.SZA
    000596.SZA
    000598.SZA
    000625.SZA
    000651.SZA
    000656.SZA
    000725.SZA
    000735.SZA
    000750.SZA
    000825.SZA
    000858.SZA
    000895.SZA
    000935.SZA
    000951.SZA
    000959.SZA
    000975.SZA
    002025.SZA
    002050.SZA
    002051.SZA
    002056.SZA
    002065.SZA
    002075.SZA
    002085.SZA
    002152.SZA
    002153.SZA
    002156.SZA
    002157.SZA
    002185.SZA
    002195.SZA
    002250.SZA
    002252.SZA
    002352.SZA
    002353.SZA
    002385.SZA
    002405.SZA
    002415.SZA
    002450.SZA
    002456.SZA
    002458.SZA
    002465.SZA
    002475.SZA
    002500.SZA
    002506.SZA
    002507.SZA
    002508.SZA
    002511.SZA
    002531.SZA
    002537.SZA
    002555.SZA
    002557.SZA
    002558.SZA
    002563.SZA
    002572.SZA
    002594.SZA
    002597.SZA
    002653.SZA
    002675.SZA
    002705.SZA
    300015.SZA
    300058.SZA
    300059.SZA
    300115.SZA
    300251.SZA
    300253.SZA
    300285.SZA
    300315.SZA
    300357.SZA
    300450.SZA
    300454.SZA
    300529.SZA
    300558.SZA
    300595.SZA
    300750.SZA
    600015.SHA
    600025.SHA
    600050.SHA
    600056.SHA
    600085.SHA
    600115.SHA
    600150.SHA
    600153.SHA
    600155.SHA
    600157.SHA
    600185.SHA
    600195.SHA
    600252.SHA
    600256.SHA
    600258.SHA
    600305.SHA
    600315.SHA
    600325.SHA
    600350.SHA
    600352.SHA
    600415.SHA
    600435.SHA
    600500.SHA
    600507.SHA
    600516.SHA
    600518.SHA
    600519.SHA
    600521.SHA
    600522.SHA
    600528.SHA
    600529.SHA
    600535.SHA
    600536.SHA
    600546.SHA
    600547.SHA
    600548.SHA
    600549.SHA
    600566.SHA
    600567.SHA
    600570.SHA
    600572.SHA
    600575.SHA
    600578.SHA
    600580.SHA
    600582.SHA
    600583.SHA
    600584.SHA
    600585.SHA
    600588.SHA
    600597.SHA
    600598.SHA
    600635.SHA
    600655.SHA
    600675.SHA
    600685.SHA
    600705.SHA
    600745.SHA
    600754.SHA
    600755.SHA
    600795.SHA
    600835.SHA
    600845.SHA
    600850.SHA
    600875.SHA
    600885.SHA
    600895.SHA
    600958.SHA
    600959.SHA
    601005.SHA
    601155.SHA
    601158.SHA
    601225.SHA
    601519.SHA
    601555.SHA
    601857.SHA
    601958.SHA
    601985.SHA
    603156.SHA
    603259.SHA
    603456.SHA
    603501.SHA
    603515.SHA
    603517.SHA
    603568.SHA
    603589.SHA
    603658.SHA
    603659.SHA
    603858.SHA
    603885.SHA
    """,
        max_count=0
    )
    
    m17 = M.general_feature_extractor.v7(
        instruments=m9.data,
        features=m3.data,
        start_date='2016-03-01',
        end_date='2019-11-01',
        before_start_days=20
    )
    
    m18 = M.derived_feature_extractor.v3(
        input_data=m17.data,
        features=m3.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=True,
        remove_extra_columns=True
    )
    
    m14 = M.dropnan.v1(
        input_data=m18.data
    )
    
    m8 = M.stock_ranker_predict.v5(
        model=m6.model,
        data=m14.data,
        m_lazy_run=False
    )
    
    m19 = M.trade.v4(
        instruments=m9.data,
        options_data=m8.predictions,
        start_date='',
        end_date='',
        initialize=m19_initialize_bigquant_run,
        handle_data=m19_handle_data_bigquant_run,
        prepare=m19_prepare_bigquant_run,
        volume_limit=0.025,
        order_price_field_buy='vwap_2',
        order_price_field_sell='open',
        capital_base=1000000,
        auto_cancel_non_tradable_orders=True,
        data_frequency='daily',
        price_type='真实价格',
        product_type='股票',
        plot_charts=True,
        backtest_only=False,
        benchmark='00300.SHA'
    )
    
    设置测试数据集,查看训练迭代过程的NDCG
    bigcharts-data-start/{"__id":"bigchart-d681a248dadc40a9b66dfd114834c7e9","__type":"tabs"}/bigcharts-data-end
    • 收益率238.01%
    • 年化收益率40.01%
    • 基准收益率0.0%
    • 阿尔法0
    • 贝塔0
    • 夏普比率1.38
    • 胜率0.52
    • 盈亏比1.29
    • 收益波动率24.36%
    • 信息比率0.09
    • 最大回撤22.77%
    bigcharts-data-start/{"__id":"bigchart-240bd15b262e4122abf2cb1118d20d22","__type":"tabs"}/bigcharts-data-end

    策略建好后,11月21日之前的数据正常,但是22日之后的交易出了问题,主要有几个问题:
    1、一只股票策略运行的时候提示停牌,实际上没有停牌;
    2、没有产生买入的股票,只有卖出的股票,导致22日之后一直空仓。

    (focus777) #2

    m9和m1日期有部分重合了。m1是训练集,m9是测试集。不能重合 否则会有过拟合嫌疑


    (bonjovy) #3

    谢谢指导!