从 yfinance python 获取股票价格的最快查询

Fastest query for getting stock prices from yfinance python

我正在开发一个 Flask Web 服务器,它要求我在每次加载特定页面时动态提取当前的加密货币价格。我正在使用 Yfinance 库从加密美元对中获取价格。为此,我 运行 针对每种加密货币的查询:

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

这工作得很好,但是,查询多对时需要很长时间。 我的问题是:有没有更快的方法来查询 yfinance 中的价格对象?

一起查询所有代码--来自文档

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/