Skip to content

Commit ae61a24

Browse files
committed
fix(ws): route Binance futures candles and depth to dedicated paths
Signed-off-by: TIANHE <[email protected]>
1 parent 83c707a commit ae61a24

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎src/utils/exchangeOrderBookWs.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export function applyHtxOrderBook (book, data) {
241241
export const ORDER_BOOK_WS = {
242242
binance: {
243243
buildUrl (context) {
244-
const base = context.marketType === 'swap' ? 'wss://fstream.binance.com/ws' : 'wss://data-stream.binance.vision/ws'
244+
const base = context.marketType === 'swap' ? 'wss://fstream.binance.com/public/ws' : 'wss://data-stream.binance.vision/ws'
245245
return `${base}/${compactSymbol(context.symbol).toLowerCase()}@depth20@100ms`
246246
},
247247
apply: applyBinanceOrderBook,

‎src/utils/exchangeWs.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const EXCHANGE_WS = {
106106
buildUrl (symbol, interval, context) {
107107
const s = normalizedSymbol(context.instrumentId || symbol).toLowerCase()
108108
const base = normalizedMarketType(context.marketType) === 'swap'
109-
? 'wss://fstream.binance.com/ws'
109+
? 'wss://fstream.binance.com/market/ws'
110110
: 'wss://data-stream.binance.vision/ws'
111111
return `${base}/${s}@kline_${interval}`
112112
},

‎tests/unit/exchangeOrderBookWs.test.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ test('Binance spot depth uses the official market-data-only endpoint', () => {
133133
const spotUrl = ORDER_BOOK_WS.binance.buildUrl({ exchangeId: 'binance', symbol: 'ETH/USDT', marketType: 'spot' })
134134
const swapUrl = ORDER_BOOK_WS.binance.buildUrl({ exchangeId: 'binance', symbol: 'ETH/USDT', marketType: 'swap' })
135135
assert.equal(spotUrl, 'wss://data-stream.binance.vision/ws/ethusdt@depth20@100ms')
136-
assert.equal(swapUrl, 'wss://fstream.binance.com/ws/ethusdt@depth20@100ms')
136+
assert.equal(swapUrl, 'wss://fstream.binance.com/public/ws/ethusdt@depth20@100ms')
137137
})
138138

139139
test('WebSocket snapshots carry the correct quantity unit for every venue and market', () => {

‎tests/unit/exchangeWs.test.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ test('all six exchanges expose venue-scoped spot and swap endpoints', () => {
103103
const swap = { marketType: 'swap', instrumentId: '' }
104104

105105
assert.equal(EXCHANGE_WS.binance.buildUrl('BTC/USDT', '1m', spot), 'wss://data-stream.binance.vision/ws/btcusdt@kline_1m')
106-
assert.equal(EXCHANGE_WS.binance.buildUrl('BTC/USDT', '1m', swap), 'wss://fstream.binance.com/ws/btcusdt@kline_1m')
106+
assert.equal(EXCHANGE_WS.binance.buildUrl('BTC/USDT', '1m', swap), 'wss://fstream.binance.com/market/ws/btcusdt@kline_1m')
107107
assert.equal(EXCHANGE_WS.okx.buildUrl('BTC/USDT', '1m', spot), 'wss://ws.okx.com/ws/v5/business')
108108
assert.equal(EXCHANGE_WS.bybit.buildUrl('BTC/USDT', '1', spot), 'wss://stream.bybit.com/v5/public/spot')
109109
assert.equal(EXCHANGE_WS.bybit.buildUrl('BTC/USDT', '1', swap), 'wss://stream.bybit.com/v5/public/linear')

0 commit comments

Comments
 (0)