YFinance - tickerData.info 不适用于某些股票 [英] YFinance - tickerData.info not working for some stocks

查看:24
本文介绍了YFinance - tickerData.info 不适用于某些股票的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import yfinance as yf

#define the ticker symbol
tickerSymbol = "AFT.NZ"

#get data on this ticker
tickerData = yf.Ticker(tickerSymbol)
print(tickerData.info)

这似乎不起作用.IndexError: 列表索引超出范围

将AFT.NZ"替换为MSFT"或FPH.NZ",效果很好.转到雅虎网站,不明白为什么它没有数据.

Replace "AFT.NZ" with "MSFT" or "FPH.NZ" and it works fine. Going to the Yahoo website, can't see why it wouldn't have data on it.

更令人困惑的是,将 print(tickerData.info) 替换为 tickerDf = tickerData.history(period='max') 确实会打印一些数据.

What's more confusing, is that replacing print(tickerData.info) with tickerDf = tickerData.history(period='max') does print some of the data.

我需要这些信息,因为我想要公司的全名以及股票交易的货币.这就是为什么仅仅拥有价格数据不是解决方案的原因.

I need the info because I want the full name of the company along with the currency the shares are traded in. Which is why just having the price data isn't the solution.

AFT.NZ 只是一个例子,NZX50 上的大多数其他人似乎都有同样的问题.

The AFT.NZ is just an example, most others on the NZX50 seem to have the same problem.

推荐答案

williamsiuhang 提出了一个合并请求,以解决目前 9 天前的问题.https://github.com/ranaroussi/yfinance/commits/7e137357296a1df177399d26543e889848efc0217e137357296a1df177399d26543e889848efc021

我只是自己手动进行了更改,进入 base.py(在 your_py_dir\Lib\site-packages\yfinance 中)并更改第 286 行:

I just made the change manually myself, go into base.py (in your_py_dir\Lib\site-packages\yfinance) and change line 286:

旧行:

self._institutional_holders = holders[1]

换行:

self._institutional_holders = holders[1] if len(holders) > 1 else []

这篇关于YFinance - tickerData.info 不适用于某些股票的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆