@dxfeed/dxlink-api
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

@dxfeed/dxlink-api

This package provides access to market data from dxFeed services via dxLink API.

Install

npm install @dxfeed/dxlink-api

Usage

Import client and feed into your project.

import { DXLinkWebSocket, DXLinkFeed } from '@dxfeed/dxlink-api'

Client

Create instance of the client.

const client = new DXLinkWebSocketClient()

Connect to the server.

client.connect('wss://demo.dxfeed.com/dxlink-ws')

Provide auth token if required by the server.

client.setAuthToken(token)

Feed API

Create market data feed API with delivery contract AUTO.

const feed = new DXLinkFeed(client, 'AUTO')

Configure created feed.

feed.configure({
  acceptAggregationPeriod: 10,
  acceptDataFormat: FeedDataFormat.COMPACT,
  acceptEventFields: {
    Quote: ['eventSymbol', 'askPrice', 'bidPrice'],
    Candle: ['eventSymbol', 'open', 'close', 'high', 'low', 'volume'],
  },
})

Add subscription to the feed.

const sub1 = {
  type: 'Quote',
  symbol: 'AAPL',
}

feed.addSubscriptions(sub1)

Remove subscription from the feed.

feed.removeSubscriptions(sub1)

Receive data from the channel.

feed.addEventListener(events) => {
  // do something with events
})

Depth Of Market API

Create Depth Of Market API with desired symbol and sources.

const dom = new DXLinkDepthOfMarket(client, { symbol: 'AAPL', sources: ['ntv'] })

Configure created dom.

dom.configure({
  acceptAggregationPeriod: 10,
  acceptDepthLimit: 5,
})

Receive data from the channel.

dom.addSnapshotListener((time, bids, asks) => {
  // do something with snapshot
})

Package Sidebar

Install

npm i @dxfeed/dxlink-api

Homepage

dxfeed.com/

Weekly Downloads

33

Version

0.2.0

License

MPL-2.0

Unpacked Size

20.8 kB

Total Files

11

Last publish

Collaborators

  • mvkvl
  • vitaliymatveev
  • dvpetrov