计算指数收益率作为因子


(iQuant) #1
克隆策略

    {"Description":"实验创建于2019/1/21","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-228:input_data","SourceOutputPortId":"-106:data"},{"DestinationInputPortId":"-87:features","SourceOutputPortId":"-131:data"},{"DestinationInputPortId":"-248:features","SourceOutputPortId":"-131:data"},{"DestinationInputPortId":"-106:features","SourceOutputPortId":"-150:data"},{"DestinationInputPortId":"-242:columns_ds","SourceOutputPortId":"-150:data"},{"DestinationInputPortId":"-87:instruments","SourceOutputPortId":"-154:data"},{"DestinationInputPortId":"-93:instruments","SourceOutputPortId":"-154:data"},{"DestinationInputPortId":"-106:instruments","SourceOutputPortId":"-184:data"},{"DestinationInputPortId":"-242:input_ds","SourceOutputPortId":"-228:data"},{"DestinationInputPortId":"-130:data2","SourceOutputPortId":"-242:data"},{"DestinationInputPortId":"-123:data2","SourceOutputPortId":"-248:data"},{"DestinationInputPortId":"-228:features","SourceOutputPortId":"-271:data"},{"DestinationInputPortId":"-248:input_data","SourceOutputPortId":"-87:data"},{"DestinationInputPortId":"-123:data1","SourceOutputPortId":"-93:data"},{"DestinationInputPortId":"-130:data1","SourceOutputPortId":"-123:data"},{"DestinationInputPortId":"-119:input_data","SourceOutputPortId":"-130: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,"Comment":"bar1d_index_CN_STOCK_A表中抽取指数close数据","CommentCollapsed":false},{"Id":"-131","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nreturn_0\navg_turn_9/2","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,"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,"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,"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,"Comment":"","CommentCollapsed":true},{"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,"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,"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,"Comment":"","CommentCollapsed":false},{"Id":"-271","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nclose/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,"Comment":"表达式引擎因子计算5日收益率","CommentCollapsed":false},{"Id":"-87","ModuleId":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v7","ModuleParameters":[{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"before_start_days","Value":90,"ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-87"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-87"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-87","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"Comment":"","CommentCollapsed":true},{"Id":"-93","ModuleId":"BigQuantSpace.advanced_auto_labeler.advanced_auto_labeler-v2","ModuleParameters":[{"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","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","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":"-93"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-93","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":10,"Comment":"","CommentCollapsed":true},{"Id":"-119","ModuleId":"BigQuantSpace.dropnan.dropnan-v1","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-119"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-119","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":8,"Comment":"","CommentCollapsed":true},{"Id":"-123","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":"-123"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"data2","NodeId":"-123"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-123","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":12,"Comment":"","CommentCollapsed":true},{"Id":"-130","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":"-130"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"data2","NodeId":"-130"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-130","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":13,"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='-195.54864311218262,29.39427947998047,200,200'/><NodePosition Node='-131' Position='-617.9013366699219,-59.3579626083374,200,200'/><NodePosition Node='-150' Position='10.946815490722656,-56.86253356933594,200,200'/><NodePosition Node='-154' Position='-969.1491374969482,-42.99092090129852,200,200'/><NodePosition Node='-184' Position='-278.50714111328125,-58.4863977432251,200,200'/><NodePosition Node='-228' Position='-180.67316055297852,153.89881134033203,200,200'/><NodePosition Node='-242' Position='-185.73278045654297,258.7704162597656,200,200'/><NodePosition Node='-248' Position='-683.1490631103516,140.02716636657715,200,200'/><NodePosition Node='-271' Position='175.56161499023438,41.21528625488281,200,200'/><NodePosition Node='-87' Position='-669.7495880126953,53.510358810424805,200,200'/><NodePosition Node='-93' Position='-1050.2554321289062,142.29505920410156,200,200'/><NodePosition Node='-119' Position='-403.3955383300781,491.998046875,200,200'/><NodePosition Node='-123' Position='-774.8417358398438,283.62579345703125,200,200'/><NodePosition Node='-130' Position='-450.5057678222656,395.96563720703125,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 [7]:
    # 本代码由可视化策略环境自动生成 2019年1月24日 11:30
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m5 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    return_0
    avg_turn_9/2"""
    )
    
    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.general_feature_extractor.v7(
        instruments=m6.data,
        features=m5.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m11 = M.derived_feature_extractor.v3(
        input_data=m4.data,
        features=m5.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    
    m10 = M.advanced_auto_labeler.v2(
        instruments=m6.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,
        user_functions={}
    )
    
    m12 = M.join.v3(
        data1=m10.data,
        data2=m11.data,
        on='date,instrument',
        how='inner',
        sort=False
    )
    
    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
    )
    
    m15 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    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
    )
    
    m13 = M.join.v3(
        data1=m12.data,
        data2=m9.data,
        on='date',
        how='inner',
        sort=False
    )
    
    m8 = M.dropnan.v1(
        input_data=m13.data
    )
    
    [2019-01-24 11:29:35.394570] INFO: bigquant: input_features.v1 开始运行..
    [2019-01-24 11:29:35.399504] INFO: bigquant: 命中缓存
    [2019-01-24 11:29:35.400386] INFO: bigquant: input_features.v1 运行完成[0.005857s].
    [2019-01-24 11:29:35.402017] INFO: bigquant: input_features.v1 开始运行..
    [2019-01-24 11:29:35.406236] INFO: bigquant: 命中缓存
    [2019-01-24 11:29:35.407015] INFO: bigquant: input_features.v1 运行完成[0.005s].
    [2019-01-24 11:29:35.409093] INFO: bigquant: instruments.v2 开始运行..
    [2019-01-24 11:29:35.412931] INFO: bigquant: 命中缓存
    [2019-01-24 11:29:35.413752] INFO: bigquant: instruments.v2 运行完成[0.00465s].
    [2019-01-24 11:29:35.418562] INFO: bigquant: general_feature_extractor.v7 开始运行..
    [2019-01-24 11:29:35.424103] INFO: bigquant: 命中缓存
    [2019-01-24 11:29:35.425064] INFO: bigquant: general_feature_extractor.v7 运行完成[0.006531s].
    [2019-01-24 11:29:35.427578] INFO: bigquant: derived_feature_extractor.v3 开始运行..
    [2019-01-24 11:29:35.432613] INFO: bigquant: 命中缓存
    [2019-01-24 11:29:35.433498] INFO: bigquant: derived_feature_extractor.v3 运行完成[0.005919s].
    [2019-01-24 11:29:35.435988] INFO: bigquant: advanced_auto_labeler.v2 开始运行..
    [2019-01-24 11:29:35.440124] INFO: bigquant: 命中缓存
    [2019-01-24 11:29:35.440993] INFO: bigquant: advanced_auto_labeler.v2 运行完成[0.005011s].
    [2019-01-24 11:29:35.443619] INFO: bigquant: join.v3 开始运行..
    [2019-01-24 11:29:35.447796] INFO: bigquant: 命中缓存
    [2019-01-24 11:29:35.448830] INFO: bigquant: join.v3 运行完成[0.005203s].
    [2019-01-24 11:29:35.450664] INFO: bigquant: instruments.v2 开始运行..
    [2019-01-24 11:29:35.454273] INFO: bigquant: 命中缓存
    [2019-01-24 11:29:35.455032] INFO: bigquant: instruments.v2 运行完成[0.004369s].
    [2019-01-24 11:29:35.456531] INFO: bigquant: use_datasource.v1 开始运行..
    [2019-01-24 11:29:36.353504] INFO: bigquant: use_datasource.v1 运行完成[0.896911s].
    [2019-01-24 11:29:36.356249] INFO: bigquant: input_features.v1 开始运行..
    [2019-01-24 11:29:36.361302] INFO: bigquant: 命中缓存
    [2019-01-24 11:29:36.362166] INFO: bigquant: input_features.v1 运行完成[0.00593s].
    [2019-01-24 11:29:36.364732] INFO: bigquant: derived_feature_extractor.v3 开始运行..
    [2019-01-24 11:29:36.385353] INFO: derived_feature_extractor: 提取完成 close/shift(close,5)-1, 0.003s
    [2019-01-24 11:29:36.803882] INFO: derived_feature_extractor: /data, 732
    [2019-01-24 11:29:36.823085] INFO: bigquant: derived_feature_extractor.v3 运行完成[0.458321s].
    [2019-01-24 11:29:36.826083] INFO: bigquant: select_columns.v3 开始运行..
    列: ['close', 'instrument']
    /data: 732
    [2019-01-24 11:29:36.879420] INFO: bigquant: select_columns.v3 运行完成[0.053304s].
    [2019-01-24 11:29:36.881833] INFO: bigquant: join.v3 开始运行..
    [2019-01-24 11:29:36.943100] INFO: join: /y_2014, 行数=0/0, 耗时=0.023424s
    [2019-01-24 11:29:37.989562] INFO: join: /y_2015, 行数=560424/560424, 耗时=1.045306s
    [2019-01-24 11:29:39.393459] INFO: join: /y_2016, 行数=637453/637453, 耗时=1.360764s
    [2019-01-24 11:29:40.113758] INFO: join: /y_2017, 行数=721150/721150, 耗时=0.646124s
    [2019-01-24 11:29:40.171048] INFO: join: 最终行数: 1919027
    [2019-01-24 11:29:40.173216] INFO: bigquant: join.v3 运行完成[3.291319s].
    [2019-01-24 11:29:40.177438] INFO: bigquant: dropnan.v1 开始运行..
    [2019-01-24 11:29:40.216623] INFO: dropnan: /y_2014, 0/0
    [2019-01-24 11:29:40.801500] INFO: dropnan: /y_2015, 548452/560424
    [2019-01-24 11:29:41.443032] INFO: dropnan: /y_2016, 637303/637453
    [2019-01-24 11:29:42.203126] INFO: dropnan: /y_2017, 720315/721150
    [2019-01-24 11:29:42.234100] INFO: dropnan: 行数: 1906070/1919027
    [2019-01-24 11:29:42.257674] INFO: bigquant: dropnan.v1 运行完成[2.080186s].
    

    查看结果

    大盘的5日收益率计算值与其余计算的close、open、low和high合并在一张表中,如下所示

    In [8]:
    m8.data.read_df().head()
    
    Out[8]:
    avg_turn_9 date instrument return_0 avg_turn_9/2 m:low m:high m:amount m:close m:open label close/shift(close,5)-1
    11630 2.235081 2015-01-12 000001.SZA 0.979443 1.117541 1030.278564 1069.358154 2.293105e+09 1049.463135 1056.568481 6 -0.03514
    11631 3.887733 2015-01-12 000002.SZA 0.975465 1.943867 1572.025024 1642.303711 3.180963e+09 1617.644531 1642.303711 6 -0.03514
    11632 2.993092 2015-01-12 000004.SZA 0.967742 1.496546 64.046463 66.240952 2.645168e+07 64.615402 66.240952 8 -0.03514
    11633 3.836331 2015-01-12 000006.SZA 0.961194 1.918165 200.214417 211.019638 1.999203e+08 204.663620 211.019638 5 -0.03514
    11634 1.095602 2015-01-12 000007.SZA 0.991724 0.547801 78.290504 79.781227 1.796301e+07 79.394737 79.505165 7 -0.03514