业绩暴雷指数-股票黑名单收益

策略分享
标签: #<Tag:0x00007fb3dfeb53f8>

(think) #1

我们来跟踪一下券商股票黑名/业绩暴雷股票 A股上市公司股票黑名单 的收益情况。

  1. 设置股票为 A股上市公司股票黑名单 这里的股票代码
  2. 自定义买入:在第一天等量买入这些股票
# 用户自定义买入函数
def bigquant_run(context, data, input_1, input_2, param_1, param_2, param_3):
    if context.trading_day_index > 0:
        # 只在第一天建立仓位
        return

    instrument_data = context.options['data'].read()
    for instrument in instrument_data['instruments']:
        context.order_target_percent(context.symbol(instrument), 1.0 / len(instrument_data['instruments']))

    return True
  1. 结果:稳定的跑赢大盘 😢

完整策略

克隆策略

    {"Description":"实验创建于2017/8/26","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-120:instruments","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"DestinationInputPortId":"-120:options_data","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-62:data"},{"DestinationInputPortId":"-120:handle_bar_functions","SourceOutputPortId":"-141:functions"}],"ModuleNodes":[{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-62","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2019-01-30","ValueType":"Literal","LinkedGlobalParameter":"交易日期"},{"Name":"end_date","Value":"2019-03-07","ValueType":"Literal","LinkedGlobalParameter":"交易日期"},{"Name":"market","Value":"CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_list","Value":"300269.SZA\n600267.SHA\n600598.SHA\n002763.SZA\n300117.SZA\n601519.SHA\n000691.SZA\n000922.SZA\n601777.SHA\n002574.SZA\n300267.SZA\n000636.SZA\n300056.SZA\n300043.SZA\n601808.SHA\n000933.SZA\n600397.SHA\n601106.SHA\n600121.SHA\n601558.SHA\n002180.SZA\n002181.SZA\n600165.SHA\n002312.SZA\n600594.SHA\n603169.SHA\n002333.SZA\n300362.SZA\n002464.SZA\n002759.SZA\n002188.SZA\n000971.SZA\n002354.SZA\n600721.SHA\n002247.SZA\n002113.SZA\n000662.SZA\n002619.SZA\n300143.SZA\n300299.SZA\n600242.SHA\n000976.SZA\n000526.SZA\n002072.SZA\n000835.SZA\n600898.SHA\n600682.SHA\n002071.SZA\n002647.SZA\n002437.SZA\n000697.SZA\n603518.SHA\n002384.SZA\n600525.SHA\n600011.SHA\n002102.SZA\n600751.SHA\n600699.SHA\n600094.SHA\n300148.SZA\n600157.SHA\n002434.SZA\n300008.SZA\n600654.SHA\n002491.SZA\n002342.SZA\n300702.SZA\n600074.SHA\n002490.SZA\n000798.SZA\n600710.SHA\n600812.SHA\n300255.SZA\n300072.SZA\n300137.SZA\n000042.SZA\n601717.SHA\n600532.SHA\n600654.SHA\n000898.SZA\n600010.SHA\n600804.SHA\n600983.SHA\n002715.SZA\n300208.SZA\n300431.SZA\n600418.SHA\n002113.SZA\n002384.SZA\n002426.SZA\n002684.SZA\n002667.SZA\n600250.SHA\n600807.SHA\n002306.SZA\n600281.SHA\n002569.SZA\n600155.SHA\n600598.SHA\n600076.SHA\n300277.SZA\n300268.SZA\n002323.SZA\n000972.SZA\n600575.SHA\n002769.SZA\n002252.SZA\n603168.SHA\n002076.SZA\n603355.SHA\n603777.SHA\n000732.SZA\n600225.SHA\n002721.SZA\n600759.SHA\n600399.SHA\n300156.SZA\n000820.SZA\n002011.SZA\n002226.SZA\n002366.SZA\n000422.SZA\n000707.SZA\n002069.SZA\n603988.SHA\n002089.SZA\n300166.SZA\n600079.SHA\n600880.SHA\n002162.SZA\n000806.SZA\n600112.SHA\n601012.SHA\n600887.SHA\n300426.SZA\n600207.SHA\n600100.SHA\n300663.SZA\n002231.SZA\n000545.SZA\n002477.SZA\n002164.SZA\n002431.SZA\n000662.SZA\n002002.SZA\n000980.SZA\n000518.SZA\n002147.SZA\n603389.SHA\n002131.SZA\n300266.SZA\n000673.SZA\n000576.SZA\n002621.SZA\n600290.SHA\n603032.SHA\n600614.SHA\n600256.SHA\n603568.SHA\n600868.SHA\n002617.SZA\n300676.SZA\n000039.SZA\n600226.SHA\n600146.SHA\n002239.SZA\n002143.SZA\n002292.SZA\n600249.SHA\n002571.SZA\n300364.SZA\n002445.SZA\n002576.SZA\n600240.SHA\n600666.SHA\n002118.SZA\n002512.SZA\n002602.SZA\n000018.SZA\n300116.SZA\n600518.SHA\n000802.SZA\n300027.SZA\n002442.SZA\n300106.SZA\n002735.SZA\n300050.SZA\n300688.SZA\n002584.SZA\n002413.SZA\n000040.SZA\n000413.SZA\n002486.SZA\n600771.SHA\n000793.SZA\n002519.SZA\n002573.SZA\n300004.SZA\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,"Comment":"预测数据,用于回测和模拟","CommentCollapsed":false},{"Id":"-120","ModuleId":"BigQuantSpace.tradex.tradex-v1","ModuleParameters":[{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"handle_data","Value":"# 回测引擎:每日数据处理函数,每天执行一次\ndef bigquant_run(context, data):\n # curr_data:用于当前handle_bar,各处理函数可以用 curr_data 传递数据\n context.curr_data = {}\n if 'handle_bar_functions' in context.options:\n for func in context.options['handle_bar_functions']:\n if not func(context, data):\n # 如果有处理函数返回False,则表示跳过后续执行\n return\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"prepare","Value":"# 回测引擎:准备数据,只执行一次\ndef bigquant_run(context):\n pass\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"initialize","Value":"# 回测引擎:初始化函数,只执行一次\ndef bigquant_run(context):\n if 'initialize_functions' in context.options:\n for func in context.options['initialize_functions']:\n if not func(context):\n # 如果有处理函数返回False,则表示跳过后续执行\n return\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"before_trading_start","Value":"# 回测引擎:每个单位时间开始前调用一次,即每日开盘前调用一次。\ndef bigquant_run(context, data):\n pass\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"volume_limit","Value":0.025,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"order_price_field_buy","Value":"open","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"order_price_field_sell","Value":"close","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"capital_base","Value":"100000000","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}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-120"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"history_ds","NodeId":"-120"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"benchmark","NodeId":"-120"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"trading_calendar","NodeId":"-120"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"initialize_functions","NodeId":"-120"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"handle_bar_functions","NodeId":"-120"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"options_data","NodeId":"-120"}],"OutputPortsInternal":[{"Name":"raw_perf","NodeId":"-120","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":1,"Comment":"","CommentCollapsed":true},{"Id":"-141","ModuleId":"BigQuantSpace.trade_func_customized_buy.trade_func_customized_buy-v1","ModuleParameters":[{"Name":"func","Value":"# 用户自定义买入函数\ndef bigquant_run(context, data, input_1, input_2, param_1, param_2, param_3):\n if context.trading_day_index > 0:\n # 只在第一天建立仓位\n return\n\n instrument_data = context.options['data'].read()\n for instrument in instrument_data['instruments']:\n context.order_target_percent(context.symbol(instrument), 1.0 / len(instrument_data['instruments']))\n\n return True\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"param_1","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"param_2","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"param_3","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_functions","NodeId":"-141"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_1","NodeId":"-141"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_2","NodeId":"-141"}],"OutputPortsInternal":[{"Name":"functions","NodeId":"-141","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":2,"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-62' Position='880.39990234375,672.5999755859375,200,200'/><NodePosition Node='-120' Position='879.5179443359375,818.6300048828125,200,200'/><NodePosition Node='-141' Position='1184.2178955078125,683.3300170898438,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 [8]:
    # 本代码由可视化策略环境自动生成 2019年3月7日 19:34
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # 用户自定义买入函数
    def m2_func_bigquant_run(context, data, input_1, input_2, param_1, param_2, param_3):
        if context.trading_day_index > 0:
            # 只在第一天建立仓位
            return
    
        instrument_data = context.options['data'].read()
        for instrument in instrument_data['instruments']:
            context.order_target_percent(context.symbol(instrument), 1.0 / len(instrument_data['instruments']))
    
        return True
    
    # 回测引擎:每日数据处理函数,每天执行一次
    def m1_handle_data_bigquant_run(context, data):
        # curr_data:用于当前handle_bar,各处理函数可以用 curr_data 传递数据
        context.curr_data = {}
        if 'handle_bar_functions' in context.options:
            for func in context.options['handle_bar_functions']:
                if not func(context, data):
                    # 如果有处理函数返回False,则表示跳过后续执行
                    return
    
    # 回测引擎:准备数据,只执行一次
    def m1_prepare_bigquant_run(context):
        pass
    
    # 回测引擎:初始化函数,只执行一次
    def m1_initialize_bigquant_run(context):
        if 'initialize_functions' in context.options:
            for func in context.options['initialize_functions']:
                if not func(context):
                    # 如果有处理函数返回False,则表示跳过后续执行
                    return
    
    # 回测引擎:每个单位时间开始前调用一次,即每日开盘前调用一次。
    def m1_before_trading_start_bigquant_run(context, data):
        pass
    
    
    m9 = M.instruments.v2(
        start_date=T.live_run_param('trading_date', '2019-01-30'),
        end_date=T.live_run_param('trading_date', '2019-03-07'),
        market='CN_STOCK_A',
        instrument_list="""300269.SZA
    600267.SHA
    600598.SHA
    002763.SZA
    300117.SZA
    601519.SHA
    000691.SZA
    000922.SZA
    601777.SHA
    002574.SZA
    300267.SZA
    000636.SZA
    300056.SZA
    300043.SZA
    601808.SHA
    000933.SZA
    600397.SHA
    601106.SHA
    600121.SHA
    601558.SHA
    002180.SZA
    002181.SZA
    600165.SHA
    002312.SZA
    600594.SHA
    603169.SHA
    002333.SZA
    300362.SZA
    002464.SZA
    002759.SZA
    002188.SZA
    000971.SZA
    002354.SZA
    600721.SHA
    002247.SZA
    002113.SZA
    000662.SZA
    002619.SZA
    300143.SZA
    300299.SZA
    600242.SHA
    000976.SZA
    000526.SZA
    002072.SZA
    000835.SZA
    600898.SHA
    600682.SHA
    002071.SZA
    002647.SZA
    002437.SZA
    000697.SZA
    603518.SHA
    002384.SZA
    600525.SHA
    600011.SHA
    002102.SZA
    600751.SHA
    600699.SHA
    600094.SHA
    300148.SZA
    600157.SHA
    002434.SZA
    300008.SZA
    600654.SHA
    002491.SZA
    002342.SZA
    300702.SZA
    600074.SHA
    002490.SZA
    000798.SZA
    600710.SHA
    600812.SHA
    300255.SZA
    300072.SZA
    300137.SZA
    000042.SZA
    601717.SHA
    600532.SHA
    600654.SHA
    000898.SZA
    600010.SHA
    600804.SHA
    600983.SHA
    002715.SZA
    300208.SZA
    300431.SZA
    600418.SHA
    002113.SZA
    002384.SZA
    002426.SZA
    002684.SZA
    002667.SZA
    600250.SHA
    600807.SHA
    002306.SZA
    600281.SHA
    002569.SZA
    600155.SHA
    600598.SHA
    600076.SHA
    300277.SZA
    300268.SZA
    002323.SZA
    000972.SZA
    600575.SHA
    002769.SZA
    002252.SZA
    603168.SHA
    002076.SZA
    603355.SHA
    603777.SHA
    000732.SZA
    600225.SHA
    002721.SZA
    600759.SHA
    600399.SHA
    300156.SZA
    000820.SZA
    002011.SZA
    002226.SZA
    002366.SZA
    000422.SZA
    000707.SZA
    002069.SZA
    603988.SHA
    002089.SZA
    300166.SZA
    600079.SHA
    600880.SHA
    002162.SZA
    000806.SZA
    600112.SHA
    601012.SHA
    600887.SHA
    300426.SZA
    600207.SHA
    600100.SHA
    300663.SZA
    002231.SZA
    000545.SZA
    002477.SZA
    002164.SZA
    002431.SZA
    000662.SZA
    002002.SZA
    000980.SZA
    000518.SZA
    002147.SZA
    603389.SHA
    002131.SZA
    300266.SZA
    000673.SZA
    000576.SZA
    002621.SZA
    600290.SHA
    603032.SHA
    600614.SHA
    600256.SHA
    603568.SHA
    600868.SHA
    002617.SZA
    300676.SZA
    000039.SZA
    600226.SHA
    600146.SHA
    002239.SZA
    002143.SZA
    002292.SZA
    600249.SHA
    002571.SZA
    300364.SZA
    002445.SZA
    002576.SZA
    600240.SHA
    600666.SHA
    002118.SZA
    002512.SZA
    002602.SZA
    000018.SZA
    300116.SZA
    600518.SHA
    000802.SZA
    300027.SZA
    002442.SZA
    300106.SZA
    002735.SZA
    300050.SZA
    300688.SZA
    002584.SZA
    002413.SZA
    000040.SZA
    000413.SZA
    002486.SZA
    600771.SHA
    000793.SZA
    002519.SZA
    002573.SZA
    300004.SZA
    """,
        max_count=0
    )
    
    m2 = M.trade_func_customized_buy.v1(
        func=m2_func_bigquant_run,
        param_1='',
        param_2='',
        param_3=''
    )
    
    m1 = M.tradex.v1(
        instruments=m9.data,
        handle_bar_functions=m2.functions,
        options_data=m9.data,
        start_date='',
        end_date='',
        handle_data=m1_handle_data_bigquant_run,
        prepare=m1_prepare_bigquant_run,
        initialize=m1_initialize_bigquant_run,
        before_trading_start=m1_before_trading_start_bigquant_run,
        volume_limit=0.025,
        order_price_field_buy='open',
        order_price_field_sell='close',
        capital_base=100000000,
        auto_cancel_non_tradable_orders=True,
        data_frequency='daily',
        price_type='真实价格',
        product_type='股票',
        plot_charts=True,
        backtest_only=False
    )
    
    • 收益率40.48%
    • 年化收益率4807.6%
    • 基准收益率19.25%
    • 阿尔法2.83
    • 贝塔0.54
    • 夏普比率16.37
    • 胜率1.0
    • 盈亏比0.0
    • 收益波动率23.95%
    • 信息比率0.52
    • 最大回撤1.02%

    (bravo) #2

    暴雷发生在1月底前,回测起始时利空基本被市场消化完毕,所以无法看出暴雷事件的空头效应