market_tbt
v1.1.2
Published
Market SDK for subscribing/unsubscribing to market tick data
Downloads
4
Readme
Market_TBT
Market_TBT provide realtime markets tick data. For now, it supports only zerodha sdk.
Design Principle
To provide a common interface to interact with market by abstracting the overall complexity to simple APIs.
Design Pattern
Goal is to solve this problems:
- Abstract the complexity behind a well-defined interface
- Easy to change the underlying system
The Facade pattern and Singleton pattern are the most relatable pattern to solve the above design problems. Why Facade pattern? Read this
How to install
npm install market_tbt --save
This command will install and add market-tbt to your project dependencies.
APIs
- subscribe
- unsubscribe
- instruments
- Auto-connect is managed internally. Also, you can subscribe to instruments before receiving connect event and the ticker will take care off subscription process for you. Not yet finished, more to come....
How to use
- Initialize SDK
const { Ticker } = require('market_tbt'); const TBTListener = Ticker({ api_key: "api_key", access_token: "access_token" }); // Attach event listener TBTListener.on('ticks', async (data) => console.log(data)); TBTListener.on('connect', () => console.log('connected)); TBTListener.on('disconnect', () => console.log('disconnected));
- Fetch all subscribed instruments
TBTListener.getInstruments()
- Subscribe instruments
const instruments = [ 12345, 232424, 2323232 ]; const subscribedInstruments = TBTListener.subscribe(instruments);
- Unsubscribe instruments
const instruments = [ 12345, 232424, 2323232 ]; const subscribedInstruments = TBTListener.unSubscribe(instruments);