STD(VOLUME,20) 国泰191里的100因子

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

(lzh41764176) #1

我想求这个公式,在衍生特征里面对应的因子公式写为
std(volume_0, 20)
计算万科值为


但是,在网上,调用他们封装的191因子,
值为:


(lzh41764176) #2

我想问一下为什么值不一致呢?


(lzh41764176) #3


(lzh41764176) #4

我自己算了一下,也是2.6左右。是哪里出问题了呢?


(iQuant) #5

您好,收到您的提问,我们已将问题提交给策略工程师,策略工程师会尽快为您回复。


(达达) #6

您好,成交量volume的基础数据一致么?您可以检查一下不同的平台基础数据是否一致。


(达达) #7

可以看到使用dataframe和numpy计算可能也会不同
建议比对基础数据,然后详细查看算法

克隆策略

    {"Description":"实验创建于2019/1/18","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-157:instruments","SourceOutputPortId":"-148:data"},{"DestinationInputPortId":"-168:input_data","SourceOutputPortId":"-157:data"},{"DestinationInputPortId":"-157:features","SourceOutputPortId":"-163:data"},{"DestinationInputPortId":"-168:features","SourceOutputPortId":"-163:data"}],"ModuleNodes":[{"Id":"-148","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2018-12-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2019-01-20","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"market","Value":"CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_list","Value":"000002.SZA","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_count","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"rolling_conf","NodeId":"-148"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-148","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"Comment":"","CommentCollapsed":true},{"Id":"-157","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":"-157"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-157"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-157","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"Comment":"","CommentCollapsed":true},{"Id":"-163","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nstd(volume_0,20)","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-163"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-163","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":3,"Comment":"","CommentCollapsed":true},{"Id":"-168","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":"-168"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-168"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-168","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"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='-148' Position='62,123,200,200'/><NodePosition Node='-157' Position='183,274,200,200'/><NodePosition Node='-163' Position='411,117,200,200'/><NodePosition Node='-168' Position='222,374,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 [13]:
    # 本代码由可视化策略环境自动生成 2019年1月18日 15:01
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.instruments.v2(
        start_date='2018-12-01',
        end_date='2019-01-20',
        market='CN_STOCK_A',
        instrument_list='000002.SZA',
        max_count=0
    )
    
    m3 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    std(volume_0,20)"""
    )
    
    m2 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m3.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m4 = M.derived_feature_extractor.v3(
        input_data=m2.data,
        features=m3.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    
    [2019-01-18 14:36:30.304391] INFO: bigquant: instruments.v2 开始运行..
    [2019-01-18 14:36:30.308634] INFO: bigquant: 命中缓存
    [2019-01-18 14:36:30.309369] INFO: bigquant: instruments.v2 运行完成[0.005007s].
    [2019-01-18 14:36:30.311147] INFO: bigquant: input_features.v1 开始运行..
    [2019-01-18 14:36:30.314372] INFO: bigquant: 命中缓存
    [2019-01-18 14:36:30.315375] INFO: bigquant: input_features.v1 运行完成[0.004224s].
    [2019-01-18 14:36:30.321604] INFO: bigquant: general_feature_extractor.v7 开始运行..
    [2019-01-18 14:36:30.325567] INFO: bigquant: 命中缓存
    [2019-01-18 14:36:30.326576] INFO: bigquant: general_feature_extractor.v7 运行完成[0.004982s].
    [2019-01-18 14:36:30.329257] INFO: bigquant: derived_feature_extractor.v3 开始运行..
    [2019-01-18 14:36:30.334493] INFO: bigquant: 命中缓存
    [2019-01-18 14:36:30.335533] INFO: bigquant: derived_feature_extractor.v3 运行完成[0.006292s].
    
    In [16]:
    # 使用表达式引擎计算
    m4.data.read_df().tail(5)
    
    Out[16]:
    date instrument volume_0 std(volume_0,20)
    86 2019-01-11 000002.SZA 24069490 1.234722e+07
    87 2019-01-14 000002.SZA 18328134 1.089058e+07
    88 2019-01-15 000002.SZA 36875885 1.090737e+07
    89 2019-01-16 000002.SZA 26746606 1.101027e+07
    90 2019-01-17 000002.SZA 24589586 1.100062e+07
    In [25]:
    # 使用numpy计算
    s= np.array([float(x) for x in m4.data.read_df().tail(20).volume_0])
    s.std()
    
    Out[25]:
    10722080.842940118
    In [26]:
    # 使用dataFrame计算
    m4.data.read_df()[['volume_0']].rolling(20).std().tail(1)
    
    Out[26]:
    volume_0
    90 1.100062e+07

    表达式引擎的计算和使用DataFrame计算结果一致


    (lzh41764176) #8

    基础数据是一致的,另外我手动算了一下,确实是2.几。他们那边正确。


    (达达) #9

    能否展示一下您那边的基础数据和计算过程呢?


    (lzh41764176) #10

    我是手动计算的万科1.17号前10天的成交量数据,求10天的标准差。
    分别是245900,267500,368800,183300,240700,224600,340100,214400,427200,377700。(约等于)
    这样算出来的结果,就是2.6*e+10左右。


    (lzh41764176) #11

    2.6*e+9


    (达达) #12

    不应该是求20天的么?


    (lzh41764176) #13

    我重新试了一下,应该是他们那边有问题。


    (lzh41764176) #14

    他们那边在计算的时候没有靠谱复权因素,所以有出入。