- Notifications
You must be signed in to change notification settings - Fork132
addisonlynch/iexfinance
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Python SDK forIEX Cloud. Architecture mirrorsthat 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 quotes
- Historical data (daily and minutely)
- Financial statements (Balance Sheet, Income Statement, Cash Flow)
- End of Day Options Prices
- Institutional and Fund ownership
- Analyst estimates, Price targets
- Corporate actions (Dividends, Splits)
- Sector performance
- Market analysis (gainers, losers, volume, etc.)
- IEX market data & statistics (IEX supported/listed symbols, volume, etc)
- Social Sentiment and CEO Compensation
Stable documentation is hosted ongithub.io.
Development documentation is also available for the latest changes in master.
From PyPI with pip (latest stable release):
$ pip3 install iexfinance
From development repository (dev version):
$ git clone https://github.com/addisonlynch/iexfinance.git$cd iexfinance$ python3 setup.py install
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 aStock
object.The easiest way to store a token is in theIEX_TOKEN
environment variable.
The authentication token can also be passed to any function call:
fromiexfinance.refdataimportget_symbolsget_symbols(token="<YOUR-TOKEN>")
or at the instantiation of aStock
object:
fromiexfinance.stocksimportStocka=Stock("AAPL",token="<YOUR-TOKEN>")a.get_quote()
iexfinance
is designed to mirror the structure of the IEX Cloud API. Thefollowing IEX Cloud endpoint groups are mapped to their respectiveiexfinance
modules:
The most commonly-usedendpoints are theStocksendpoints, which allow access to various information regarding equities,including quotes, historical prices, dividends, and much more.
TheStock
objectprovides access to most endpoints, and can be instantiated with a symbol orlist 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 Data endpointgroup, obtain theSocial Sentiment endpoint withiexfinance.altdata.get_social_sentiment
:
fromiexfinance.altdataimportget_social_sentimentget_social_sentiment("AAPL")
Theiex-examples repository provides a number of detailed examples of iexfinance usage. Basic examples are also provided below.
To obtain real-time quotes for one or more symbols, use theget_price
method of theStock
object:
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()
It's possible to obtain historical data usingget_historical_data
andget_historical_intraday
.
To obtain daily historical price data for one or more symbols, use theget_historical_data
function. This will return a daily time-series of the tickerrequested over the desired date range (start
andend
passed asdatetime.datetime
objects):
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()
To obtain historical intraday data, useget_historical_intraday
as follows.Pass an optionaldate
to specify a date within three months prior to thecurrent 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')
fromiexfinance.stocksimportStockaapl=Stock("AAPL")aapl.get_balance_sheet()
aapl.get_income_statement()
aapl.get_cash_flow()
fromiexfinance.stocksimportStockaapl=Stock("AAPL")aapl.get_estimates()
aapl.get_price_target()
fromiexfinance.altdataimportget_social_sentimentget_social_sentiment("AAPL")
fromiexfinance.altdataimportget_ceo_compensationget_ceo_compensation("AAPL")
fromiexfinance.stocksimportStockaapl=Stock("AAPL")# Fund ownershipaapl.get_fund_ownership()# Institutional ownershipaapl.get_institutional_ownership()
List of Symbols IEX supports for API calls
fromiexfinance.refdataimportget_symbolsget_symbols()
List of Symbols IEX supports for trading
fromiexfinance.refdataimportget_iex_symbolsget_iex_symbols()
fromiexfinance.accountimportget_usageget_usage(quota_type='messages')
fromiexfinance.accountimportget_api_statusget_api_status()
By default,iexfinance
returns data for most endpoints in apandasDataFrame
.
Selectingjson
as the output format returns data formattedexactly as received fromthe IEX Endpoint. Configuringiexfinance
's output format can be done in two ways:
For persistent configuration of a specified output format, use the environmentvariableIEX_OUTPUT_FORMAT
. This value will be overridden by theoutput_format
argument if it is passed.
Type the following command into your terminal:
$export IEX_OUTPUT_FORMAT=pandas
Seehere for instructions on setting environment variables in Windows operating systems.
Passoutput_format
as an argument to any function call:
fromiexfinance.refdataimportget_symbolsget_symbols(output_format='pandas').head()
or at the instantiation of aStock
object:
fromiexfinance.stocksimportStockaapl=Stock("AAPL",output_format='pandas')aapl.get_quote().head()
Email:ahlshop@gmail.com
Twitter:alynchfc
Copyright © 2020 Addison Lynch
See LICENSE for details
About
Python SDK for IEX Cloud
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors14
Uh oh!
There was an error while loading.Please reload this page.