Use EODHistoricalData API to Find Time of Daily High and Low

Many trading applications start with reliable access to data. There are numerous providers one of which is EODHistorical Data.com, providing convenient access to over 70 world wide security exchanges. This API can be used with any programming language, including Excel. This tutorial demonstartes one of their endpoints and the convenient Python helper library to determine the time a stock trades at its low and high each day.

The data API used in the video is free to use, however you are limited to 20 API calls/day. If you find that you like the service and need more API calls, I have arranged for special pricing at this link (I earn a referral fee if you sign up for a paid account): https://eodhistoricaldata.com/alphabench

Use EODHistoricalData API for Daily High & Low

What the Tutorial Covers

  • Setting up with datetime, the EOD Historical Data helper library and pandas
  • Keeping your API key out of the notebook by reading it from a file
  • Converting a start date to the Unix timestamp the intraday endpoint expects (one-minute data goes back 120 days, five-minute data 600 days)
  • Downloading one-minute Tesla prices into a pandas DataFrame
  • Calling the endpoint directly with requests, without the helper library
  • Converting UTC times to New York time and keeping regular trading hours with between_time
  • Finding each day's high and low with groupby, and the time each occurred with idxmin and idxmax

Over the ten days analysed, Tesla's daily low usually came close to the open, which fits the upward trend at the time. With more data you can test whether a pattern like that holds. The notebook is on GitHub.

To use the same API for portfolio risk, see portfolio variance with Python.


Advertisement