EodData Client¶
Usage¶
Working with data frames:
import os
from eoddata_client import EodDataHttpClient
client = EodDataHttpClient(os.environ['EOD_DATA_LOGIN'],
os.environ['EOD_DATA_PASSWORD'])
quotes = client.symbol_history('nasdaq', 'msft', datetime.date(1992, 1, 1))
quotes['Diff'] = quotes['Close'].shift(1) - quotes['Close']
print(quotes.tail())
# Symbol Open High Low Close Volume Diff
# 2017-09-20 MSFT 75.35 75.55 74.31 74.94 21587800 0.50
# 2017-09-21 MSFT 75.11 75.24 74.11 74.21 19186100 0.73
# 2017-09-22 MSFT 73.99 74.51 73.85 74.41 14111300 -0.20
# 2017-09-25 MSFT 74.09 74.25 72.92 73.26 24149100 1.15
# 2017-09-26 MSFT 73.67 73.81 72.99 73.26 18019500 0.00
Working with regular list of objects:
import os
from eoddata_client import EodDataHttpClient
client = EodDataHttpClient(os.environ['EOD_DATA_LOGIN'],
os.environ['EOD_DATA_PASSWORD'])
quotes = client.symbol_history('nasdaq', 'msft', datetime.date(1992, 1, 1))
print(quotes[:2])
"""
[EodDataQuoteExtended(symbol=MSFT, quote_datetime=1992-01-01 00:00:00, open=2.319, high=2.319, low=2.319, close=2.319, volume=0, open_interest=0, previous=0.0, change=0.0, bid=0.0, ask=0.0, previous_close=0.0, next_open=0.0, modified=0001-01-01 00:00:00, name=Microsoft Corp, description=Microsoft Corp),
EodDataQuoteExtended(symbol=MSFT, quote_datetime=1992-01-02 00:00:00, open=2.308, high=2.392, low=2.282, close=2.377, volume=1551300, open_interest=0, previous=0.0, change=0.0, bid=0.0, ask=0.0, previous_close=0.0, next_open=0.0, modified=2008-12-27 12:51:50.413000, name=Microsoft Corp, description=Microsoft Corp)]
"""
Client API¶
Http client¶
-
class
EodDataHttpClient
(username, password, base_url='http://ws.eoddata.com/data.asmx/', max_login_retries=3, logger=None)[source]¶ EodData web service client.
- Endpoints:
- CountryList - country_list;
- DataClientLatestVersion - data_client_latest_version;
- DataFormats - data_formats;
- ExchangeGet - exchange_detail;
- ExchangeList - exchange_list;
- ExchangeMonths - exchange_months;
- FundamentalList - fundamental_list;
- Login - login;
- NewsList - news_list;
- NewsListBySymbol - news_list_by_symbol;
- QuoteGet - quote_detail;
- QuoteList - quote_list;
- QuoteList2 - quote_list_specific;
- QuoteListByDate - quote_list_by_date;
- QuoteListByDate2 - quote_list_by_date_compact;
- QuoteListByDatePeriod - quote_list_by_date_period;
- QuoteListByDatePeriod2 - quote_list_by_date_period_compact;
- SplitListByExchange;
- SplitListBySymbol;
- SymbolChangesByExchange;
- SymbolChart;
- SymbolGet;
- SymbolHistory - symbol_history;
- SymbolHistoryPeriod - symbol_history_period;
- SymbolHistoryPeriodByDateRange - symbol_history_period;
- SymbolList - symbol_list;
- SymbolList2 - symbol_list_compact;
- TechnicalList;
- Top10Gains;
- Top10Losses;
- UpdateDataFormat;
- ValidateAccess.
-
country_list
()[source]¶ Returns a list of available countries.
Returns: - [(‘AF’, ‘Afghanistan’), (‘AL’, ‘Albania’), (‘DZ’, ‘Algeria’),
- (‘AS’, ‘American Samoa’), (‘AD’, ‘Andorra’), (‘AO’, ‘Angola’)]
Return type: List of tuples with country code and country name. For example
-
data_client_latest_version
()[source]¶ Returns the latest version information of Data Client.
Returns: - String with the latest version of data client in format
- ”MAJOR.MINOR.PATCH.HOTFIX”.
-
exchange_detail
(exchange_code)[source]¶ Get detailed information about an exchange.
Returns: EodDataExchange or None
-
exchange_list
(output_format='entity-list')[source]¶ Get all available exchanges.
Returns: EodData exchanges. Return type: list or pandas.DataFrame
-
get_params
(additional=None)[source]¶ Get dictionary with parameters for a request.
Parameters: additional (dict or None) – Additional parameters for a request. Returns: Dictionary with parameters for a request.
-
login
()[source]¶ - Login to EODData Financial Information Web Service.
- Used for Web Authentication.
Returns: bool, whether authentication was successful or not.
-
news_list_by_symbol
(exchange_code)[source]¶ Returns a list of News articles for a given Exchange and Symbol.
-
process_response
(response)[source]¶ - Process response from EodData web service. All responses from
- EodData web service have common format. This method is kind of a wrapper to process all responses.
Parameters: response (requests.Response) – Response that comes from EodData web service.
Returns: bool, True - success, False - expired / invalid token
Raises: - InvalidExchangeCode, InvalidSymbolCode, EodDataInternalServerError,
NoDataAvailableError
-
quote_detail
(exchange_code, symbol)[source]¶ Get an end of day quote for a specific symbol.
Returns: EodDataQuoteExtended or None.
-
quote_list
(exchange_code, output_format='entity-list')[source]¶ Get a complete list of end of day quotes for an entire exchange.
Parameters: exchange_code (str) – Exchange code. Returns: EodData extended quotes. Return type: list or pandas.DataFrame
-
quote_list_by_date
(exchange_code, date, output_format='entity-list')[source]¶ - Get a complete list of end of day quotes for an entire exchange
- and a specific date.
Parameters: - exchange_code – Exchange code.
- date (datetime.date) – Date.
Returns: EodData extended quotes
Return type: list or pandas.DataFrame
-
quote_list_by_date_compact
(exchange_code, date, output_format='entity-list')[source]¶ - Get a complete list of end of day quotes for an entire exchange
- and a specific date (compact format).
Returns: EodData compact quotes Return type: list or pandas.DataFrame
-
quote_list_by_date_period
(exchange_code, date, period, output_format='entity-list')[source]¶ - Get a complete list of end of day quotes for an entire exchange
- and a specific date (compact format).
Returns: EodData extended quotes Return type: list or pandas.DataFrame
-
quote_list_by_date_period_compact
(exchange_code, date, period, output_format='entity-list')[source]¶ - Get a complete list of end of day quotes for an entire exchange
- and a specific date (compact format).
Parameters: - exchange_code (str) – Exchange code.
- date (datetime.date) – Date.
- period (str) – Period code.
Returns: EodData compact quotes.
Return type: list or pandas.DataFrame
-
quote_list_specific
(exchange_code, symbol_list, output_format='entity-list')[source]¶ Get end of day quotes for specific symbols.
Parameters: - exchange_code (str) – Exchange code.
- symbol_list (list of str) – Symbol list.
Returns: EodData extended quotes.
Return type: list or pandas.DataFrame
-
retry
(func, *args, **kwargs)[source]¶ Try to get a new token and call function one more time
Parameters: func – Function to retry Returns: Result of func() call
-
retry_limit
(func)[source]¶ Decorator to have control over retry count.
Returns: Wrapped function. Raises: ReloginDepthReachedError
-
symbol_history
(exchange_code, symbol, start_date, output_format='entity-list')[source]¶ - Get a list of historical end of day data of a specified symbol
- and specified start date up to today’s date.
Parameters: - exchange_code (str) – Exchange code.
- symbol (str) – Symbol.
- start_date (datetime.date) – Start date.
Returns: EodData extended quotes.
Return type: list or pandas.DataFrame
-
symbol_history_period
(exchange_code, symbol, date, period, output_format='entity-list')[source]¶ - Get a list of historical data of a specified symbol, specified date
- and specified period.
Parameters: - exchange_code (str) – Exchange code.
- symbol (str) – Symbol.
- date (datetime.date) – Date.
- period (str) – Period code.
Returns: EodData extended quotes.
Return type: list or pandas.DataFrame
-
symbol_history_period_by_range
(exchange_code, symbol, start_date, end_date, period, output_format='entity-list')[source]¶ - Get a list of historical data of a specified symbol,
- specified date range and specified period.
Parameters: - exchange_code (str) – Exchange code.
- symbol (str) – Symbol.
- start_date (datetime.date) – Period start.
- end_date (datetime.date) – Period end.
- period (str) – Period code.
Returns: EodData extended quotes.
Return type: list or pandas.DataFrame
Business entities and utils¶
Business entities¶
-
class
EodDataExchange
(code, name, last_trade_time, country_code, currency, advances, declines, timezone, suffix='', is_intraday=False, intraday_start_date=None, has_intraday=False)[source]¶ EodData Exchange.
-
code
¶ str – Exchange code
-
name
¶ str – Datetime of the last trade
-
last_trade_time
¶ datetime – Datetime of the last trade
-
country_code
¶ str – Code of the country where this exchange is situated
-
currency
¶ str – Exchange currency
-
advances
¶ int – Advances count
-
declines
¶ int – Declines count
-
suffix
¶ str – Exchange suffix
-
timezone
¶ str – Exchange timezone
-
is_intraday
¶ bool – Availability of intraday data.
-
intraday_start_date
¶ datetime or None – Intraday data availability start date.
-
has_intraday
¶ bool – Indicates if EodData has intraday data for this exchange.
-
-
class
EodDataQuoteCompact
(symbol, quote_datetime, open, high, low, close, volume, open_interest, before, after)[source]¶ EodData quote.
-
symbol
¶ str – Symbol.
-
quote_datetime
¶ datetime – Quote datetime.
-
open
¶ float – Open price.
-
high
¶ float – High price.
-
low
¶ float – Low price.
-
close
¶ float – Close price.
-
volume
¶ int – Traded volume.
-
open_interest
¶ int – Open interest.
-
before
¶ float
-
after
¶ float
-
classmethod
from_xml
(xml_quote)[source]¶ Get instance from xml.
Returns: EodDataQuoteCompact instance or None.
-
symbol
= None¶ Security symbol
-
-
class
EodDataQuoteExtended
(symbol, quote_datetime, open, high, low, close, volume, open_interest, previous, change, bid, ask, modified, previous_close=0, next_open=0, name='', description='')[source]¶ EodData extended quote.
-
symbol
¶ str – Symbol.
-
quote_datetime
¶ datetime – Quote datetime.
-
open
¶ float – Open price.
-
high
¶ float – High price.
-
low
¶ float – Low price.
-
close
¶ float – Close price.
-
volume
¶ int – Traded volume.
-
open_interest
¶ int – Open interest.
-
previous
¶ float – Previous close price.
-
change
¶ float – Change from previous close.
-
bid
¶ float – Bid price.
-
ask
¶ float – Ask price.
-
modified
¶ datetime – Time of the last update for this security.
-
name
¶ str – Full name of a traded asset.
-
description
¶ str – Description.
-
df_columns
¶ tuple of str – Data frame columns (static attribute).
-