WebSocket Price Streaming for ETH/BTC

I am using WebSockets for Price streaming. It works good for URLs like: wss://fstream.binance.com/ws/bnbusdt@aggTrade which returns the Symbol BNBUSDT. All good so far, but when I am trying to retrieve symbols with no USDT as base, then it siimply does not work. For example, URLs like: wss://fstream.binance.com/ws/ethbtc@aggTrade this does not work and does not return any error either.

Anyone knows a solution for this?

ETHBTC is not a valid symbol on the Futures Exchange.

For a list of available symbols, use the exchange information endpoint

https://binance-docs.github.io/apidocs/futures/en/#exchange-information

Hello @tantialex, thank you for your response. And how then can I get price streaming for Symbols with base in “BTC”, like ETH/BTC?

Use the exchange information endpoint mentioned above and filter symbols where the quoteAsset is equal to the asset you desire.

Open a websocket connection for market streams, iterate the filtered symbols and subscribe to the appropriate market stream of each symbol.

I am following your instrucions, but it still does not work. I am receiving the symbol through the Exchange information endpoint and received this:

"symbols":[{"symbol":"ETHBTC","status":"TRADING","baseAsset":"ETH","baseAssetPrecision":8,"quoteAsset":"BTC","quotePrecision":8,"quoteAssetPrecision":8,"baseCommissionPrecision":8,"quoteCommissionPrecision":8,"orderTypes":["LIMIT","LIMIT_MAKER","MARKET","STOP_LOSS_LIMIT","TAKE_PROFIT_LIMIT"],"icebergAllowed":true,"ocoAllowed":true,"quoteOrderQtyMarketAllowed":true,"isSpotTradingAllowed":true,"isMarginTradingAllowed":true,"filters":[{"filterType":"PRICE_FILTER","minPrice":"0.00000100","maxPrice":"922327.00000000","tickSize":"0.00000100"},{"filterType":"PERCENT_PRICE","multiplierUp":"5","multiplierDown":"0.2","avgPriceMins":5},{"filterType":"LOT_SIZE","minQty":"0.00010000","maxQty":"100000.00000000","stepSize":"0.00010000"},{"filterType":"MIN_NOTIONAL","minNotional":"0.00010000","applyToMarket":true,"avgPriceMins":5},{"filterType":"ICEBERG_PARTS","limit":10},{"filterType":"MARKET_LOT_SIZE","minQty":"0.00000000","maxQty":"872.29171869","stepSize":"0.00000000"},{"filterType":"MAX_NUM_ORDERS","maxNumOrders":200},{"filterType":"MAX_NUM_ALGO_ORDERS","maxNumAlgoOrders":5}],"permissions":["SPOT","MARGIN"]}

All good. Then I use WebSocket to retrieve Market Price streaming with this URL: wss://fstream.binance.com/stream?streams=ethbtc@markPrice and nothing happens, no response. Then I try this URL: wss://fstream.binance.com/stream?streams=btcusdt@markPrice and it retrieves prices normally. Where do you think is the mistake?

1 Like

I think you may have confused the using the SPOT Exchange Information endpoint for the FUTURES Exchange Information endpoint.

Please confirm you are using GET https://fapi.binance.com/api/v3/exchangeInfo

It seems like that end-point is not working very well. I am using the binance-java-connector and this is the reponse I get using the URL you suggested:

`2022-01-17 13:18:06.815[1642443486815] | INFO | main | c.b.c.client.utils.RequestHandler - GET https://fapi.binance.com/api/v3/exchangeInfo
Exception in thread “main” com.binance.connector.client.exceptions.BinanceClientException:

Binance body { margin: 0 }
.img {
  width: 611px;
  margin: 68px auto 0
}

.info {
  width: 370px;
  margin: 0 auto;
  text-align: center;
  font-family: Arial;
}

.info h3 {
  margin: 0;
  font-size: 25px;
  color: #333;
  font-weight: normal;
}

.info p {
  font-size: 14px;
  font-family: Arial;
  color: #333;
  line-height: 18px;
  margin: 0
}

.info button {
  margin-top: 20px;
  width: 231px;
  height: 34px;
  background: #FFFFFF;
  border: 1px solid #F0B90B;
  box-sizing: border-box;
  border-radius: 3px;
  font-size: 14px;
  line-height: 16px;
  color: #F0B90B;
}

出错啦!您访问的网页不存在。

Sorry! The page you’re looking for cannot be found.

Return to Binance home page
`

However, if I send a request to: https://fapi.binance.com/fapi/v1/exchangeInfo, it does retrieve some Symbol details.

BTW, if you can see above in my previous response, the HTML was not escaped by the System, I’m pretty sure I can inject some JS here. Perhaps, you may talk to the people in charge to get it fixed.