Git Product home page Git Product logo

iex-api-python's Introduction

Build Status Coverage Status Python 3.6 Documentation

IEX-API-Python

IEX-API-Python Logo

under construction

This module is currently being actively developed. Feedback is welcomed.

Summary

The iex-api-python module is a wrapper for the IEX API, and is designed to closely map to the organization of the original API while adding functionality. A few examples of the additional functionality are:

  • Many queries are retadurned as Pandas Dataframes.
  • Built-in support for websockets connections.
  • Option to format timestamps as datetime objects or ISO format.

Installation

Note that you must be using Python >=3.6

pip install iex-api-python

Getting Started

From the API documenation:

The IEX API is a set of services designed for developers and engineers. It can be used to build high-quality apps and services. We’re always working to improve the IEX API. Please check back for enhancements and improvements.

The API terms apply to the use of this module, as does the requirement to properly attribute the use of IEX data.

Organization

The IEX-API-Python module is designed to map closely to the API from IEX. For many of the API calls, the resulting dataset is better represented in a tabular format. For these calls, data are returned as a pandas.DataFrame.

Examples

To illustrate a few things you can do with iex-api-python, take a look at the examples below.

Fetch all stock symbols

from iex import reference
reference.symbols() # Returns a Pandas Dataframe of all stock symbols, names, and more.
     symbol        date  iexId  isEnabled  \
0         A  2018-05-16      2       True
1        AA  2018-05-16  12042       True
2      AABA  2018-05-16   7653       True
3       AAC  2018-05-16   9169       True

Get a stock price

from iex import Stock
Stock("F").price()
11.4

Get a stocks price for the last year

from iex import Stock
Stock("F").chart_table(range="1y")
       change  changeOverTime  changePercent    close        date     high  \
0    0.000000        0.000000          0.000  10.2760  2017-05-16  10.3982
1   -0.169075       -0.016446         -1.645  10.1070  2017-05-17  10.2854
2    0.028180       -0.013712          0.279  10.1351  2017-05-18  10.1633
3    0.075144       -0.006394          0.741  10.2103  2017-05-19  10.2760
4    0.216042        0.014626          2.116  10.4263  2017-05-22  10.4545
5   -0.046966        0.010062         -0.450  10.3794  2017-05-23  10.4874
6   -0.084539        0.001830         -0.814  10.2948  2017-05-24  10.3888
...

iex-api-python's People

Contributors

danielecook avatar mtchavez avatar steveltn avatar thedatadavis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iex-api-python's Issues

Stock.peers() returns NameError

Calling the peers method does not return a list of Stock objects; instead errors.

def peers(self, as_string=False):
  if as_string:
    return [x for x in self._get("peers")]
  else:
    return [stock(x) for x in self._get("peers")]

` NameError: name 'stock' is not defined

However, using the as_string=True parameter does successfully return the list which can then be looped through to get each peer's info.

403: Forbidden

Getting Exception: 403: Forbidden
on the example:
Stock("F").price()

Did the api change?

Stock.dividends return unexpected values.

Hi,
Stock.dividends() returns chart response. Is that expected behavior?
If not, need to change to call dividends API.

def dividends(self, range='1m'):
    """
        Args:
            range - what range of data to retrieve. The variable
                    'DIVIDEND_RANGES' has possible values in addition to a date.
    """
    validate_range_set(range, RANGES)
    return self._get(f"**dividends**/{range}")

Problem with import

Could you help with this issue?
c:\RH\myRH>python3 iex.py
Traceback (most recent call last):
File "iex.py", line 1, in
from iex import stock
File "c:\RH\myRH\iex.py", line 1, in
from iex import stock
ImportError: cannot import name 'stock' from 'iex' (c:\RH\myRH\iex.py)

Print revisited

I actually meant this print statement:

diff --git a/iex/stocks.py b/iex/stocks.py
index 8d031e0..03c9d8e 100644
--- a/iex/stocks.py
+++ b/iex/stocks.py
@@ -26,7 +26,8 @@ class Stock:
     def _get(self, url, params={}):
         request_url =f"{BASE_URL}/stock/{self.symbol}/{url}"
         response = requests.get(request_url, params=params)
-        print(response.url)
+        # Removed print for every URL we request
+        #print(response.url)
         if response.status_code != 200:
             raise Exception(f"{response.status_code}: {response.content.decode('utf-8')}")
         result = response.json()

Can't import iex at Google Colab

After installing iex-api-python on fresh notebook at Google Colab, got error

!pip install iex-api-python
from iex import Stock
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-13-5a07ca1b682b> in <module>()
----> 1 from iex import Stock

/usr/local/lib/python3.6/dist-packages/iex/__init__.py in <module>()
      2 from iex.stocks import Stock
      3 from iex.batch import Batch
----> 4 from iex.market import market, Market
      5 from iex.iex_stats import iex_stats, IexStats
      6 from iex.iex_market import IexMarket

ImportError: cannot import name 'market'

---------------------------------------------------------------------------

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.