简体   繁体   English

来自单个 API 调用 yfinance Python 的多个报价

[英]Multiple Quotes from single API call yfinance Python

I want a quote for multiple stock symbols with one API call using Yahoo Finance.我想要使​​用雅虎财经通过一个 API 调用获得多个股票代码的报价。

import yfinance as yf

t = yf.Tickers('msft aapl goog')
print(t.info)

Yahoo Finance API is being discontinued .雅虎财经 API 已停止使用

I would suggest using the Financial Modeling Prep API as an alternative.我建议使用 Financial Modeling Prep API 作为替代方案。

https://financialmodelingprep.com/api/v3/historical-price-full/MSFT,AAPL,GOOG https://financialmodelingprep.com/api/v3/historical-price-full/MSFT,AAPL,GOOG

Returns the data you are looking for.返回您要查找的数据。

Full API Documentation can be found here完整的 API 文档可以在 这里找到

Here's a sample code downloading a json with the data:这是下载带有数据的 json 的示例代码:

import json
import requests

url = "https://financialmodelingprep.com/api/v3/historical-price-full/MSFT,AAPL,GOOG"
session = requests.session()
request = session.get(url, timeout=15)
stock_data = request.json()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM