特征抽取处理的因子值有点困惑,希望能解答一下。

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

(lzh41764176) #1

以通过数据源进行基础特征抽取给的例子为例,
这里取得是 `000002.SZA 万科的open,close,high。
为什么值会是4000多呢?


(达达) #3
克隆策略

    {"Description":"实验创建于2019/1/16","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-185:input_1","SourceOutputPortId":"-163:data"},{"DestinationInputPortId":"-163:instruments","SourceOutputPortId":"-169:data"}],"ModuleNodes":[{"Id":"-163","ModuleId":"BigQuantSpace.use_datasource.use_datasource-v1","ModuleParameters":[{"Name":"datasource_id","Value":"bar1d_CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-163"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-163"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-163","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"Comment":"","CommentCollapsed":true},{"Id":"-169","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2018-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2018-06-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":"-169"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-169","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"Comment":"","CommentCollapsed":true},{"Id":"-185","ModuleId":"BigQuantSpace.cached.cached-v3","ModuleParameters":[{"Name":"run","Value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\ndef bigquant_run(input_1, input_2, input_3):\n # 示例代码如下。在这里编写您的代码\n df = input_1.read_df()\n df['close']=df['close']/df['adjust_factor']\n df['high']=df['high']/df['adjust_factor']\n df['low']=df['low']/df['adjust_factor']\n df['open']=df['open']/df['adjust_factor']\n data_1 = DataSource.write_pickle(df)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"post_run","Value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"input_ports","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"params","Value":"{}","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"output_ports","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_1","NodeId":"-185"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_2","NodeId":"-185"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_3","NodeId":"-185"}],"OutputPortsInternal":[{"Name":"data_1","NodeId":"-185","OutputType":null},{"Name":"data_2","NodeId":"-185","OutputType":null},{"Name":"data_3","NodeId":"-185","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"Comment":"计算真实价格","CommentCollapsed":false}],"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='-163' Position='200.09661865234375,221.8295440673828,200,200'/><NodePosition Node='-169' Position='67.09660339355469,72.82954406738281,200,200'/><NodePosition Node='-185' Position='202.09661865234375,314.6477355957031,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年1月16日 22:47
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m4_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        df = input_1.read_df()
        df['close']=df['close']/df['adjust_factor']
        df['high']=df['high']/df['adjust_factor']
        df['low']=df['low']/df['adjust_factor']
        df['open']=df['open']/df['adjust_factor']
        data_1 = DataSource.write_pickle(df)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m4_post_run_bigquant_run(outputs):
        return outputs
    
    
    m2 = M.instruments.v2(
        start_date='2018-01-01',
        end_date='2018-06-01',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m1 = M.use_datasource.v1(
        instruments=m2.data,
        datasource_id='bar1d_CN_STOCK_A',
        start_date='',
        end_date=''
    )
    
    m4 = M.cached.v3(
        input_1=m1.data,
        run=m4_run_bigquant_run,
        post_run=m4_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    [2019-01-16 22:47:17.231586] INFO: bigquant: instruments.v2 开始运行..
    [2019-01-16 22:47:17.238064] INFO: bigquant: 命中缓存
    [2019-01-16 22:47:17.238963] INFO: bigquant: instruments.v2 运行完成[0.007427s].
    [2019-01-16 22:47:17.240998] INFO: bigquant: use_datasource.v1 开始运行..
    [2019-01-16 22:47:17.245107] INFO: bigquant: 命中缓存
    [2019-01-16 22:47:17.245884] INFO: bigquant: use_datasource.v1 运行完成[0.004887s].
    [2019-01-16 22:47:17.250319] INFO: bigquant: cached.v3 开始运行..
    [2019-01-16 22:47:17.600100] INFO: bigquant: cached.v3 运行完成[0.349734s].
    
    In [11]:
    # 查看后复权价格
    m1.data.read().head()
    
    Out[11]:
    adjust_factor amount close date deal_number high instrument low open turn volume
    0 5.008553 16917760.0 49.584675 2018-01-02 2942 49.734932 002472.SZA 48.883476 49.234077 0.315558 1717932.0
    1 1.002466 79965455.0 6.125067 2018-01-02 6746 6.135092 601228.SHA 6.064919 6.094993 1.880484 13138563.0
    2 1.000000 17078973.0 30.590000 2018-01-02 1014 30.950001 603580.SHA 30.299999 30.360001 3.351530 558700.0
    3 1.804982 0.0 85.375648 2018-01-02 0 85.375648 300523.SZA 85.375648 85.375648 0.000000 0.0
    4 7.717918 27859895.0 60.971554 2018-01-02 2843 62.823853 002349.SZA 58.733356 58.810535 0.592948 3531922.0
    In [12]:
    # m4中计算后复权价格
    m4.data_1.read().head()
    
    Out[12]:
    adjust_factor amount close date deal_number high instrument low open turn volume
    0 5.008553 16917760.0 9.900000 2018-01-02 2942 9.930000 002472.SZA 9.759999 9.830000 0.315558 1717932.0
    1 1.002466 79965455.0 6.110000 2018-01-02 6746 6.120000 601228.SHA 6.050000 6.080000 1.880484 13138563.0
    2 1.000000 17078973.0 30.590000 2018-01-02 1014 30.950001 603580.SHA 30.299999 30.360001 3.351530 558700.0
    3 1.804982 0.0 47.300003 2018-01-02 0 47.300003 300523.SZA 47.300003 47.300003 0.000000 0.0
    4 7.717918 27859895.0 7.900000 2018-01-02 2843 8.140000 002349.SZA 7.610000 7.620000 0.592948 3531922.0