把交易市场换成CN_FUND基金,马上就出错,实在想不明白

新手专区
标签: #<Tag:0x00007f4ce9513348>

(189) #1

麻烦解答一下困惑:

克隆策略
In [ ]:
 
In [29]:
###把交易市场换成CN_FUND基金,那么表达式引擎类似close_10之类表达方式能继续用吗?
#我把交易市场改了以后,随便写一个510300.HOF代码进去,运行即出错

    {"Description":"实验创建于2019/10/31","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-276:instruments","SourceOutputPortId":"-61:data"},{"DestinationInputPortId":"-283:input_data","SourceOutputPortId":"-276:data"},{"DestinationInputPortId":"-276:features","SourceOutputPortId":"-298:data"},{"DestinationInputPortId":"-283:features","SourceOutputPortId":"-298:data"}],"ModuleNodes":[{"Id":"-61","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2019-09-30","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2019-10-30","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"market","Value":"CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_list","Value":"601318.SHA","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_count","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"rolling_conf","NodeId":"-61"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-61","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"Comment":"","CommentCollapsed":true},{"Id":"-276","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":"-276"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-276"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-276","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":3,"Comment":"","CommentCollapsed":true},{"Id":"-283","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":"-283"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-283"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-283","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"Comment":"","CommentCollapsed":true},{"Id":"-298","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nclose_0\nclose_20","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-298"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-298","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":6,"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='-61' Position='-55.49174499511719,142.14105224609375,200,200'/><NodePosition Node='-276' Position='60.62120056152344,254.63900756835938,200,200'/><NodePosition Node='-283' Position='300.8497314453125,365.14410400390625,200,200'/><NodePosition Node='-298' Position='245.94036865234375,149.6248016357422,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 [24]:
    # 本代码由可视化策略环境自动生成 2019年10月31日 17:57
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.instruments.v2(
        start_date='2019-09-30',
        end_date='2019-10-30',
        market='CN_STOCK_A',
        instrument_list='601318.SHA',
        max_count=0
    )
    
    m6 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    close_0
    close_20"""
    )
    
    m3 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m6.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m4 = M.derived_feature_extractor.v3(
        input_data=m3.data,
        features=m6.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    

    (189) #2

    搞不明白,为什么把交易市场换成基金,特征因子就根本抽取不出来、??


    (达达) #4

    基金我们只提供了基础数据,没有提供因子,因子只提供了股票。但是你可以把衍生特征抽取模块当作因子计算器,比如你的原始基金数据是close,open列,你可以通过数据源模块抽基金行情数据表的数据,然后连接到衍生特征抽取模块,再使用输入特征列表模块定义close+open这样就利用衍生特征抽取模块作为计算器计算出了你的close+open这个因子数据了


    (189) #5

    多谢,我刚才已经用数据源来构造了类似close_10之类的因子,还有一个问题就是:除了股票之外,比如类似基金,必须要用到数据源来取数据吗?因为我看到很多连股票代码之外,接着连基础特征抽取和衍生特征抽取,就没有连数据源?


    (达达) #6

    是的,平台只提供了内置计算的股票常用因子库,对于基金,商品等每个人的需求不同,很难逐一满足,因此靠用户自己来使用衍生特征抽取模块构建因子。


    (189) #7

    好的,知悉,多谢!