指数换手率获取问题

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

(donkyxote) #1

获取策略如下。时间设定是2019-02-01到2020-09-24,但是结果只有46个交易日的数据,很奇怪,想问下为什么。。。

克隆策略
In [ ]:
 

    In [ ]:
     
    
    In [ ]:
     
    

    (adhaha111) #2

    您好,这边克隆的策略是空白,您能再分享一下吗


    (donkyxote) #3
    克隆策略

      {"Description":"实验创建于2020/9/28","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-160:features","SourceOutputPortId":"-166:data"}],"ModuleNodes":[{"Id":"-160","ModuleId":"BigQuantSpace.use_datasource.use_datasource-v1","ModuleParameters":[{"Name":"datasource_id","Value":"shgt_zhangfubang_hs","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"start_date","Value":"2020-09-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2020-09-28","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"instruments","NodeId":"-160"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-160"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-160","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"Comment":"","CommentCollapsed":true},{"Id":"-166","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"\n# #号开始的表示注释,注释需单独一行\n# 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征\ndate\ninstrument\n#name\n#list_date\namount \t\n#chg_5m \t\n#chg_amount \t\n#date \t\n#high \t\n#higher_speed \t\t\n#low \t\n#market_cap \n#pct_chg \t\n#pct_chg_60d \t\n#pct_chg_year_now \t\n#pe \t\n#pre_close \t\n#price \t \t\n#swing \t\n#turn \t\nvolume\n#close\n#close_0\n#open_0\n#jmje\n#open_1","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-166"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-166","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='-160' Position='308,268,200,200'/><NodePosition Node='-166' Position='331,-38,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]:
      # 本代码由可视化策略环境自动生成 2020年9月30日 09:50
      # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
      
      
      m2 = M.input_features.v1(
          features="""
      # #号开始的表示注释,注释需单独一行
      # 多个特征,每行一个,可以包含基础特征和衍生特征,特征须为本平台特征
      date
      instrument
      #name
      #list_date
      amount 	
      #chg_5m 	
      #chg_amount 	
      #date 	
      #high 	
      #higher_speed 		
      #low 	
      #market_cap 
      #pct_chg 	
      #pct_chg_60d 	
      #pct_chg_year_now 	
      #pe 	
      #pre_close 	
      #price 	 	
      #swing 	
      #turn 	
      volume
      #close
      #close_0
      #open_0
      #jmje
      #open_1"""
      )
      
      m1 = M.use_datasource.v1(
          features=m2.data,
          datasource_id='shgt_zhangfubang_hs',
          start_date='2020-09-01',
          end_date='2020-09-28'
      )
      

      (adhaha111) #4

      您好,请问您的设置的参数是怎么样的呢,这边并没有复现出您的问题


      (donkyxote) #5

      抱歉,日期是2019-01-01 – 2020-09-01


      (donkyxote) #6
      克隆策略

        {"Description":"实验创建于2020/9/29","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-8901:instruments","SourceOutputPortId":"-8888:data"},{"DestinationInputPortId":"-8901:features","SourceOutputPortId":"-8896:data"},{"DestinationInputPortId":"-8908:features","SourceOutputPortId":"-8896:data"},{"DestinationInputPortId":"-8908:input_data","SourceOutputPortId":"-8901:data"},{"DestinationInputPortId":"-8917:input_ds","SourceOutputPortId":"-8908:data"}],"ModuleNodes":[{"Id":"-8888","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2019-02-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2020-09-24","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"market","Value":"CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_list","Value":"399006.ZIX","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_count","Value":"0","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"rolling_conf","NodeId":"-8888"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-8888","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"Comment":"预测数据,用于回测和模拟","CommentCollapsed":true},{"Id":"-8896","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"avg_amount=mean(amount, 10)\nstd_amount=std(amount,10)\nrisk_amount=avg_amount - 0.12*std_amount\n#risky=where(amount<avg_amount, 1, 0)\n\navg_turn_5 = mean(turn,5)\navg_turn_10 = mean(turn,10)\nstd_turn_5 = std(turn,5)\nstd_turn_10 = std(turn,10)\nrisk_turn_5 = (avg_turn_5 - 0.12*std_turn_10)\nrisk_turn_10 = (avg_turn_10 - 0.12*std_turn_10)\n\n\n\n\nshort_period = 5\nlong_period = 20\n\nshort_mavg = mean(close,short_period)\nlong_mavg = mean(close,long_period)\n\nz_risky = where(risk_turn_5<risk_turn_10,1,0) \nz_riskier = where(short_mavg < long_mavg,1,0)","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"-8896"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-8896","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"Comment":"","CommentCollapsed":true},{"Id":"-8901","ModuleId":"BigQuantSpace.use_datasource.use_datasource-v1","ModuleParameters":[{"Name":"datasource_id","Value":"bar1d_index_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":"-8901"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-8901"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-8901","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":3,"Comment":"","CommentCollapsed":true},{"Id":"-8908","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":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"remove_extra_columns","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_functions","Value":"{}","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-8908"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features","NodeId":"-8908"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-8908","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"Comment":"","CommentCollapsed":true},{"Id":"-8917","ModuleId":"BigQuantSpace.select_columns.select_columns-v3","ModuleParameters":[{"Name":"columns","Value":"date,z_risky","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"reverse_select","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_ds","NodeId":"-8917"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"columns_ds","NodeId":"-8917"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-8917","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":5,"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='-8888' Position='645.9999694824219,277.99998474121094,200,200'/><NodePosition Node='-8896' Position='938.9999694824219,305.99998474121094,200,200'/><NodePosition Node='-8901' Position='642.9999694824219,422.99998474121094,200,200'/><NodePosition Node='-8908' Position='659.9999694824219,550.9999847412109,200,200'/><NodePosition Node='-8917' Position='686.9091491699219,685.8182220458984,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月29日 18:08
        # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
        
        
        m1 = M.instruments.v2(
            start_date='2019-02-01',
            end_date='2020-09-24',
            market='CN_STOCK_A',
            instrument_list='399006.ZIX',
            max_count=0
        )
        
        m2 = M.input_features.v1(
            features="""avg_amount=mean(amount, 10)
        std_amount=std(amount,10)
        risk_amount=avg_amount - 0.12*std_amount
        #risky=where(amount<avg_amount, 1, 0)
        
        avg_turn_5 = mean(turn,5)
        avg_turn_10 = mean(turn,10)
        std_turn_5 = std(turn,5)
        std_turn_10 = std(turn,10)
        risk_turn_5 = (avg_turn_5 - 0.12*std_turn_10)
        risk_turn_10 = (avg_turn_10 - 0.12*std_turn_10)
        
        
        
        
        short_period = 5
        long_period = 20
        
        short_mavg = mean(close,short_period)
        long_mavg = mean(close,long_period)
        
        z_risky = where(risk_turn_5<risk_turn_10,1,0) 
        z_riskier = where(short_mavg < long_mavg,1,0)"""
        )
        
        m3 = M.use_datasource.v1(
            instruments=m1.data,
            features=m2.data,
            datasource_id='bar1d_index_CN_STOCK_A',
            start_date='',
            end_date=''
        )
        
        m4 = M.derived_feature_extractor.v3(
            input_data=m3.data,
            features=m2.data,
            date_col='date',
            instrument_col='instrument',
            drop_na=True,
            remove_extra_columns=True,
            user_functions={}
        )
        
        m5 = M.select_columns.v3(
            input_ds=m4.data,
            columns='date,z_risky',
            reverse_select=False,
            m_cached=False
        )
        
        列: ['date', 'z_risky']
        /data: 46
        

        (adhaha111) #7

        您好,您这里只有46列是因为turn字段有很多nan,衍生抽取模块中又对nan进行了drop操作,这就导致了很多样本被删除了。目前的行情表中的turn字段是以前保留下来的,后面会删除turn字段,所以您可以先将含turn字段的表达式删除


        (donkyxote) #8

        那请问现在要获取换手率需要调用什么ne?


        (adhaha111) #9

        您好,目前暂时没有指数的换手率


        (donkyxote) #10

        好吧谢谢。。还想请问下北资的数据是不是也还不齐全呢?