问题描述
我正在使用yfinance API,并希望从ETF中检索更多数据,具体而言,该标签位于标签中的特定ETF的行业权重(%)。 Yahoo网站上的持股:https://finance.yahoo.com/quote/IWDA.AS/holdings?p=IWDA.AS
在当前的API中可能吗?
如果不是,是否有人知道如何将其添加到API?我猜应该在base.py
中,但是我不确定在哪里。欢迎所有帮助!
解决方法
虽然我没有关于yfinance的答案,但是您可以使用名为yahooquery的软件包来检索该数据。免责声明:我是该软件包的作者。
from yahooquery import Ticker
t = Ticker('IWDA.AS')
# sector weightings,returns pandas DataFrame
t.fund_sector_weightings
IWDA.AS
0
realestate 0.0303
consumer_cyclical 0.1036
basic_materials 0.0411
consumer_defensive 0.0857
technology 0.1920
communication_services 0.0917
financial_services 0.1453
utilities 0.0329
industrials 0.1013
energy 0.0331
healthcare 0.1430
t.fund_holding_info
或从整个页面中检索大多数数据:
t.fund_holding_info
{
'IWDA.AS': {
'maxAge': 1,'stockPosition': 0.9959,'bondPosition': 0.0,'holdings': [{
'symbol': 'AAPL','holdingName': 'Apple Inc','holdingPercent': 0.038
},{
'symbol': 'MSFT','holdingName': 'Microsoft Corp','holdingPercent': 0.035099998
},{
'symbol': 'AMZN','holdingName': 'Amazon.com Inc','holdingPercent': 0.0278
},{
'symbol': 'FB','holdingName': 'Facebook Inc A','holdingPercent': 0.012999999
},{
'symbol': 'GOOG','holdingName': 'Alphabet Inc Class C','holdingPercent': 0.010299999
},{
'symbol': 'GOOGL','holdingName': 'Alphabet Inc A','holdingPercent': 0.0101
},{
'symbol': 'JNJ','holdingName': 'Johnson & Johnson','holdingPercent': 0.0088
},{
'symbol': 'V','holdingName': 'Visa Inc Class A','holdingPercent': 0.007900001
},{
'symbol': 'NESN','holdingName': 'Nestle SA','holdingPercent': 0.0078
},{
'symbol': 'PG','holdingName': 'Procter & Gamble Co','holdingPercent': 0.0070999996
}],'equityHoldings': {
'priceToEarnings': 20.47,'priceToBook': 2.34,'priceToSales': 1.62,'priceToCashflow': 11.82
},'bondHoldings': {},'bondRatings': [{
'bb': 0.0
},{
'aa': 0.0
},{
'aaa': 0.0
},{
'a': 0.0
},{
'other': 0.0
},{
'b': 0.0
},{
'bbb': 0.0
},{
'below_b': 0.0
},{
'us_government': 0.0
}],'sectorWeightings': [{
'realestate': 0.030299999
},{
'consumer_cyclical': 0.103599995
},{
'basic_materials': 0.041100003
},{
'consumer_defensive': 0.0857
},{
'technology': 0.192
},{
'communication_services': 0.0917
},{
'financial_services': 0.1453
},{
'utilities': 0.032899998
},{
'industrials': 0.1013
},{
'energy': 0.033099998
},{
'healthcare': 0.143
}]
}
}
您可以通过documentation找到其他数据访问器。