Listen to real-time data feed from ThinkOrSwim using Node JS and Excel
Only works with Windows operating systems due to limitations with ThinkOrSwim.
- Launch ThinkOrSwim and log in.
- Open "MarketWatch" tab and customize a data set.
- Click the tiny settings icon in the right most column then click "Customize".
- Click the "Show actions menu" button (list icon) in the top right.
- Hover over "Export" and click "To Microsoft Excel".
- The current watchlist, formatted for Excel, is copied to the clipboard.
- Open "tos-rtd.xlsm" from the tos_rtd repository.
- Either paste directly into the Excel document or into "scanner.csv" and save the file.
- The Excel script is written to "pick up" the changes made to scanner.csv every minute.
- Using a terminal app like Command Prompt navigate to the tos_rtd directory and run "node listen.js".
Once a watchlist has been configured, only step #1, #5, and #7 are needed. To edit a watchlist, all steps are required.
How it works
Excel acts as a middle man between ThinkOrSwim and Node JS by importing data from TOS and exporting for use with Node.
- ThinkOrSwim creates a new RTD server instance for use with RTD client applications like Microsoft Excel.
- Once the RTD connection has been established, an Excel script (VBA) runs in the background to listen for changes to the Excel document.
- If a change is detected, that row of data is exported to a file in the tos_rtd directory in a querystring format:
- The Node JS script "listen.js" uses a built-in function to listen for changes in the "data-stream" directory and parses the contents of the changed file.