AKShare-指数数据-全球指数

数据科学实战

共 5818字,需浏览 12分钟

 · 2021-09-14

作者寄语

本次更新主要是修复了之前全球指数接口的部分bug,另外新增了一个通过 URL 地址来获取指数数据的接口,该接口的实用性相对于之前的接口更强,用下就知道了!

更新接口

  • "index_investing_global" # 全球指数数据
  • "index_investing_global_from_url" # 全球指数数据-URL版

全球指数数据

接口: 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 循环获取多个国家的多个指数, 注意不要大量获取, 以免给对方服务器造成压力!

输入参数

名称类型描述
countrystrcountry="美国"
index_namestrindex_name="美元指数"; 可以通过 ak.index_investing_global_country_name_url("美国") 获取
periodstrperiod="每月"; choice of {"每日", "每周", "每月"}
start_datestrstart_date='20000101'
end_datestrend_date='20191017'

输出参数

名称类型描述
日期object日期
收盘float64收盘价
开盘float64开盘价
float64最高价
float64最低价
交易量float64交易量

接口示例

import akshare as ak
index_investing_global_df = ak.index_investing_global(country="中国", index_name="富时中国A50指数", period="每日", start_date="20000101", end_date="20210909")
print(index_investing_global_df)

数据示例

       日期        收盘        开盘         高         低  交易量
0     2010-05-19   9047.81   9106.26   9191.26   8929.31  0.0
1     2010-05-20   8924.33   9047.81   9143.00   8905.52  0.0
2     2010-05-21   9026.51   8924.33   9030.58   8686.36  0.0
3     2010-05-24   9317.78   9026.51   9375.71   9026.51  0.0
4     2010-05-25   9077.53   9317.78   9317.78   9050.91  0.0
          ...       ...       ...       ...       ...  ...
2783  2021-09-03  15136.65  15093.72  15247.63  14902.02  0.0
2784  2021-09-06  15388.35  15136.65  15462.80  15087.18  0.0
2785  2021-09-07  15544.89  15388.35  15600.47  15283.45  0.0
2786  2021-09-08  15397.64  15544.89  15589.33  15347.35  0.0
2787  2021-09-09  15366.34  15397.64  15402.02  15256.98  0.0

全球指数数据-URL版

接口: index_investing_global_from_url

目标地址: https://www.investing.com/indices/ftse-epra-nareit-eurozone

描述: 世界主要国家的各种指数, 该接口需要通过代理访问; 该接口只需要输入相应指数的 URL 地址

限量: 单次返回某一个国家的具体某一个指数, 建议用 for 循环获取多个国家的多个指数, 注意不要大量获取, 以免给对方服务器造成压力!

输入参数

名称类型描述
urlstrurl="https://www.investing.com/indices/ftse-epra-nareit-eurozone"; 具体指数的页面 URL 地址
periodstrperiod="每月"; choice of {"每日", "每周", "每月"}
start_datestrstart_date='20000101'
end_datestrend_date='20191017'

输出参数

名称类型描述
日期object日期
收盘float64收盘价
开盘float64开盘价
float64最高价
float64最低价
交易量float64交易量

接口示例

import akshare as ak
index_investing_global_df = ak.index_investing_global_from_url(url="https://www.investing.com/indices/ftse-epra-nareit-hong-kong", period="每日", start_date="19900101", end_date="20210909")
print(index_investing_global_df)

数据示例

       日期       收盘       开盘        高        低  交易量
0     2010-05-18  1601.97  1582.11  1605.89  1571.07  0.0
1     2010-05-19  1577.06  1583.19  1594.69  1569.45  0.0
2     2010-05-20  1568.02  1585.58  1585.65  1541.22  0.0
3     2010-05-21  1565.46  1564.88  1565.74  1562.59  0.0
4     2010-05-24  1611.90  1555.62  1615.30  1555.62  0.0
          ...      ...      ...      ...      ...  ...
2959  2021-09-03  1803.02  1813.51  1819.92  1767.47  0.0
2960  2021-09-06  1792.55  1797.30  1799.81  1790.49  0.0
2961  2021-09-07  1798.50  1797.41  1802.65  1790.11  0.0
2962  2021-09-08  1799.42  1793.50  1806.87  1793.24  0.0
2963  2021-09-09  1803.44  1794.91  1819.65  1794.91  0.0


浏览 42
点赞
评论
收藏
分享

手机扫一扫分享

举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

举报