High latency between orders response sending via websocket

I am sending market orders via a websocket connection and the response delay is 200-300 ms, why is that???

“transactTime”:1689492825627
“transactTime”:1689492825917

There’s a number of factors which could be the cause of this. Your internet connection speed and location are the main factors. Do you usually get lower latency when sending market orders via websockets?

I have ping about 40 ms. I run my program in server where ping 0.5 ms and i have the same result.

We’re currently working with latency data ourselves.

Could you clarify how you’re sending the market order requests through a websocket connection? I wasn’t aware that is possible. The only thing I know is receiving the responses.

Other than that, your question doesn’t have enough information. The only thing that comes to mind is you ignored the time it takes Binance to receive, process, and respond to your request.

At given times latency is 300ms+ even when sending the request from a AWS Tokyo based 5Gbps VPS, but for us other times it’s more around 14ms. It all depends when you tested.

Please provide more info

Hi,

You can actually use the Websocket API to place/cancel/query orders along with lots of other operations. Keep in mind that currently the Websocket API is only available for Spot.

@Nikita_Timofeenko - please provide as much information as you can. As feliks912 mentioned, what you’ve provided so far isn’t really enough information to diagnose your specific issue as there’s such a broad range of issues which you could be facing.

My rust code

pub struct WebSocket {
pub url: Url,
pub ws_reader: Option<futures::stream::SplitStream<WebSocketStream<tokio_tungstenite::MaybeTlsStream>>>,
pub ws_writer: Option<futures::stream::SplitSink<WebSocketStream<tokio_tungstenite::MaybeTlsStream>, Message>>
}

#[async_trait]
pub trait WebSocketOrdersSenderAndReceiver {
async fn connect(&mut self);
async fn send(&mut self, message: &str);
async fn receive(&mut self) → Result<Option, Error>;
async fn place_order(
&mut self,
symbol: &str,
side: &str,
order_type:
&str, quantity:
Option<&str>,
quote_order_qty:
Option<&str>, id: &str
) → Result<(), WebsocketErrors>;
}

// Implementations for async_trait

//

let mut client = WebSocket {url, ws_writer: None, ws_reader: None};
client.connect().await;

client.place_order(//parameteres for 1 order ).await.expect(“message”);
awaiting response from 1 order
client.receive().await.expect(“message”);

client.place_order(//parameteres for 2 order).await.expect(“message”);
awaiting response from 2 order
client.receive().await.expect(“message”);

client.place_order(//parameteres for 3 order).await.expect(“message”);
awaiting response from 3 order
client.receive().await.expect(“message”);

full server responses

{“status”:200,“result”:{“symbol”:“XRPUSDT”,“orderId”:3284690,“orderListId”:-1,“transactTime”:1690188957667,“price”:“0.00000000”,“origQty”:“50.00000000”,“executedQty”:“50.00000000”,“cummulativeQuoteQty”:“35.89000000”,“status”:“FILLED”,“timeInForce”:“GTC”,“type”:“MARKET”,“side”:“BUY”,“workingTime”:1690188957667,“fills”:[{“price”:“0.71780000”,“qty”:“50.00000000”,“commission”:“0.00000000”,“commissionAsset”:“XRP”,“tradeId”:356028}],“selfTradePreventionMode”:“NONE”},“rateLimits”:[{“rateLimitType”:“ORDERS”,“interval”:“SECOND”,“intervalNum”:10,“limit”:50,“count”:1},{“rateLimitType”:“ORDERS”,“interval”:“DAY”,“intervalNum”:1,“limit”:160000,“count”:1},{“rateLimitType”:“REQUEST_WEIGHT”,“interval”:“MINUTE”,“intervalNum”:1,“limit”:1200,“count”:1}]}

{“status”:200,“result”:{“symbol”:“XRPBTC”,“orderId”:663098,“orderListId”:-1,“transactTime”:1690188957955,“price”:“0.00000000”,“origQty”:“50.00000000”,“executedQty”:“50.00000000”,“cummulativeQuoteQty”:“0.00120500”,“status”:“FILLED”,“timeInForce”:“GTC”,“type”:“MARKET”,“side”:“SELL”,“workingTime”:1690188957955,“fills”:[{“price”:“0.00002410”,“qty”:“50.00000000”,“commission”:“0.00000000”,“commissionAsset”:“BTC”,“tradeId”:83844}],“selfTradePreventionMode”:“NONE”},“rateLimits”:[{“rateLimitType”:“ORDERS”,“interval”:“SECOND”,“intervalNum”:10,“limit”:50,“count”:2},{“rateLimitType”:“ORDERS”,“interval”:“DAY”,“intervalNum”:1,“limit”:160000,“count”:2},{“rateLimitType”:“REQUEST_WEIGHT”,“interval”:“MINUTE”,“intervalNum”:1,“limit”:1200,“count”:2}]}

{“status”:200,“result”:{“symbol”:“BTCUSDT”,“orderId”:8776715,“orderListId”:-1,“transactTime”:1690188958243,“price”:“0.00000000”,“origQty”:“0.00120000”,“executedQty”:“0.00120000”,“cummulativeQuoteQty”:“35.70582000”,“status”:“FILLED”,“timeInForce”:“GTC”,“type”:“MARKET”,“side”:“SELL”,“workingTime”:1690188958243,“fills”:[{“price”:“29754.85000000”,“qty”:“0.00120000”,“commission”:“0.00000000”,“commissionAsset”:“USDT”,“tradeId”:2542020}],“selfTradePreventionMode”:“NONE”},“rateLimits”:[{“rateLimitType”:“ORDERS”,“interval”:“SECOND”,“intervalNum”:10,“limit”:50,“count”:3},{“rateLimitType”:“ORDERS”,“interval”:“DAY”,“intervalNum”:1,“limit”:160000,“count”:3},{“rateLimitType”:“REQUEST_WEIGHT”,“interval”:“MINUTE”,“intervalNum”:1,“limit”:1200,“count”:3}]}