
作者寄语
本次修改原来的 「全球指数数据」 接口,重命名函数和增加频率字段,可以设定:日、周、月的数据频率。
更新接口
-
"index_investing_global" # 全球指数数据接口
全球指数数据
接口: index_investing_global
目标地址: https://cn.investing.com/indices/
描述: 获取世界主要国家的各种指数, 由于涉及国家和指数(「1000」 + 个指数)具体参见国家-指数目录具体的调用方式可以参照:
-
先查询指数所在的国家名称; -
复制网页上国家名称(推荐复制), 如 「美国」; -
复制所显示的具体指数名称(推荐复制, 如果英文中间有空格, 也需要保留空格), 如 「美元指数」; 也可以调用 「ak.index_investing_global_country_name_url("美国")」 获取需要国家的具体指数名称 -
在安装 AkShare 后输入, 如 「ak.index_investing_global(country="美国", index_name="VIX恐慌指数", period="每月", start_date="2005-01-01", end_date="2020-06-05")」; -
稍后就可以获得所需数据.
限量: 单次返回某一个国家的具体某一个指数, 建议用 for 循环获取多个国家的多个指数, 注意不要大量获取, 以免给对方服务器造成压力!
输入参数
| 名称 | 类型 | 必选 | 描述 |
|---|---|---|---|
| country | str | Y | country="美国" |
| index_name | str | Y | index_name="美元指数"; 可以通过 ak.index_investing_global_country_name_url("美国") 获取 |
| period | str | Y | period="每月"; choice of {"每日", "每周", "每月"} |
| start_date | str | Y | start_date='2000-01-01' |
| end_date | str | Y | end_date='2019-10-17' |
输出参数
| 名称 | 类型 | 默认显示 | 描述 |
|---|---|---|---|
| 日期 | str | Y | 日期-索引 |
| 收盘 | float | Y | 收盘 |
| 开盘 | float | Y | 开盘 |
| 高 | float | Y | 高 |
| 低 | float | Y | 低 |
| 交易量 | float | Y | 交易量 |
接口示例
import akshare as ak
index_investing_global_df = ak.index_investing_global(country="美国", index_name="VIX恐慌指数", period="每月", start_date="2005-01-01", end_date="2020-06-05")
print(index_investing_global_df)
数据示例
收盘 开盘 高 低 交易量
日期
2020-06-01 24.30 28.90 30.60 23.60 0.0
2020-05-01 27.51 38.17 40.32 25.92 0.0
2020-04-01 34.15 57.38 60.59 30.54 0.0
2020-03-01 53.54 34.86 85.47 24.93 0.0
2020-02-01 40.11 18.64 49.48 13.38 0.0
... ... ... ... ...
2005-05-01 13.29 15.45 17.70 11.65 0.0
2005-04-01 15.31 13.64 18.59 11.20 0.0
2005-03-01 14.02 11.95 14.89 11.66 0.0
2005-02-01 12.08 12.80 13.20 10.90 0.0
2005-01-01 12.82 13.39 14.75 12.29 0.0
本文分享自微信公众号 - 数据科学实战(dsaction)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。
来源:oschina
链接:https://my.oschina.net/u/4486485/blog/4341004