IEXStock Classes

IEXStock Class

class iex.IEXStock(ticker, period='quarter', last=1, autopopulate=False)

A class that is built around retrieving data from the IEX Cloud API service. All available data is derived from functions defined in the stock.py module, and are implemented here with a get_ prefix. All data retrieved is automatically stored in the corrosponding class attribute (sans get_ prefix). Data set to class attributes can be saved to file and subsequently loaded from that file to limit credit usage in IEX Cloud.

Parameters
  • ticker (string, required) – The symbol or ticker of the stock for which the class is to be created.

  • period (string, optional) – Default is ‘quarter’. Allows a user to set period data for all income statement requests.

  • last (integer, optional) – Default is 1. Allows a user to specify how many statements to retrieve of financial statement data.

  • autopopulate (boolean, optional) – Automatically populates key information as class attributes. Uses methods ‘basic_information’ and ‘price_information’

basic_information()

6 credits per symbol requested. Makes requests to the company and key stat IEX endpoints. Sets class attributes for:

Company name (self.company_name)

Industry (self.industry)

Market Capitalization (self.market_cap)

P/E Ratio (self.pe_ratio)

Beta (self.beta)

get_advanced_fundementals(period, output=None)

75,000 credits per symbol requested. CSV is formatted vertically with keys in the first column. Sets class attribute ‘advanced_fundementals’

Returns

Immediate access to the data points in IEX models for 2850+ companies. Models are updated daily.

Parameters
  • period (accepted values are ['annual', 'quarterly'], optional) – Time interval of statements. Defaults to quarterly

  • last (integer, optional) – Number of periods to return, up to 4 for annual and 16 for quarterly. Defaults to 1.

  • output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_advanced_stats(output=None)

3,005 credits per symbol requested. Sets class attribute ‘advanced_stats’.

Returns

Buffed version of key stats with selected financial data and more. Includes all data points from ‘key stats’.

Parameters

output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_analyst_recommendations(output=None)

Premium Data. 1,000 premium credits per symbol requested. Sets class attribute ‘analyst_recommendations’.

Returns

Analyst stock recommendations for the requested stock from the last four months.

Parameters

output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_balance_sheet(period=None, last=None, output=None)

3,000 credits per symbol requested.

Sets class attribute ‘self.balance_sheet’

Returns

Balance sheet data for the requested company. If any non-JSON output is chosen, the method will return a Pandas DataFrame with the data from this endpoint.

Parameters
  • period (accepted values are ['annual', 'quarterly'], optional) – Time interval of statements. Defaults to quarterly

  • last (integer, optional) – Number of periods to return, up to 4 for annual and 16 for quarterly. Defaults to 1.

  • output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_basic_financials(output=None)

5000 credits per symbol requested. Note that fetching all three full financial statements has the same credit cost as this endpoint. Sets class attribute ‘basic_financials’.

Returns

Basic financial data from the requested company.

Parameters

output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_cash_flow_statement(period=None, last=None, output=None)

1,000 credits per symbol requested.

Sets class attribute ‘self.cash_flow_statement’

Returns

Cash flow statement data for the requested company. If any non-JSON output is chosen, the method will return a Pandas DataFrame with the data from this endpoint.

Parameters
  • period (accepted values are ['annual', 'quarterly'], optional) – Time interval of statements. Defaults to quarterly

  • last (integer, optional) – Number of periods to return, up to 4 for annual and 16 for quarterly. Defaults to 1.

  • output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_company(output=None)

1 credit per symbol requested. Sets class attribute ‘company’.

Returns

General information on the company requested.

Parameters

output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_delayed_quote(output=None)

1 credit per symbol requested. Sets class attribute ‘delayed_quote’.

Returns

15 minute delayed quote for the requested symbol.

Parameters

output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_dividends(scope, output=None)

10 credits per symbol requested. Sets class attribute ‘dividends’.

Returns

Basic dividend information for the requested symbol.

Parameters
  • scope (accepted arguments: ['5y','2y','1y','ytd','6m','3m','1m','next'], required) – the range of data needed.

  • output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_financial_statements(period=None, last=None, output=None)

5,000 credits per symbol requested. This is useful if you want to update the query parameters after you’ve made some requests. It’s just a time saver.

Returns

All financial statement data for the requested company and sets class attribute for each individual statement, and returns a list of the attribute names.

Parameters
  • period (accepted values are ['annual', 'quarterly'], optional) – Time interval of statements. Defaults to quarterly

  • last (integer, optional) – Number of periods to return, up to 4 for annual and 16 for quarterly. Defaults to 1.

  • output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_fund_ownership(output=None)

10,000 credits per symbol requested. Sets class attribute ‘fund_ownership’.

Returns

10 largest institutional holders of the requested company.

Parameters

output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_historical_price(time_frame, date=None, chart_by_day=False, chart_close_only=False, output=None)

10 credits per day requested when part of a time frame. (Full Data) 50 credits per single day, minute data.

Parameters
  • time_frame (string) – Determines how far back to retrieve data. Set to ‘date’ if only one specific day is required.

  • date (string) – If ‘date’ is specified in time_frame, this is the date that you wish to access.

  • chart_by_date (boolean) – If a single date is requested, setting param to True only returns OHLC data instead of minutely data.

  • output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_income_statement(period=None, last=None, output=None)

1,000 credits per symbol requested.

Sets class attribute ‘self.income_sheet’

Returns

Income sheet data for the requested company. If any non-JSON output is chosen, the method will return a Pandas DataFrame with the data from this endpoint.

Parameters
  • period (accepted values are ['annual', 'quarterly'], optional) – Time interval of statements. Defaults to quarterly

  • last (integer, optional) – Number of periods to return, up to 4 for annual and 16 for quarterly. Defaults to 1.

  • output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_insider_roster(output=None)

5,000 credits per symbol requested. Sets class attribute ‘insider_roster’.

Returns

Top 10 insiders, with the most recent information.

Parameters

output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_insider_transactions(output=None)

50 credits per transaction per symbol requested. Sets class attribute ‘insider_transactions’.

Returns

Insider transactions with the most recent information.

Parameters

output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_institutional_ownership(output=None)

10,000 credits per symbol requested. Sets class attribute ‘institutional_ownership’.

Returns

10 largest instituional owners for the requested stock. This is defined as explicitly buy or sell-side only.

Parameters

output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_key_stats(stat=None, output=None)

5 credits per symbol requested, 1 credit per stat per symbol requested. Sets class attribute ‘key_stats’.

Returns

Important stats for the requested company.

Parameters
  • stat (string, optional) – If you would like to querie one single stat, you can enter that here.

  • output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_largest_trades(output=None)

1 credit per trade per symbol requested. Sets class attribute ‘largest_trades’.

Returns

15 minute delayed, last sale eligible trades.

Parameters
  • stat (string, optional) – If you would like to querie one single stat, you can enter that here.

  • output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

1 credit per symbol requested. Sets class attribute ‘logo’.

Returns

Google APIs link (bare url string) to the logo for the requested stock.

get_news(last=10, output=None)

1 credit per news article per symbol requested. Sets class attribute ‘news’.

Returns

Intraday news from over 3,000 global news sources including major publications, regional media, and social.

Parameters
  • last (integer, min = 1 max = 50) – Number of article to return. Defualt = 10

  • output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_ohlc(output=None)

2 credits per symbol requested. Sets class attribute ‘ohlc’.

Returns

Official open and close for a give symbol.

Parameters

output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_peers()

500 credits per symbol requested. Sets class attribute ‘peers’.

Returns

List of peer company’s tickers in Python list form.

get_price_target(output=None)

Premium Data. 500 premium credits per symbol requested. CSV is formatted vertically with keys in the first column. Sets class attribute ‘price_target’.

Returns

Latest avg, high, and low analyst price target for a symbol.

Parameters

output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

get_quote(output=None)

1 credit per symbol requested. CSV is formatted vertically with keys in the first column. Sets class attribute ‘quote’.

Returns

Quote data for the requested symbol.

Parameters

output (accepted values are ['dataframe', 'csv', 'excel'], optional) – Determines the output of the data. Default is raw JSON.

pandas_financial_json(json, statement)

Returns a dataframe for the requested financial statement.

Parameters
  • json (string, raw json, required) – the raw json output from IEX Cloud containing financial statement data.

  • statement (accepted values are : 'balancesheet', 'incomestatement', and 'cashflow'.) – the name of the statement as used by IEX Cloud.

pandas_listofdict_json(json)

Returns a dataframe for the requested list of dictionaries json document.

Parameters

json (raw json) – the raw json output from IEX Cloud containing a list of dictionary.

pandas_price_json(json)

Returns a dataframe for the requested price statement.

Parameters

json (raw json) – the raw json output from IEX Cloud containing daily price data.

pandas_singledict_json(json, in_list=False)

Returns a dataframe for the requested dictionary json document.

Parameters
  • json (raw json) – the raw json output from IEX Cloud containing a list of dictionary.

  • in_list (boolean) – whether the disctionary is conatined within a list element, that is, inside square braces.

pickle_class_state()

This method takes the current state of the class and pickles it as-is. This will preserve all attributes of the current class instance. Recalling/loading the class can be done with the iex.unpickle_class_state() Filename is automatically created as ‘#ticker#_#date#_pickle.pickle’

price()

1 credit per symbol requested.

Returns

Most recent price for the requested company and sets class attribute ‘self.price’.

price_information()

6 credits per symbol requested. Makes requests to the key stat and price endpoints. Sets class attributes for:

52 week high (week52_high), 52 week low (week52_low)

200 day moving average (moving_average_200), 50 day moving average (moving_average_50)

Most recent price (self.price)

set_date()

Sets the date attribute. This is needed keep save and load funcionality smooth.

IEXMarket Class

class iex.IEXMarket
get_all_commodity_data(output_csv=False)

10,000 credits per request per day. Returns all available current commodity datapoints.

Parameters

output (boolean, optional) – Determines the output of the data. Default is raw JSON.

get_all_economic_data(output_csv=False)

18,000 credits per request per day. :return: All available current economic indicator datapoints.

Parameters

output (boolean, optional) – Determines the output of the data. Default is raw JSON.

get_market_datapoint(symbol, key='market', **queries)

1,000 credits per symbol requested per date. Sets a class attribute equal to the symbol requested.

Class attribute ‘available_economic_symbols’ is a dictionary of available economic symbols and their description. Class attribute ‘available_commodity_symbols’ is a dictionary of available commodity symbols and their description

Returns

Various economic and commodity values as a datapoint.

Parameters
  • symbol (string, required) – The symbol of the economic indicator or commodity datapoint requested.

  • **queries

    Additional query parameters you want to include as listed in IEX Docs.