Real-Time Market Data in Google Sheets with WebSocket

Step-by-step guide on how to set up a WebSocket connection with EODHD’s API using Google Apps Script

EODHD APIs
4 min readApr 23, 2024

As a financial professional, analyst, or investor, access to real-time market data is crucial. Leveraging EODHD’s financial API together with Google Sheets allows you to stream live stock quotes directly into your spreadsheets. This setup enables you to make well-informed decisions with the most current market data, all within the familiar environment of Google Sheets.

In this article, we will provide a step-by-step guide on how to establish a WebSocket connection with EODHD’s API using Google Apps Script. This connection will allow you to continuously retrieve and display data for stocks, cryptocurrencies, and FOREX directly in your Google Sheets.

You can also explore our guides for creating a Stock Market Dashboard in Google Sheets, setting up a Google Sheets Portfolio Tracker, and using the EODHD Google Sheets Add-in. In these guides, you’ll find detailed information about our Ready-to-Go solutions that can enhance your financial tracking and analysis capabilities.

Getting Started with the Sample Real-Time Market Data Google Sheet

First, access our sample spreadsheet. Ensure you make a copy for your Google Drive by selecting “File” > “Make a copy.” This step allows you to tailor the spreadsheet to your specific needs without altering the original.

In your newly copied spreadsheet, find the “EODHD” button. This button is linked to the `showDiag` script, which opens a dialog window that facilitates the configuration of the WebSocket connection.

The extension comprises two main files: `Code.gs` and `Dialog.html`. `Code.gs` handles the parsing of data, while `Dialog.html` focuses on the user interface and the invocation of the Websockets API. To integrate this into your spreadsheet, navigate to Extensions > Apps Script, select the appropriate file, and then copy the code directly into your spreadsheet.

Initiate the WebSocket Connection

First, within your spreadsheet, select the cells that contain the tickers you wish to monitor. Ensure each ticker is placed in a separate cell.

Click on the “EODHD Real-Time” button to bring up the configuration dialog. In this dialog, input your EOD Historical Data API key. If you don’t already have an API key, consider signing up for a free trial or subscribing to a plan at the EODHD website. For initial testing, you may use the “demo” key, which grants access to a limited set of tickers: AAPL.US, MSFT.US, EURUSD.FOREX, AUDUSD.FOREX, ETH-USD.CC, and BTC-USD.CC.

Remember that when subscribing to tickers, you should use the exchange code portion. From the options provided in the dialog, select the type of market data you require, whether it be US stocks, forex pairs, or cryptocurrencies.

Receiving and Analyzing Real-Time Market Data

After choosing the market data type, click the “Connect” button in the configuration dialog to activate the WebSocket connection and begin receiving real-time data. Ensure that you have selected the tickers before running the script.

A new sheet will automatically be created in your spreadsheet corresponding to the selected market data type, such as “US_Data,” “FOREX_Data,” or “CRYPTO_Data.” The script will continue to add live data points as new rows in the relevant sheet.

To halt the real-time data feed, click the “Disconnect” button in the configuration dialog. If you wish to resume receiving data, simply click “Connect” again.

Utilize the real-time data in your spreadsheet for comprehensive analysis, calculations, and visualizations. Take advantage of Google Sheets’ extensive built-in functions and tools to derive valuable insights from the live market data.

EOD Historical Data Platform and API

EOD Historical Data is a robust platform that offers high-quality financial market data across a diverse range of instruments including stocks, ETFs, mutual funds, indices, forex pairs, and cryptocurrencies. It covers over 70 exchanges worldwide and provides data that goes back more than 30 years, making it an essential resource for investors, traders, and financial professionals.

The platform features a comprehensive array of data feeds and APIs. These APIs are designed by EODHD to be flexible, reliable, and straightforward to integrate into various applications and tools, including Google Sheets, Excel, Python, and more, catering to a wide spectrum of financial data needs.

Conclusion

With this integration, real-time stock data is now readily accessible within the familiar environment of Google Sheets. Whether you’re analyzing market trends or keeping tabs on your portfolio, the combination of EODHD’s API and this dynamic Google Sheets integration delivers the real-time financial data essential for your needs.

For those eager to delve deeper into such insightful articles and broaden their understanding of different strategies in financial markets, we invite you to follow our account and subscribe for email notifications.

We publish 2 pieces per week!

Stay tuned for more valuable articles that aim to enhance your data science skills and market analysis capabilities.

--

--

EODHD APIs
EODHD APIs

Written by EODHD APIs

eodhd.com — stock market fundamental and historical prices API for stocks, ETFs, mutual funds and bonds all over the world.

Responses (3)