Skip to content

Commit

Permalink
fix bybit liqs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tucsky committed Mar 6, 2024
1 parent 131ea04 commit 189b0b2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
10 changes: 3 additions & 7 deletions src/exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,9 @@ class Exchange extends EventEmitter {
api._pending.push(pair)

if (api.readyState === WebSocket.OPEN) {
this.schedule(
() => {
this.subscribePendingPairs(api)
},
'subscribe-' + api.url,
1000
)
setTimeout(() => {
this.subscribePendingPairs(api)
})
}

return api
Expand Down
26 changes: 12 additions & 14 deletions src/exchanges/bybit.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class Bybit extends Exchange {
return {
exchange: this.id,
pair: liquidation.symbol,
timestamp: +liquidation.updateTime,
timestamp: +liquidation.updatedTime || +liquidation.updateTime,
size,
price: +liquidation.price,
side: liquidation.side === 'Buy' ? 'sell' : 'buy',
Expand All @@ -158,20 +158,18 @@ class Bybit extends Exchange {
return
}

if (json.data.length) {
if (TRADE_TOPIC_REGEX.test(json.topic)) {
const isSpot = api.url === SPOT_WS
if (TRADE_TOPIC_REGEX.test(json.topic)) {
const isSpot = api.url === SPOT_WS

return this.emitTrades(
api.id,
json.data.map(trade => this.formatTrade(trade, isSpot))
)
} else {
return this.emitLiquidations(
api.id,
json.data.map(liquidation => this.formatLiquidation(liquidation))
)
}
return this.emitTrades(
api.id,
json.data.map(trade => this.formatTrade(trade, isSpot))
)
} else {
return this.emitLiquidations(
api.id,
[this.formatLiquidation(json.data)]
)
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/services/connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ const indexes = (module.exports.indexes = [])
continue
}

console.log(market, product.local, product.type)

if (!cacheIndexes[product.local]) {
cacheIndexes[product.local] = {
id: product.local,
Expand Down

0 comments on commit 189b0b2

Please sign in to comment.