PDF下载 下载

股票与指数数据函数

阅读 4044

股票与指数数据函数(beta版)

python股票与指数数据API包含在gm3.0.145版本及以上版本,不需要引入新库


stk_get_index_constituents - 查询指数最新成分股

查询指定指数在最新交易日的成分股和权重

函数原型:

  1. stk_get_index_constituents(index)

参数:

参数名 类型 中文名称 必填 默认值 参数用法说明
index str 指数代码 Y 必填,只能输入一个指数,如:'SHSE.000905'

返回值:dataframe

字段名 类型 中文名称 说明
index str 指数代码 查询成分股的指数代码
symbol str 成分股代码 exchange.sec_id
weight float 成分股权重 成分股symbol对应的指数权重
trade_date datetime.datetime 交易日期 最新交易日,%Y-%m-%d 格式

示例:

  1. stk_get_index_constituents(index='SHSE.000905')

输出:

  1. index symbol weight date
  2. 0 SHSE.000905 SZSE.000009 0.0060 2022-09-07
  3. 1 SHSE.000905 SZSE.000012 0.0015 2022-09-07
  4. 2 SHSE.000905 SZSE.000021 0.0018 2022-09-07
  5. 3 SHSE.000905 SZSE.000027 0.0020 2022-09-07
  6. 4 SHSE.000905 SZSE.000028 0.0007 2022-09-07
  7. .. ... ... ... ...
  8. 495 SHSE.000905 SHSE.688390 0.0032 2022-09-07
  9. 496 SHSE.000905 SHSE.688521 0.0020 2022-09-07
  10. 497 SHSE.000905 SHSE.688777 0.0035 2022-09-07
  11. 498 SHSE.000905 SHSE.688819 0.0008 2022-09-07
  12. 499 SHSE.000905 SHSE.689009 0.0025 2022-09-07
  13. [500 rows x 4 columns]

注意:

1. 数据日频更新,当日更新前返回前一交易日的成分数据,约在交易日20点左右更新当日数据。

0 篇笔记