复制链接
克隆策略
In [2]:
DataSource('hxie_limitStatics_U').read() 
Out[2]:
date limitup_nums limitup_percent limitdown_nums limitdown_percent
0 2022-10-10 65 1.32 65 1.32
1 2022-10-11 17 0.34 17 0.34
2 2022-10-12 2 0.04 2 0.04
3 2022-10-13 10 0.20 10 0.20
4 2022-10-14 3 0.06 3 0.06
... ... ... ... ... ...
86 2023-02-15 2 0.04 2 0.04
87 2023-02-16 6 0.12 6 0.12
88 2023-02-17 7 0.14 7 0.14
89 2023-02-20 20 0.39 20 0.39
90 2023-02-21 5 0.10 5 0.10

91 rows × 5 columns

    {"description":"实验创建于2022/11/9","graph":{"edges":[{"to_node_id":"-216:instruments","from_node_id":"-203:data"},{"to_node_id":"-216:features","from_node_id":"-211:data"},{"to_node_id":"-226:input_1","from_node_id":"-216:data"},{"to_node_id":"-174:input_data","from_node_id":"-226:data_1"}],"nodes":[{"node_id":"-203","module_id":"BigQuantSpace.instruments.instruments-v2","parameters":[{"name":"start_date","value":"2023-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2050-01-01","type":"Literal","bound_global_parameter":"交易日期"},{"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":"-203"}],"output_ports":[{"name":"data","node_id":"-203"}],"cacheable":true,"seq_num":1,"comment":"","comment_collapsed":true},{"node_id":"-211","module_id":"BigQuantSpace.input_features.input_features-v1","parameters":[{"name":"features","value":"price_limit_status_0","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"features_ds","node_id":"-211"}],"output_ports":[{"name":"data","node_id":"-211"}],"cacheable":true,"seq_num":2,"comment":"","comment_collapsed":true},{"node_id":"-216","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":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"instruments","node_id":"-216"},{"name":"features","node_id":"-216"}],"output_ports":[{"name":"data","node_id":"-216"}],"cacheable":true,"seq_num":3,"comment":"","comment_collapsed":true},{"node_id":"-226","module_id":"BigQuantSpace.cached.cached-v3","parameters":[{"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()\n dates = df.date.unique()\n dates.sort()\n limitup_df = pd.DataFrame({'date': dates, 'limitup_nums':0, 'limitup_percent':0,\"limitdown_nums\":0,'limitdown_percent':0})\n def cpt_limitup_nums(x):\n date = x.date.values[0]\n limitup_df.loc[limitup_df.date==date, 'limitup_nums'] = len(x[x.price_limit_status_0==1])\n limitup_df.loc[limitup_df.date==date, 'limitup_percent'] = round((len(x[x.price_limit_status_0==1]) / len(x)) * 100, 2)\n limitup_df.loc[limitup_df.date==date, 'limitdown_nums'] = len(x[x.price_limit_status_0==1])\n limitup_df.loc[limitup_df.date==date, 'limitdown_percent'] = round((len(x[x.price_limit_status_0==1]) / len(x)) * 100, 2)\n df.groupby('date').apply(cpt_limitup_nums)\n print(m1.data.read()['end_date'])\n data_1 = DataSource.write_df(limitup_df)\n return Outputs(data_1=data_1, data_2=None, data_3=None)\n","type":"Literal","bound_global_parameter":null},{"name":"post_run","value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","type":"Literal","bound_global_parameter":null},{"name":"input_ports","value":"","type":"Literal","bound_global_parameter":null},{"name":"params","value":"{}","type":"Literal","bound_global_parameter":null},{"name":"output_ports","value":"","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_1","node_id":"-226"},{"name":"input_2","node_id":"-226"},{"name":"input_3","node_id":"-226"}],"output_ports":[{"name":"data_1","node_id":"-226"},{"name":"data_2","node_id":"-226"},{"name":"data_3","node_id":"-226"}],"cacheable":true,"seq_num":6,"comment":"","comment_collapsed":true},{"node_id":"-174","module_id":"BigQuantSpace.datahub_update_datasource2.datahub_update_datasource2-v1","parameters":[{"name":"alias","value":"hxie_limitStatics","type":"Literal","bound_global_parameter":null},{"name":"date_field","value":"date","type":"Literal","bound_global_parameter":null},{"name":"primary_key","value":"# #号开始的表示注释,注释需单独一行\n# 主键字段, 每个字段为一行\n# 主键字段主要用于数据去重, 建议填写, 避免过多重复数据\n# 示例如下: \n# col_xxx\n# col_yyy\ndate\n","type":"Literal","bound_global_parameter":null},{"name":"friendly_name","value":"涨跌停统计","type":"Literal","bound_global_parameter":null},{"name":"desc","value":"涨跌停统计","type":"Literal","bound_global_parameter":null},{"name":"public","value":"True","type":"Literal","bound_global_parameter":null},{"name":"rewrite","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[{"name":"input_data","node_id":"-174"}],"output_ports":[{"name":"data","node_id":"-174"}],"cacheable":false,"seq_num":5,"comment":"","comment_collapsed":true},{"node_id":"-390","module_id":"BigQuantSpace.datahub_usertask2.datahub_usertask2-v3","parameters":[{"name":"task_name","value":"hxie_limit_task","type":"Literal","bound_global_parameter":null},{"name":"description","value":"更新涨跌停","type":"Literal","bound_global_parameter":null},{"name":"run_time","value":"16:08","type":"Literal","bound_global_parameter":null},{"name":"day_of_week","value":"每天","type":"Literal","bound_global_parameter":null},{"name":"day_of_month","value":"每天","type":"Literal","bound_global_parameter":null},{"name":"not_run_weekly","value":"True","type":"Literal","bound_global_parameter":null},{"name":"update_mode","value":"False","type":"Literal","bound_global_parameter":null}],"input_ports":[],"output_ports":[{"name":"task","node_id":"-390"}],"cacheable":false,"seq_num":4,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-203' Position='33,243,200,200'/><node_position Node='-211' Position='398,249,200,200'/><node_position Node='-216' Position='164,355,200,200'/><node_position Node='-226' Position='237,473,200,200'/><node_position Node='-174' Position='240.631591796875,596.3157958984375,200,200'/><node_position Node='-390' Position='147,100,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [1]:
    # 本代码由可视化策略环境自动生成 2023年2月23日 18:13
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    def m6_run_bigquant_run(input_1, input_2, input_3):
        # 示例代码如下。在这里编写您的代码
        df = input_1.read()
        dates = df.date.unique()
        dates.sort()
        limitup_df = pd.DataFrame({'date': dates, 'limitup_nums':0, 'limitup_percent':0,"limitdown_nums":0,'limitdown_percent':0})
        def cpt_limitup_nums(x):
            date = x.date.values[0]
            limitup_df.loc[limitup_df.date==date, 'limitup_nums'] = len(x[x.price_limit_status_0==1])
            limitup_df.loc[limitup_df.date==date, 'limitup_percent'] = round((len(x[x.price_limit_status_0==1]) / len(x))  * 100, 2)
            limitup_df.loc[limitup_df.date==date, 'limitdown_nums'] = len(x[x.price_limit_status_0==1])
            limitup_df.loc[limitup_df.date==date, 'limitdown_percent'] = round((len(x[x.price_limit_status_0==1]) / len(x))  * 100, 2)
        df.groupby('date').apply(cpt_limitup_nums)
        print(m1.data.read()['end_date'])
        data_1 = DataSource.write_df(limitup_df)
        return Outputs(data_1=data_1, data_2=None, data_3=None)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m6_post_run_bigquant_run(outputs):
        return outputs
    
    
    m1 = M.instruments.v2(
        start_date='2023-01-01',
        end_date=T.live_run_param('trading_date', '2050-01-01'),
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m2 = M.input_features.v1(
        features='price_limit_status_0'
    )
    
    m3 = M.general_feature_extractor.v7(
        instruments=m1.data,
        features=m2.data,
        start_date='',
        end_date=''
    )
    
    m6 = M.cached.v3(
        input_1=m3.data,
        run=m6_run_bigquant_run,
        post_run=m6_post_run_bigquant_run,
        input_ports='',
        params='{}',
        output_ports=''
    )
    
    m5 = M.datahub_update_datasource2.v1(
        input_data=m6.data_1,
        alias='hxie_limitStatics',
        date_field='date',
        primary_key="""# #号开始的表示注释,注释需单独一行
    # 主键字段, 每个字段为一行
    # 主键字段主要用于数据去重, 建议填写, 避免过多重复数据
    # 示例如下: 
    # col_xxx
    # col_yyy
    date
    """,
        friendly_name='涨跌停统计',
        desc='涨跌停统计',
        public=True,
        rewrite=False
    )
    
    m4 = M.datahub_usertask2.v3(
        task_name='hxie_limit_task',
        description='更新涨跌停',
        run_time='16:08',
        day_of_week='每天',
        day_of_month='每天',
        not_run_weekly=True,
        update_mode=False
    )
    
    2050-01-01
    

    数据保存/更新(数据平台) 数据统计 (前 91 行) </font></font>

    date limitup_nums limitup_percent limitdown_nums limitdown_percent
    count(Nan) 0 0 0 0 0
    type datetime64[ns] int64 float64 int64 float64

    数据保存/更新(数据平台) 数据预览 (前 5 行) </font></font>

    date limitup_nums limitup_percent limitdown_nums limitdown_percent
    0 2022-10-10 65 1.32 65 1.32
    1 2022-10-11 17 0.34 17 0.34
    2 2022-10-12 2 0.04 2 0.04
    3 2022-10-13 10 0.20 10 0.20
    4 2022-10-14 3 0.06 3 0.06