搜索与查询#
类#
Search模块允许您以Python风格的方式访问搜索数据。
|
从Yahoo Finance获取并整理搜索结果,包括股票报价和新闻文章。 |
Lookup模块允许您以Python风格的方式查找股票代码。
|
从Yahoo Finance获取股票代码查询。 |
示例代码#
Search模块允许您以Pythonic方式访问搜索数据。
import yfinance as yf
# get list of quotes
quotes = yf.Search("AAPL", max_results=10).quotes
# get list of news
news = yf.Search("Google", news_count=10).news
# get list of related research
research = yf.Search("apple", include_research=True).research
Lookup模块允许您以Python风格的方式查找股票代码。
import yfinance as yf
# Get All
all = yf.Lookup("AAPL").all
all = yf.Lookup("AAPL").get_all(count=100)
# Get Stocks
stock = yf.Lookup("AAPL").stock
stock = yf.Lookup("AAPL").get_stock(count=100)
# Get Mutual Funds
mutualfund = yf.Lookup("AAPL").mutualfund
mutualfund = yf.Lookup("AAPL").get_mutualfund(count=100)
# Get ETFs
etf = yf.Lookup("AAPL").etf
etf = yf.Lookup("AAPL").get_etf(count=100)
# Get Indices
index = yf.Lookup("AAPL").index
index = yf.Lookup("AAPL").get_index(count=100)
# Get Futures
future = yf.Lookup("AAPL").future
future = yf.Lookup("AAPL").get_future(count=100)
# Get Currencies
currency = yf.Lookup("AAPL").currency
currency = yf.Lookup("AAPL").get_currency(count=100)
# Get Cryptocurrencies
cryptocurrency = yf.Lookup("AAPL").cryptocurrency
cryptocurrency = yf.Lookup("AAPL").get_cryptocurrency(count=100)