克隆策略

StockRanker多因子选股策略

    {"description":"实验创建于2017/8/26","graph":{"edges":[{"to_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-15:instruments","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"to_node_id":"-274:instruments","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"to_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data1","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-15:data"},{"to_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-43:features","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-274:features","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-281:features","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-288:features","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"-295:features","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"to_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:model","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-43:model"},{"to_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-84:input_data","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data"},{"to_node_id":"-10933:options_data","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:predictions"},{"to_node_id":"-288:instruments","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"to_node_id":"-10933:instruments","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"to_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-43:training_ds","from_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-84:data"},{"to_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-60:data","from_node_id":"-86:data"},{"to_node_id":"-281:input_data","from_node_id":"-274:data"},{"to_node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-53:data2","from_node_id":"-281:data"},{"to_node_id":"-295:input_data","from_node_id":"-288:data"},{"to_node_id":"-86:input_data","from_node_id":"-295:data"}],"nodes":[{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2021-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2021-02-01","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"000021.SZA\n002460.SZA\n000027.SZA\n000050.SZA\n000333.SZA\n000338.SZA\n000521.SZA\n000538.SZA\n000615.SZA\n000625.SZA\n000626.SZA\n000651.SZA\n000661.SZA\n000713.SZA\n000733.SZA\n000768.SZA\n000798.SZA\n000858.SZA\n000928.SZA\n000963.SZA\n000995.SZA\n002007.SZA\n002055.SZA\n002074.SZA\n002092.SZA\n002125.SZA\n002151.SZA\n002156.SZA\n002162.SZA\n002163.SZA\n002179.SZA\n002184.SZA\n002185.SZA\n002190.SZA\n002192.SZA\n002221.SZA\n002237.SZA\n002240.SZA\n002245.SZA\n002271.SZA\n002340.SZA\n002352.SZA\n002371.SZA\n002386.SZA\n002389.SZA\n002407.SZA\n002415.SZA\n002430.SZA\n002466.SZA\n002497.SZA\n002529.SZA\n002557.SZA\n002594.SZA\n002601.SZA\n002607.SZA\n002625.SZA\n002668.SZA\n002709.SZA\n002756.SZA\n002799.SZA\n002812.SZA\n002813.SZA\n002821.SZA\n002906.SZA\n002920.SZA\n300003.SZA\n300014.SZA\n300015.SZA\n300034.SZA\n300037.SZA\n300059.SZA\n300122.SZA\n300124.SZA\n300142.SZA\n300244.SZA\n300251.SZA\n300274.SZA\n300316.SZA\n300339.SZA\n300340.SZA\n300347.SZA\n300357.SZA\n300433.SZA\n300450.SZA\n300477.SZA\n300496.SZA\n300529.SZA\n300558.SZA\n300567.SZA\n300576.SZA\n300581.SZA\n300595.SZA\n300601.SZA\n300604.SZA\n300623.SZA\n300648.SZA\n300661.SZA\n300685.SZA\n300690.SZA\n300699.SZA\n300719.SZA\n300722.SZA\n300726.SZA\n300750.SZA\n300759.SZA\n300760.SZA\n300763.SZA\n300769.SZA\n600016.SHA\n600031.SHA\n600089.SHA\n600110.SHA\n600183.SHA\n600196.SHA\n600198.SHA\n600237.SHA\n600256.SHA\n600276.SHA\n600295.SHA\n600305.SHA\n600309.SHA\n600316.SHA\n600325.SHA\n600392.SHA\n600398.SHA\n600418.SHA\n600438.SHA\n600460.SHA\n600499.SHA\n600516.SHA\n600570.SHA\n600584.SHA\n600585.SHA\n600596.SHA\n600660.SHA\n600685.SHA\n600690.SHA\n600699.SHA\n600703.SHA\n600733.SHA\n600745.SHA\n600760.SHA\n600763.SHA\n600805.SHA\n600809.SHA\n600862.SHA\n600864.SHA\n600882.SHA\n600886.SHA\n600887.SHA\n600893.SHA\n600977.SHA\n600988.SHA\n601012.SHA\n601100.SHA\n601611.SHA\n601633.SHA\n601865.SHA\n601866.SHA\n601869.SHA\n601888.SHA\n601899.SHA\n601901.SHA\n601919.SHA\n603005.SHA\n603019.SHA\n603025.SHA\n603027.SHA\n603185.SHA\n603197.SHA\n603259.SHA\n603260.SHA\n603267.SHA\n603501.SHA\n603517.SHA\n603605.SHA\n603650.SHA\n603678.SHA\n603707.SHA\n603799.SHA\n603806.SHA\n603882.SHA","type":"Literal","bound_global_parameter":null},{"name":"max_count","value":"0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"rolling_conf","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-15","module_id":"BigQuantSpace.advanced_auto_labeler.advanced_auto_labeler-v2","parameters":[{"name":"label_expr","value":"# #号开始的表示注释\n# 0. 每行一个,顺序执行,从第二个开始,可以使用label字段\n# 1. 可用数据字段见 https://bigquant.com/docs/data_history_data.html\n# 添加benchmark_前缀,可使用对应的benchmark数据\n# 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/big_expr.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","type":"Literal","bound_global_parameter":null},{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"benchmark","value":"000300.SHA","type":"Literal","bound_global_parameter":null},{"name":"drop_na_label","value":"True","type":"Literal","bound_global_parameter":null},{"name":"cast_label_int","value":"True","type":"Literal","bound_global_parameter":null},{"name":"user_functions","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-15"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-15"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"# #号开始的表示注释\n# 多个特征,每行一个,可以包含基础特征和衍生特征\npe_ttm_0\n","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-43","module_id":"BigQuantSpace.stock_ranker_train.stock_ranker_train-v5","parameters":[{"name":"learning_algorithm","value":"排序","type":"Literal","bound_global_parameter":null},{"name":"number_of_leaves","value":"3","type":"Literal","bound_global_parameter":null},{"name":"minimum_docs_per_leaf","value":"100","type":"Literal","bound_global_parameter":null},{"name":"number_of_trees","value":"5","type":"Literal","bound_global_parameter":null},{"name":"learning_rate","value":"0.5","type":"Literal","bound_global_parameter":null},{"name":"max_bins","value":1023,"type":"Literal","bound_global_parameter":null},{"name":"feature_fraction","value":1,"type":"Literal","bound_global_parameter":null},{"name":"m_lazy_run","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"training_ds","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"},{"name":"features","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"},{"name":"test_ds","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"},{"name":"base_model","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"}],"output_ports":[{"name":"model","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"},{"name":"feature_gains","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"},{"name":"m_lazy_run","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-43"}],"cacheable":true,"seq_num":6,"comment":"","comment_collapsed":true},{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-53","module_id":"BigQuantSpace.join.join-v3","parameters":[{"name":"on","value":"date,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":"287d2cb0-f53c-4101-bdf8-104b137c8601-53"},{"name":"data2","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-53"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-53"}],"cacheable":true,"seq_num":7,"comment":"","comment_collapsed":true},{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-60","module_id":"BigQuantSpace.stock_ranker_predict.stock_ranker_predict-v5","parameters":[{"name":"m_lazy_run","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"model","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-60"},{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-60"}],"output_ports":[{"name":"predictions","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-60"},{"name":"m_lazy_run","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-60"}],"cacheable":false,"seq_num":8,"comment":"","comment_collapsed":true},{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2021-02-01","type":"Literal","bound_global_parameter":"交易日期"},{"name":"end_date","value":"2021-03-01","type":"Literal","bound_global_parameter":"交易日期"},{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"000021.SZA\n002460.SZA\n000027.SZA\n000050.SZA\n000333.SZA\n000338.SZA\n000521.SZA\n000538.SZA\n000615.SZA\n000625.SZA\n000626.SZA\n000651.SZA\n000661.SZA\n000713.SZA\n000733.SZA\n000768.SZA\n000798.SZA\n000858.SZA\n000928.SZA\n000963.SZA\n000995.SZA\n002007.SZA\n002055.SZA\n002074.SZA\n002092.SZA\n002125.SZA\n002151.SZA\n002156.SZA\n002162.SZA\n002163.SZA\n002179.SZA\n002184.SZA\n002185.SZA\n002190.SZA\n002192.SZA\n002221.SZA\n002237.SZA\n002240.SZA\n002245.SZA\n002271.SZA\n002340.SZA\n002352.SZA\n002371.SZA\n002386.SZA\n002389.SZA\n002407.SZA\n002415.SZA\n002430.SZA\n002466.SZA\n002497.SZA\n002529.SZA\n002557.SZA\n002594.SZA\n002601.SZA\n002607.SZA\n002625.SZA\n002668.SZA\n002709.SZA\n002756.SZA\n002799.SZA\n002812.SZA\n002813.SZA\n002821.SZA\n002906.SZA\n002920.SZA\n300003.SZA\n300014.SZA\n300015.SZA\n300034.SZA\n300037.SZA\n300059.SZA\n300122.SZA\n300124.SZA\n300142.SZA\n300244.SZA\n300251.SZA\n300274.SZA\n300316.SZA\n300339.SZA\n300340.SZA\n300347.SZA\n300357.SZA\n300433.SZA\n300450.SZA\n300477.SZA\n300496.SZA\n300529.SZA\n300558.SZA\n300567.SZA\n300576.SZA\n300581.SZA\n300595.SZA\n300601.SZA\n300604.SZA\n300623.SZA\n300648.SZA\n300661.SZA\n300685.SZA\n300690.SZA\n300699.SZA\n300719.SZA\n300722.SZA\n300726.SZA\n300750.SZA\n300759.SZA\n300760.SZA\n300763.SZA\n300769.SZA\n600016.SHA\n600031.SHA\n600089.SHA\n600110.SHA\n600183.SHA\n600196.SHA\n600198.SHA\n600237.SHA\n600256.SHA\n600276.SHA\n600295.SHA\n600305.SHA\n600309.SHA\n600316.SHA\n600325.SHA\n600392.SHA\n600398.SHA\n600418.SHA\n600438.SHA\n600460.SHA\n600499.SHA\n600516.SHA\n600570.SHA\n600584.SHA\n600585.SHA\n600596.SHA\n600660.SHA\n600685.SHA\n600690.SHA\n600699.SHA\n600703.SHA\n600733.SHA\n600745.SHA\n600760.SHA\n600763.SHA\n600805.SHA\n600809.SHA\n600862.SHA\n600864.SHA\n600882.SHA\n600886.SHA\n600887.SHA\n600893.SHA\n600977.SHA\n600988.SHA\n601012.SHA\n601100.SHA\n601611.SHA\n601633.SHA\n601865.SHA\n601866.SHA\n601869.SHA\n601888.SHA\n601899.SHA\n601901.SHA\n601919.SHA\n603005.SHA\n603019.SHA\n603025.SHA\n603027.SHA\n603185.SHA\n603197.SHA\n603259.SHA\n603260.SHA\n603267.SHA\n603501.SHA\n603517.SHA\n603605.SHA\n603650.SHA\n603678.SHA\n603707.SHA\n603799.SHA\n603806.SHA\n603882.SHA","type":"Literal","bound_global_parameter":null},{"name":"max_count","value":"0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"rolling_conf","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62"}],"cacheable":true,"seq_num":9,"comment":"预测数据,用于回测和模拟","comment_collapsed":false},{"node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-84","module_id":"BigQuantSpace.dropnan.dropnan-v1","parameters":[],"input_ports":[{"name":"input_data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-84"}],"output_ports":[{"name":"data","node_id":"287d2cb0-f53c-4101-bdf8-104b137c8601-84"}],"cacheable":true,"seq_num":13,"comment":"","comment_collapsed":true},{"node_id":"-86","module_id":"BigQuantSpace.dropnan.dropnan-v1","parameters":[],"input_ports":[{"name":"input_data","node_id":"-86"}],"output_ports":[{"name":"data","node_id":"-86"}],"cacheable":true,"seq_num":14,"comment":"","comment_collapsed":true},{"node_id":"-274","module_id":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v7","parameters":[{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"before_start_days","value":0,"type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-274"},{"name":"features","node_id":"-274"}],"output_ports":[{"name":"data","node_id":"-274"}],"cacheable":true,"seq_num":15,"comment":"","comment_collapsed":true},{"node_id":"-281","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":"-281"},{"name":"features","node_id":"-281"}],"output_ports":[{"name":"data","node_id":"-281"}],"cacheable":true,"seq_num":16,"comment":"","comment_collapsed":true},{"node_id":"-288","module_id":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v7","parameters":[{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"before_start_days","value":"60","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-288"},{"name":"features","node_id":"-288"}],"output_ports":[{"name":"data","node_id":"-288"}],"cacheable":true,"seq_num":17,"comment":"","comment_collapsed":true},{"node_id":"-295","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":"-295"},{"name":"features","node_id":"-295"}],"output_ports":[{"name":"data","node_id":"-295"}],"cacheable":true,"seq_num":18,"comment":"","comment_collapsed":true},{"node_id":"-10933","module_id":"BigQuantSpace.hftrade.hftrade-v1","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 df = DataSource(\"bar1d_index_CN_STOCK_A\").read(instruments=\"000300.HIX\",start_date=\"2021-01-01\",end_date=\"2021-08-01\")\n df[\"ma\"] = df.close.rolling(5).mean()\n df[\"signal\"] = df.apply(lambda x:1 if x.close>x.ma else 0,axis=1)\n df[\"signal\"] = df[\"signal\"].shift(1) #取昨日的收盘信号\n df=df[[\"date\",\"signal\"]]\n #信号数据\n context.signal_df = df\n #每支股票占比\n context.order_pct = 0.1\n #获取预测股票集\n context.to_buy = context.options['data'].read()\n\n ","type":"Literal","bound_global_parameter":null},{"name":"before_trading_start","value":"# 交易引擎:每个单位时间开盘前调用一次。\ndef bigquant_run(context, data):\n now = data.current_dt.strftime('%Y-%m-%d')\n context.today = data.current_dt.strftime('%Y-%m-%d')\n context.signal = context.signal_df[context.signal_df.date==now][\"signal\"].iloc[0]\n context.handle_flag = 0 #由于是分钟回测,每天只需要处理一次买卖\n context.sold_stock_list = []\n context.position_check = context.get_positions()\n print('日期{} 持仓 {} -----------'.format(now, context.position_check))\n","type":"Literal","bound_global_parameter":null},{"name":"handle_tick","value":"# 交易引擎:bar数据处理函数,每个单位执行一次\ndef bigquant_run(context, data):\n pass\n","type":"Literal","bound_global_parameter":null},{"name":"handle_data","value":"#卖出函数\ndef sell_stock(context,data,msg):\n #获取当前所有持仓\n stock_hold_now = context.get_account_positions()\n for instr in stock_hold_now:\n if instr not in context.sold_stock_list:\n #卖出可用仓位(可能有今仓)\n position = context.get_position(instr).avail_qty\n if(position>0):\n #最新价格\n price = data.current(instr, 'close')\n context.order(instr, -position, price, order_type=OrderType.MARKET)\n context.sold_stock_list.append(instr)\n print(\"{}卖出{} {}\".format(msg,instr,position))\n\n# 交易引擎:bar数据处理函数,每个单位执行一次\ndef bigquant_run(context, data):\n \n #signal为0开盘卖\n if context.signal == 0:\n msg = context.today+\" 开盘\"\n sell_stock(context,data,msg)\n \n current_stopwin_stock = []\n current_stoploss_stock = []\n if len(context.position_check) > 0:\n #------------------------START:止赢止损模块(含建仓期)---------------\n positions_cost={e:p.cost_price for e,p in context.get_positions().items()}\n avail_positions = {e: p.avail_qty for e, p in context.get_positions().items()}\n for instrument in positions_cost.keys():\n s = context.get_position(instrument).cost_price\n stock_cost=positions_cost[instrument]\n stock_market_price=data.current(context.symbol(instrument),'price')\n if stock_market_price/stock_cost-1>=0.05 and avail_positions[instrument] != 0:\n context.order_target(instrument, 0, order_type=OrderType.MARKET)\n print('止盈成功, 止盈标的{}'.format(instrument))\n current_stopwin_stock.append(instrument)\n elif stock_market_price/stock_cost-1 <= -0.02 and avail_positions[instrument] != 0:\n context.order_target(instrument, 0, order_type=OrderType.MARKET)\n print('止损成功, 止损标的{}'.format(instrument))\n current_stoploss_stock.append(instrument)\n if len(current_stopwin_stock)>0:\n# print(context.today,'止盈股票列表',current_stopwin_stock)\n context.sold_stock_list += current_stopwin_stock\n if len(current_stoploss_stock)>0:\n# print(context.today,'止损股票列表',current_stoploss_stock)\n context.sold_stock_list += current_stoploss_stock\n #--------------------------END: 止赢止损模块--------------------------\n \n\n #signal为1尾盘卖\n if context.signal == 1:\n cur_date = data.current_dt\n cur_hm = cur_date.strftime('%H:%M')\n if(cur_hm==\"14:55\"):\n msg = str(cur_date)+\" 尾盘\"\n sell_stock(context,data,msg)\n \n #每天只处理一次\n if context.handle_flag==1:\n return\n \n #买入预测集的前5只股票\n now_data = context.to_buy[context.to_buy['date']==context.today]\n today_to_buy = []\n if not now_data.empty:\n today_to_buy = now_data.instrument[:5].to_list()\n print(context.today,\"=======早盘计划买入股票 {}\".format(today_to_buy))\n \n # 获取账户资金\n total_portfolio = context.portfolio.portfolio_value\n\n for instr in today_to_buy:\n if instr not in context.sold_stock_list:\n #最新价格\n price = data.current(instr, 'close')\n\n #计算买入此股票的数量,不要超过总资金的某个比例\n context.order_value(instr, total_portfolio*context.order_pct, price, order_type=OrderType.MARKET)\n print(\"买入{}\".format(instr))\n \n context.handle_flag = 1\n\n\n \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":1000000,"type":"Literal","bound_global_parameter":null},{"name":"frequency","value":"minute","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":"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":"True","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":"-10933"},{"name":"history_ds","node_id":"-10933"},{"name":"benchmark_ds","node_id":"-10933"},{"name":"options_data","node_id":"-10933"}],"output_ports":[{"name":"raw_perf","node_id":"-10933"}],"cacheable":false,"seq_num":5,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-8' Position='211,64,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-15' Position='70,183,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-24' Position='695,-14,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-43' Position='718,485,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-53' Position='249,375,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-60' Position='864,597,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-62' Position='1078,75,200,200'/><node_position Node='287d2cb0-f53c-4101-bdf8-104b137c8601-84' Position='376,465,200,200'/><node_position Node='-86' Position='1078,418,200,200'/><node_position Node='-274' Position='381,188,200,200'/><node_position Node='-281' Position='385,280,200,200'/><node_position Node='-288' Position='1078,236,200,200'/><node_position Node='-295' Position='1081,327,200,200'/><node_position Node='-10933' Position='754,743,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [4]:
    # 本代码由可视化策略环境自动生成 2021年9月16日 15:47
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # 交易引擎:初始化函数,只执行一次
    def m5_initialize_bigquant_run(context):
        df = DataSource("bar1d_index_CN_STOCK_A").read(instruments="000300.HIX",start_date="2021-01-01",end_date="2021-08-01")
        df["ma"] = df.close.rolling(5).mean()
        df["signal"] = df.apply(lambda x:1 if x.close>x.ma else 0,axis=1)
        df["signal"] = df["signal"].shift(1) #取昨日的收盘信号
        df=df[["date","signal"]]
        #信号数据
        context.signal_df = df
        #每支股票占比
        context.order_pct = 0.1
        #获取预测股票集
        context.to_buy = context.options['data'].read()
    
        
    # 交易引擎:每个单位时间开盘前调用一次。
    def m5_before_trading_start_bigquant_run(context, data):
        now = data.current_dt.strftime('%Y-%m-%d')
        context.today = data.current_dt.strftime('%Y-%m-%d')
        context.signal = context.signal_df[context.signal_df.date==now]["signal"].iloc[0]
        context.handle_flag = 0 #由于是分钟回测,每天只需要处理一次买卖
        context.sold_stock_list = []
        context.position_check = context.get_positions()
        print('日期{} 持仓 {} -----------'.format(now, context.position_check))
    
    # 交易引擎:bar数据处理函数,每个单位执行一次
    def m5_handle_tick_bigquant_run(context, data):
        pass
    
    #卖出函数
    def sell_stock(context,data,msg):
        #获取当前所有持仓
        stock_hold_now = context.get_account_positions()
        for instr in stock_hold_now:
            if instr not in context.sold_stock_list:
                #卖出可用仓位(可能有今仓)
                position = context.get_position(instr).avail_qty
                if(position>0):
                    #最新价格
                    price = data.current(instr, 'close')
                    context.order(instr, -position, price, order_type=OrderType.MARKET)
                    context.sold_stock_list.append(instr)
                    print("{}卖出{} {}".format(msg,instr,position))
    
    # 交易引擎:bar数据处理函数,每个单位执行一次
    def m5_handle_data_bigquant_run(context, data):
        
        #signal为0开盘卖
        if context.signal == 0:
            msg = context.today+" 开盘"
            sell_stock(context,data,msg)
            
        current_stopwin_stock = []
        current_stoploss_stock = []
        if len(context.position_check) > 0:
            #------------------------START:止赢止损模块(含建仓期)---------------
            positions_cost={e:p.cost_price for e,p in context.get_positions().items()}
            avail_positions = {e: p.avail_qty for e, p in context.get_positions().items()}
            for instrument in positions_cost.keys():
                s = context.get_position(instrument).cost_price
                stock_cost=positions_cost[instrument]
                stock_market_price=data.current(context.symbol(instrument),'price')
                if stock_market_price/stock_cost-1>=0.05 and avail_positions[instrument] != 0:
                    context.order_target(instrument, 0, order_type=OrderType.MARKET)
                    print('止盈成功, 止盈标的{}'.format(instrument))
                    current_stopwin_stock.append(instrument)
                elif stock_market_price/stock_cost-1 <= -0.02 and avail_positions[instrument] != 0:
                    context.order_target(instrument, 0, order_type=OrderType.MARKET)
                    print('止损成功, 止损标的{}'.format(instrument))
                    current_stoploss_stock.append(instrument)
            if len(current_stopwin_stock)>0:
    #             print(context.today,'止盈股票列表',current_stopwin_stock)
                context.sold_stock_list += current_stopwin_stock
            if len(current_stoploss_stock)>0:
    #             print(context.today,'止损股票列表',current_stoploss_stock)
                context.sold_stock_list += current_stoploss_stock
            #--------------------------END: 止赢止损模块--------------------------
        
    
        #signal为1尾盘卖
        if context.signal == 1:
            cur_date = data.current_dt
            cur_hm =  cur_date.strftime('%H:%M')
            if(cur_hm=="14:55"):
                msg = str(cur_date)+" 尾盘"
                sell_stock(context,data,msg)
            
        #每天只处理一次
        if context.handle_flag==1:
            return
        
        #买入预测集的前5只股票
        now_data = context.to_buy[context.to_buy['date']==context.today]
        today_to_buy = []
        if not now_data.empty:
            today_to_buy = now_data.instrument[:5].to_list()
        print(context.today,"=======早盘计划买入股票 {}".format(today_to_buy))
        
        # 获取账户资金
        total_portfolio = context.portfolio.portfolio_value
    
        for instr in today_to_buy:
            if instr not in context.sold_stock_list:
                #最新价格
                price = data.current(instr, 'close')
    
                #计算买入此股票的数量,不要超过总资金的某个比例
                context.order_value(instr, total_portfolio*context.order_pct, price, order_type=OrderType.MARKET)
                print("买入{}".format(instr))
                
        context.handle_flag = 1
    
    
        
    
    # 交易引擎:成交回报处理函数,每个成交发生时执行一次
    def m5_handle_trade_bigquant_run(context, data):
        pass
    
    # 交易引擎:委托回报处理函数,每个委托变化时执行一次
    def m5_handle_order_bigquant_run(context, data):
        pass
    
    # 交易引擎:盘后处理函数,每日盘后执行一次
    def m5_after_trading_bigquant_run(context, data):
        pass
    
    
    m1 = M.instruments.v2(
        start_date='2021-01-01',
        end_date='2021-02-01',
        market='CN_STOCK_A',
        instrument_list="""000021.SZA
    002460.SZA
    000027.SZA
    000050.SZA
    000333.SZA
    000338.SZA
    000521.SZA
    000538.SZA
    000615.SZA
    000625.SZA
    000626.SZA
    000651.SZA
    000661.SZA
    000713.SZA
    000733.SZA
    000768.SZA
    000798.SZA
    000858.SZA
    000928.SZA
    000963.SZA
    000995.SZA
    002007.SZA
    002055.SZA
    002074.SZA
    002092.SZA
    002125.SZA
    002151.SZA
    002156.SZA
    002162.SZA
    002163.SZA
    002179.SZA
    002184.SZA
    002185.SZA
    002190.SZA
    002192.SZA
    002221.SZA
    002237.SZA
    002240.SZA
    002245.SZA
    002271.SZA
    002340.SZA
    002352.SZA
    002371.SZA
    002386.SZA
    002389.SZA
    002407.SZA
    002415.SZA
    002430.SZA
    002466.SZA
    002497.SZA
    002529.SZA
    002557.SZA
    002594.SZA
    002601.SZA
    002607.SZA
    002625.SZA
    002668.SZA
    002709.SZA
    002756.SZA
    002799.SZA
    002812.SZA
    002813.SZA
    002821.SZA
    002906.SZA
    002920.SZA
    300003.SZA
    300014.SZA
    300015.SZA
    300034.SZA
    300037.SZA
    300059.SZA
    300122.SZA
    300124.SZA
    300142.SZA
    300244.SZA
    300251.SZA
    300274.SZA
    300316.SZA
    300339.SZA
    300340.SZA
    300347.SZA
    300357.SZA
    300433.SZA
    300450.SZA
    300477.SZA
    300496.SZA
    300529.SZA
    300558.SZA
    300567.SZA
    300576.SZA
    300581.SZA
    300595.SZA
    300601.SZA
    300604.SZA
    300623.SZA
    300648.SZA
    300661.SZA
    300685.SZA
    300690.SZA
    300699.SZA
    300719.SZA
    300722.SZA
    300726.SZA
    300750.SZA
    300759.SZA
    300760.SZA
    300763.SZA
    300769.SZA
    600016.SHA
    600031.SHA
    600089.SHA
    600110.SHA
    600183.SHA
    600196.SHA
    600198.SHA
    600237.SHA
    600256.SHA
    600276.SHA
    600295.SHA
    600305.SHA
    600309.SHA
    600316.SHA
    600325.SHA
    600392.SHA
    600398.SHA
    600418.SHA
    600438.SHA
    600460.SHA
    600499.SHA
    600516.SHA
    600570.SHA
    600584.SHA
    600585.SHA
    600596.SHA
    600660.SHA
    600685.SHA
    600690.SHA
    600699.SHA
    600703.SHA
    600733.SHA
    600745.SHA
    600760.SHA
    600763.SHA
    600805.SHA
    600809.SHA
    600862.SHA
    600864.SHA
    600882.SHA
    600886.SHA
    600887.SHA
    600893.SHA
    600977.SHA
    600988.SHA
    601012.SHA
    601100.SHA
    601611.SHA
    601633.SHA
    601865.SHA
    601866.SHA
    601869.SHA
    601888.SHA
    601899.SHA
    601901.SHA
    601919.SHA
    603005.SHA
    603019.SHA
    603025.SHA
    603027.SHA
    603185.SHA
    603197.SHA
    603259.SHA
    603260.SHA
    603267.SHA
    603501.SHA
    603517.SHA
    603605.SHA
    603650.SHA
    603678.SHA
    603707.SHA
    603799.SHA
    603806.SHA
    603882.SHA""",
        max_count=0
    )
    
    m2 = M.advanced_auto_labeler.v2(
        instruments=m1.data,
        label_expr="""# #号开始的表示注释
    # 0. 每行一个,顺序执行,从第二个开始,可以使用label字段
    # 1. 可用数据字段见 https://bigquant.com/docs/data_history_data.html
    #   添加benchmark_前缀,可使用对应的benchmark数据
    # 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/big_expr.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='',
        end_date='',
        benchmark='000300.SHA',
        drop_na_label=True,
        cast_label_int=True
    )
    
    m3 = M.input_features.v1(
        features="""# #号开始的表示注释
    # 多个特征,每行一个,可以包含基础特征和衍生特征
    pe_ttm_0
    """
    )
    
    m15 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m3.data,
        start_date='',
        end_date='',
        before_start_days=0
    )
    
    m16 = M.derived_feature_extractor.v3(
        input_data=m15.data,
        features=m3.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False
    )
    
    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=3,
        minimum_docs_per_leaf=100,
        number_of_trees=5,
        learning_rate=0.5,
        max_bins=1023,
        feature_fraction=1,
        m_lazy_run=False
    )
    
    m9 = M.instruments.v2(
        start_date=T.live_run_param('trading_date', '2021-02-01'),
        end_date=T.live_run_param('trading_date', '2021-03-01'),
        market='CN_STOCK_A',
        instrument_list="""000021.SZA
    002460.SZA
    000027.SZA
    000050.SZA
    000333.SZA
    000338.SZA
    000521.SZA
    000538.SZA
    000615.SZA
    000625.SZA
    000626.SZA
    000651.SZA
    000661.SZA
    000713.SZA
    000733.SZA
    000768.SZA
    000798.SZA
    000858.SZA
    000928.SZA
    000963.SZA
    000995.SZA
    002007.SZA
    002055.SZA
    002074.SZA
    002092.SZA
    002125.SZA
    002151.SZA
    002156.SZA
    002162.SZA
    002163.SZA
    002179.SZA
    002184.SZA
    002185.SZA
    002190.SZA
    002192.SZA
    002221.SZA
    002237.SZA
    002240.SZA
    002245.SZA
    002271.SZA
    002340.SZA
    002352.SZA
    002371.SZA
    002386.SZA
    002389.SZA
    002407.SZA
    002415.SZA
    002430.SZA
    002466.SZA
    002497.SZA
    002529.SZA
    002557.SZA
    002594.SZA
    002601.SZA
    002607.SZA
    002625.SZA
    002668.SZA
    002709.SZA
    002756.SZA
    002799.SZA
    002812.SZA
    002813.SZA
    002821.SZA
    002906.SZA
    002920.SZA
    300003.SZA
    300014.SZA
    300015.SZA
    300034.SZA
    300037.SZA
    300059.SZA
    300122.SZA
    300124.SZA
    300142.SZA
    300244.SZA
    300251.SZA
    300274.SZA
    300316.SZA
    300339.SZA
    300340.SZA
    300347.SZA
    300357.SZA
    300433.SZA
    300450.SZA
    300477.SZA
    300496.SZA
    300529.SZA
    300558.SZA
    300567.SZA
    300576.SZA
    300581.SZA
    300595.SZA
    300601.SZA
    300604.SZA
    300623.SZA
    300648.SZA
    300661.SZA
    300685.SZA
    300690.SZA
    300699.SZA
    300719.SZA
    300722.SZA
    300726.SZA
    300750.SZA
    300759.SZA
    300760.SZA
    300763.SZA
    300769.SZA
    600016.SHA
    600031.SHA
    600089.SHA
    600110.SHA
    600183.SHA
    600196.SHA
    600198.SHA
    600237.SHA
    600256.SHA
    600276.SHA
    600295.SHA
    600305.SHA
    600309.SHA
    600316.SHA
    600325.SHA
    600392.SHA
    600398.SHA
    600418.SHA
    600438.SHA
    600460.SHA
    600499.SHA
    600516.SHA
    600570.SHA
    600584.SHA
    600585.SHA
    600596.SHA
    600660.SHA
    600685.SHA
    600690.SHA
    600699.SHA
    600703.SHA
    600733.SHA
    600745.SHA
    600760.SHA
    600763.SHA
    600805.SHA
    600809.SHA
    600862.SHA
    600864.SHA
    600882.SHA
    600886.SHA
    600887.SHA
    600893.SHA
    600977.SHA
    600988.SHA
    601012.SHA
    601100.SHA
    601611.SHA
    601633.SHA
    601865.SHA
    601866.SHA
    601869.SHA
    601888.SHA
    601899.SHA
    601901.SHA
    601919.SHA
    603005.SHA
    603019.SHA
    603025.SHA
    603027.SHA
    603185.SHA
    603197.SHA
    603259.SHA
    603260.SHA
    603267.SHA
    603501.SHA
    603517.SHA
    603605.SHA
    603650.SHA
    603678.SHA
    603707.SHA
    603799.SHA
    603806.SHA
    603882.SHA""",
        max_count=0
    )
    
    m17 = M.general_feature_extractor.v7(
        instruments=m9.data,
        features=m3.data,
        start_date='',
        end_date='',
        before_start_days=60
    )
    
    m18 = M.derived_feature_extractor.v3(
        input_data=m17.data,
        features=m3.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False
    )
    
    m14 = M.dropnan.v1(
        input_data=m18.data
    )
    
    m8 = M.stock_ranker_predict.v5(
        model=m6.model,
        data=m14.data,
        m_lazy_run=False,
        m_cached=False
    )
    
    m5 = M.hftrade.v1(
        instruments=m9.data,
        options_data=m8.predictions,
        start_date='',
        end_date='',
        initialize=m5_initialize_bigquant_run,
        before_trading_start=m5_before_trading_start_bigquant_run,
        handle_tick=m5_handle_tick_bigquant_run,
        handle_data=m5_handle_data_bigquant_run,
        handle_trade=m5_handle_trade_bigquant_run,
        handle_order=m5_handle_order_bigquant_run,
        after_trading=m5_after_trading_bigquant_run,
        capital_base=1000000,
        frequency='minute',
        price_type='真实价格',
        product_type='股票',
        before_start_days='0',
        benchmark='000300.HIX',
        plot_charts=True,
        disable_cache=True,
        show_debug_info=False,
        backtest_only=False
    )
    
    设置测试数据集,查看训练迭代过程的NDCG
    bigcharts-data-start/{"__type":"tabs","__id":"bigchart-0f98b58ab5e846af9212f185429b9211"}/bigcharts-data-end
    2021-09-16 14:43:24.632660 run trading v1.7.8 
    2021-09-16 14:43:24.632961 init history datas... 
    2021-09-16 14:43:25.288836 init trading env... 
    日期2021-02-01 持仓 {} -----------
    2021-02-01 =======早盘计划买入股票 ['000768.SZA', '002156.SZA', '002607.SZA', '002709.SZA', '002812.SZA']
    买入000768.SZA
    买入002156.SZA
    买入002607.SZA
    买入002709.SZA
    买入002812.SZA
    日期2021-02-02 持仓 {'000768.SZA': StockPosition(bkt000,000768.SZA,long,current_qty:3100,avail_qty:3100,cost_price:31.47,last_price:31.650002), '002156.SZA': StockPosition(bkt000,002156.SZA,long,current_qty:3600,avail_qty:3600,cost_price:27.04,last_price:28.9), '002607.SZA': StockPosition(bkt000,002607.SZA,long,current_qty:2500,avail_qty:2500,cost_price:39.04,last_price:41.210003), '002709.SZA': StockPosition(bkt000,002709.SZA,long,current_qty:1000,avail_qty:1000,cost_price:95.85,last_price:94.2), '002812.SZA': StockPosition(bkt000,002812.SZA,long,current_qty:700,avail_qty:700,cost_price:132.81,last_price:135.41)} -----------
    2021-02-02 开盘卖出000768.SZA 3100
    2021-02-02 开盘卖出002156.SZA 3600
    2021-02-02 开盘卖出002607.SZA 2500
    2021-02-02 开盘卖出002709.SZA 1000
    2021-02-02 开盘卖出002812.SZA 700
    2021-02-02 =======早盘计划买入股票 ['000768.SZA', '002156.SZA', '002607.SZA', '002709.SZA', '002812.SZA']
    日期2021-02-03 持仓 {} -----------
    2021-02-03 =======早盘计划买入股票 ['000768.SZA', '002709.SZA', '002812.SZA', '002920.SZA', '300581.SZA']
    买入000768.SZA
    买入002709.SZA
    买入002812.SZA
    买入002920.SZA
    买入300581.SZA
    日期2021-02-04 持仓 {'000768.SZA': StockPosition(bkt000,000768.SZA,long,current_qty:3000,avail_qty:3000,cost_price:33.03,last_price:32.300003), '002709.SZA': StockPosition(bkt000,002709.SZA,long,current_qty:900,avail_qty:900,cost_price:103.34,last_price:103.840004), '002812.SZA': StockPosition(bkt000,002812.SZA,long,current_qty:700,avail_qty:700,cost_price:139.9,last_price:135.57), '002920.SZA': StockPosition(bkt000,002920.SZA,long,current_qty:800,avail_qty:800,cost_price:113.68,last_price:114.8), '300581.SZA': StockPosition(bkt000,300581.SZA,long,current_qty:2700,avail_qty:2700,cost_price:37.39,last_price:35.589996)} -----------
    止损成功, 止损标的002812.SZA
    止损成功, 止损标的300581.SZA
    2021-02-04 =======早盘计划买入股票 ['000768.SZA', '002709.SZA', '002812.SZA', '002920.SZA', '300759.SZA']
    买入000768.SZA
    买入002709.SZA
    买入002920.SZA
    买入300759.SZA
    止损成功, 止损标的002709.SZA
    止损成功, 止损标的002920.SZA
    止损成功, 止损标的000768.SZA
    日期2021-02-05 持仓 {'000768.SZA': StockPosition(bkt000,000768.SZA,long,current_qty:3000,avail_qty:3000,cost_price:32.705,last_price:31.67), '002709.SZA': StockPosition(bkt000,002709.SZA,long,current_qty:900,avail_qty:900,cost_price:103.425,last_price:96.13999), '002920.SZA': StockPosition(bkt000,002920.SZA,long,current_qty:800,avail_qty:800,cost_price:113.46,last_price:109.73999), '300759.SZA': StockPosition(bkt000,300759.SZA,long,current_qty:600,avail_qty:600,cost_price:151.0,last_price:150.50002)} -----------
    止损成功, 止损标的002709.SZA
    止损成功, 止损标的002920.SZA
    2021-02-05 =======早盘计划买入股票 ['000768.SZA', '002497.SZA', '002709.SZA', '002812.SZA', '002920.SZA']
    买入000768.SZA
    买入002497.SZA
    买入002812.SZA
    止损成功, 止损标的000768.SZA
    止盈成功, 止盈标的300759.SZA
    日期2021-02-08 持仓 {'000768.SZA': StockPosition(bkt000,000768.SZA,long,current_qty:3000,avail_qty:3000,cost_price:32.408,last_price:30.660002), '002497.SZA': StockPosition(bkt000,002497.SZA,long,current_qty:4500,avail_qty:4500,cost_price:21.6,last_price:20.2), '002812.SZA': StockPosition(bkt000,002812.SZA,long,current_qty:700,avail_qty:700,cost_price:137.75,last_price:131.79001)} -----------
    止损成功, 止损标的000768.SZA
    止损成功, 止损标的002497.SZA
    止损成功, 止损标的002812.SZA
    2021-02-08 =======早盘计划买入股票 ['000768.SZA', '002709.SZA', '002812.SZA', '002821.SZA', '002920.SZA']
    买入002709.SZA
    买入002821.SZA
    买入002920.SZA
    日期2021-02-09 持仓 {'002709.SZA': StockPosition(bkt000,002709.SZA,long,current_qty:1000,avail_qty:1000,cost_price:95.75,last_price:98.99), '002821.SZA': StockPosition(bkt000,002821.SZA,long,current_qty:300,avail_qty:300,cost_price:314.79,last_price:328.58), '002920.SZA': StockPosition(bkt000,002920.SZA,long,current_qty:800,avail_qty:800,cost_price:110.17,last_price:111.92)} -----------
    止盈成功, 止盈标的002821.SZA
    2021-02-09 =======早盘计划买入股票 ['000768.SZA', '002709.SZA', '002821.SZA', '002920.SZA', '300685.SZA']
    买入000768.SZA
    买入002709.SZA
    买入002920.SZA
    买入300685.SZA
    止盈成功, 止盈标的002709.SZA
    止损成功, 止损标的002920.SZA
    日期2021-02-10 持仓 {'002709.SZA': StockPosition(bkt000,002709.SZA,long,current_qty:900,avail_qty:900,cost_price:97.602,last_price:102.0), '002920.SZA': StockPosition(bkt000,002920.SZA,long,current_qty:800,avail_qty:800,cost_price:111.365,last_price:109.7), '000768.SZA': StockPosition(bkt000,000768.SZA,long,current_qty:3200,avail_qty:3200,cost_price:30.86,last_price:32.24), '300685.SZA': StockPosition(bkt000,300685.SZA,long,current_qty:1100,avail_qty:1100,cost_price:84.37,last_price:92.11)} -----------
    止盈成功, 止盈标的300685.SZA
    2021-02-10 =======早盘计划买入股票 ['000768.SZA', '002709.SZA', '002821.SZA', '002920.SZA', '300581.SZA']
    买入000768.SZA
    买入002709.SZA
    买入002821.SZA
    买入002920.SZA
    买入300581.SZA
    止损成功, 止损标的002920.SZA
    2021-02-10 14:55:00 尾盘卖出002709.SZA 900
    2021-02-10 14:55:00 尾盘卖出000768.SZA 3200
    日期2021-02-18 持仓 {'002709.SZA': StockPosition(bkt000,002709.SZA,long,current_qty:900,avail_qty:900,cost_price:99.896,last_price:100.0), '002920.SZA': StockPosition(bkt000,002920.SZA,long,current_qty:900,avail_qty:900,cost_price:110.431,last_price:111.549995), '000768.SZA': StockPosition(bkt000,000768.SZA,long,current_qty:3100,avail_qty:3100,cost_price:31.377,last_price:31.640001), '002821.SZA': StockPosition(bkt000,002821.SZA,long,current_qty:300,avail_qty:300,cost_price:328.11,last_price:329.34998), '300581.SZA': StockPosition(bkt000,300581.SZA,long,current_qty:2700,avail_qty:2700,cost_price:36.5,last_price:35.249996)} -----------
    2021-02-18 =======早盘计划买入股票 ['000768.SZA', '002812.SZA', '002920.SZA', '300685.SZA', '600703.SHA']
    买入000768.SZA
    买入002812.SZA
    买入002920.SZA
    买入300685.SZA
    买入600703.SHA
    止损成功, 止损标的300581.SZA
    止损成功, 止损标的002709.SZA
    止损成功, 止损标的002821.SZA
    2021-02-18 14:55:00 尾盘卖出002920.SZA 900
    2021-02-18 14:55:00 尾盘卖出000768.SZA 3100
    日期2021-02-19 持仓 {'002920.SZA': StockPosition(bkt000,002920.SZA,long,current_qty:800,avail_qty:800,cost_price:112.12,last_price:113.48999), '000768.SZA': StockPosition(bkt000,000768.SZA,long,current_qty:3100,avail_qty:3100,cost_price:31.748,last_price:32.100002), '002812.SZA': StockPosition(bkt000,002812.SZA,long,current_qty:600,avail_qty:600,cost_price:147.23,last_price:133.02), '300685.SZA': StockPosition(bkt000,300685.SZA,long,current_qty:1000,avail_qty:1000,cost_price:94.31,last_price:83.02), '600703.SHA': StockPosition(bkt000,600703.SHA,long,current_qty:3400,avail_qty:3400,cost_price:28.84,last_price:29.460001)} -----------
    止损成功, 止损标的002812.SZA
    止损成功, 止损标的300685.SZA
    2021-02-19 =======早盘计划买入股票 ['000768.SZA', '002812.SZA', '002920.SZA', '300014.SZA', '300576.SZA']
    买入000768.SZA
    买入002920.SZA
    买入300014.SZA
    买入300576.SZA
    止损成功, 止损标的002920.SZA
    止盈成功, 止盈标的600703.SHA
    2021-02-19 14:55:00 尾盘卖出000768.SZA 3100
    日期2021-02-22 持仓 {'002920.SZA': StockPosition(bkt000,002920.SZA,long,current_qty:800,avail_qty:800,cost_price:111.855,last_price:102.14), '000768.SZA': StockPosition(bkt000,000768.SZA,long,current_qty:3000,avail_qty:3000,cost_price:31.882,last_price:32.329998), '300014.SZA': StockPosition(bkt000,300014.SZA,long,current_qty:900,avail_qty:900,cost_price:100.04,last_price:97.5), '300576.SZA': StockPosition(bkt000,300576.SZA,long,current_qty:2600,avail_qty:2600,cost_price:37.34,last_price:40.87)} -----------
    止损成功, 止损标的002920.SZA
    止盈成功, 止盈标的300576.SZA
    2021-02-22 =======早盘计划买入股票 ['000768.SZA', '002812.SZA', '002920.SZA', '300014.SZA', '300576.SZA']
    买入000768.SZA
    买入002812.SZA
    买入300014.SZA
    止损成功, 止损标的000768.SZA
    止损成功, 止损标的300014.SZA
    日期2021-02-23 持仓 {'000768.SZA': StockPosition(bkt000,000768.SZA,long,current_qty:3000,avail_qty:3000,cost_price:31.891,last_price:30.880001), '300014.SZA': StockPosition(bkt000,300014.SZA,long,current_qty:900,avail_qty:900,cost_price:99.4,last_price:93.77), '002812.SZA': StockPosition(bkt000,002812.SZA,long,current_qty:800,avail_qty:800,cost_price:121.19,last_price:116.0)} -----------
    2021-02-23 开盘卖出000768.SZA 3000
    2021-02-23 开盘卖出300014.SZA 900
    2021-02-23 开盘卖出002812.SZA 800
    2021-02-23 =======早盘计划买入股票 ['000768.SZA', '002812.SZA', '300014.SZA', '300576.SZA', '600703.SHA']
    买入300576.SZA
    买入600703.SHA
    日期2021-02-24 持仓 {'300576.SZA': StockPosition(bkt000,300576.SZA,long,current_qty:2200,avail_qty:2200,cost_price:41.78,last_price:42.320004), '600703.SHA': StockPosition(bkt000,600703.SHA,long,current_qty:3400,avail_qty:3400,cost_price:27.75,last_price:28.04)} -----------
    2021-02-24 开盘卖出300576.SZA 2200
    2021-02-24 开盘卖出600703.SHA 3400
    2021-02-24 =======早盘计划买入股票 ['000768.SZA', '002497.SZA', '300014.SZA', '300576.SZA', '600703.SHA']
    买入000768.SZA
    买入002497.SZA
    买入300014.SZA
    日期2021-02-25 持仓 {'000768.SZA': StockPosition(bkt000,000768.SZA,long,current_qty:2900,avail_qty:2900,cost_price:32.94,last_price:32.15), '002497.SZA': StockPosition(bkt000,002497.SZA,long,current_qty:4600,avail_qty:4600,cost_price:20.59,last_price:19.37), '300014.SZA': StockPosition(bkt000,300014.SZA,long,current_qty:1000,avail_qty:1000,cost_price:93.35,last_price:88.5)} -----------
    2021-02-25 开盘卖出000768.SZA 2900
    2021-02-25 开盘卖出002497.SZA 4600
    2021-02-25 开盘卖出300014.SZA 1000
    2021-02-25 =======早盘计划买入股票 ['000768.SZA', '002497.SZA', '300014.SZA', '300496.SZA', '300576.SZA']
    买入300496.SZA
    买入300576.SZA
    日期2021-02-26 持仓 {'300496.SZA': StockPosition(bkt000,300496.SZA,long,current_qty:700,avail_qty:700,cost_price:127.31,last_price:123.10999), '300576.SZA': StockPosition(bkt000,300576.SZA,long,current_qty:2100,avail_qty:2100,cost_price:44.6,last_price:43.51)} -----------
    2021-02-26 开盘卖出300496.SZA 700
    2021-02-26 开盘卖出300576.SZA 2100
    2021-02-26 =======早盘计划买入股票 ['000768.SZA', '002906.SZA', '300014.SZA', '300357.SZA', '300496.SZA']
    买入000768.SZA
    买入002906.SZA
    买入300014.SZA
    买入300357.SZA
    日期2021-03-01 持仓 {'000768.SZA': StockPosition(bkt000,000768.SZA,long,current_qty:2900,avail_qty:2900,cost_price:32.43,last_price:31.67), '002906.SZA': StockPosition(bkt000,002906.SZA,long,current_qty:3200,avail_qty:3200,cost_price:29.39,last_price:28.59), '300014.SZA': StockPosition(bkt000,300014.SZA,long,current_qty:1000,avail_qty:1000,cost_price:85.66,last_price:85.5), '300357.SZA': StockPosition(bkt000,300357.SZA,long,current_qty:1200,avail_qty:1200,cost_price:77.44,last_price:75.15)} -----------
    2021-03-01 开盘卖出000768.SZA 2900
    2021-03-01 开盘卖出002906.SZA 3200
    2021-03-01 开盘卖出300014.SZA 1000
    2021-03-01 开盘卖出300357.SZA 1200
    2021-03-01 =======早盘计划买入股票 ['000768.SZA', '300014.SZA', '300357.SZA', '300496.SZA', '300576.SZA']
    买入300496.SZA
    买入300576.SZA
    
    • 收益率-6.42%
    • 年化收益率nan%
    • 基准收益率0.02%
    • 阿尔法-0.68
    • 贝塔0.47
    • 夏普比率-6.15
    • 胜率0.18
    • 盈亏比0.5
    • 收益波动率17.2%
    • 信息比率-0.43
    • 最大回撤8.3%
    bigcharts-data-start/{"__type":"tabs","__id":"bigchart-bddb4d1a3b434107a3f53f395f1690e5"}/bigcharts-data-end