Alternatives

Comparison to yfinance

In [1]:
import os

import pandas as pd
from IPython.core.interactiveshell import InteractiveShell

from yahooquery import Ticker
import yfinance as yf

InteractiveShell.ast_node_interactivity = "all"
pd.options.display.float_format = '{:,}'.format
pd.options.display.max_columns = None
pd.set_option('display.max_rows', 100)
In [2]:
symbol = 'aapl'

YF_aapl = yf.Ticker('aapl')
YQ_aapl = Ticker('aapl')

Financials

yfinance

In [3]:
%%time
attrs = ['cashflow', 'balance_sheet', 'financials']
yf_d = {}
for attr in attrs:
    df = getattr(YF_aapl, attr)
    yf_d[attr] = df.shape[0]
Wall time: 3.15 s

yahooquery

In [4]:
%%time
methods = ['cash_flow', 'balance_sheet', 'income_statement']
yq_d = {}
for method in methods:
    df = getattr(YQ_aapl, method)()
    df.set_index(['asOfDate', 'periodType'], inplace=True)
    df = df.T
    yq_d[method] = df.shape[0]
Wall time: 1.34 s
In [5]:
# Comparison of the number of items returned for each
cash_flow = yf_d.pop('cashflow')
income_statement = yf_d.pop('financials')
yf_d.update({'cash_flow': cash_flow, 'income_statement': income_statement})
pd.DataFrame({'yahooquery': yq_d, 'yfinance': yf_d})
Out[5]:
yahooquery yfinance
cash_flow 26 19
balance_sheet 66 25
income_statement 39 22

Yahooquery retrieves more cash flow, balance sheet, and income statement data than yfinance and quicker!

Historical Pricing

In [6]:
# Compare downloads for all companies within the S&P500
tables = pd.read_html("https://en.wikipedia.org/wiki/List_of_S%26P_500_companies")
sp500 = tables[0]['Symbol'].tolist()
sp500 = [symbol.replace(".", "-") for symbol in sp500]

yfinance

In [7]:
%%time
yf_data = yf.download(sp500, period='ytd', interval='1d', group_by='ticker')
[*********************100%***********************]  505 of 505 completed
Wall time: 56.1 s
In [8]:
type(yf_data)
yf_data.shape
yf_data.head()
Out[8]:
pandas.core.frame.DataFrame
Out[8]:
(181, 3030)
Out[8]:
FDX SO UNP CCL LW TTWO GILD GS EMN PFE CPRT CE ALXN EXPE WLTW NBL BIIB MGM ULTA ARE TFX AMP HPE FANG MO RTX OKE PSX ORLY MCD BK WEC WFC AZO SEE GOOG BIO CERN SNA CMCSA J FLIR TDY LYB NRG CVS RCL CL GOOGL AAL LLY LNT PCAR ETR PAYC EOG TGT MAS AAP ETFC MDLZ PAYX ABBV IVZ HSY AMGN CDNS ALL SJM AMCR MA COG DISH PLD USB CRM LIN F NKE TYL VTR UNH RHI MET KR WU REGN AMAT GM HWM EFX PNW ODFL TIF JNPR D AMD PXD NCLH AIV MPC NDAQ CAH FFIV ATVI CCI ORCL PM KEY SLG VRTX DRE AJG PBCT IT QRVO OMC AEP CMI AKAM SNPS AON PHM DFS IRM BEN ABT K NWSA RMD MAA NVR APH PYPL DISCA ILMN IPG ISRG MKC MU OTIS GLW APD LVS TXT ALK MTB FOX PEP CMA C COST COP EL AVY FTNT IEX EW TMUS KHC AXP IP AES BDX AFL GPC DVA NLSN GPN SYK DGX CBRE NWL CDW GPS PH LH LEN AMT HPQ LKQ HAL CMS DOW KMX NOC HAS V MXIM WY STT DE TEL STZ GRMN L COTY HFC MRK BWA ADP GIS LOW FLS TWTR TSN HSIC ZION QCOM LUV LNC CVX MCO DVN UAA MSCI ES INCY CBOE CF HUM TRV MSI UNM CMG BKNG PFG CTVA ABC DIS RL HD INTC OXY SHW HCA HRB TROW FRT PVH UPS CHRW GL ESS XEL IBM JPM EXPD FOXA WDC KEYS EQIX CB UDR VLO CI CTAS SLB LB ANTM WELL ADBE NSC FE KO WBA CLX PNC ED BAC JCI RSG TPR XRX JKHY ETN LRCX COF AAPL NFLX DG MTD CNP DAL WM TFC CME BLL MOS AVB DRI BSX AME JBHT IFF PEG PEAK CTXS SWK UA DISCK DUK RE PSA TMO DXCM WST ANSS CAT AIZ APTV BA CHD PWR CXO DHR HRL CTSH EMR IQV LDOS CPB BF-B MRO DXC HBAN ALGN MNST FTI ZTS COO ITW IR BKR ROP RF MLM GWW NWS REG LYV LEG DPZ TXN DOV FMC TT SPG GE SPGI CARR WRK T PG MHK BR DTE FLT AOS PNR HBI APA KSU MMC VRSN TJX SWKS SYF YUM ALB BAX URI PRGO KLAC MYL UHS NEE XRAY CFG XOM STE TDG CAG FITB MKTX SBUX ACN HES NUE SRE PPL NOV PPG HLT WAB TSCO NI AIG VIAC VZ VAR WMB BRK-B EQR EA AMZN VNO MAR HON JNJ MS BLK FRC FTV WRB MCHP HII PGR ZBH VMC IPGP SYY MCK ATO IDXX XLNX ALLE XYL PRU WHR SIVB ECL CNC PKI VFC ANET VRSK KMB CINF ICE FCX WYNN INFO SCHW EXC MSFT DLTR ABMD HIG KMI NTRS MDT EIX CSX ZBRA DHI HST CTL AEE LMT SBAC O ADI ROK ROL DD INTU TAP NLOK NOW GD FBHS KSS AVGO BBY EBAY FAST ROST ADM NEM DLR NVDA PKG FB AWK RJF BXP BMY STX CSCO FIS CHTR A EVRG KIM FISV NTAP ADSK UAL EXR LHX WAT MMM WMT HOLX
Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume Open High Low Close Adj Close Volume
Date