复制链接
克隆策略

    {"description":"实验创建于2023/3/1","graph":{"edges":[{"to_node_id":"-1060:instruments","from_node_id":"-1047:data"},{"to_node_id":"-1060:features","from_node_id":"-1055:data"},{"to_node_id":"-1067:features","from_node_id":"-1055:data"},{"to_node_id":"-1067:input_data","from_node_id":"-1060:data"}],"nodes":[{"node_id":"-1047","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2023-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2023-03-01","type":"Literal","bound_global_parameter":null},{"name":"market","value":"CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"instrument_list","value":"","type":"Literal","bound_global_parameter":null},{"name":"max_count","value":0,"type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"rolling_conf","node_id":"-1047"}],"output_ports":[{"name":"data","node_id":"-1047"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-1055","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"amount_zf=amount_0/amount_1\n#是否异动,成交量翻倍,涨幅超过5%\nyidong=where((amount_zf>2)&(return_0>1.05),1,0)\n\n#获取最近10天内的出现异动是哪一天\nyidong_day=ts_argmax(yidong, 10)\n\n#获取异动那天的开盘价,取值方式一\nyidong_open=shift(open_0,yidong_day)\n#报错信息: cannot convert the series to <class 'int'>\n\n#获取异动那天的开盘价,取值方式二\nyidong_open_1=shift(open_0,floor(yidong_day))\n#报错信息:only size-1 arrays can be converted to Python scalars","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-1055"}],"output_ports":[{"name":"data","node_id":"-1055"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-1060","module_id":"BigQuantSpace.general_feature_extractor.general_feature_extractor-v7","parameters":[{"name":"start_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"","type":"Literal","bound_global_parameter":null},{"name":"before_start_days","value":90,"type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-1060"},{"name":"features","node_id":"-1060"}],"output_ports":[{"name":"data","node_id":"-1060"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-1067","module_id":"BigQuantSpace.derived_feature_extractor.derived_feature_extractor-v3","parameters":[{"name":"date_col","value":"date","type":"Literal","bound_global_parameter":null},{"name":"instrument_col","value":"instrument","type":"Literal","bound_global_parameter":null},{"name":"drop_na","value":"False","type":"Literal","bound_global_parameter":null},{"name":"remove_extra_columns","value":"False","type":"Literal","bound_global_parameter":null},{"name":"user_functions","value":"{}","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-1067"},{"name":"features","node_id":"-1067"}],"output_ports":[{"name":"data","node_id":"-1067"}],"cacheable":true,"seq_num":4,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-1047' Position='52,136,200,200'/><node_position Node='-1055' Position='375,284.5856018066406,200,200'/><node_position Node='-1060' Position='213,254,200,200'/><node_position Node='-1067' Position='224,377,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [2]:
    # 本代码由可视化策略环境自动生成 2023年3月1日 15:30
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.instruments.v2(
        start_date='2023-01-01',
        end_date='2023-03-01',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m2 = M.input_features.v1(
        features="""amount_zf=amount_0/amount_1
    #是否异动,成交量翻倍,涨幅超过5%
    yidong=where((amount_zf>2)&(return_0>1.05),1,0)
    
    #获取最近10天内的出现异动是哪一天
    yidong_day=ts_argmax(yidong, 10)
    
    #获取异动那天的开盘价,取值方式一
    yidong_open=shift(open_0,yidong_day)
    #报错信息: cannot convert the series to <class 'int'>
    
    #获取异动那天的开盘价,取值方式二
    yidong_open_1=shift(open_0,floor(yidong_day))
    #报错信息:only size-1 arrays can be converted to Python scalars"""
    )
    
    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={}
    )