Note
Refer to IEX Jupyter Notebook for more details.
IEX¶
Insider Trades`_
Installation¶
Note
Before working with this API, you will need to obtain a key from IEX Cloud
Install pyEX with pip:
pip install pyEX
Usage¶
Note
This library will output a Pandas DataFrame when the function ends with “DF”. Otherwise, they can easily be converted to a dataframe, as show in the Stream Realtime Data section.
Import all necessary libraries:
import pandas as pd
import pyEX as p
import requests
Show all Functions¶
The following command shows all functions available, all of which follow the same structure as the examples below.
[_ for _ in dir(p) if _.endswith('DF')]
Historical Price and Volume for 1 Stock¶
Outputs the OHLCV for the given ticker.
history = conn.chartDF(ticker)
Adding Time Periods or Frequency¶
Changing the timeframe variable adjusts the time frame
and frequency of the OHLCV data.
timeframe = '5d' # up to 15 years, or minute-by-minute for the last 30 days
history = conn.chartDF(ticker, timeframe=timeframe)
Stock Split and Dividends¶
Warning
This feature requires a premium subscription
timeframe = '6m'
dividends = conn.dividendsDF(ticker)
Sentiment and News¶
Outputs the headline, source, summary, URL and image of the given ticker.
news = conn.newsDF(ticker, count=10)
Insider Trades¶
Warning
This feature requires a premium subscription
trades = conn.insiderTransactionsDF(ticker)
Stream Realtime Data¶
Each invocation of this function outputs all current data available for the
ticker.
ticker = 'GE'
real_time = conn.quote(ticker)
# convert to Pandas DataFrame
real_time = pd.DataFrame(real_time, index = ['value']).T