Skip to main content

Python module to get stock data from IEX API 1.0

Project description

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 module to retrieve stock data from the Investors Exchange (IEX) Developer API platform. iexfinance provides real-time financial data from the various IEX endpoints, as well as historical time-series data.

This data includes stock quotes, fundamentals, actions, and information. In addition, support for IEX market data and statistics is provided.

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

Usage Examples

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.

All top-level functions (such as 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).

Stock Endpoints

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

It’s also possible to obtain historical data from the get_historical_data top-level 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).

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

Historical Data

from iexfinance import get_historical_data
from datetime import datetime

start = datetime(2017, 2, 9)
end = datetime(2017, 5, 24)

df = get_historical_data("AAPL", start=start, end=end, output_format='pandas')
df.head()

The resulting DataFrame will indexed by date, with a column for each OHLC datapoint:

/docs/source/images/dfdailyaapl.JPG

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

import matplotlib.pyplot as plt

df.plot()
plt.show()
/docs/source/images/plotdailyaapl.jpg

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()

Contact

Email: ahlshop@gmail.com

Twitter: alynchfc

License

Copyright © 2018 Addison Lynch

See LICENSE for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iexfinance-0.3.4.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iexfinance-0.3.4-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file iexfinance-0.3.4.tar.gz.

File metadata

  • Download URL: iexfinance-0.3.4.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for iexfinance-0.3.4.tar.gz
Algorithm Hash digest
SHA256 e68e79f1cdcd6170eb36eecd8b9d37f8a4a33c48953a66c2548c423b0171618c
MD5 2729785b30c8dcf97345c723a7656f00
BLAKE2b-256 6162f83c988be191305997a3ffe2cbea07aa346592658b5ed5f3ddb23f8bd1c0

See more details on using hashes here.

File details

Details for the file iexfinance-0.3.4-py3-none-any.whl.

File metadata

File hashes

Hashes for iexfinance-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f15e9568b81e32b0e777fa75a7d57875022554a0c69b91a7b703619fb3153354
MD5 ba1b9f9e7bd57d6d3f25633c194b8618
BLAKE2b-256 d2ecfd3a6d0bd5a6141a12da10a6dacebd342cbc739f7a80cd5ca1e2a4d6048d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page