把证券代码列表改为CN_FUND马上就会出错?

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

(189) #1
克隆策略
In [35]:
m6.data.read()
Out[35]:
close_0 date instrument return_5 m:low m:amount m:close m:high m:open label
0 1577.498169 2019-09-02 000001.SZA 0.986348 1540.380615 1.955673e+09 1577.498169 1582.956665 1544.747437 9
1 3842.384521 2019-09-02 000002.SZA 0.960312 3812.702148 1.138397e+09 3842.384521 3867.614502 3821.606934 11
2 81.439796 2019-09-02 000004.SZA 1.004511 78.473175 1.875437e+07 81.439796 82.862144 80.627022 7
3 29.285625 2019-09-02 000005.SZA 1.032680 28.266190 3.762398e+07 29.285625 29.378302 28.266190 16
4 190.237411 2019-09-02 000006.SZA 0.988950 186.340546 5.703612e+07 190.237411 192.362961 187.757584 11
5 65.936882 2019-09-02 000007.SZA 0.944247 64.197342 1.449893e+08 65.936882 66.765236 64.777191 10
6 78.164955 2019-09-02 000008.SZA 1.000000 76.601654 4.581676e+07 78.164955 78.388283 77.048309 11
7 41.814342 2019-09-02 000009.SZA 0.989518 40.928448 1.022830e+08 41.814342 42.257290 40.928448 11
8 36.956703 2019-09-02 000010.SZA 0.952778 36.310230 2.526827e+06 36.956703 37.172195 36.310230 8
9 36.898529 2019-09-02 000011.SZA 0.990329 35.853550 4.341522e+07 36.898529 37.439034 36.069756 11
10 112.221336 2019-09-02 000012.SZA 1.011905 109.316788 4.497813e+07 112.221336 112.485390 109.580833 9
11 53.396278 2019-09-02 000014.SZA 0.977183 52.203671 5.239473e+07 53.396278 54.101002 52.691555 14
12 96.498009 2019-09-02 000016.SZA 1.013667 93.245262 1.333885e+08 96.498009 97.365402 94.329514 10
13 16.606136 2019-09-02 000017.SZA 1.163534 13.977055 3.538027e+08 16.606136 16.606136 14.674566 3
14 6.853602 2019-09-02 000018.SZA 0.879310 6.719218 2.978330e+07 6.853602 6.920794 6.719218 4
15 27.041327 2019-09-02 000019.SZA 0.986507 26.589268 4.247890e+07 27.041327 27.329000 26.589268 11
16 19.848177 2019-09-02 000020.SZA 1.002655 19.094893 3.451678e+07 19.848177 20.496353 19.270075 15
17 156.263153 2019-09-02 000021.SZA 0.865116 149.682175 1.167400e+09 156.263153 156.683212 152.622604 19
18 37.072594 2019-09-02 000023.SZA 0.991441 36.139111 5.697354e+07 37.072594 37.472656 36.432491 12
19 58.270897 2019-09-02 000025.SZA 0.925011 57.342495 1.646377e+08 58.270897 58.871628 57.615555 13
20 60.871475 2019-09-02 000026.SZA 1.030769 59.054417 5.072156e+07 60.871475 61.325741 59.508682 11
21 80.675362 2019-09-02 000027.SZA 0.991681 79.186386 4.896949e+07 80.675362 81.081444 79.863190 10
22 188.479553 2019-09-02 000028.SZA 1.041394 185.443375 1.608536e+08 188.479553 189.859634 187.966965 6
23 15.352728 2019-09-02 000030.SZA 1.045147 14.954817 1.486925e+07 15.352728 15.385887 15.021135 9
24 91.032417 2019-09-02 000031.SZA 0.992248 89.610031 9.489182e+07 91.032417 91.601372 90.463463 11
25 46.638283 2019-09-02 000032.SZA 1.092233 41.580620 1.133327e+08 46.638283 46.638283 42.202461 14
26 44.124916 2019-09-02 000034.SZA 1.047210 42.527496 2.353260e+08 44.124916 44.456455 42.798756 19
27 26.562735 2019-09-02 000035.SZA 0.976271 26.332155 1.063249e+08 26.562735 27.162241 26.332155 14
28 49.361790 2019-09-02 000036.SZA 0.976087 48.482292 4.993886e+07 49.361790 49.691601 48.922039 7
29 78.993858 2019-09-02 000037.SZA 1.022711 77.126526 8.755685e+07 78.993858 81.087540 77.239700 12
... ... ... ... ... ... ... ... ... ... ...
116917 47.200001 2019-10-23 688006.SHA 1.035088 44.599998 2.476945e+08 47.200001 47.889999 44.869999 3
116918 35.070000 2019-10-23 688007.SHA 1.102830 31.580000 2.586458e+08 35.070000 35.900002 31.860001 1
116919 62.139999 2019-10-23 688008.SHA 1.008439 58.590000 2.772700e+08 62.139999 62.880001 59.000000 7
116920 8.220000 2019-10-23 688009.SHA 0.984431 7.850000 5.311168e+08 8.220000 8.300000 7.900000 5
116921 48.110001 2019-10-23 688010.SHA 0.944444 44.709999 2.096209e+08 48.110001 49.080002 44.740002 12
116922 50.439999 2019-10-23 688011.SHA 0.957116 47.759998 1.186975e+08 50.439999 51.439999 48.099998 2
116923 65.230003 2019-10-23 688012.SHA 0.977521 61.509998 1.955895e+08 65.230003 66.279999 62.029999 10
116924 39.490002 2019-10-23 688015.SHA 1.050266 36.599998 1.814968e+08 39.490002 39.849998 37.410000 6
116925 149.100006 2019-10-23 688016.SHA 1.082317 141.699997 3.002145e+08 149.100006 152.300003 145.699997 4
116926 150.800003 2019-10-23 688018.SHA 0.995380 143.880005 3.090764e+08 150.800003 153.770004 146.000000 3
116927 122.400002 2019-10-23 688019.SHA 0.958572 115.660004 1.271317e+08 122.400002 124.949997 116.500000 6
116928 93.489998 2019-10-23 688020.SHA 1.066264 88.400002 2.132347e+08 93.489998 94.580002 89.900002 2
116929 50.270000 2019-10-23 688022.SHA 0.959717 47.080002 1.489290e+08 50.270000 51.250000 47.230000 4
116930 82.680000 2019-10-23 688028.SHA 0.922150 76.010002 3.334539e+08 82.680000 84.199997 77.500000 0
116931 160.000000 2019-10-23 688029.SHA 1.034327 157.600006 4.720773e+08 160.000000 166.589996 163.500000 12
116932 60.000000 2019-10-23 688030.SHA 1.253919 51.000000 1.050701e+09 60.000000 62.029999 51.540001 0
116933 33.500000 2019-10-23 688033.SHA 1.007519 31.010000 1.208214e+08 33.500000 33.959999 31.420000 3
116934 45.310001 2019-10-23 688036.SHA 0.970859 41.240002 7.209056e+08 45.310001 46.750000 41.889999 8
116935 41.680000 2019-10-23 688066.SHA 0.966829 38.599998 2.141851e+08 41.680000 42.320000 39.049999 5
116936 65.330002 2019-10-23 688068.SHA 1.044611 59.700001 3.555282e+08 65.330002 68.199997 60.709999 0
116937 54.779999 2019-10-23 688088.SHA 1.031250 51.880001 2.514658e+08 54.779999 55.430000 51.880001 0
116938 65.400002 2019-10-23 688099.SHA 0.998626 57.930000 3.834733e+08 65.400002 67.000000 58.000000 3
116939 32.990002 2019-10-23 688116.SHA 1.001518 30.549999 4.612129e+08 32.990002 33.750000 31.629999 3
116940 36.000000 2019-10-23 688122.SHA 0.992009 32.849998 1.822197e+08 36.000000 37.000000 32.869999 2
116941 113.000000 2019-10-23 688168.SHA 0.977678 105.629997 2.091516e+08 113.000000 116.970001 106.330002 1
116942 126.120003 2019-10-23 688188.SHA 0.974276 117.879997 2.463069e+08 126.120003 128.000000 118.300003 8
116943 59.660000 2019-10-23 688321.SHA 1.074955 49.080002 3.158419e+08 59.660000 59.660000 49.740002 0
116944 81.000000 2019-10-23 688333.SHA 1.064389 70.010002 3.937417e+08 81.000000 81.000000 73.000000 0
116945 80.489998 2019-10-23 688368.SHA 0.893837 75.580002 2.757887e+08 80.489998 82.879997 77.000000 1
116946 47.180000 2019-10-23 688388.SHA 0.972383 44.110001 1.776274e+08 47.180000 47.869999 44.660000 9

116947 rows × 10 columns

    {"Description":"实验创建于2019/10/30","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-1889:instruments","SourceOutputPortId":"-1876:data"},{"DestinationInputPortId":"-1904:instruments","SourceOutputPortId":"-1876:data"},{"DestinationInputPortId":"-1896:features","SourceOutputPortId":"-1884:data"},{"DestinationInputPortId":"-1889:features","SourceOutputPortId":"-1884:data"},{"DestinationInputPortId":"-1896:input_data","SourceOutputPortId":"-1889:data"},{"DestinationInputPortId":"-1915:data2","SourceOutputPortId":"-1896:data"},{"DestinationInputPortId":"-1915:data1","SourceOutputPortId":"-1904:data"}],"ModuleNodes":[{"Id":"-1876","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2019-09-01","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":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_count","Value":"0","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"rolling_conf","NodeId":"-1876"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-1876","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"Comment":"","CommentCollapsed":true},{"Id":"-1884","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\nreturn_5\nclose_0","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-1884"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-1884","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"Comment":"","CommentCollapsed":true},{"Id":"-1889","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":"-1889"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-1889"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-1889","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":3,"Comment":"","CommentCollapsed":true},{"Id":"-1896","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":"-1896"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-1896"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-1896","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"Comment":"","CommentCollapsed":true},{"Id":"-1904","ModuleId":"BigQuantSpace.advanced_auto_labeler.advanced_auto_labeler-v2","ModuleParameters":[{"Name":"label_expr","Value":"# #号开始的表示注释\n# 0. 每行一个,顺序执行,从第二个开始,可以使用label字段\n# 1. 可用数据字段见 https://bigquant.com/docs/develop/datasource/deprecated/history_data.html\n# 添加benchmark_前缀,可使用对应的benchmark数据\n# 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/develop/bigexpr/usage.html>`_\n\n# 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)\nshift(close, -5) / shift(open, -1)\n\n# 极值处理:用1%和99%分位的值做clip\nclip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))\n\n# 将分数映射到分类,这里使用20个分类\nall_wbins(label, 20)\n\n# 过滤掉一字涨停的情况 (设置label为NaN,在后续处理和训练中会忽略NaN的label)\nwhere(shift(high, -1) == shift(low, -1), NaN, label)\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"start_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"benchmark","Value":"000300.SHA","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"drop_na_label","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"cast_label_int","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_functions","Value":"{}","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-1904"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-1904","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":5,"Comment":"","CommentCollapsed":true},{"Id":"-1915","ModuleId":"BigQuantSpace.join.join-v3","ModuleParameters":[{"Name":"on","Value":"date,instrument","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"how","Value":"inner","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"sort","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"data1","NodeId":"-1915"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"data2","NodeId":"-1915"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-1915","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='-1876' Position='249.03817749023438,104.13194274902344,200,200'/><NodePosition Node='-1884' Position='620.0382080078125,84.2430419921875,200,200'/><NodePosition Node='-1889' Position='364.0381774902344,245.57638549804688,200,200'/><NodePosition Node='-1896' Position='409.0382080078125,355.5763854980469,200,200'/><NodePosition Node='-1904' Position='20.038177490234375,312.36456298828125,200,200'/><NodePosition Node='-1915' Position='311.0381774902344,515.142333984375,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 [34]:
    # 本代码由可视化策略环境自动生成 2019年10月30日 17:58
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.instruments.v2(
        start_date='2019-09-01',
        end_date='2019-10-30',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m5 = M.advanced_auto_labeler.v2(
        instruments=m1.data,
        label_expr="""# #号开始的表示注释
    # 0. 每行一个,顺序执行,从第二个开始,可以使用label字段
    # 1. 可用数据字段见 https://bigquant.com/docs/develop/datasource/deprecated/history_data.html
    #   添加benchmark_前缀,可使用对应的benchmark数据
    # 2. 可用操作符和函数见 `表达式引擎 <https://bigquant.com/docs/develop/bigexpr/usage.html>`_
    
    # 计算收益:5日收盘价(作为卖出价格)除以明日开盘价(作为买入价格)
    shift(close, -5) / shift(open, -1)
    
    # 极值处理:用1%和99%分位的值做clip
    clip(label, all_quantile(label, 0.01), all_quantile(label, 0.99))
    
    # 将分数映射到分类,这里使用20个分类
    all_wbins(label, 20)
    
    # 过滤掉一字涨停的情况 (设置label为NaN,在后续处理和训练中会忽略NaN的label)
    where(shift(high, -1) == shift(low, -1), NaN, label)
    """,
        start_date='',
        end_date='',
        benchmark='000300.SHA',
        drop_na_label=True,
        cast_label_int=True,
        user_functions={}
    )
    
    m2 = M.input_features.v1(
        features="""
    # #号开始的表示注释,注释需单独一行
    # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
    return_5
    close_0"""
    )
    
    m3 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m2.data,
        start_date='',
        end_date='',
        before_start_days=90
    )
    
    m4 = M.derived_feature_extractor.v3(
        input_data=m3.data,
        features=m2.data,
        date_col='date',
        instrument_col='instrument',
        drop_na=False,
        remove_extra_columns=False,
        user_functions={}
    )
    
    m6 = M.join.v3(
        data1=m5.data,
        data2=m4.data,
        on='date,instrument',
        how='inner',
        sort=False
    )