For investors, traders, financial analysts, and researchers, having access to delayed real-time data is indispensable. It allows them to stay informed about the latest market movements, track specific stock performance, and identify potential investment opportunities. While the data is not suitable for high-frequency trading or immediate decision-making, it is more than sufficient for conducting various research tasks.
Quick jump:
Here are some of the key ways in which delayed real-time data can be utilized for research and analysis:
- Trend Analysis: By monitoring delayed price movements and trends, researchers can identify patterns and long-term trends in a stock’s performance. This information is valuable for making informed investment decisions based on historical price behavior.
- Correlation Studies: Researchers can use delayed data to perform correlation studies between different stocks or other financial instruments. Understanding the relationships between various assets can help in creating diversified portfolios and managing risk effectively.
- Technical Analysis: Technical analysts can use delayed real-time data to apply various charting techniques and technical indicators. These analyses help in predicting potential price movements and making entry or exit points for trades.
- Historical Performance: By accessing delayed historical data, researchers can study a stock’s historical performance, evaluate past volatility, and understand how it has responded to previous market events.
- Modeling and Backtesting: Delayed real-time data is crucial for building and testing trading models and strategies. Researchers can simulate different scenarios and assess the profitability and risk associated with their trading ideas.
- Market Sentiment Analysis: Researchers can use delayed data in conjunction with other sources to gauge market sentiment. Understanding market sentiment can provide insights into market dynamics and potential shifts in trends.
- Educational Purposes: Delayed real-time data is an excellent resource for educational purposes. Students, aspiring traders, and researchers can use this data to learn about financial markets, practice analysis, and refine their skills.
It is important to reiterate that while delayed real-time data is immensely valuable for research and analysis, it should be used appropriately and in context. Traders looking for immediate data for high-frequency trading strategies should explore other real-time data sources. Additionally, researchers should always consider the delay factor when interpreting and using the data for decision-making.
In this article, we have explored how to access real-time data (delayed by 15 minutes) using the official EODHD APIs Python financial library. Although the data comes with a slight delay, it remains incredibly valuable for conducting research and performing thorough analysis.
Installing the Required Library
Before we proceed with fetching the data, we need to install the EODHD APIs Python Financial Library by running this command in a terminal window:
pip install eodhd
Importing Required Libraries
Let’s create a new Python script file, or a Jupiter notebook. Let’s start by importing the necessary libraries. We will need the “eodhd” library for accessing the API, and the “pandas” library for organizing the data into a DataFrame.
from eodhd import APIClient
import pandas as pd
Accessing the EODHD API
To access the EODHD API, we need to create an instance of the “APIClient” class and pass it our API key. In this example, we will use the demo API key provided by EODHD, but in a 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.
Retrieving Real-Time (Delayed) Data
With the API client set up, we can now request real-time (delayed) data for a specific stock symbol. In this example, we will fetch data for “AAPL.US,” which represents Apple Inc. on the US stock exchange.
resp = api.get_live_stock_prices(“AAPL.US”)
The API response will be the single JSON structure.
Converting JSON Response to DataFrame
To make the data more readable and easier to work with, we can convert the JSON response into a pandas DataFrame. However, the original response contains only one non-indexed element. To create a DataFrame, we need to specify an index. In this case, we will use index 0.
df = pd.DataFrame(resp, index=[0])
Exploring the DataFrame
Now that we have our DataFrame, we can explore the data and analyze it more conveniently. The DataFrame will contain information such as “open,” “high,” “low,” “close,” and “volume” for the specified stock symbol (“AAPL.US”).
print(df)
Accessing Specific Data Points
We can also access specific data points from the resulting dictionary (JSON response). For example, if we want to get the current live (delayed) price of the stock, we can do the following:
current_price = resp[‘close’]
print(“Current live (delayed) price:”, current_price)
Requesting Real-Time Data for Multiple Tickers
In addition to fetching real-time data for a single stock symbol, you can also retrieve data for multiple tickers simultaneously using the EODHD APIs Python financial library. This feature is particularly useful for conducting comparative analysis, tracking various assets, and monitoring a diversified portfolio. To obtain information on several tickers, you can use the ‘s’ parameter with the get_live_stock_prices() function, which allows requests to multiple tickers via the Live (delayed) Stock Price API.
For example, to fetch real-time data for Apple Inc. (AAPL.US) and Vanguard Total Stock Market ETF (VTI) on the US stock exchange, as well as the Euro to US Dollar exchange rate (EUR.FOREX), you can use the following code:
multiple_resp = api.get_live_stock_prices(ticker=”AAPL.US”, s=”VTI,EUR.FOREX”)
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:
df_m = pd.DataFrame(multiple_resp)
By utilizing the ‘s’ parameter, you can efficiently retrieve data for multiple tickers in a single API call, which can save time and streamline your analysis. The resulting DataFrame will contain information for each ticker, including attributes such as “open,” “high,” “low,” “close,” and “volume.” This data can be instrumental in comparing the performance of different assets, identifying trends, and making informed investment decisions.
print(df_m)
Here is a video illustrating the work with the eodxd library to get real-time data:
Conclusion
In this article, we learned how to fetch real-time data (delayed by 15 minutes) using the EODHD APIs Python financial library. We saw how to install the required library, access the EODHD API, retrieve live stock prices for a specific stock symbol, and convert the API response to a pandas DataFrame for easy analysis. We also demonstrated how to access specific data points, such as the current live (delayed) stock price.
Remember that while delayed data can still provide valuable insights, it’s essential to be aware of the latency and use it appropriately for your trading or investment strategies. For real-time data with lower latency, you might need to explore other options.