Skip to content

Commit f83dca3

Browse files
committed
fix(ws): route Binance futures candles and depth to dedicated paths
Signed-off-by: TIANHE <TIANHE@GMAIL.COM>
1 parent c51d72e commit f83dca3

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
@@ -240,7 +240,7 @@ export function applyHtxOrderBook (book, data) {
240240
export const ORDER_BOOK_WS = {
241241
binance: {
242242
buildUrl (context) {
243-
const base = context.marketType === 'swap' ? 'wss://fstream.binance.com/ws' : 'wss://data-stream.binance.vision/ws'
243+
const base = context.marketType === 'swap' ? 'wss://fstream.binance.com/public/ws' : 'wss://data-stream.binance.vision/ws'
244244
return `${base}/${compactSymbol(context.symbol).toLowerCase()}@depth20@100ms`
245245
},
246246
apply: applyBinanceOrderBook,

‎src/utils/exchangeWs.js‎

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

‎tests/unit/chart-stream.test.mjs‎

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

138138
assert.equal(EXCHANGE_WS.binance.buildUrl('BTC/USDT', '1m', spot), 'wss://data-stream.binance.vision/ws/btcusdt@kline_1m')
139-
assert.equal(EXCHANGE_WS.binance.buildUrl('BTC/USDT', '1m', swap), 'wss://fstream.binance.com/ws/btcusdt@kline_1m')
139+
assert.equal(EXCHANGE_WS.binance.buildUrl('BTC/USDT', '1m', swap), 'wss://fstream.binance.com/market/ws/btcusdt@kline_1m')
140140
assert.equal(EXCHANGE_WS.okx.buildUrl('BTC/USDT', '1m', spot), 'wss://ws.okx.com/ws/v5/business')
141141
assert.equal(EXCHANGE_WS.bybit.buildUrl('BTC/USDT', '1', spot), 'wss://stream.bybit.com/v5/public/spot')
142142
assert.equal(EXCHANGE_WS.bybit.buildUrl('BTC/USDT', '1', swap), 'wss://stream.bybit.com/v5/public/linear')

‎tests/unit/exchangeOrderBookWs.test.mjs‎

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

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

0 commit comments

Comments
 (0)