从yfnance python获取股价的最快查询



我正在一个flask web服务器上工作,该服务器要求我每次加载某个页面时都动态获取当前加密货币价格。我正在使用Yfinance库从加密货币美元对中获取价格。为了做到这一点,我为每种加密货币运行这个查询:

import yfinance as yf
bch_price = yf.Ticker("BCH-USD").info["regularMarketPrice"]

这非常好用,但是,查询多对时会花费很长时间。我的问题是:有没有一种更快的方法来查询金融中的价格对象?

从文档一起查询所有股票行情

data = yf.download(  # or pdr.get_data_yahoo(...
# tickers list or string as well
tickers = "SPY AAPL MSFT",
# use "period" instead of start/end
# valid periods: 1d,5d,1mo,3mo,6mo,1y,2y,5y,10y,ytd,max
# (optional, default is '1mo')
period = "ytd",
# fetch data by interval (including intraday if period < 60 days)
# valid intervals: 1m,2m,5m,15m,30m,60m,90m,1h,1d,5d,1wk,1mo,3mo
# (optional, default is '1d')
interval = "1m",
# group by ticker (to access via data['SPY'])
# (optional, default is 'column')
group_by = 'ticker',
# adjust all OHLC automatically
# (optional, default is False)
auto_adjust = True,
# download pre/post regular market hours data
# (optional, default is False)
prepost = True,
# use threads for mass downloading? (True/False/Integer)
# (optional, default is True)
threads = True,
# proxy URL scheme use use when downloading?
# (optional, default is None)
proxy = None
)

https://pypi.org/project/yfinance/

相关内容

  • 没有找到相关文章

最新更新