yfinance 文档#
从Yahoo! Finance的API下载市场数据#
安装#
$ pip install yfinance
快速开始#
展示了一个yfinance API的小样本,完整的API要大得多,并在API Reference中涵盖。
import yfinance as yf
dat = yf.Ticker("MSFT")
一个股票代码
dat = yf.Ticker("MSFT")
dat.info
dat.calendar
dat.analyst_price_targets
dat.quarterly_income_stmt
dat.history(period='1mo')
dat.option_chain(dat.options[0]).calls
多个股票代码
tickers = yf.Tickers('MSFT AAPL GOOG')
tickers.tickers['MSFT'].info
yf.download(['MSFT', 'AAPL', 'GOOG'], period='1mo')
资金
spy = yf.Ticker('SPY').funds_data
spy.description
spy.top_holdings