Skip to content

Commit

Permalink
fix: handle book1. messages with no best bid/ask info
Browse files Browse the repository at this point in the history
  • Loading branch information
thaaddeus committed Nov 6, 2024
1 parent fef8806 commit a3eafce
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/mappers/bitget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ export class BitgetBookTickerMapper implements Mapper<'bitget' | 'bitget-futures
symbol: message.arg.instId,
exchange: this._exchange,

askAmount: Number(bboMessage.asks[0][1]),
askPrice: Number(bboMessage.asks[0][0]),
askAmount: bboMessage.asks[0] ? Number(bboMessage.asks[0][1]) : undefined,
askPrice: bboMessage.asks[0] ? Number(bboMessage.asks[0][0]) : undefined,

bidPrice: Number(bboMessage.bids[0][0]),
bidAmount: Number(bboMessage.bids[0][1]),
bidPrice: bboMessage.bids[0] ? Number(bboMessage.bids[0][0]) : undefined,
bidAmount: bboMessage.bids[0] ? Number(bboMessage.bids[0][1]) : undefined,
timestamp: new Date(Number(bboMessage.ts)),
localTimestamp: localTimestamp
}
Expand Down
16 changes: 16 additions & 0 deletions test/__snapshots__/mappers.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,22 @@ Array [
]
`;

exports[`map bitget-futures messages 10`] = `
Array [
Object {
"askAmount": 4.58,
"askPrice": 1.4138,
"bidAmount": undefined,
"bidPrice": undefined,
"exchange": "bitget-futures",
"localTimestamp": 2024-08-23T00:00:00.498Z,
"symbol": "AQTUSDT",
"timestamp": 2024-11-06T02:32:10.169Z,
"type": "book_ticker",
},
]
`;

exports[`map bitnomial messages 1`] = `
Array [
Object {
Expand Down
6 changes: 6 additions & 0 deletions test/mappers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9279,6 +9279,12 @@ test('map bitget-futures messages', () => {
}
],
ts: 1730332823221
},
{
action: 'snapshot',
arg: { instType: 'SPOT', channel: 'books1', instId: 'AQTUSDT' },
data: [{ asks: [['1.4138', '4.58']], bids: [], checksum: 0, ts: '1730860330169' }],
ts: 1730860330170
}
]

Expand Down

0 comments on commit a3eafce

Please sign in to comment.