126 |
127 | Field |
128 | Name |
129 | Description |
130 | Examples |
131 |
132 |
133 | d |
134 | Trailing Delta |
135 | Appears only for trailing stop orders. |
136 | "d": 4 |
137 |
138 |
139 | D |
140 | Trailing Time |
141 | "D": 1668680518494 |
142 |
143 |
144 | j |
145 | Strategy Id |
146 | Appears only if the strategyId parameter was provided upon order placement. |
147 | "j": 1 |
148 |
149 |
150 | J |
151 | Strategy Type |
152 | Appears only if the strategyType parameter was provided upon order placement. |
153 | "J": 1000000 |
154 |
155 |
156 | v |
157 | Prevented Match Id |
158 | Appears only for orders that expired due to STP. |
159 | "v": 3 |
160 |
161 |
162 | A
163 | | Prevented Quantity |
164 | "A":"3.000000" |
165 |
166 |
167 | B |
168 | Last Prevented Quantity |
169 | "B":"3.000000" |
170 |
171 |
172 | u |
173 | Trade Group Id |
174 | "u":1 |
175 |
176 |
177 | U |
178 | Counter Order Id |
179 | "U":37 |
180 |
181 |
182 | Cs |
183 | Counter Symbol |
184 | "Cs": "BTCUSDT" |
185 |
186 |
187 | pl |
188 | Prevented Execution Quantity |
189 | "pl":"2.123456" |
190 |
191 |
192 | pL |
193 | Prevented Execution Price |
194 | "pL":"0.10000001" |
195 |
196 |
197 | pY |
198 | Prevented Execution Quote Qty |
199 | "pY":"0.21234562" |
200 |
201 |
202 | W |
203 | Working Time |
204 | Appears when the order is working on the book |
205 | "W": 1668683798379 |
206 |
207 |
208 | b |
209 | Match Type |
210 | Appears for orders that have allocations |
211 | "b":"ONE_PARTY_TRADE_REPORT" |
212 |
213 |
214 | a |
215 | Allocation ID |
216 | "a":1234 |
217 |
218 |
219 | k |
220 | Working Floor |
221 | Appears for orders that potentially have allocations |
222 | "k":"SOR" |
223 |
224 |
225 | uS |
226 | UsedSor |
227 | Appears for orders that used SOR |
228 | "uS":true |
229 |
230 |
231 |
232 | #### Order Reject Reason
233 |
234 | For additional details, look up the Error Message in the [Errors](errors.md#other-errors) documentation.
235 |
236 | |Rejection Reason (`r`)| Error Message|
237 | |--- | --- |
238 | |`NONE` | N/A (i.e. The order was not rejected.)|
239 | |`INSUFFICIENT_BALANCES`|"Account has insufficient balance for requested action."|
240 | |`STOP_PRICE_WOULD_TRIGGER_IMMEDIATELY`|"Order would trigger immediately."|
241 | |`WOULD_MATCH_IMMEDIATELY`|"Order would immediately match and take."|
242 | |`OCO_BAD_PRICES`|"The relationship of the prices for the orders is not correct."|
243 |
244 | If the order is an order list, an event named `ListStatus` will be sent in addition to the `executionReport` event.
245 |
246 | **Payload**
247 | ```javascript
248 | {
249 | "e": "listStatus", // Event Type
250 | "E": 1564035303637, // Event Time
251 | "s": "ETHBTC", // Symbol
252 | "g": 2, // OrderListId
253 | "c": "OCO", // Contingency Type
254 | "l": "EXEC_STARTED", // List Status Type
255 | "L": "EXECUTING", // List Order Status
256 | "r": "NONE", // List Reject Reason
257 | "C": "F4QN4G8DlFATFlIUQ0cjdD", // List Client Order ID
258 | "T": 1564035303625, // Transaction Time
259 | "O": [ // An array of objects
260 | {
261 | "s": "ETHBTC", // Symbol
262 | "i": 17, // OrderId
263 | "c": "AJYsMjErWJesZvqlJCTUgL" // ClientOrderId
264 | },
265 | {
266 | "s": "ETHBTC",
267 | "i": 18,
268 | "c": "bfYPSQdLoqAJeNrOr9adzq"
269 | }
270 | ]
271 | }
272 | ```
273 |
274 | #### Execution types
275 |
276 | * `NEW` - The order has been accepted into the engine.
277 | * `CANCELED` - The order has been canceled by the user.
278 | * `REPLACED` - The order has been amended.
279 | * `REJECTED` - The order has been rejected and was not processed. (e.g. Cancel Replace orders where the new order placement was rejected even if the cancel request succeeded.)
280 | * `TRADE` - Part of the order or all of the order's quantity has filled.
281 | * `EXPIRED` - The order was canceled according to the order type's rules (e.g. LIMIT FOK orders with no fill, LIMIT IOC or MARKET orders that partially fill) or by the exchange, (e.g. orders canceled during liquidation, orders canceled during maintenance).
282 | * `TRADE_PREVENTION` - The order has expired due to STP.
283 |
284 | Check the [Enums Documentation](enums.md) for more relevant enum definitions.
285 |
286 | ### Listen Key Expired
287 |
288 | This event is sent when the listen key expires.
289 |
290 | No more events will be sent after this until a new `listenKey` is created.
291 |
292 | This event will not be pushed when the stream is closed normally.
293 |
294 | **Payload:**
295 |
296 | ```javascript
297 | {
298 | "e": "listenKeyExpired", // Event type
299 | "E": "1699596037418", // Event time
300 | "listenKey": "OfYGbUzi3PraNagEkdKuFwUHn48brFsItTdsuiIXrucEvD0rhRXZ7I6URWfE8YE8"
301 | }
302 | ```
303 |
304 | ### Event Stream Terminated
305 |
306 | This event appears only for WebSocket API.
307 |
308 | `eventStreamTerminated` is sent when the User Data Stream is stopped. For example, after you send a `userDataStream.unsubscribe` request, or a `session.logout` request.
309 |
310 | **Payload:**
311 |
312 | ```javascript
313 | {
314 | "event": {
315 | "e": "eventStreamTerminated", // Event Type
316 | "E": 1728973001334 // Event Time
317 | }
318 | }
319 | ```
320 |
321 | ### External Lock Update
322 |
323 | `externalLockUpdate` is sent when part of your spot wallet balance is locked/unlocked by an external system, for example when used as margin collateral.
324 |
325 | **Payload:**
326 |
327 | ```javascript
328 | {
329 | "e": "externalLockUpdate", // Event Type
330 | "E": 1581557507324, // Event Time
331 | "a": "NEO", // Asset
332 | "d": "10.00000000", // Delta
333 | "T": 1581557507268 // Transaction Time
334 | }```
335 |
--------------------------------------------------------------------------------
/user-data-stream.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
4 |
5 | - [User Data Stream Events](#user-data-stream-events)
6 | - [Account Update](#account-update)
7 | - [Balance Update](#balance-update)
8 | - [Order Update](#order-update)
9 | - [Conditional Fields in Execution Report](#conditional-fields-in-execution-report)
10 | - [Order Reject Reason](#order-reject-reason)
11 | - [Listen Key Expired](#listen-key-expired)
12 | - [Event Stream Terminated](#event-stream-terminated)
13 | - [External Lock Update](#external-lock-update)
14 |
15 |
16 |
17 | # User Data Streams for Binance
18 |
19 | **Last Updated: 2025-04-08**
20 |
21 | * There are currently two ways to subscribe to the User Data Stream:
22 | * **[Preferred]** Subscribing directly through the [WebSocket API](web-socket-api.md#user_data_stream_subscribe) using an API Key.
23 | * **[Deprecated]** Generating a **listen key** using [the REST API](rest-api.md#user-data-stream-requests) or [the WebSocket API](web-socket-api.md#user-data-stream-requests) and using it to listen on **stream.binance.com**
24 | * Both sources will push all events related to your account **in real-time**.
25 | * How to use a listen key on **stream.binance.com**:
26 | * The base endpoint is: **wss://stream.binance.com:9443** or **wss://stream.binance.com:443**.
27 | * A single connection to **stream.binance.com** is only valid for 24 hours; expect to be disconnected at the 24 hour mark.
28 | * User Data Streams are accessed at **/ws/\