Package: eodhdc
EODHDCPython client for the EOD Historical Data service REST / WebSockets API and provides various financial data
including stock market, splits and dividends, fundamental and economic, exchanges and alternative data feeds.
Provides synchronous and asynchronous interfaces for HTTP API, asynchronous interface for WebSockets.InstallationFor normal usage you will need API key which you can get fromhere.Supported Python version >= 3.7Package can be installed using pip or poetry:pip install eodhdcpoetry add eodhdcTo support additional HTTP clients install with extras:pip install eodhdc[httpx,aiohttp]QuickstartAsynchronous usageimportasynciofromeodhdcimportEODHDClienteodhdc=EODHDClient("httpxa",key="demo")asyncwitheodhdc.session:results=awaitasyncio.gather(eodhdc.market.historical("MCD.US",start="2023-01-01",finish="2023-01-10",fmt="csv"),eodhdc.market.historical("MCD.US",start="2023-01-01",finish="2023-01-10",fmt="json"))forresultinresults:print(result)Synchronous usagefromeodhdcimportEODHDClienteodhdc=EODHDClient("requests",key="demo")result=eodhdc.market.historical("AAPL.US",start="2023-01-01",finish="2023-01-10",fmt="json",output="pandas:./response.csv",writer={"header":False})print(result,"\n")WebSockets usagefromeodhdcimportEODHDWebSocketseodhdws=EODHDWebSockets(buffer=100)asyncwitheodhdws.connect("us")aswebsocket:awaiteodhdws.subscribe(websocket,["TSLA","EURUSD"])asyncformessageineodhdws.receive(websocket):print(message)iflen(eodhdws.buffer)>5:awaiteodhdws.unsubscribe(websocket,["EURUSD"])iflen(eodhdws.buffer)>10:eodhdws.deactivate()print(eodhdws.buffer)Also checkplayground.pyfor quickstart examples.DescriptionMain client modulesEODHDClient: HTTP API client, parameters are:client: http client module to use.key: api token.args: http clientgetargs to use across requests.EODHDWebSockets: WebSockets API client, parameters are:key: api token.buffer: enable and set buffer size.args: websocket client args.EODHDClient will automatically determine sync or async http client and provide corresponding interface
with same signature, so for example usage can easily be changed:eodhdc=EODHDClient("httpxs")result=eodhdc.market.historical(...)eodhdc=EODHDClient("httpsxa")result=awaiteodhdc.market.historical(...)Asynchronous version of EODHDClient can be used without context manager, do not forget to calldestroymethod to close session in that case.You can also get response headers from last request, for example to checkX-RateLimit-LimitandX-RateLimit-Remainingvalues by usingheadersproperty:result=awaiteodhdc.market.historical(...)print(eodhdc.market.headers["X-RateLimit-Remaining"])EODHDWebSockets client provides following methods:connect: connect to web-socket endpoint, returns context manager.authorize: check authorization status, do not use directly as it will consume messages.subscribe: subscribe to the tickers.unsubscribe: unsubscribe from the tickers.receive: receive messages, async generator.activate: activate message loop.deactivate: deactivate message loop.HTTP client modulesrequests: default, well known, synchronous module.httpxs: httpx library, synchronous mode, 'httpx' extra.httpxa: httpx library, asynchronous mode, 'httpx' extra.aiohttp: aiohttp library, asynchronous mode, 'aiohttp' extra.HTTP API groupsMain HTTP API module contains groups that corresponds to EODHD API groups, and can be accessed like:eodhdc.market.<method>oreodhdc.exchange.<method>See below mapping for client groups and methods.Visit official APIdocumentationfor detailed description.HTTP API group methodsIn addition to original API parameters each method have:args: override or add http clientgetargs.output: output format and optionally file location, format is<type>[:path]types: response type"response": raw binary response body"content": decoded as response content type"pandas": pandas dataframepath: additionally save response to filefor "response" and "content" will save as isfor "pandas" will save in format specified by extension:
parquet, pickle, csv, hdf, xlsx, json, html, feather, tex, dta, mdwriter: pandas writer parameters, seeoriginalto_<format>methods for more details.note that some formats may require 3rd-party libraries.additionally writer can be provided with:change:columns - dict to rename DataFrame columns.change:reorder - bool to use columns dict for DataFrame columns order.change:reindex - str or list to set DataFrame columns as index.API support statusAPI support status and mapping for client groups and methods.HTTPStock Market Prices, Splits and Dividends Data APIEnd-Of-Day Historical Stock Market Data APImarket.historicalLive (Delayed) Stock Prices APImarket.delayedHistorical Splits and Dividends APImarket.dividendsmarket.splitsTechnical Indicator APImarket.indicatorsIntraday Historical Data APImarket.intradayOptions Data APImarket.optionsFundamental and Economic Financial Data APIFundamental Data for Cryptocurrenciesfundamental.cryptoHistorical Market Capitalization APIfundamental.capitalizationInsider Transactions APIfundamental.insiderFundamental Data: Stocks, ETFs, Mutual Funds, Indicesfundamental.fundamentalsfundamental.bulkCalendar. Upcoming Earnings, Trends, IPOs and Splitsfundamental.calendarBonds Fundamentals and Historical APIfundamental.bondsExchanges (Stock Market) Financial APIsBulk API for EOD, Splits and Dividendsexchange.bulkExchanges API. Get List of Tickersexchange.exchangesexchange.tickersExchanges API. Trading Hours, Stock Market Holidays, Symbols Change Historyexchange.detailsexchange.historyStock Market Screener APIexchange.screenerSearch API for Stocks, ETFs, Mutual Funds and Indicesexchange.searchAlternative Data Financial APISentiment Data Financial API for News and Tweetsalternative.sentimentEconomic Events Data APIalternative.eventsStock Market and Financial News APIalternative.newsMacro Indicators APIalternative.macroindicatorsMacroeconomic Data APIalternative.macroeconomicWebSocketsStock Market Prices, Splits and Dividends Data APIReal-Time Data APIExceptionsExceptions hierarchy:ClientException: Base HTTP client exception.ClientConnectionTimeout: Client connection timeout exception.ClientConnectionError: Client connection error exception.ClientHTTPError: Client HTTP error exception.ModuleException: Base module exception.FileIOError: File IO exception.UnsupportedContentType: Unsupported response content exception.UnsupportedExtension: Unsupported pandas extension exception.JSONDecodeError: JSON decoding exception.BytesDecodeError: Bytes decoding exception.PandasRuntimeError: Pandas runtime exception.UnknownClient: Unknown client exception.ImproperClient: Improper client exception.WebsocketException: Base websocket exception.WebsocketUnknownEndpoint: Websocket unknown endpoint exception.WebsocketAuthError: Websocket authentication exception.WebsocketResponseError: Websocket response error exception.Custom HTTP clientsAdditionally, you can provide your own HTTP client by passing its module instead of name string.Module should implementgetmethod andcreateanddestroycan be provided for asynchronous session management.Check modules undereodhd.clientsfor details about required parameters, return data type and exceptions handling.DisclaimerThe information in this document is for informational and educational purposes only. Nothing in this document
can be construed as financial, legal, or tax advice. The content of this document is solely the opinion of the
author, who is not a licensed financial advisor or registered investment advisor. The author is not affiliated
as a promoter of EOD Historical Data services.This document is not an offer to buy or sell financial instruments. Never invest more than you can afford to
lose. You should consult a registered professional advisor before making any investment.