Skip to main content
https://travis-ci.org/addisonlynch/iexfinance.svg?branch=master https://codecov.io/gh/addisonlynch/iexfinance/branch/master/graphs/badge.svg?branch=master https://badge.fury.io/py/iexfinance.svg https://img.shields.io/badge/License-Apache%202.0-blue.svg

Python wrapper around the Investors Exchange (IEX) Developer API.

An easy-to-use interface to obtain:

  • Real-time quotes

  • Historical data

  • Fundamentals,

  • Actions (dividends, splits), Sector Performance

  • Trading analyses (gainers, losers, etc.)

  • IEX Market Data & Stats

iexfinance provides real-time financial data from the various IEX endpoints, including:

Documentation

Stable documentation is hosted on github.io.

Development documentation is also available for the latest changes in master.

Install

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

Common Usage Examples

The iex-examples repository provides a number of detailed examples of iexfinance usage. Basic examples are also provided below.

Using iexfinance to access data from IEX is quite easy. The most commonly-used endpoints are the Stocks endpoints, which allow access to various information regarding equities, including quotes, historical prices, dividends, and much more.

Real-time Quotes

To obtain real-time quotes for one or more symbols, use the get_price method of the Stock object:

from iexfinance.stocks import Stock
tsla = 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 Data

It’s possible to obtain historical data the get_historical_data and get_historical_intraday.

Daily

To obtain daily historical price data for one or more symbols, use the get_historical_data function. This will return a daily time-series of the ticker requested over the desired date range (start and end passed as datetime.datetime objects):

from datetime import datetime
from iexfinance.stocks import get_historical_data

start = datetime(2017, 1, 1)
end = datetime(2018, 1, 1)

df = get_historical_data("TSLA", start, end)

For Pandas DataFrame output formatting, pass output_format:

df = get_historical_data("TSLA", start, end, output_format='pandas')

It’s really simple to plot this data, using matplotlib:

import matplotlib.pyplot as plt

df.plot()
plt.show()

Minutely (Intraday)

To obtain historical intraday data, use get_historical_intraday as follows. Pass an optional date to specify a date within three months prior to the current day (default is current date):

from datetime import datetime
from iexfinance.stocks import get_historical_intraday

date = 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')

Endpoints

Stock Endpoints

The Stock function creates a StockReader instance which has a method to retrieve each of the Stocks endpoints (get_quote, get_book, get_volume_by_venue, etc.):

from iexfinance.stocks import Stock
tsla = Stock('TSLA')
tsla.get_open()
tsla.get_price()

Pandas DataFrame and JSON (dict) output formatting are selected with the output_format parameter when calling Stock.

tsla = Stock("TSLA", output_format='pandas')
tsla.get_quote()

IEX Reference Data

Support for the IEX Reference Data endpoints is available through the top level functions get_available_symbols, get_corporate_actions, get_dividends, get_next_day_ex_date, and get_listed_symbol_dir. As with all endpoints, request parameters such as retry_count and output format selection (through output_format) can be passed to the call.

from iexfinance import get_available_symbols

get_available_symbols(output_format='pandas')[:2]

IEX Market Data

The IEX Market Data endpoints are supported through various top-level functions, including get_market_tops and get_market_deep.

from iexfinance import get_market_tops

get_market_tops()

IEX Stats

The IEX Stats endpoints are supported through various top-level functions, including get_stats_intraday and get_stats_recent. These endpoints provide IEX’s trading statistics for a given ticker.

from iexfinance import get_stats_intraday

get_stats_intraday()

Debugging & Caching

All functions (including Stock and get_historical_data) allow for Request Parameters, which include retry_count, pause, and session. These parameters are entirely optional. The first two deal with how unsuccessful requests are handled, and the third allows for the passing of a cached requests-cache session (see caching).

Contact

Email: ahlshop@gmail.com

Twitter: alynchfc

License

Copyright © 2018 Addison Lynch

See LICENSE for details

Metadata

Release files for iexfinance 0.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iexfinance 0.3.5
File Size Uploaded
iexfinance-0.3.5.tar.gz 22.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for iexfinance 0.3.5
File Interpreter ABI Platform
iexfinance-0.3.5-py3-none-any.whl Python 3 none any Details

Total release size: 44.3 kB

Release files / iexfinance-0.3.5.tar.gz

Download URL iexfinance-0.3.5.tar.gz
Size 22.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9e2643c7583d877fd55d24cf4a3d1173d761b42bd66a926734436a95d148f52b
BLAKE2b-256 checksum
How to use checksums
5694cea4adc6376a12f19e5ba0bbdd96a99e9a585bb9fa3baaad98870f7cea0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

Release files / iexfinance-0.3.5-py3-none-any.whl

Download URL iexfinance-0.3.5-py3-none-any.whl
Size 21.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0523d02fbdd042060c9c816972cdbaaa4fde1cf3451b3caaeda9c6b1253cb4b
BLAKE2b-256 checksum
How to use checksums
f38c1b63aaeca15a69b7821e9a0394950465bc546fe282fd4bc7a0ddde3c4343
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

Release history Release notifications | RSS feed

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

This release

0.3.5 This release

2 release files

0.3.4

2 release files

0.3.3

1 release file

0.3.2

1 release file

0.3.1

2 release files

0.3.0

2 release files

0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page