因子看板数据的获取

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

(达达) #1

经常有小伙伴问怎么调用因子看板的数据,这里给出一个例子,可以看到可以调取看因子的各种分析结果数据,这里仅展示原始因子和处理后的因子数据读取,大家可以参考案例中的字段自行读取研究相关因子分析结果数据。

克隆策略

    {"Description":"实验创建于2020/2/14","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-175:factor_ids","SourceOutputPortId":"-70:data"}],"ModuleNodes":[{"Id":"-70","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"# 复制因子看板详情页的因子ID\nalpha_36805\nalpha_33704","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-70"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-70","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"Comment":"","CommentCollapsed":true},{"Id":"-175","ModuleId":"BigQuantSpace.factorlens_data.factorlens_data-v1","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"factor_ids","NodeId":"-175"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-175","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"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='-70' Position='278.03338623046875,225.5596923828125,200,200'/><NodePosition Node='-175' Position='269.9152526855469,295.3671569824219,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 [2]:
    # 本代码由可视化策略环境自动生成 2021年1月13日12:00
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.input_features.v1(
        features="""# 复制因子看板详情页的因子ID
    alpha_36805
    alpha_33704"""
    )
    
    m2 = M.factorlens_data.v1(
        factor_ids=m1.data
    )
    
    In [3]:
    m2.data.read().keys()
    
    Out[3]:
    dict_keys(['alpha_33704', 'alpha_36805'])
    In [7]:
    m2.data.read()['alpha_33704'].keys()
    
    Out[7]:
    dict_keys(['meta', 'options', 'data', 'summary'])
    In [13]:
    m2.data.read()['alpha_33704']['data'].keys()
    
    Out[13]:
    dict_keys(['QuantileReturns', 'IC', 'BasicDescription', 'Industry', 'RebalanceOverlap', 'PBRatio', 'Turnover', 'Stocks', 'MarketCap', 'FactorValue'])
    In [15]:
    m2.data.read()['alpha_33704']['data']['BasicDescription'].keys()
    
    Out[15]:
    dict_keys(['raw_hist', 'adjusted_hist'])
    In [24]:
    # 因子原始数据和处理后数据
    m2.data.read()['alpha_33704']['data']['FactorValue'].head(2)
    
    Out[24]:
    date instrument FACTOR RAW_FACTOR
    242 2019-01-14 000001.SZA -1.936147 -10.524574
    264 2019-02-20 000001.SZA 0.863822 0.477967