复制链接
克隆策略

本模块演示"读取数据(DataSource)"模块的具体使用

表名:bar1d_CN_STOCK_A 日线行情表

开始时间:2021-01-01

结束时间:2021-11-10

股票列表: 000002.SZA, 600000.SHA, 000333.SZA

字段列表: close, high

该模块调用等价于代码如下运行:

df = DataSource('bar1d_CN_STOCK_A').read(instruments=['000002.SZA','600000.SHA','000333.SZA'], start_date='2021-01-01' end_date='2021-11-10', fields=['close','high'] )

    {"description":"实验创建于2021/12/3","graph":{"edges":[],"nodes":[{"node_id":"-260","module_id":"BigQuantSpace.datahub_load_datasource.datahub_load_datasource-v1","parameters":[{"name":"table","value":"bar1d_CN_STOCK_A","type":"Literal","bound_global_parameter":null},{"name":"start_date","value":"2021-01-01","type":"Literal","bound_global_parameter":null},{"name":"end_date","value":"2021-11-10","type":"Literal","bound_global_parameter":null},{"name":"instruments","value":"# #号开始的表示注释,注释需单独一行\n# 每行一条\n000002.SZA\n600000.SHA\n000333.SZA","type":"Literal","bound_global_parameter":null},{"name":"fields","value":"# #号开始的表示注释,注释需单独一行\n# 每行一条\nclose\nhigh","type":"Literal","bound_global_parameter":null}],"input_ports":[],"output_ports":[{"name":"data","node_id":"-260"}],"cacheable":false,"seq_num":1,"comment":"","comment_collapsed":true}],"node_layout":"<node_postions><node_position Node='-260' Position='-36.710357666015625,-303.2218933105469,200,200'/></node_postions>"},"nodes_readonly":false,"studio_version":"v2"}
    In [2]:
    # 本代码由可视化策略环境自动生成 2021年12月9日 18:26
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    m1 = M.datahub_load_datasource.v1(
        table='bar1d_CN_STOCK_A',
        start_date='2021-01-01',
        end_date='2021-11-10',
        instruments="""# #号开始的表示注释,注释需单独一行
    # 每行一条
    000002.SZA
    600000.SHA
    000333.SZA""",
        fields="""# #号开始的表示注释,注释需单独一行
    # 每行一条
    close
    high"""
    )
    

    读取数据(DataSource) 数据统计 (前 618 行) </font></font>

    instrument close date high
    count(Nan) 0 0 0 0
    type object float32 datetime64[ns] float32

    读取数据(DataSource) 数据预览 (前 5 行) </font></font>

    instrument close date high
    0 600000.SHA 129.901932 2021-01-04 130.438156
    1 000333.SZA 458.925323 2021-01-04 472.552612
    2 000002.SZA 4275.360840 2021-01-04 4370.779297
    3 600000.SHA 129.767868 2021-01-05 129.767868
    4 000333.SZA 470.652222 2021-01-05 472.506287
    In [5]:
    # 模块结果查看
    m1.data.read()
    
    Out[5]:
    instrument close date high
    0 600000.SHA 129.901932 2021-01-04 130.438156
    1 000333.SZA 458.925323 2021-01-04 472.552612
    2 000002.SZA 4275.360840 2021-01-04 4370.779297
    3 600000.SHA 129.767868 2021-01-05 129.767868
    4 000333.SZA 470.652222 2021-01-05 472.506287
    ... ... ... ... ...
    613 000002.SZA 2965.075928 2021-11-09 2979.722168
    614 600000.SHA 120.263733 2021-11-09 120.404556
    615 000002.SZA 3088.756348 2021-11-10 3093.638428
    616 000333.SZA 328.955170 2021-11-10 329.995270
    617 600000.SHA 119.418785 2021-11-10 120.122910

    618 rows × 4 columns