【自定义因子】构建个股相对大盘收益率因子


(iQuant) #1
克隆策略

    {"Description":"实验创建于2019/1/21","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-228:input_data","SourceOutputPortId":"-106:data"},{"DestinationInputPortId":"-204:features","SourceOutputPortId":"-131:data"},{"DestinationInputPortId":"-266:columns_ds","SourceOutputPortId":"-131:data"},{"DestinationInputPortId":"-106:features","SourceOutputPortId":"-150:data"},{"DestinationInputPortId":"-242:columns_ds","SourceOutputPortId":"-150:data"},{"DestinationInputPortId":"-204:instruments","SourceOutputPortId":"-154:data"},{"DestinationInputPortId":"-106:instruments","SourceOutputPortId":"-184:data"},{"DestinationInputPortId":"-528:input_data","SourceOutputPortId":"-197:data"},{"DestinationInputPortId":"-248:input_data","SourceOutputPortId":"-204:data"},{"DestinationInputPortId":"-242:input_ds","SourceOutputPortId":"-228:data"},{"DestinationInputPortId":"-197:data1","SourceOutputPortId":"-242:data"},{"DestinationInputPortId":"-266:input_ds","SourceOutputPortId":"-248:data"},{"DestinationInputPortId":"-248:features","SourceOutputPortId":"-256:data"},{"DestinationInputPortId":"-197:data2","SourceOutputPortId":"-266:data"},{"DestinationInputPortId":"-228:features","SourceOutputPortId":"-271:data"},{"DestinationInputPortId":"-528:features","SourceOutputPortId":"-546:data"}],"ModuleNodes":[{"Id":"-106","ModuleId":"BigQuantSpace.use_datasource.use_datasource-v1","ModuleParameters":[{"Name":"datasource_id","Value":"bar1d_index_CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"start_date","Value":"2015-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2018-01-01","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-106"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-106"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-106","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":1,"IsPartOfPartialRun":null,"Comment":"bar1d_index_CN_STOCK_A表中抽取指数close数据","CommentCollapsed":false},{"Id":"-131","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nclose\nopen\nlow\nhigh\nadjust_factor","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-131"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-131","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":5,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-150","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nclose\ninstrument\n\n","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-150"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-150","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":3,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-154","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2015-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2018-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"market","Value":"CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_list","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_count","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"rolling_conf","NodeId":"-154"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-154","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":6,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-184","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2015-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2018-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"market","Value":"CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_list","Value":"000300.HIX","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_count","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"rolling_conf","NodeId":"-184"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-184","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-197","ModuleId":"BigQuantSpace.join.join-v3","ModuleParameters":[{"Name":"on","Value":"date","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":"-197"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"data2","NodeId":"-197"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-197","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":8,"IsPartOfPartialRun":null,"Comment":"合并股票真实价格和大盘5日收益率","CommentCollapsed":false},{"Id":"-204","ModuleId":"BigQuantSpace.use_datasource.use_datasource-v1","ModuleParameters":[{"Name":"datasource_id","Value":"bar1d_CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-204"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-204"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-204","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"IsPartOfPartialRun":null,"Comment":"bar1d_CN_STOCK_A表中抽取全市场股票的基础行情数据","CommentCollapsed":false},{"Id":"-228","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":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"remove_extra_columns","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_functions","Value":"{}","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-228"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-228"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-228","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":7,"IsPartOfPartialRun":null,"Comment":"计算指数5日收益率","CommentCollapsed":false},{"Id":"-242","ModuleId":"BigQuantSpace.select_columns.select_columns-v3","ModuleParameters":[{"Name":"columns","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"reverse_select","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_ds","NodeId":"-242"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"columns_ds","NodeId":"-242"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-242","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":9,"IsPartOfPartialRun":null,"Comment":"过滤指定的列","CommentCollapsed":false},{"Id":"-248","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":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"remove_extra_columns","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_functions","Value":"{}","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-248"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-248"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-248","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":11,"IsPartOfPartialRun":null,"Comment":"抽取真实价格","CommentCollapsed":false},{"Id":"-256","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nstockret=close/shift(close,5)-1","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-256"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-256","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":12,"IsPartOfPartialRun":null,"Comment":"表达式引擎计算个股过去5日收益率","CommentCollapsed":false},{"Id":"-266","ModuleId":"BigQuantSpace.select_columns.select_columns-v3","ModuleParameters":[{"Name":"columns","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"reverse_select","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_ds","NodeId":"-266"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"columns_ds","NodeId":"-266"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-266","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":14,"IsPartOfPartialRun":null,"Comment":"过滤指定的列","CommentCollapsed":false},{"Id":"-271","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nbmret=close/shift(close,5)-1\n","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-271"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-271","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":15,"IsPartOfPartialRun":null,"Comment":"表达式引擎因子计算5日收益率","CommentCollapsed":false},{"Id":"-528","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":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"remove_extra_columns","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_functions","Value":"{}","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-528"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-528"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-528","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":17,"IsPartOfPartialRun":null,"Comment":"抽取相对收益率","CommentCollapsed":false},{"Id":"-546","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nrelative_ret=stockret-bmret","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-546"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-546","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":18,"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='-106' Position='-750,91,200,200'/><NodePosition Node='-131' Position='96,-6,200,200'/><NodePosition Node='-150' Position='-558,-17,200,200'/><NodePosition Node='-154' Position='-248,-14,200,200'/><NodePosition Node='-184' Position='-900,-15,200,200'/><NodePosition Node='-197' Position='-180,467,200,200'/><NodePosition Node='-204' Position='-99,110,200,200'/><NodePosition Node='-228' Position='-534,230,200,200'/><NodePosition Node='-242' Position='-491,343,200,200'/><NodePosition Node='-248' Position='38,227,200,200'/><NodePosition Node='-256' Position='202,109,200,200'/><NodePosition Node='-266' Position='187.4876708984375,339.3773498535156,200,200'/><NodePosition Node='-271' Position='-426,130,200,200'/><NodePosition Node='-528' Position='-38,589,200,200'/><NodePosition Node='-546' Position='131,505,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 [43]:
    # 本代码由可视化策略环境自动生成 2019年1月30日 15:19
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m5 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    close
    open
    low
    high
    adjust_factor"""
    )
    
    m3 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    close
    instrument
    
    """
    )
    
    m6 = M.instruments.v2(
        start_date='2015-01-01',
        end_date='2018-01-01',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m4 = M.use_datasource.v1(
        instruments=m6.data,
        features=m5.data,
        datasource_id='bar1d_CN_STOCK_A',
        start_date='',
        end_date=''
    )
    
    m2 = M.instruments.v2(
        start_date='2015-01-01',
        end_date='2018-01-01',
        market='CN_STOCK_A',
        instrument_list='000300.HIX',
        max_count=0
    )
    
    m1 = M.use_datasource.v1(
        instruments=m2.data,
        features=m3.data,
        datasource_id='bar1d_index_CN_STOCK_A',
        start_date='2015-01-01',
        end_date='2018-01-01',
        m_cached=False
    )
    
    m12 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    stockret=close/shift(close,5)-1"""
    )
    
    m11 = M.derived_feature_extractor.v3(
        input_data=m4.data,
        features=m12.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    
    m14 = M.select_columns.v3(
        input_ds=m11.data,
        columns_ds=m5.data,
        columns='',
        reverse_select=True
    )
    
    m15 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    bmret=close/shift(close,5)-1
    """
    )
    
    m7 = M.derived_feature_extractor.v3(
        input_data=m1.data,
        features=m15.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    
    m9 = M.select_columns.v3(
        input_ds=m7.data,
        columns_ds=m3.data,
        columns='',
        reverse_select=True
    )
    
    m8 = M.join.v3(
        data1=m9.data,
        data2=m14.data,
        on='date',
        how='inner',
        sort=False
    )
    
    m18 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    relative_ret=stockret-bmret"""
    )
    
    m17 = M.derived_feature_extractor.v3(
        input_data=m8.data,
        features=m18.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    
    [2019-01-30 15:16:05.849510] INFO: bigquant: input_features.v1 开始运行..
    [2019-01-30 15:16:05.877396] INFO: bigquant: 命中缓存
    [2019-01-30 15:16:05.878507] INFO: bigquant: input_features.v1 运行完成[0.02901s].
    [2019-01-30 15:16:05.881706] INFO: bigquant: input_features.v1 开始运行..
    [2019-01-30 15:16:05.889688] INFO: bigquant: 命中缓存
    [2019-01-30 15:16:05.891005] INFO: bigquant: input_features.v1 运行完成[0.009339s].
    [2019-01-30 15:16:05.894118] INFO: bigquant: instruments.v2 开始运行..
    [2019-01-30 15:16:05.900310] INFO: bigquant: 命中缓存
    [2019-01-30 15:16:05.901428] INFO: bigquant: instruments.v2 运行完成[0.007318s].
    [2019-01-30 15:16:05.904185] INFO: bigquant: use_datasource.v1 开始运行..
    [2019-01-30 15:16:05.909892] INFO: bigquant: 命中缓存
    [2019-01-30 15:16:05.910868] INFO: bigquant: use_datasource.v1 运行完成[0.006695s].
    [2019-01-30 15:16:05.913153] INFO: bigquant: instruments.v2 开始运行..
    [2019-01-30 15:16:05.978230] INFO: bigquant: 命中缓存
    [2019-01-30 15:16:05.979590] INFO: bigquant: instruments.v2 运行完成[0.066406s].
    [2019-01-30 15:16:05.982358] INFO: bigquant: use_datasource.v1 开始运行..
    [2019-01-30 15:16:06.306435] INFO: bigquant: use_datasource.v1 运行完成[0.324067s].
    [2019-01-30 15:16:06.309129] INFO: bigquant: input_features.v1 开始运行..
    [2019-01-30 15:16:06.314538] INFO: bigquant: 命中缓存
    [2019-01-30 15:16:06.315499] INFO: bigquant: input_features.v1 运行完成[0.006373s].
    [2019-01-30 15:16:06.318564] INFO: bigquant: derived_feature_extractor.v3 开始运行..
    [2019-01-30 15:16:06.323535] INFO: bigquant: 命中缓存
    [2019-01-30 15:16:06.324371] INFO: bigquant: derived_feature_extractor.v3 运行完成[0.005809s].
    [2019-01-30 15:16:06.327886] INFO: bigquant: select_columns.v3 开始运行..
    [2019-01-30 15:16:06.332565] INFO: bigquant: 命中缓存
    [2019-01-30 15:16:06.333360] INFO: bigquant: select_columns.v3 运行完成[0.005469s].
    [2019-01-30 15:16:06.335265] INFO: bigquant: input_features.v1 开始运行..
    [2019-01-30 15:16:06.339582] INFO: bigquant: 命中缓存
    [2019-01-30 15:16:06.340548] INFO: bigquant: input_features.v1 运行完成[0.005281s].
    [2019-01-30 15:16:06.342588] INFO: bigquant: derived_feature_extractor.v3 开始运行..
    [2019-01-30 15:16:06.363115] INFO: derived_feature_extractor: 提取完成 bmret=close/shift(close,5)-1, 0.003s
    [2019-01-30 15:16:06.406837] INFO: derived_feature_extractor: /data, 732
    [2019-01-30 15:16:06.425306] INFO: bigquant: derived_feature_extractor.v3 运行完成[0.082683s].
    [2019-01-30 15:16:06.428096] INFO: bigquant: select_columns.v3 开始运行..
    列: ['close', 'instrument']
    /data: 732
    [2019-01-30 15:16:06.516838] INFO: bigquant: select_columns.v3 运行完成[0.08872s].
    [2019-01-30 15:16:06.519281] INFO: bigquant: join.v3 开始运行..
    [2019-01-30 15:16:08.772888] INFO: join: /data, 行数=2169374/2169374, 耗时=2.157599s
    [2019-01-30 15:16:08.906454] INFO: join: 最终行数: 2169374
    [2019-01-30 15:16:08.908564] INFO: bigquant: join.v3 运行完成[2.389269s].
    [2019-01-30 15:16:08.910635] INFO: bigquant: input_features.v1 开始运行..
    [2019-01-30 15:16:08.915374] INFO: bigquant: 命中缓存
    [2019-01-30 15:16:08.916121] INFO: bigquant: input_features.v1 运行完成[0.005496s].
    [2019-01-30 15:16:08.918103] INFO: bigquant: derived_feature_extractor.v3 开始运行..
    [2019-01-30 15:16:09.632502] INFO: derived_feature_extractor: 提取完成 relative_ret=stockret-bmret, 0.006s
    [2019-01-30 15:16:10.439075] INFO: derived_feature_extractor: /data, 2169374
    [2019-01-30 15:16:11.872004] INFO: bigquant: derived_feature_extractor.v3 运行完成[2.953855s].
    

    查看结果

    相对大盘5日收益率计算值与如下表所示

    In [46]:
    m17.data.read_df().tail()
    
    Out[46]:
    date instrument stockret bmret relative_ret
    2169369 2017-12-29 000150.SZA 0.040136 -0.005856 0.045992
    2169370 2017-12-29 300452.SZA 0.137307 -0.005856 0.143163
    2169371 2017-12-29 002064.SZA -0.021956 -0.005856 -0.016100
    2169372 2017-12-29 600116.SHA -0.027322 -0.005856 -0.021466
    2169373 2017-12-29 600731.SHA 0.021614 -0.005856 0.027470

    【精品推荐】如何按需求实现自定义因子?