Our Exchanges Details API for Exchange Trading Hours and Holidays provides exchange details, trading hours and stock market holidays data. Exchange details shows us data where stock buyers connect with stock sellers and Stock Market Holidays Data shows the schedule of the Holidays on Stocks.
Please note: before continuing to work with our APIs, make sure that you import and install all required libraries. A more detailed information about the functions of Exchange Trading Hours and Holidays API you can find on our documentation web-page.
Accessing the EODHD API
To access the EODHD API, we need to create an instance of the “APIClient” class and pass to it our API key. In this example, we will use the demo API key provided by EODHD, but in your real application, you should use your registered API key.
api = APIClient("demo")
Please, note that you can also specify the API key in a configuration file or as an environment variable, as described in the library documentation here. Also, do not forget to visit our documentation web-page about the Exchanges API.
1. Use the “demo” API key to test our data from a limited set of the tickers without registering:
AAPL.US | TSLA.US | VTI.US | AMZN.US | BTC-USD | EUR-USD
Real-Time Data and All of the APIs (except Bulk) are included without limitations on API calls.
2. Register to get your free API key (limitated by 20 API calls per day) with access to:
End-Of-Day Historical Data with only past year for any ticker and List of tickers per Exchange
3. To unlock your API key we recommend to choose the subscription which covers your needs.
Retrieving Exchange Trading Hours and Holidays Data
After we are done with the Exchanges API client, we can start requesting exchange details, trading hours and information about stock market holidays for a specific exchange code.
resp = api.get_details_trading_hours_stock_market_holidays (code = "US")
The API response will be a single JSON structure.
Converting JSON Response to DataFrame
To convert JSON to DataFrame it is possible to use:
exchange = pd.DataFrame(resp)
All data in DataFrame will contain information such as: “name”, “code”, “operating”, “MIC”, “country”, “currency” and “timezone” for the code which was used when we called the API in particular (“US“).
Extended functions of Exchange Trading Hours and Holidays API
For a more accurate research, it is possible to use additional parameters of the Exchange Trading Hours and Holidays API, particularly in the stock market holidays section. It is possible to use the parameters from and to, which will show you holidays for some specific period.
exchange_extended = api.get_details_trading_hours_stock_market_holidays (code = "US", from_date = "2023-10-15", to_date = "2023-11-15")
The API response is a JSON array containing data for all the requested tickers. You can convert the resulting JSON array to a DataFrame for further analysis:
e_m = pd.DataFrame (exchange_extended) print(e_m)
In essence, the Exchange Trading Hours and Holidays API is a powerful tool that enables you to navigate the complex world of stock exchanges with precision and efficiency. It offers insight into trading hours, holidays, and exchange details, equipping you with the knowledge needed for well-informed investment decisions. Whether you’re a seasoned investor or just beginning your journey in finance, this API is your gateway to understanding the rhythm and nuances of global financial markets. Happy exploring!