Skip to content

Commit

Permalink
improvement: tweak delta order book mapping code to handle undefined …
Browse files Browse the repository at this point in the history
…bids or asks
  • Loading branch information
thaaddeus committed Oct 21, 2022
1 parent 7e40aa3 commit 6854671
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/mappers/delta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,16 @@ export const deltaBookChangeMapper: Mapper<'delta', BookChange> = {
},

*map(message: DeltaL2OrderBook, localTimestamp: Date): IterableIterator<BookChange> {
if (message.buy === undefined && message.sell === undefined) {
return
}
yield {
type: 'book_change',
symbol: message.symbol,
exchange: 'delta',
isSnapshot: true,
bids: message.buy.map(mapBookLevel),
asks: message.sell.map(mapBookLevel),
bids: message.buy !== undefined ? message.buy.map(mapBookLevel) : [],
asks: message.sell !== undefined ? message.sell.map(mapBookLevel) : [],
timestamp: message.timestamp !== undefined ? fromMicroSecondsToDate(message.timestamp) : localTimestamp,
localTimestamp
}
Expand Down

0 comments on commit 6854671

Please sign in to comment.