克隆策略
In [ ]:
 

    {"Description":"实验创建于2020/9/24","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-148:input_data","SourceOutputPortId":"-141:data"},{"DestinationInputPortId":"-148:features","SourceOutputPortId":"-156:data"}],"ModuleNodes":[{"Id":"-141","ModuleId":"BigQuantSpace.use_datasource.use_datasource-v1","ModuleParameters":[{"Name":"datasource_id","Value":"bar5m_CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"start_date","Value":"2020-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2020-01-31","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-141"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-141"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-141","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"Comment":"","CommentCollapsed":true},{"Id":"-148","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":"-148"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-148"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-148","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"Comment":"","CommentCollapsed":true},{"Id":"-156","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nzf = close/shift(close,1)-1","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-156"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-156","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":3,"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='-141' Position='100,220,200,200'/><NodePosition Node='-148' Position='214,333,200,200'/><NodePosition Node='-156' Position='392,220,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]:
    # 本代码由可视化策略环境自动生成 2020年9月24日 16:23
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.use_datasource.v1(
        datasource_id='bar5m_CN_STOCK_A',
        start_date='2020-01-01',
        end_date='2020-01-31'
    )
    
    m3 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    zf = close/shift(close,1)-1"""
    )
    
    m2 = M.derived_feature_extractor.v3(
        input_data=m1.data,
        features=m3.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    
    In [16]:
    m1.data.read().head(2)
    
    Out[16]:
    date open close high low volume amount instrument
    0 2020-01-02 09:35:00 4.89 4.94 4.94 4.89 650640.0 3.202554e+06 600185.SHA
    1 2020-01-02 09:35:00 4.76 4.75 4.79 4.75 689000.0 3.284253e+06 600151.SHA
    In [18]:
    df = m2.data.read()
    df[df.instrument=='600185.SHA']
    
    Out[18]:
    date open close high low volume amount instrument zf
    0 2020-01-02 09:35:00 4.89 4.94 4.94 4.89 650640.0 3.202554e+06 600185.SHA NaN
    4684 2020-01-02 09:40:00 4.95 4.91 4.95 4.90 345700.0 1.702572e+06 600185.SHA -0.006073
    8398 2020-01-02 09:45:00 4.91 4.90 4.92 4.90 247300.0 1.213299e+06 600185.SHA -0.002037
    11278 2020-01-02 09:50:00 4.89 4.90 4.90 4.88 196540.0 9.609246e+05 600185.SHA 0.000000
    14580 2020-01-02 09:55:00 4.89 4.89 4.90 4.89 170680.0 8.348252e+05 600185.SHA -0.002041
    20103 2020-01-02 10:00:00 4.90 4.91 4.91 4.89 98100.0 4.805400e+05 600185.SHA 0.004090
    22118 2020-01-02 10:05:00 4.91 4.91 4.92 4.90 179400.0 8.797240e+05 600185.SHA 0.000000
    24465 2020-01-02 10:10:00 4.91 4.90 4.91 4.90 78700.0 3.860840e+05 600185.SHA -0.002037
    27071 2020-01-02 10:15:00 4.90 4.90 4.91 4.90 72000.0 3.529850e+05 600185.SHA 0.000000
    30812 2020-01-02 10:20:00 4.90 4.89 4.91 4.89 161900.0 7.934900e+05 600185.SHA -0.002041
    34758 2020-01-02 10:25:00 4.89 4.89 4.90 4.89 77300.0 3.780000e+05 600185.SHA 0.000000
    40026 2020-01-02 10:30:00 4.89 4.89 4.90 4.89 105600.0 5.168200e+05 600185.SHA 0.000000
    42659 2020-01-02 10:35:00 4.89 4.89 4.90 4.89 102900.0 5.036820e+05 600185.SHA 0.000000
    45777 2020-01-02 10:40:00 4.90 4.90 4.90 4.89 117100.0 5.736930e+05 600185.SHA 0.002045
    48928 2020-01-02 10:45:00 4.90 4.89 4.90 4.89 45400.0 2.222890e+05 600185.SHA -0.002041
    50611 2020-01-02 10:50:00 4.90 4.89 4.90 4.88 309400.0 1.513012e+06 600185.SHA 0.000000
    55909 2020-01-02 10:55:00 4.88 4.89 4.89 4.88 245800.0 1.201010e+06 600185.SHA 0.000000
    58766 2020-01-02 11:00:00 4.89 4.88 4.89 4.88 288400.0 1.408428e+06 600185.SHA -0.002045
    60626 2020-01-02 11:05:00 4.88 4.89 4.89 4.88 54300.0 2.650280e+05 600185.SHA 0.002049
    66345 2020-01-02 11:10:00 4.88 4.88 4.88 4.87 124900.0 6.092870e+05 600185.SHA -0.002045
    69665 2020-01-02 11:15:00 4.88 4.88 4.88 4.88 79000.0 3.855200e+05 600185.SHA 0.000000
    72758 2020-01-02 11:20:00 4.88 4.87 4.88 4.87 132100.0 6.435190e+05 600185.SHA -0.002049
    74288 2020-01-02 11:25:00 4.88 4.87 4.88 4.87 144500.0 7.041870e+05 600185.SHA 0.000000
    78108 2020-01-02 11:30:00 4.87 4.87 4.88 4.87 106800.0 5.209410e+05 600185.SHA 0.000000
    81454 2020-01-02 13:05:00 4.88 4.87 4.88 4.87 133700.0 6.517060e+05 600185.SHA 0.000000
    86883 2020-01-02 13:10:00 4.87 4.87 4.88 4.87 30940.0 1.506878e+05 600185.SHA 0.000000
    87948 2020-01-02 13:15:00 4.87 4.86 4.87 4.86 116860.0 5.686732e+05 600185.SHA -0.002053
    91647 2020-01-02 13:20:00 4.87 4.87 4.87 4.86 39100.0 1.901380e+05 600185.SHA 0.002058
    95563 2020-01-02 13:25:00 4.86 4.87 4.88 4.86 75340.0 3.668708e+05 600185.SHA 0.000000
    100217 2020-01-02 13:30:00 4.87 4.87 4.88 4.87 43900.0 2.139700e+05 600185.SHA 0.000000
    ... ... ... ... ... ... ... ... ... ...
    4982615 2020-01-31 11:05:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    4986541 2020-01-31 11:10:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    4990866 2020-01-31 11:15:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    4992783 2020-01-31 11:20:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    4998517 2020-01-31 11:25:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5000998 2020-01-31 11:30:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5003875 2020-01-31 13:05:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5009729 2020-01-31 13:10:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5011476 2020-01-31 13:15:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5014827 2020-01-31 13:20:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5018557 2020-01-31 13:25:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5022753 2020-01-31 13:30:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5027520 2020-01-31 13:35:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5028732 2020-01-31 13:40:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5031406 2020-01-31 13:45:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5037486 2020-01-31 13:50:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5040926 2020-01-31 13:55:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5042904 2020-01-31 14:00:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5048166 2020-01-31 14:05:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5051551 2020-01-31 14:10:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5054549 2020-01-31 14:15:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5059515 2020-01-31 14:20:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5060165 2020-01-31 14:25:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5064338 2020-01-31 14:30:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5070171 2020-01-31 14:35:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5072406 2020-01-31 14:40:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5075344 2020-01-31 14:45:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5077603 2020-01-31 14:50:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5082275 2020-01-31 14:55:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000
    5086313 2020-01-31 15:00:00 4.62 4.62 4.63 4.62 0.0 0.000000e+00 600185.SHA 0.000000

    1440 rows × 9 columns