npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

xts-marketdata-api

v3.0.10

Published

The official JS client library for the Symphony Fintech MarketData API's

Downloads

78

Readme

xts-marketdata-nodeJS-api-client-V2

Welcome to the XTS-MarketData-API SDK, This repository is Official Node.js library for Symphony XTS-MarketData-API.

API Documentation for XTS-MarketData API can be found in the below link.

https://symphonyfintech.com/xts-market-data-front-end-api/

The XTS market data API provides developer, data-scientist, financial analyst and investor the market data with very low latency. It provides market data from various Indian electronic exchanges.

With the use of the socket.io library, the API has streaming capability and will push data notifications in a JSON format.

There is also an examples folder available which illustrates how to create a connection to XTS marketdata component in order to subscribe to real-time events. Please request for apikeys with Symphony Fintech developer support team to start integrating your application with XTS OEMS.

Installation

npm install xts-marketdata-api

Usage

Access the interactive component of xts-marketdata-api like below.

var XtsMarketDataAPI = require('xts-marketdata-api').XtsMarketDataAPI;

Creating the instance of xtsMarketDataAPI

xtsMarketDataAPI = new XtsMarketDataAPI(
  'https://developers.symphonyfintech.in/marketdata'
);

call the login API to generate the token

var loginRequest = {
  secretKey: 'Drty585#w',
  appKey: 'c4e15efa9c97e489f80873',
};

let logIn = await xtsMarketDataAPI.logIn(loginRequest);

Once the token is generated you can call any api provided in the documentation. All API’s are easy to integrate and implemented with async-await mechanism. Below is the sample Code snippet which calls the client config API.

let response = await xtsMarketDataAPI.clientConfig();

console.log(response);

Instantiating the XtsMarketDataWS

This component provides functionality to access the socket related events. All real-time events can be registered via XtsMarketDataWS . After token is generated, you can access the socket component and instantiate the socket Instance and call the init method of the socket like below

var XtsMarketDataWS = require('xts-marketdata-api').WS;
xtsMarketDataWS = new XtsMarketDataWS('https://developers.symphonyfintech.in/marketdata');
var socketInitRequest = {
  userID: 'XYZ',
  publishFormat: 'JSON',
  broadcastMode: 'Full',
  token: logIn.result.token, // Token Generated after successful LogIn
};
xtsMarketDataWS.init(socketInitRequest);

You can now register events to listen to the real time market data events and will be receiving the json objects in the response.

var registerEvents = async function () {
  //instantiating the listeners for all event related data

  //"connect" event listener
  xtsMarketDataWS.onConnect((connectData) => {
    console.log(connectData);
  });

  //"joined" event listener
  xtsMarketDataWS.onJoined((joinedData) => {
    console.log(joinedData);
  });

  //"error" event listener
  xtsMarketDataWS.onError((errorData) => {
    console.log(errorData);
  });

  //"disconnect" event listener
  xtsMarketDataWS.onDisconnect((disconnectData) => {
    console.log(disconnectData);
  });

  //"marketDepthEvent" event listener
  xtsMarketDataWS.onMarketDepthEvent((marketDepthData) => {
    console.log(marketDepthData);
  });

  //"openInterestEvent" event listener
  xtsMarketDataWS.onOpenInterestEvent((openInterestData) => {
    console.log(openInterestData);
  });

  //"indexDataEvent" event listener
  xtsMarketDataWS.onIndexDataEvent((indexData) => {
    console.log(indexData);
  });

  //"marketDepth100Event" event listener
  xtsMarketDataWS.onMarketDepth100Event((marketDepth100Data) => {
    console.log(marketDepth100Data);
  });

  //"instrumentPropertyChangeEvent" event listener
  xtsMarketDataWS.onInstrumentPropertyChangeEvent((propertyChangeData) => {
    console.log(propertyChangeData);
  });

  //"candleDataEvent" event listener
  xtsMarketDataWS.onCandleDataEvent((candleData) => {
    console.log(candleData);
  });

  // //"logout" event listener
  xtsMarketDataWS.onLogout((logoutData) => {
    console.log(logoutData);
  });
};

Detailed explanation of API

Below is the brief information related to api’s provided by XTS-marketdata-API SDK.

instruments API

subscription

Calls POST /instruments/subscription.

let response = await xtsMarketDataAPI.subscription({
    instruments: [
      {
        exchangeSegment: xtsMarketDataAPI.exchangeSegments.NSECM,
        exchangeInstrumentID: 22,
      },
      {
        exchangeSegment: xtsMarketDataAPI.exchangeSegments.NSECM,
        exchangeInstrumentID: 11536,
      },
    ],
    xtsMessageCode: 1502,
  };

unSubscription

Calls PUT /instruments/subscription.

let response = await xtsMarketDataAPI.unSubscription({
  instruments: [
    {
      exchangeSegment: xtsMarketDataAPI.exchangeSegments.NSECM,
      exchangeInstrumentID: 2885,
    },
    {
      exchangeSegment: xtsMarketDataAPI.exchangeSegments.NSECM,
      exchangeInstrumentID: 11536,
    },
  ],
  xtsMessageCode: 1502,
});

quotes

Calls POST /instruments/quotes.

let response = await xtsMarketDataAPI.getQuotes({
  isTradeSymbol: isTradeSymbol,
  instruments: [
    {
      exchangeSegment: xtsMarketDataAPI.exchangeSegments.NSECM,
      exchangeInstrumentID: 2885,
    },
    {
      exchangeSegment: xtsMarketDataAPI.exchangeSegments.NSECM,
      exchangeInstrumentID: 11536,
    },
  ],
  xtsMessageCode: 1502,
  publishFormat: 'JSON',
});

clientConfig

Calls POST /config/clientConfig.

let response = await xtsMarketDataAPI.clientConfig();

search API

searchInstrumentsById

Calls POST /search/instrumentsbyid.

let response = await xtsMarketDataAPI.searchInstrumentsById({
  source: 'WEBAPI',
  isTradeSymbol: false,
  instruments: [
    {
      exchangeSegment: xtsMarketDataAPI.exchangeSegments.NSECM,
      exchangeInstrumentID: '3045',
    },
  ],
});

searchInstruments

Calls POST /search/instruments.

let response = await xtsMarketDataAPI.searchInstrument({
  searchString: 'REL',
  source: source,
});

We do have a trading API component which will provide the trading capability of our application. For more info please check the following link.

https://symphonyfintech.com/xts-trading-front-end-api/