Giter Club home page Giter Club logo

iexfinance's Introduction

iexfinance

https://travis-ci.org/addisonlynch/iexfinance.svg?branch=master https://codecov.io/gh/addisonlynch/iexfinance/branch/master/graphs/badge.svg?branch=master

Now Supporting IEX Cloud

Python SDK for IEX Cloud and the legacy Version 1.0 Investors Exchange (IEX) Developer API. Architecture mirrors that of the IEX Cloud API (and its documentation).

iexfinance will maintain compatibility and support for the IEX Version Developer API until June 2019.

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

Example

https://addisonlynch.github.io/public/img/iexexample.gif

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

Basics

iexfinance is designed to mirror the structure of the IEX Cloud API. The following IEX Cloud endpoint groups are mapped to their respective iexfinance modules:

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.

The Stock object provides access to most endpoints, and can be instantiated with a symbol or list of symbols:

from iexfinance.stocks import Stock

aapl = Stock("AAPL")
aapl.get_balance_sheet()

The rest of the package is designed as a 1:1 mirror. For example, using the Alternative Data endpoint group, obtain the Social Sentiment endpoint with iexfinance.altdata.get_social_sentiment:

from iexfinance.altdata import get_social_sentiment

get_social_sentiment("AAPL")

Configuration

Selecting an API Version

Note to Version 1.0 users: see Migrating to IEX Cloud for more information about migrating to IEX Cloud.

iexfinance now supports both active IEX APIs: IEX Cloud, as well as the legacy Version 1.0 IEX Developer API.

The IEX API version can be selected by setting the environment variable IEX_API_VERSION to one of the following values:

IEX is continuing support for the legacy API until at least May 29th, 2019.

Output Formatting

By default, iexfinance returns data formatted exactly as received from the IEX Endpoint. pandas DataFrame output formatting is available for most endpoints.

pandas DataFrame output formatting can be selected by setting the IEX_OUTPUT_FORMAT environment variable to pandas or by passing output_format as an argument to any function call (or at the instantiation of a Stock object).

Common Usage Examples

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

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 using 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')

Fundamentals

Financial Statements

Balance Sheet

from iexfinance.stocks import Stock

aapl = Stock("AAPL")
aapl.get_balance_sheet()

Income Statement

aapl.get_income_statement()

Cash Flow

aapl.get_cash_flow()

Modeling/Valuation Tools

Analyst Estimates

from iexfinance.stocks import Stock

aapl = Stock("AAPL")

aapl.get_estimates()

Price Target

aapl.get_price_target()

Social Sentiment

from iexfinance.altdata import get_social_sentiment
get_social_sentiment()

Reference Data

List of Symbols IEX supports for API calls

from iexfinance.refdata import get_symbols

get_symbols()

List of Symbols IEX supports for trading

from iexfinance.refdata import get_iex_symbols

get_iex_symbols()

Account Usage

Message Count

from iexfinance.account import get_usage

get_usage(quota_type='messages')

API Status

IEX Cloud API Status

from iexfinance.account import get_api_status

get_api_status()

Contact

Email: [email protected]

Twitter: alynchfc

License

Copyright © 2019 Addison Lynch

See LICENSE for details

iexfinance's People

Contributors

addisonlynch avatar stubs avatar kafana avatar dgnsrekt avatar edwardbetts avatar jackmoody11 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.