mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-10 16:58:08 +00:00
* add docs * Add Binance exchange support - Updated the environment configuration to include Binance as a selectable exchange option. - Enhanced the README documentation to reflect the addition of Binance. - Implemented the Binance exchange adapter and integrated it into the existing exchange framework. - Modified the basis arbitrage strategy to support Binance alongside existing exchanges. - Added tests to ensure proper functionality and integration of Binance within the trading system. * Enhance README with detailed Binance exchange configuration - Added comprehensive instructions for setting up Binance as an exchange option. - Included environment variable specifications for API keys, market types, and trading symbols. - Provided examples for both perpetual and spot trading strategies. - Clarified the use of WebSocket and REST for the Binance adapter. * Enhance exchange support and testing framework - Added a new test suite for exchange contracts to ensure consistency and functionality across supported exchanges. - Refactored exchange ID handling to utilize a centralized list of supported exchanges, improving maintainability. - Updated CLI argument parsing and help documentation to reflect the new exchange structure. - Introduced utility functions for validating supported exchanges and their display names. - Enhanced the BasisApp and strategy runner to leverage the new exchange validation logic. - Added a new test command for running exchange-related tests. * Refactor exchange contract tests and update CLI commands - Removed the trailing supported exchanges set and simplified the logic for trailing stop support in the exchange contract tests. - Updated the test command for exchange contracts to exclude unnecessary tests, streamlining the testing process. - Enhanced test descriptions for clarity and improved understanding of the functionality being tested.
100 lines
6.1 KiB
Markdown
100 lines
6.1 KiB
Markdown
---
|
||
title: "SBE Market Data | Binance Open Platform"
|
||
source: "https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams"
|
||
fetched_at: "2026-02-26T10:38:10.990Z"
|
||
---
|
||
# SBE Market Data Streams
|
||
|
||
## General Information[](https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams)
|
||
|
||
- The base endpoint is **stream-sbe.testnet.binance.vision** or **stream-sbe.testnet.binance.vision:9443**.
|
||
- To retrieve market data in JSON format, please refer to [this page](https://developers.binance.com/docs/binance-spot-api-docs/testnet/web-socket-streams).
|
||
- SBE schema used for decoding the streams can be found [here](https://github.com/binance/binance-spot-api-docs/blob/master/sbe/schemas/stream_1_0.xml).
|
||
- All symbols in stream names are **lowercase**.
|
||
- You can subscribe to a single stream at **/ws/<streamName>**.
|
||
- You can subscribe to multiple streams at **/stream?streams=<streamName1>/<streamName2>/<streamName3>**.
|
||
- A single connection to **stream-sbe.testnet.binance.vision** is **only valid for 24 hours**; expect to be disconnected at the 24 hour mark.
|
||
- All time and timestamp fields are in **microseconds**.
|
||
- **An API Key is necessary for access**.
|
||
- Only Ed25519 keys are allowed.
|
||
- Please put your API Key in the `X-MBX-APIKEY` header when opening the connection. Timestamp and signature are not necessary.
|
||
- No extra API key permissions are necessary to access public market data. Symbol whitelist also does not affect access to SBE Market Data Streams.
|
||
- However, if you use an IP whitelist for the API key, only specified IP addresses are allowed to use the API key.
|
||
- The server sends a `ping frame` every 20 seconds.
|
||
- If the server does not receive a `pong frame` back from you within a minute, the connection will be closed.
|
||
- When you receive a ping, you must send a pong with a copy of ping's payload as soon as possible.
|
||
- Unsolicited `pong frames` are allowed, but will not prevent disconnection. **It is recommended that the payload for these pong frames are empty.**
|
||
- [Live Subscribing and Unsubscribing](https://developers.binance.com/docs/binance-spot-api-docs/testnet/web-socket-streams) is also supported.
|
||
- You must send the subscription requests in JSON, and will receive the subscription response also in JSON.
|
||
- You can differentiate subscription responses from market data events by looking at the WebSocket frame type: subscription responses are always sent in text frames (containing JSON), and events are always sent in binary frames (containing SBE).
|
||
|
||
## WebSocket Limits[](https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams)
|
||
|
||
- WebSocket connections have a rate limit of **5 requests per second**.
|
||
- Only messages from your client are considered:
|
||
- `PING frame`
|
||
- `PONG frame`
|
||
- `Text frame` with JSON control request
|
||
- Events pushed by the server are not rate-limited.
|
||
- Connections that go beyond the limit will be closed. Repeatedly disconnected IP addresses may be banned.
|
||
- A single connection can listen to a maximum of 1024 streams.
|
||
- There is a limit of **300 connection attempts every 5 minutes per IP address**.
|
||
|
||
## Available Streams[](https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams)
|
||
|
||
### Trades Streams[](https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams)
|
||
|
||
Raw trade information, pushed in real-time.
|
||
|
||
**SBE Message Name:** `TradesStreamEvent`
|
||
|
||
**Stream Name**: <symbol>@trade
|
||
|
||
**Update Speed**: Real time
|
||
|
||
### Best Bid/Ask Streams[](https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams)
|
||
|
||
The best bid and ask price and quantity, pushed in real-time when the order book changes.
|
||
|
||
> \[!NOTE\] Best bid/ask streams in SBE are the equivalent of bookTicker streams in JSON, except they support auto-culling, and also include the `eventTime` field.
|
||
|
||
**SBE Message Name:** `BestBidAskStreamEvent`
|
||
|
||
**Stream Name**: <symbol>@bestBidAsk
|
||
|
||
**Update Speed**: Real time
|
||
|
||
SBE best bid/ask streams use **auto-culling**: when the system is under high load, it may drop outdated events instead of queuing all events and delivering them with a delay.
|
||
|
||
For example, if a best bid/ask event is generated at time T2 when there is still an undelivered event queued at time T1 (where T1 < T2), the event for T1 is dropped, and the system will deliver only the event for T2. This is done on a per-symbol basis.
|
||
|
||
### Diff. Depth Streams[](https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams)
|
||
|
||
Incremental updates to the order book, pushed at regular intervals. Use this stream to maintain a local order book.
|
||
|
||
[How to manage a local order book.](https://developers.binance.com/docs/binance-spot-api-docs/testnet/web-socket-streams)
|
||
|
||
**SBE Message Name:** `DepthDiffStreamEvent`
|
||
|
||
**Stream Name**: <symbol>@depth
|
||
|
||
**Update Speed:** 50ms
|
||
|
||
### Partial Book Depth Streams[](https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams)
|
||
|
||
Snapshots of the top 20 levels of the order book, pushed at regular intervals.
|
||
|
||
**SBE Message Name:** `DepthSnapshotStreamEvent`
|
||
|
||
**Stream Name**: <symbol>@depth20
|
||
|
||
**Update Speed:** 50ms
|
||
|
||
- [General Information](https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams)
|
||
- [WebSocket Limits](https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams)
|
||
- [Available Streams](https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams)
|
||
- [Trades Streams](https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams)
|
||
- [Best Bid/Ask Streams](https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams)
|
||
- [Diff. Depth Streams](https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams)
|
||
- [Partial Book Depth Streams](https://developers.binance.com/docs/binance-spot-api-docs/testnet/sbe-market-data-streams)
|