Skip to content

Instantly share code, notes, and snippets.

@Fyzu
Last active April 21, 2025 15:10
Show Gist options
  • Save Fyzu/01e79a54a17f69e1e1e35c99ef0d165a to your computer and use it in GitHub Desktop.
Save Fyzu/01e79a54a17f69e1e1e35c99ef0d165a to your computer and use it in GitHub Desktop.
dxLink Depth Of Market Service
{
"type": "CHANNEL_REQUEST",
"channel": 5,
"service": "DOM",
"parameters": {
"symbol": "AAPL",
"sources": ["NTV"]
}
}
{
"type": "CHANNEL_OPENED",
"channel": 5,
"service": "DOM",
"parameters": {
"symbol": "AAPL",
"sources": ["NTV"]
}
}
{
"type": "DOM_SETUP",
"channel": 5,
"acceptDepthLimit": 100,
"acceptAggregationPeriod": 1.0,
"acceptDataFormat": "FULL",
"acceptIndividualOrders": true,
"acceptLevelFields": ["price", "size", "count"],
"acceptOrderFields": ["price", "size", "time"],
"acceptOrderSizeFilter": 1,
"acceptLevelSizeFilter": 1,
"acceptLevelCountFilter": 1
}
{
"type": "DOM_CONFIG",
"channel": 5,
"depthLimit": 5,
"aggregationPeriod": 1.0,
"dataFormat": "FULL",
"individualOrders": true,
"levelFields": ["price", "size", "count"],
"orderFields": ["price", "size", "time"],
"orderSizeFilter": 1,
"levelSizeFilter": 1,
"levelCountFilter": 1
}
{
"type": "DOM_SNAPSHOT",
"channel": 5,
"time": 1706025203484,
"bids": [{
"price": 136.2,
"size": 10,
"count": 5,
"orders": [{
"price": 136.2,
"size": 4,
"time": 1706025203484
}]
}],
"asks": [{
"price": 136.2,
"size": 10,
"count": 5,
"orders": [{
"price": 136.2,
"size": 4,
"time": 1706025203484
}]
}]
}
const client = new DXLinkWebSocketClient()
client.connect('wss://demo.dxfeed.com/dxlink-ws-dom')
const dom = new DXLinkDepthOfMarket(client, {
symbol: 'AAPL',
source: 'NTV'
})
dom.configure({
acceptDepthLimit: 10,
acceptAggregationPeriod: 2,
// TODO
})
dom.addSnapshotListener((time, bids, asks) => {
// do some work
console.log('Market Depth', time, bids, asks)
})
const config = dom.getConfig()
onClose(() => {
dom.close()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment