Package: iexfinance
Python SDK forIEX Cloud. Architecture mirrors
that of the IEX Cloud API (and itsdocumentation).An easy-to-use toolkit to obtain data for Stocks, ETFs, Mutual Funds,
Forex/Currencies, Options, Commodities, Bonds, and Cryptocurrencies:Real-time and delayed quotesHistorical data (daily and minutely)Financial statements (Balance Sheet, Income Statement, Cash Flow)End of Day Options PricesInstitutional and Fund ownershipAnalyst estimates, Price targetsCorporate actions (Dividends, Splits)Sector performanceMarket analysis (gainers, losers, volume, etc.)IEX market data & statistics (IEX supported/listed symbols, volume, etc)Social Sentiment and CEO CompensationExampleDocumentationStable documentation is hosted ongithub.io.Development documentationis also available for the latest changes in master.InstallFrom PyPI with pip (latest stable release):$ pip3 install iexfinanceFrom development repository (dev version):$gitclonehttps://github.com/addisonlynch/iexfinance.git$cdiexfinance$python3setup.pyinstallWhat’s Needed to Access IEX Cloud?An IEX Cloud account is required to acecss the IEX Cloud API. Variousplansare availalbe, free, paid, and pay-as-you-go.Your IEX Cloud (secret) authentication token can be passed to any function or at the instantiation of aStockobject.
The easiest way to store a token is in theIEX_TOKENenvironment variable.Passing as an ArgumentThe authentication token can also be passed to any function call:fromiexfinance.refdataimportget_symbolsget_symbols(token="<YOUR-TOKEN>")or at the instantiation of aStockobject:fromiexfinance.stocksimportStocka=Stock("AAPL",token="<YOUR-TOKEN>")a.get_quote()How This Package is Structurediexfinanceis designed to mirror the structure of the IEX Cloud API. The
following IEX Cloud endpoint groups are mapped to their respectiveiexfinancemodules:The most commonly-used
endpoints are theStocksendpoints, which allow access to various information regarding equities,
including quotes, historical prices, dividends, and much more.TheStockobjectprovides access to most endpoints, and can be instantiated with a symbol or
list of symbols:fromiexfinance.stocksimportStockaapl=Stock("AAPL")aapl.get_balance_sheet()The rest of the package is designed as a 1:1 mirror. For example, using theAlternative Dataendpoint
group, obtain theSocial Sentimentendpoint withiexfinance.altdata.get_social_sentiment:fromiexfinance.altdataimportget_social_sentimentget_social_sentiment("AAPL")Common Usage ExamplesTheiex-examplesrepository provides a number of detailed examples of iexfinance usage. Basic examples are also provided below.Real-time QuotesTo obtain real-time quotes for one or more symbols, use theget_pricemethod of theStockobject:fromiexfinance.stocksimportStocktsla=Stock('TSLA')tsla.get_price()or for multiple symbols, use a list or list-like object (Tuple, Pandas Series,
etc.):batch=Stock(["TSLA","AAPL"])batch.get_price()Historical DataIt’s possible to obtain historical data usingget_historical_dataandget_historical_intraday.DailyTo obtain daily historical price data for one or more symbols, use theget_historical_datafunction. This will return a daily time-series of the ticker
requested over the desired date range (startandendpassed asdatetime.datetimeobjects):fromdatetimeimportdatetimefromiexfinance.stocksimportget_historical_datastart=datetime(2017,1,1)end=datetime(2018,1,1)df=get_historical_data("TSLA",start,end)To obtain daily closing prices only (reduces message count), setclose_only=True:df=get_historical_data("TSLA","20190617",close_only=True)For Pandas DataFrame output formatting, passoutput_format:df=get_historical_data("TSLA",start,end,output_format='pandas')It’s really simple to plot this data, usingmatplotlib:importmatplotlib.pyplotaspltdf.plot()plt.show()Minutely (Intraday)To obtain historical intraday data, useget_historical_intradayas follows.
Pass an optionaldateto specify a date within three months prior to the
current day (default is current date):fromdatetimeimportdatetimefromiexfinance.stocksimportget_historical_intradaydate=datetime(2018,11,27)get_historical_intraday("AAPL",date)or for a Pandas Dataframe indexed by each minute:get_historical_intraday("AAPL",output_format='pandas')FundamentalsFinancial StatementsBalance Sheetfromiexfinance.stocksimportStockaapl=Stock("AAPL")aapl.get_balance_sheet()Income Statementaapl.get_income_statement()Cash Flowaapl.get_cash_flow()Modeling/Valuation ToolsAnalyst Estimatesfromiexfinance.stocksimportStockaapl=Stock("AAPL")aapl.get_estimates()Price Targetaapl.get_price_target()Social Sentimentfromiexfinance.altdataimportget_social_sentimentget_social_sentiment("AAPL")CEO Compensationfromiexfinance.altdataimportget_ceo_compensationget_ceo_compensation("AAPL")Fund and Institutional Ownershipfromiexfinance.stocksimportStockaapl=Stock("AAPL")# Fund ownershipaapl.get_fund_ownership()# Institutional ownershipaapl.get_institutional_ownership()Reference DataList of Symbols IEX supports for API callsfromiexfinance.refdataimportget_symbolsget_symbols()List of Symbols IEX supports for tradingfromiexfinance.refdataimportget_iex_symbolsget_iex_symbols()Account UsageMessage Countfromiexfinance.accountimportget_usageget_usage(quota_type='messages')API StatusIEX Cloud API Statusfromiexfinance.accountimportget_api_statusget_api_status()ConfigurationOutput FormattingBy default,iexfinancereturns data for most endpoints in apandasDataFrame.Selectingjsonas the output format returns data formattedexactlyas received from
the IEX Endpoint. Configuringiexfinance’s output format can be done in two ways:Environment Variable (Recommended)For persistent configuration of a specified output format, use the environment
variableIEX_OUTPUT_FORMAT. This value will be overridden by theoutput_formatargument if it is passed.macOS/LinuxType the following command into your terminal:$exportIEX_OUTPUT_FORMAT=pandasWindowsSeeherefor instructions on setting environment variables in Windows operating systems.output_formatArgumentPassoutput_formatas an argument to any function call:fromiexfinance.refdataimportget_symbolsget_symbols(output_format='pandas').head()or at the instantiation of aStockobject:fromiexfinance.stocksimportStockaapl=Stock("AAPL",output_format='pandas')aapl.get_quote().head()ContactEmail:ahlshop@gmail.comTwitter:alynchfcLicenseCopyright © 2020 Addison LynchSee LICENSE for details