标准化处理模块报错

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

(ljj13802239795) #1

如下策略的标准化处理(v8)模块报错了,但开始日期如果定在‘2018-01-01’之后又可以正常执行,何解?

克隆策略

    {"Description":"实验创建于2019/9/11","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-2701:instruments","SourceOutputPortId":"-2688:data"},{"DestinationInputPortId":"-2876:input_data","SourceOutputPortId":"-2701:data"},{"DestinationInputPortId":"-3450:input_1","SourceOutputPortId":"-2876:data"},{"DestinationInputPortId":"-2701:features","SourceOutputPortId":"-2696:data"},{"DestinationInputPortId":"-3450:input_2","SourceOutputPortId":"-2696:data"}],"ModuleNodes":[{"Id":"-2688","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2012-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2013-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":"-2688"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-2688","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-2701","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":"-2701"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-2701"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-2701","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-2876","ModuleId":"BigQuantSpace.dropnan.dropnan-v1","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-2876"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-2876","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":3,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-2696","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nreturn_5\nreturn_10\nreturn_20\nrank_return_0\nrank_return_5\nrank_return_10\navg_amount_0\navg_amount_5\npe_ttm_0\n","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-2696"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-2696","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"IsPartOfPartialRun":null,"Comment":"","CommentCollapsed":true},{"Id":"-3450","ModuleId":"BigQuantSpace.standardlize.standardlize-v8","ModuleParameters":[{"Name":"columns_input","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_1","NodeId":"-3450"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_2","NodeId":"-3450"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-3450","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":5,"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='-2688' Position='550,299,200,200'/><NodePosition Node='-2701' Position='561,448,200,200'/><NodePosition Node='-2876' Position='612,548,200,200'/><NodePosition Node='-2696' Position='792,360,200,200'/><NodePosition Node='-3450' Position='707,647,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 [10]:
    # 本代码由可视化策略环境自动生成 2019年10月21日 18:58
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.instruments.v2(
        start_date='2012-01-01',
        end_date='2013-01-01',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m4 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    return_5
    return_10
    return_20
    rank_return_0
    rank_return_5
    rank_return_10
    avg_amount_0
    avg_amount_5
    pe_ttm_0
    """
    )
    
    m2 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m4.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m3 = M.dropnan.v1(
        input_data=m2.data
    )
    
    m5 = M.standardlize.v8(
        input_1=m3.data,
        input_2=m4.data,
        columns_input=''
    )
    

    标准化处理(standardlize)使用错误,你可以:

    1.一键查看文档

    2.一键搜索答案

    ---------------------------------------------------------------------------
    ValueError                                Traceback (most recent call last)
    <ipython-input-10-0d2c4c6c6087> in <module>()
         42     input_1=m3.data,
         43     input_2=m4.data,
    ---> 44     columns_input=''
         45 )
    
    ValueError: cannot reindex from a duplicate axis
    In [5]:
    m5.data.read_df().head()
    
    Out[5]:
    avg_amount_0 avg_amount_5 date instrument pe_ttm_0 rank_return_0 rank_return_10 rank_return_5 return_10 return_20 return_5
    0 7.203730 7.681121 2018-10-08 000001.SZA -0.001780 -1.161180 1.430982 1.342301 1.132480 0.952223 0.956938
    1 9.500288 10.000891 2018-10-08 000002.SZA -0.001400 -1.671240 -0.457938 -1.371357 -0.218238 -0.118257 -0.998733
    2 -0.282585 -0.329601 2018-10-08 000005.SZA 0.035293 0.219688 -0.558226 -1.037916 -0.283103 0.050633 -0.635945
    3 0.369349 0.903048 2018-10-08 000006.SZA -0.001907 -1.643182 1.104044 -1.688252 0.680779 0.023872 -2.292005
    4 -0.320587 -0.320546 2018-10-08 000007.SZA -0.093982 -1.699298 -1.729085 -1.733379 -5.680527 -4.220059 -7.355463

    (iQuant) #2

    您好,已将问题提交给策略工程师,会尽快给您回复。


    (blsm001) #3

    数据的索引有重复导致的问题,临时处理可以用自定义模块重新reset_index一下


    (ljj13802239795) #4

    搞定了,多谢指导!