AkShare-指数数据-全球指数

时间:2022-07-22
本文章向大家介绍AkShare-指数数据-全球指数,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

作者寄语

本次修改原来的 「全球指数数据」 接口,重命名函数和增加频率字段,可以设定:日、周、月的数据频率。

更新接口

  • "index_investing_global" # 全球指数数据接口

全球指数数据

接口: index_investing_global

目标地址: https://cn.investing.com/indices/

描述: 获取世界主要国家的各种指数, 由于涉及国家和指数(「1000」 + 个指数)具体参见国家-指数目录具体的调用方式可以参照:

  1. 先查询指数所在的国家名称;
  2. 复制网页上国家名称(推荐复制), 如 「美国」;
  3. 复制所显示的具体指数名称(推荐复制, 如果英文中间有空格, 也需要保留空格), 如 「美元指数」; 也可以调用 「ak.index_investing_global_country_name_url("美国")」 获取需要国家的具体指数名称
  4. 在安装 AkShare 后输入, 如 「ak.index_investing_global(country="美国", index_name="VIX恐慌指数", period="每月", start_date="2005-01-01", end_date="2020-06-05")」;
  5. 稍后就可以获得所需数据.

限量: 单次返回某一个国家的具体某一个指数, 建议用 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