WebSocket Trading is a WhiteBIT API feature that allows you to receive market data and manage orders through the same persistent WebSocket connection. It can reduce the number of communication steps between detecting a market change and submitting an order instruction. Detailed specifications are available in the WebSocket Order Management overview.
How Does WebSocket Trading Work?
WebSocket maintains a continuous two-way connection between your trading system and the platform. Unlike a separate HTTP request, the connection does not need to be created again for every action. For technical details on the underlying protocol, refer to the WebSocket API overview.
A trading system can use the connection to:
- receive market updates
- analyse the received information
- submit an instruction to place, modify, or cancel an order
- receive order and execution updates
This creates a continuous workflow between market data, trading decisions, and order management.
How Is It Different from the REST API?
In a traditional integration, a trading system may receive market data through WebSocket but use the REST API to manage orders. Each order action then requires a separate HTTP request and response.
WebSocket Trading allows the resulting instruction to be sent through the already active connection. This can shorten the path between the trading decision and order submission.
WebSocket Trading does not fully replace the REST API. REST requests may still be used to retrieve initial account data, balances, trading history, or other information required by the integration.
Who Can Use WebSocket Trading?
WebSocket Trading can be useful for:
- algorithmic traders
- trading bot developers
- market makers
- automated trading systems
- strategies that frequently update orders
- systems that react to short-term market changes
The benefit may be less noticeable for strategies that place only a few orders. It is more relevant when a system frequently updates quotes, replaces outdated orders, or responds to real-time market events. To set up your first connection, follow the WebSocket Quickstart guide.
What Are the Main Benefits?
WebSocket Trading provides:
- fewer separate requests
- lower order-submission latency
- one connection for market data and order management
- fewer communication channels within the integration
- support for systems that frequently place or update orders
The feature optimises the transmission of an order instruction. Other parts of the trading process still depend on your infrastructure, network conditions, and market state.
Does WebSocket Trading Guarantee Order Execution?
WebSocket Trading does not guarantee immediate execution or execution at a specific price.
After receiving an instruction, the platform validates the order parameters and either accepts or rejects the request. The execution of an accepted order depends on:
- order type and parameters
- available liquidity
- position in the order queue
- current market conditions
- network quality
- performance of the trading system
Please note: order submission and order execution are different stages. Monitor the order status and individual fills to confirm the execution result.
Factors Affecting Trading System Speed
Even with fewer requests, the overall performance of your trading system depends on several infrastructure and market factors:
- network quality and stability
- geographical location of your server infrastructure
- raw performance of your trading system
- time required to process market data and generate a decision
- current network and platform load
- market liquidity
- selected order type and parameters
WebSocket Trading optimizes the part of this process that can be improved at the API integration level: transmitting order-management instructions from the trading system to the platform.