/yahoo-node-streamer

Yahoo finance NodeJS Price Quote Live Streaming - using websocket to collect recent updates

Primary LanguageJavaScript

yahoo-node-streamer - Yahoo Live Quotes

Yahoo finance NodeJS Price Quote Live Streaming - using websocket to collect recent updates

App is establishing connection to Yahoo Websocket with subscribe command and listens for responses in real time. Yahoo is using protobuf to encode data and we are using protobufjs to decode those messages. Crucial file is PricingData.proto which is used as descriptin for protobufjs.

Install

Clone project and cd into project folder, than run:

npm install

Run it

node index.js

Configuration - Subscribe

For example, app will subscribe to AMC and TSLA symbols. Check config and extend the list wit symbols you need:

// Extend this list by adding more symbols ["AMC", "TSLA"]
connection.send('{"subscribe":["AMC", "TSLA"]}')

Configuration - Unsubscribe

For example, app will unsubscribe from TSLA symbols.

// Extend this list by adding more symbols ["AMC", "TSLA", "BB", "BTC-USD"]
connection.send('{"unsubscribe":["TSLA"]}')

Received messages - decoded example

App will generate object with all data described in .proto file:

*** Console log output ***

All data set:  {
  id: 'TSLA',
  price: 600.9299926757812,
  time: Long { low: -2101540592, high: 376, unsigned: false },
  currency: '',
  exchange: 'NMS',
  quoteType: 8,
  marketHours: 0,
  changePercent: -1.6947742700576782,
  dayVolume: Long { low: 0, high: 0, unsigned: false },
  dayHigh: 0,
  dayLow: 0,
  change: -10.3599853515625,
  shortName: '',
  expireDate: Long { low: 0, high: 0, unsigned: false },
  openPrice: 0,
  previousClose: 0,
  strikePrice: 0,
  underlyingSymbol: '',
  openInterest: Long { low: 0, high: 0, unsigned: false },
  optionsType: 0,
  miniOption: Long { low: 0, high: 0, unsigned: false },
  lastSize: Long { low: 0, high: 0, unsigned: false },
  bid: 0,
  bidSize: Long { low: 0, high: 0, unsigned: false },
  ask: 0,
  askSize: Long { low: 0, high: 0, unsigned: false },
  priceHint: Long { low: 2, high: 0, unsigned: false },
  vol_24hr: Long { low: 0, high: 0, unsigned: false },
  volAllCurrencies: Long { low: 0, high: 0, unsigned: false },
  fromcurrency: '',
  lastMarket: '',
  circulatingSupply: 0,
  marketcap: 0
}
Decoded message TSLA with price: 600.9299926757812

Extras

Socket.io package will be installed and app can use it to connect with another Socket.IO server where decoded data will be sent. That server can be used to distribute messages generated by this app (decoder worker) and used in different apps: React web app, display data on your website etc.

This feature is disabled by default and can be enabled in:

// Line 18
var useSocket = false;

Remember to configure connection to socket server before enabling it.

Notes

App does not provide any historycal data. It is used for live streaming only. App does not require any subscription to Yahoo services and no accounts are used. Yahoo does not limit or block any connections (at the moment) to their Websocket server.

To do (in progress and BETA at the moment)

Electron Desktop application for controlling subscribers list and UI

Requests

If you have any requests for new features, open issues tab and drop it there.