Skip to content

Commit f6bb52f

Browse files
committed
Comment
1 parent ef81440 commit f6bb52f

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

packages/sources/dxfeed/src/transport/stock-quotes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const bidSizeIndex = 7
88
const askTimeIndex = 8
99
const askPriceIndex = 10
1010
const askSizeIndex = 11
11+
const dataLength = 12
1112

1213
export const transport = buildWsTransport<BaseEndpointTypes>(
1314
(params) => ({ Quote: [params.base.toUpperCase()] }),
@@ -18,6 +19,10 @@ export const transport = buildWsTransport<BaseEndpointTypes>(
1819

1920
const data = message[0].data[1]
2021

22+
if (data.length != dataLength) {
23+
return []
24+
}
25+
2126
const bidPrice = Number(data[bidPriceIndex])
2227
const askPrice = Number(data[askPriceIndex])
2328

packages/sources/dxfeed/test/integration/__snapshots__/adapter-ws.test.ts.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`websocket quote endpoint error when data length is not valid 1`] = `
4+
{
5+
"error": {
6+
"message": "The EA has not received any values from the Data Provider for the requested data yet. Retry after a short delay, and if the problem persists raise this issue in the relevant channels.",
7+
"name": "AdapterError",
8+
},
9+
"status": "errored",
10+
"statusCode": 504,
11+
}
12+
`;
13+
314
exports[`websocket quote endpoint should return ask when bid is 0 1`] = `
415
{
516
"data": {

packages/sources/dxfeed/test/integration/adapter-ws.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,13 @@ describe('websocket', () => {
8383
})
8484
expect(response.json()).toMatchSnapshot()
8585
})
86+
87+
it('error when data length is not valid', async () => {
88+
const response = await testAdapter.request({
89+
base: 'INVALID_DATA',
90+
endpoint: 'stock_quotes',
91+
})
92+
expect(response.json()).toMatchSnapshot()
93+
})
8694
})
8795
})

packages/sources/dxfeed/test/integration/fixtures.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ export const mockWebSocketServer = (URL: string): MockWebsocketServer => {
8181
channel: '/service/data',
8282
},
8383
]
84+
const quoteReponse4 = [
85+
{
86+
data: [
87+
'Quote',
88+
['INVALID_DATA', 0, 0, 0, 1670868378000, 'V', 170.0, 148.0, 1670868370000, 'V', 0],
89+
],
90+
channel: '/service/data',
91+
},
92+
]
8493
const tradeResponse = [
8594
{
8695
data: [
@@ -118,6 +127,7 @@ export const mockWebSocketServer = (URL: string): MockWebsocketServer => {
118127
socket.send(JSON.stringify(quoteReponse))
119128
socket.send(JSON.stringify(quoteReponse2))
120129
socket.send(JSON.stringify(quoteReponse3))
130+
socket.send(JSON.stringify(quoteReponse4))
121131
socket.send(JSON.stringify(tradeResponse))
122132
})
123133
})

0 commit comments

Comments
 (0)