Skip to main content

binance_sdk/spot/websocket_api/
mod.rs

1/*
2 * Spot WebSocket API
3 *
4 * Access market data, manage accounts, and trade on Binance Spot.
5 *
6 * The version of the OpenAPI document: 1.0.0
7 *
8 *
9 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
10 * https://openapi-generator.tech
11 * Do not edit the class manually.
12 */
13
14#![allow(unused_imports)]
15use serde::de::DeserializeOwned;
16use serde_json::Value;
17use std::{collections::BTreeMap, sync::Arc};
18
19use crate::common::config::ConfigurationWebsocketApi;
20use crate::common::models::WebsocketApiResponse;
21use crate::common::utils::random_string;
22use crate::common::websocket::{
23    Subscription, WebsocketApi as WebsocketApiBase, WebsocketBase, WebsocketMessageSendOptions,
24    WebsocketStream, create_stream_handler,
25};
26use crate::errors::WebsocketError;
27use crate::models::{WebsocketEvent, WebsocketMode};
28
29mod apis;
30mod handle;
31mod models;
32
33pub use apis::*;
34pub use handle::*;
35pub use models::*;
36
37const HAS_TIME_UNIT: bool = true;
38
39#[derive(Clone)]
40pub struct WebsocketApi {
41    websocket_api_base: Arc<WebsocketApiBase>,
42
43    account_api_client: AccountApiClient,
44    auth_api_client: AuthApiClient,
45    general_api_client: GeneralApiClient,
46    market_api_client: MarketApiClient,
47    trade_api_client: TradeApiClient,
48    user_data_stream_api_client: UserDataStreamApiClient,
49}
50
51impl WebsocketApi {
52    pub(crate) async fn connect(
53        config: ConfigurationWebsocketApi,
54        mode: Option<WebsocketMode>,
55    ) -> anyhow::Result<Self> {
56        let mut cfg = config;
57        if let Some(m) = mode {
58            cfg.mode = m;
59        }
60        if !HAS_TIME_UNIT {
61            cfg.time_unit = None;
62        }
63
64        let websocket_api_base = WebsocketApiBase::new(cfg, vec![]);
65        websocket_api_base.clone().connect().await?;
66
67        Ok(Self {
68            websocket_api_base: websocket_api_base.clone(),
69            account_api_client: AccountApiClient::new(websocket_api_base.clone()),
70            auth_api_client: AuthApiClient::new(websocket_api_base.clone()),
71            general_api_client: GeneralApiClient::new(websocket_api_base.clone()),
72            market_api_client: MarketApiClient::new(websocket_api_base.clone()),
73            trade_api_client: TradeApiClient::new(websocket_api_base.clone()),
74            user_data_stream_api_client: UserDataStreamApiClient::new(websocket_api_base.clone()),
75        })
76    }
77
78    /// Subscribes to WebSocket events with a provided callback function.
79    ///
80    /// # Arguments
81    ///
82    /// * `callback` - A mutable function that will be called when a WebSocket event is received.
83    ///   The callback takes a `WebsocketEvent` as its parameter.
84    ///
85    /// # Returns
86    ///
87    /// A `Subscription` that can be used to manage the event subscription.
88    ///
89    /// # Examples
90    ///
91    ///
92    /// let subscription = `websocket_api.subscribe_on_ws_events(|event`| {
93    ///     // Handle WebSocket event
94    /// });
95    ///
96    pub fn subscribe_on_ws_events<F>(&self, callback: F) -> Subscription
97    where
98        F: FnMut(WebsocketEvent) + Send + 'static,
99    {
100        let base = Arc::clone(&self.websocket_api_base);
101        base.common.events.subscribe(callback)
102    }
103
104    /// Unsubscribes from WebSocket events using the provided `Subscription`.
105    ///
106    /// # Arguments
107    ///
108    /// * `subscription` - The `Subscription` to unsubscribe from WebSocket events.
109    ///
110    /// # Examples
111    ///
112    ///
113    /// let subscription = `websocket_api.subscribe_on_ws_events(|event`| {
114    ///     // Handle WebSocket event
115    /// });
116    /// `websocket_api.unsubscribe_from_ws_events(subscription)`;
117    ///
118    pub fn unsubscribe_from_ws_events(&self, subscription: Subscription) {
119        subscription.unsubscribe();
120    }
121
122    /// Disconnects the WebSocket connection.
123    ///
124    /// # Returns
125    ///
126    /// A `Result` indicating whether the disconnection was successful.
127    /// Returns an error if the disconnection fails.
128    ///
129    /// # Errors
130    ///
131    /// Returns an [`anyhow::Error`] if the connection fails.
132    ///
133    /// # Examples
134    ///
135    ///
136    /// let result = `websocket_api.disconnect().await`;
137    ///
138    pub async fn disconnect(&self) -> anyhow::Result<()> {
139        self.websocket_api_base
140            .disconnect()
141            .await
142            .map_err(anyhow::Error::msg)
143    }
144
145    /// Sends a ping message to the WebSocket server to check the connection status.
146    ///
147    /// # Examples
148    ///
149    ///
150    /// `websocket_api.ping_server().await`;
151    ///
152    ///
153    /// This method sends a lightweight ping request to verify the WebSocket connection is still active.
154    pub async fn ping_server(&self) {
155        self.websocket_api_base.ping_server().await;
156    }
157
158    /// Checks if the WebSocket connection is currently active.
159    ///
160    /// # Returns
161    ///
162    /// A `bool` indicating whether the WebSocket connection is established and active.
163    ///
164    /// # Examples
165    ///
166    ///
167    /// let `is_active` = `websocket_api.is_connected().await`;
168    /// if `is_active` {
169    ///     // WebSocket connection is active
170    /// }
171    ///
172    ///
173    /// This method provides a way to check the current status of the WebSocket connection.
174    pub async fn is_connected(&self) -> bool {
175        self.websocket_api_base.is_connected().await
176    }
177
178    /// Sends an unsigned WebSocket message with the specified method and payload.
179    ///
180    /// # Type Parameters
181    ///
182    /// * `R` - The response type to deserialize the message into.
183    ///
184    /// # Arguments
185    ///
186    /// * `method` - The WebSocket method to invoke.
187    /// * `payload` - A map of key-value pairs representing the message payload.
188    ///
189    /// # Returns
190    ///
191    /// A `Result` containing the deserialized response or a `WebsocketError`.
192    ///
193    /// # Errors
194    ///
195    /// Returns a `WebsocketError` if the WebSocket connection fails or the response cannot be deserialized.
196    ///
197    /// # Examples
198    ///
199    ///
200    /// let response = `websocket_api.send_message::`<ResponseType>("`method_name`", payload).await;
201    ///
202    pub async fn send_message<R: DeserializeOwned + Send + Sync + 'static>(
203        &self,
204        method: &str,
205        payload: BTreeMap<String, Value>,
206    ) -> Result<WebsocketApiResponse<R>, WebsocketError> {
207        self.websocket_api_base
208            .send_message::<R>(method, payload, WebsocketMessageSendOptions::new())
209            .await?
210            .into_iter()
211            .next()
212            .ok_or(WebsocketError::NoResponse)
213    }
214
215    /// Sends a signed WebSocket message with the specified method and payload.
216    ///
217    /// # Type Parameters
218    ///
219    /// * `R` - The response type to deserialize the message into.
220    ///
221    /// # Arguments
222    ///
223    /// * `method` - The WebSocket method to invoke.
224    /// * `payload` - A map of key-value pairs representing the message payload.
225    ///
226    /// # Returns
227    ///
228    /// A `Result` containing the deserialized response or a `WebsocketError`.
229    ///
230    /// # Errors
231    ///
232    /// Returns a `WebsocketError` if the WebSocket connection fails or the response cannot be deserialized.
233    ///
234    /// # Examples
235    ///
236    ///
237    /// let response = `websocket_api.send_signed_message::`<ResponseType>("`method_name`", payload).await;
238    ///
239    pub async fn send_signed_message<R: DeserializeOwned + Send + Sync + 'static>(
240        &self,
241        method: &str,
242        payload: BTreeMap<String, Value>,
243    ) -> Result<WebsocketApiResponse<R>, WebsocketError> {
244        self.websocket_api_base
245            .send_message::<R>(method, payload, WebsocketMessageSendOptions::new().signed())
246            .await?
247            .into_iter()
248            .next()
249            .ok_or(WebsocketError::NoResponse)
250    }
251
252    /// Account Commission Rates (`USER_DATA`)
253    ///
254    /// Get current account commission rates.
255    ///
256    /// Weight(IP): 20
257    ///
258    /// Security Type: `USER_DATA`
259    ///
260    /// Notes:
261    /// **Data Source:** Database
262    ///
263    /// # Arguments
264    ///
265    /// - `params`: [`AccountCommissionParams`]
266    ///   The parameters for this operation.
267    ///
268    /// # Returns
269    ///
270    /// [`WebsocketApiResponse<Box<models::AccountCommissionResponseResult>>`] on success.
271    ///
272    /// # Errors
273    ///
274    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
275    ///
276    ///
277    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/account#account-commission).
278    ///
279    pub async fn account_commission(
280        &self,
281        params: AccountCommissionParams,
282    ) -> anyhow::Result<WebsocketApiResponse<Box<models::AccountCommissionResponseResult>>> {
283        self.account_api_client.account_commission(params).await
284    }
285
286    /// Unfilled Order Count (`USER_DATA`)
287    ///
288    /// Query your current unfilled order count for all intervals.
289    ///
290    /// Weight(IP): 40
291    ///
292    /// Security Type: `USER_DATA`
293    ///
294    /// Notes:
295    /// **Data Source:** Memory
296    ///
297    /// # Arguments
298    ///
299    /// - `params`: [`AccountRateLimitsOrdersParams`]
300    ///   The parameters for this operation.
301    ///
302    /// # Returns
303    ///
304    /// [`WebsocketApiResponse<Vec<models::AccountRateLimitsOrdersResponseResultInner>>`] on success.
305    ///
306    /// # Errors
307    ///
308    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
309    ///
310    ///
311    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/account#account-rate-limits-orders).
312    ///
313    pub async fn account_rate_limits_orders(
314        &self,
315        params: AccountRateLimitsOrdersParams,
316    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::AccountRateLimitsOrdersResponseResultInner>>>
317    {
318        self.account_api_client
319            .account_rate_limits_orders(params)
320            .await
321    }
322
323    /// Account information (`USER_DATA`)
324    ///
325    /// Query information about your account.
326    ///
327    /// Weight(IP): 20
328    ///
329    /// Security Type: `USER_DATA`
330    ///
331    /// Notes:
332    /// **Data Source:** Memory => Database
333    ///
334    /// # Arguments
335    ///
336    /// - `params`: [`AccountStatusParams`]
337    ///   The parameters for this operation.
338    ///
339    /// # Returns
340    ///
341    /// [`WebsocketApiResponse<Box<models::AccountStatusResponseResult>>`] on success.
342    ///
343    /// # Errors
344    ///
345    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
346    ///
347    ///
348    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/account#account-status).
349    ///
350    pub async fn account_status(
351        &self,
352        params: AccountStatusParams,
353    ) -> anyhow::Result<WebsocketApiResponse<Box<models::AccountStatusResponseResult>>> {
354        self.account_api_client.account_status(params).await
355    }
356
357    /// Account order list history (`USER_DATA`)
358    ///
359    /// Query information about all your order lists, filtered by time range.
360    ///
361    /// Weight(IP): 20
362    ///
363    /// Security Type: `USER_DATA`
364    ///
365    /// Notes:
366    /// **Data Source:** Database
367    ///
368    /// Notes:
369    /// * If `startTime` and/or `endTime` are specified, `fromId` is ignored.
370    /// Order lists are filtered by `transactionTime` of the last order list execution status update.
371    /// * If `fromId` is specified, return order lists with order list ID >= `fromId`.
372    /// * If no condition is specified, the most recent order lists are returned.
373    /// * The time between `startTime` and `endTime` can't be longer than 24 hours.
374    ///
375    /// # Arguments
376    ///
377    /// - `params`: [`AllOrderListsParams`]
378    ///   The parameters for this operation.
379    ///
380    /// # Returns
381    ///
382    /// [`WebsocketApiResponse<Vec<models::AllOrderListsResponseResultInner>>`] on success.
383    ///
384    /// # Errors
385    ///
386    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
387    ///
388    ///
389    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/account#all-order-lists).
390    ///
391    pub async fn all_order_lists(
392        &self,
393        params: AllOrderListsParams,
394    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::AllOrderListsResponseResultInner>>> {
395        self.account_api_client.all_order_lists(params).await
396    }
397
398    /// Account order history (`USER_DATA`)
399    ///
400    /// Query information about all your orders – active, canceled, filled – filtered by time range.
401    ///
402    /// Weight(IP): 20
403    ///
404    /// Security Type: `USER_DATA`
405    ///
406    /// Notes:
407    /// **Data Source:** Database
408    ///
409    /// Notes:
410    ///
411    /// * If `startTime` and/or `endTime` are specified, `orderId` is ignored.
412    ///
413    /// Orders are filtered by `time` of the last execution status update.
414    ///
415    /// * If `orderId` is specified, return orders with order ID >= `orderId`.
416    ///
417    /// * If no condition is specified, the most recent orders are returned.
418    ///
419    /// * For some historical orders the `cummulativeQuoteQty` response field may be negative,
420    /// meaning the data is not available at this time.
421    ///
422    /// * The time between `startTime` and `endTime` can't be longer than 24 hours.
423    ///
424    /// # Arguments
425    ///
426    /// - `params`: [`AllOrdersParams`]
427    ///   The parameters for this operation.
428    ///
429    /// # Returns
430    ///
431    /// [`WebsocketApiResponse<Vec<models::AllOrdersResponseResultInner>>`] on success.
432    ///
433    /// # Errors
434    ///
435    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
436    ///
437    ///
438    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/account#all-orders).
439    ///
440    pub async fn all_orders(
441        &self,
442        params: AllOrdersParams,
443    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::AllOrdersResponseResultInner>>> {
444        self.account_api_client.all_orders(params).await
445    }
446
447    /// Account allocations (`USER_DATA`)
448    ///
449    /// Retrieves allocations resulting from SOR order placement.
450    ///
451    /// Weight(IP): 20
452    ///
453    /// Security Type: `USER_DATA`
454    ///
455    /// Notes:
456    /// **Data Source:** Database
457    ///
458    /// Supported parameter combinations:
459    ///
460    /// Parameters                                  | Response |
461    /// ------------------------------------------- | -------- |
462    /// `symbol`                                    | allocations from oldest to newest |
463    /// `symbol` + `startTime`                      | oldest allocations since `startTime` |
464    /// `symbol` + `endTime`                        | newest allocations until `endTime` |
465    /// `symbol` + `startTime` + `endTime`          | allocations within the time range |
466    /// `symbol` + `fromAllocationId`               | allocations by allocation ID |
467    /// `symbol` + `orderId`                        | allocations related to an order starting with oldest |
468    /// `symbol` + `orderId` + `fromAllocationId`   | allocations related to an order by allocation ID |
469    ///
470    /// **Note:** The time between `startTime` and `endTime` can't be longer than 24 hours.
471    ///
472    /// # Arguments
473    ///
474    /// - `params`: [`MyAllocationsParams`]
475    ///   The parameters for this operation.
476    ///
477    /// # Returns
478    ///
479    /// [`WebsocketApiResponse<Vec<models::MyAllocationsResponseResultInner>>`] on success.
480    ///
481    /// # Errors
482    ///
483    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
484    ///
485    ///
486    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/account#my-allocations).
487    ///
488    pub async fn my_allocations(
489        &self,
490        params: MyAllocationsParams,
491    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::MyAllocationsResponseResultInner>>> {
492        self.account_api_client.my_allocations(params).await
493    }
494
495    /// Query Relevant Filters (`USER_DATA`)
496    ///
497    /// Retrieves the list of [filters](/products/spot/filters) relevant to an account on a given symbol. This is the only method
498    /// that shows if an account has [`MAX_ASSET`](/products/spot/filters#max_asset) filters applied to it.
499    ///
500    /// Weight(IP): 40
501    ///
502    /// Security Type: `USER_DATA`
503    ///
504    /// Notes:
505    /// **Data Source:** Memory
506    ///
507    /// # Arguments
508    ///
509    /// - `params`: [`MyFiltersParams`]
510    ///   The parameters for this operation.
511    ///
512    /// # Returns
513    ///
514    /// [`WebsocketApiResponse<models::MyFiltersResponse>`] on success.
515    ///
516    /// # Errors
517    ///
518    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
519    ///
520    ///
521    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/account#my-filters).
522    ///
523    pub async fn my_filters(
524        &self,
525        params: MyFiltersParams,
526    ) -> anyhow::Result<WebsocketApiResponse<models::MyFiltersResponse>> {
527        self.account_api_client.my_filters(params).await
528    }
529
530    /// Account prevented matches (`USER_DATA`)
531    ///
532    /// Displays the list of orders that were expired due to STP.
533    ///
534    /// These are the combinations supported:
535    ///
536    /// * `symbol` + `preventedMatchId`
537    /// * `symbol` + `orderId`
538    /// * `symbol` + `orderId` + `fromPreventedMatchId` (`limit` will default to 500)
539    /// * `symbol` + `orderId` + `fromPreventedMatchId` + `limit`
540    ///
541    /// Weight: Case                            | Weight
542    /// ----                            | -----
543    /// If `symbol` is invalid          | 2
544    /// Querying by `preventedMatchId`  | 2
545    /// Querying by `orderId`           | 20
546    ///
547    /// Security Type: `USER_DATA`
548    ///
549    /// Notes:
550    /// **Data Source:** Database
551    ///
552    /// # Arguments
553    ///
554    /// - `params`: [`MyPreventedMatchesParams`]
555    ///   The parameters for this operation.
556    ///
557    /// # Returns
558    ///
559    /// [`WebsocketApiResponse<Vec<models::MyPreventedMatchesResponseResultInner>>`] on success.
560    ///
561    /// # Errors
562    ///
563    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
564    ///
565    ///
566    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/account#my-prevented-matches).
567    ///
568    pub async fn my_prevented_matches(
569        &self,
570        params: MyPreventedMatchesParams,
571    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::MyPreventedMatchesResponseResultInner>>>
572    {
573        self.account_api_client.my_prevented_matches(params).await
574    }
575
576    /// Account trade history (`USER_DATA`)
577    ///
578    /// Query information about all your trades, filtered by time range.
579    ///
580    /// Weight: Condition| Weight|
581    /// ---| ---
582    /// |Without orderId|20|
583    /// |With orderId|5|
584    ///
585    /// Security Type: `USER_DATA`
586    ///
587    /// Notes:
588    /// Data Source: Memory => Database
589    ///
590    /// Notes:
591    /// - If `fromId` is specified, return trades with trade ID >= `fromId`.
592    /// - If `startTime` and/or `endTime` are specified, trades are filtered by execution time (`time`).
593    /// - `fromId` cannot be used together with `startTime` and `endTime`.
594    /// - If `orderId` is specified, only trades related to that order are returned.
595    /// - `startTime` and `endTime` cannot be used together with `orderId`.
596    /// - If no condition is specified, the most recent trades are returned.
597    /// - The time between `startTime` and `endTime` can't be longer than 24 hours.
598    ///
599    /// # Arguments
600    ///
601    /// - `params`: [`MyTradesParams`]
602    ///   The parameters for this operation.
603    ///
604    /// # Returns
605    ///
606    /// [`WebsocketApiResponse<Vec<models::MyTradesResponseResultInner>>`] on success.
607    ///
608    /// # Errors
609    ///
610    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
611    ///
612    ///
613    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/account#my-trades).
614    ///
615    pub async fn my_trades(
616        &self,
617        params: MyTradesParams,
618    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::MyTradesResponseResultInner>>> {
619        self.account_api_client.my_trades(params).await
620    }
621
622    /// Current open Order lists (`USER_DATA`)
623    ///
624    /// Query execution status of all open order lists.
625    ///
626    /// If you need to continuously monitor order status updates, please consider using WebSocket Streams:
627    ///
628    /// * `userDataStream.subscribe` if on an authenticated session
629    /// * `userDataStream.subscribe.signature` if subscribing through signature subscription
630    ///
631    /// Weight(IP): 6
632    ///
633    /// Security Type: `USER_DATA`
634    ///
635    /// Notes:
636    /// **Data Source:** Memory -> Database
637    ///
638    /// # Arguments
639    ///
640    /// - `params`: [`OpenOrderListsStatusParams`]
641    ///   The parameters for this operation.
642    ///
643    /// # Returns
644    ///
645    /// [`WebsocketApiResponse<Vec<models::OpenOrderListsStatusResponseResultInner>>`] on success.
646    ///
647    /// # Errors
648    ///
649    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
650    ///
651    ///
652    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/account#open-order-lists-status).
653    ///
654    pub async fn open_order_lists_status(
655        &self,
656        params: OpenOrderListsStatusParams,
657    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::OpenOrderListsStatusResponseResultInner>>>
658    {
659        self.account_api_client
660            .open_order_lists_status(params)
661            .await
662    }
663
664    /// Current open orders (`USER_DATA`)
665    ///
666    /// Query execution status of all open orders.
667    ///
668    /// If you need to continuously monitor order status updates, please consider using WebSocket Streams:
669    ///
670    /// * `userDataStream.subscribe` if on an authenticated session
671    /// * `userDataStream.subscribe.signature` if subscribing through signature subscription
672    ///
673    /// Weight: | Parameter | Weight |
674    /// | --------- | ------ |
675    /// | `symbol`  |      6 |
676    /// | none      |     80 |
677    ///
678    /// Security Type: `USER_DATA`
679    ///
680    /// Notes:
681    /// Data Source: Memory => Database
682    ///
683    /// # Arguments
684    ///
685    /// - `params`: [`OpenOrdersStatusParams`]
686    ///   The parameters for this operation.
687    ///
688    /// # Returns
689    ///
690    /// [`WebsocketApiResponse<Vec<models::OpenOrdersStatusResponseResultInner>>`] on success.
691    ///
692    /// # Errors
693    ///
694    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
695    ///
696    ///
697    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/account#open-orders-status).
698    ///
699    pub async fn open_orders_status(
700        &self,
701        params: OpenOrdersStatusParams,
702    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::OpenOrdersStatusResponseResultInner>>>
703    {
704        self.account_api_client.open_orders_status(params).await
705    }
706
707    /// Query Order Amendments (`USER_DATA`)
708    ///
709    /// Queries all amendments of a single order.
710    ///
711    /// Weight(IP): 4
712    ///
713    /// Security Type: `USER_DATA`
714    ///
715    /// Notes:
716    /// **Data Source:** Database
717    ///
718    /// # Arguments
719    ///
720    /// - `params`: [`OrderAmendmentsParams`]
721    ///   The parameters for this operation.
722    ///
723    /// # Returns
724    ///
725    /// [`WebsocketApiResponse<Vec<models::OrderAmendmentsResponseResultInner>>`] on success.
726    ///
727    /// # Errors
728    ///
729    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
730    ///
731    ///
732    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/account#order-amendments).
733    ///
734    pub async fn order_amendments(
735        &self,
736        params: OrderAmendmentsParams,
737    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::OrderAmendmentsResponseResultInner>>> {
738        self.account_api_client.order_amendments(params).await
739    }
740
741    /// Query Order list (`USER_DATA`)
742    ///
743    /// Check execution status of an Order list.
744    ///
745    /// For execution status of individual orders, use `order.status`.
746    ///
747    /// Weight(IP): 4
748    ///
749    /// Security Type: `USER_DATA`
750    ///
751    /// Notes:
752    /// **Data Source:** Database
753    ///
754    /// Notes:
755    ///
756    /// * `origClientOrderId` refers to `listClientOrderId` of the order list itself.
757    ///
758    /// * If both `origClientOrderId` and `orderListId` parameters are specified,
759    /// only `origClientOrderId` is used and `orderListId` is ignored.
760    ///
761    /// # Arguments
762    ///
763    /// - `params`: [`OrderListStatusParams`]
764    ///   The parameters for this operation.
765    ///
766    /// # Returns
767    ///
768    /// [`WebsocketApiResponse<Box<models::OrderListStatusResponseResult>>`] on success.
769    ///
770    /// # Errors
771    ///
772    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
773    ///
774    ///
775    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/account#order-list-status).
776    ///
777    pub async fn order_list_status(
778        &self,
779        params: OrderListStatusParams,
780    ) -> anyhow::Result<WebsocketApiResponse<Box<models::OrderListStatusResponseResult>>> {
781        self.account_api_client.order_list_status(params).await
782    }
783
784    /// Query order (`USER_DATA`)
785    ///
786    /// Check execution status of an order.
787    ///
788    /// Weight(IP): 4
789    ///
790    /// Security Type: `USER_DATA`
791    ///
792    /// Notes:
793    /// **Data Source:** Memory => Database
794    ///
795    /// Notes:
796    ///
797    /// * If both `orderId` and `origClientOrderId` are provided, the `orderId` is searched first, then the `origClientOrderId` from that result is checked against that order. If both conditions are not met the request will be rejected.
798    ///
799    /// * For some historical orders the `cummulativeQuoteQty` response field may be negative,
800    /// meaning the data is not available at this time.
801    ///
802    /// # Arguments
803    ///
804    /// - `params`: [`OrderStatusParams`]
805    ///   The parameters for this operation.
806    ///
807    /// # Returns
808    ///
809    /// [`WebsocketApiResponse<Box<models::OrderStatusResponseResult>>`] on success.
810    ///
811    /// # Errors
812    ///
813    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
814    ///
815    ///
816    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/account#order-status).
817    ///
818    pub async fn order_status(
819        &self,
820        params: OrderStatusParams,
821    ) -> anyhow::Result<WebsocketApiResponse<Box<models::OrderStatusResponseResult>>> {
822        self.account_api_client.order_status(params).await
823    }
824
825    /// Log in with API key (`USER_DATA`)
826    ///
827    /// Authenticate WebSocket connection using the provided API key.
828    ///
829    /// After calling `session.logon`, you can omit `apiKey` and `signature` parameters for future requests that require them.
830    ///
831    /// Note that only one API key can be authenticated.
832    ///
833    /// Calling `session.logon` multiple times changes the current authenticated API key.
834    ///
835    /// **Note:** Only Ed25519 keys are supported for this feature.
836    ///
837    /// Weight(IP): 2
838    ///
839    /// Security Type: `USER_DATA`
840    ///
841    /// Notes:
842    /// **Data Source:** Memory
843    ///
844    /// # Arguments
845    ///
846    /// - `params`: [`SessionLogonParams`]
847    ///   The parameters for this operation.
848    ///
849    /// # Returns
850    ///
851    /// [`WebsocketApiResponse<Box<models::SessionLogonResponseResult>>`] on success.
852    ///
853    /// # Errors
854    ///
855    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
856    ///
857    ///
858    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/auth#session-logon).
859    ///
860    pub async fn session_logon(
861        &self,
862        params: SessionLogonParams,
863    ) -> anyhow::Result<Vec<WebsocketApiResponse<Box<models::SessionLogonResponseResult>>>> {
864        self.auth_api_client.session_logon(params).await
865    }
866
867    /// Log out of the session
868    ///
869    /// Forget the API key previously authenticated. If the connection is not authenticated, this request does nothing.
870    ///
871    /// Note that the WebSocket connection stays open after `session.logout` request. You can continue using the connection, but now you will have to explicitly provide the `apiKey` and `signature` parameters where needed.
872    ///
873    /// Weight(IP): 2
874    ///
875    /// Security Type: NONE
876    ///
877    /// Notes:
878    /// **Data Source:** Memory
879    ///
880    /// # Arguments
881    ///
882    /// - `params`: [`SessionLogoutParams`]
883    ///   The parameters for this operation.
884    ///
885    /// # Returns
886    ///
887    /// [`WebsocketApiResponse<Box<models::SessionLogoutResponseResult>>`] on success.
888    ///
889    /// # Errors
890    ///
891    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
892    ///
893    ///
894    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/auth#session-logout).
895    ///
896    pub async fn session_logout(
897        &self,
898        params: SessionLogoutParams,
899    ) -> anyhow::Result<Vec<WebsocketApiResponse<Box<models::SessionLogoutResponseResult>>>> {
900        self.auth_api_client.session_logout(params).await
901    }
902
903    /// Query session status
904    ///
905    /// Query the status of the WebSocket connection,
906    /// inspecting which API key (if any) is used to authorize requests.
907    ///
908    /// Weight(IP): 2
909    ///
910    /// Security Type: NONE
911    ///
912    /// Notes:
913    /// **Data Source:** Memory
914    ///
915    /// # Arguments
916    ///
917    /// - `params`: [`SessionStatusParams`]
918    ///   The parameters for this operation.
919    ///
920    /// # Returns
921    ///
922    /// [`WebsocketApiResponse<Box<models::SessionStatusResponseResult>>`] on success.
923    ///
924    /// # Errors
925    ///
926    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
927    ///
928    ///
929    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/auth#session-status).
930    ///
931    pub async fn session_status(
932        &self,
933        params: SessionStatusParams,
934    ) -> anyhow::Result<WebsocketApiResponse<Box<models::SessionStatusResponseResult>>> {
935        self.auth_api_client.session_status(params).await
936    }
937
938    /// Exchange information
939    ///
940    /// Query current exchange trading rules, rate limits, and symbol
941    /// information.
942    ///
943    /// Weight(IP): 20
944    ///
945    /// Security Type: NONE
946    ///
947    /// Notes:
948    /// **Data Source:** Memory
949    ///
950    /// **Notes:**
951    /// * If the value provided to `symbol` or `symbols` do not exist, the endpoint will throw an error saying the symbol is invalid.
952    /// * All parameters are optional.
953    /// * Only one of `symbol`, `symbols`, `permissions` parameters can be specified.
954    /// * Without parameters, `exchangeInfo` displays all symbols with `["SPOT", "MARGIN", "LEVERAGED"]` permissions.
955    /// * In order to list *all* active symbols on the exchange, you need to explicitly request all permissions.
956    /// * `permissions` accepts either a list of permissions, or a single permission name. E.g. `"SPOT"`.
957    ///
958    /// **Examples of Symbol Permissions Interpretation from the Response:**
959    ///
960    /// * `[["A","B"]]` means you may place an order if your account has either permission "A" **or** permission "B".
961    /// * `[["A"],["B"]]` means you can place an order if your account has permission "A" **and** permission "B".
962    /// * `[["A"],["B","C"]]` means you can place an order if your account has permission "A" **and** permission "B" or permission "C". (Inclusive or is applied here, not exclusive or, so your account may have both permission "B" and permission "C".)
963    ///
964    /// # Arguments
965    ///
966    /// - `params`: [`ExchangeInfoParams`]
967    ///   The parameters for this operation.
968    ///
969    /// # Returns
970    ///
971    /// [`WebsocketApiResponse<models::ExchangeInfoResponse>`] on success.
972    ///
973    /// # Errors
974    ///
975    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
976    ///
977    ///
978    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/general#exchange-info).
979    ///
980    pub async fn exchange_info(
981        &self,
982        params: ExchangeInfoParams,
983    ) -> anyhow::Result<WebsocketApiResponse<models::ExchangeInfoResponse>> {
984        self.general_api_client.exchange_info(params).await
985    }
986
987    /// Query Execution Rules
988    ///
989    /// Query execution rules for symbols.
990    ///
991    /// Weight: Parameter | Weight
992    /// --- | ---
993    /// `symbol` | 2
994    /// `symbols` | 2 for each `symbol`, capped at a max of 40
995    /// `symbolStatus` | 40
996    /// None | 40
997    ///
998    /// Security Type: NONE
999    ///
1000    /// Notes:
1001    /// **Data Source:** Memory
1002    ///
1003    /// **Note:** No combination of multiple parameters is allowed.
1004    ///
1005    /// # Arguments
1006    ///
1007    /// - `params`: [`ExecutionRulesParams`]
1008    ///   The parameters for this operation.
1009    ///
1010    /// # Returns
1011    ///
1012    /// [`WebsocketApiResponse<Box<models::ExecutionRulesResponseResult>>`] on success.
1013    ///
1014    /// # Errors
1015    ///
1016    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1017    ///
1018    ///
1019    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/general#execution-rules).
1020    ///
1021    pub async fn execution_rules(
1022        &self,
1023        params: ExecutionRulesParams,
1024    ) -> anyhow::Result<WebsocketApiResponse<Box<models::ExecutionRulesResponseResult>>> {
1025        self.general_api_client.execution_rules(params).await
1026    }
1027
1028    /// Test connectivity
1029    ///
1030    /// Test connectivity to the WebSocket API.
1031    ///
1032    /// Note: You can use regular WebSocket ping frames to test connectivity as well, WebSocket API will respond with pong frames as soon as possible. ping request along with time is a safe way to test request-response handling in your application.
1033    ///
1034    /// Weight(IP): 1
1035    ///
1036    /// Security Type: NONE
1037    ///
1038    /// Notes:
1039    /// **Data Source:** Memory
1040    ///
1041    /// # Arguments
1042    ///
1043    /// - `params`: [`PingParams`]
1044    ///   The parameters for this operation.
1045    ///
1046    /// # Returns
1047    ///
1048    /// [`WebsocketApiResponse<serde_json::Value>`] on success.
1049    ///
1050    /// # Errors
1051    ///
1052    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1053    ///
1054    ///
1055    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/general#ping).
1056    ///
1057    pub async fn ping(
1058        &self,
1059        params: PingParams,
1060    ) -> anyhow::Result<WebsocketApiResponse<serde_json::Value>> {
1061        self.general_api_client.ping(params).await
1062    }
1063
1064    /// Check server time
1065    ///
1066    /// Test connectivity to the WebSocket API and get the current server time.
1067    ///
1068    /// Weight(IP): 1
1069    ///
1070    /// Security Type: NONE
1071    ///
1072    /// Notes:
1073    /// **Data Source:** Memory
1074    ///
1075    /// # Arguments
1076    ///
1077    /// - `params`: [`TimeParams`]
1078    ///   The parameters for this operation.
1079    ///
1080    /// # Returns
1081    ///
1082    /// [`WebsocketApiResponse<Box<models::TimeResponseResult>>`] on success.
1083    ///
1084    /// # Errors
1085    ///
1086    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1087    ///
1088    ///
1089    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/general#time).
1090    ///
1091    pub async fn time(
1092        &self,
1093        params: TimeParams,
1094    ) -> anyhow::Result<WebsocketApiResponse<Box<models::TimeResponseResult>>> {
1095        self.general_api_client.time(params).await
1096    }
1097
1098    /// Current average price
1099    ///
1100    /// Get current average price for a symbol.
1101    ///
1102    /// Weight(IP): 2
1103    ///
1104    /// Security Type: NONE
1105    ///
1106    /// Notes:
1107    /// **Data Source:** Memory
1108    ///
1109    /// # Arguments
1110    ///
1111    /// - `params`: [`AvgPriceParams`]
1112    ///   The parameters for this operation.
1113    ///
1114    /// # Returns
1115    ///
1116    /// [`WebsocketApiResponse<Box<models::AvgPriceResponseResult>>`] on success.
1117    ///
1118    /// # Errors
1119    ///
1120    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1121    ///
1122    ///
1123    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#avg-price).
1124    ///
1125    pub async fn avg_price(
1126        &self,
1127        params: AvgPriceParams,
1128    ) -> anyhow::Result<WebsocketApiResponse<Box<models::AvgPriceResponseResult>>> {
1129        self.market_api_client.avg_price(params).await
1130    }
1131
1132    /// Historical Block Trades
1133    ///
1134    /// Get block trades.
1135    ///
1136    /// Weight(IP): 25
1137    ///
1138    /// Security Type: NONE
1139    ///
1140    /// Notes:
1141    /// - Data Source: Database
1142    ///
1143    /// # Arguments
1144    ///
1145    /// - `params`: [`BlockTradesHistoricalParams`]
1146    ///   The parameters for this operation.
1147    ///
1148    /// # Returns
1149    ///
1150    /// [`WebsocketApiResponse<Vec<models::BlockTradesHistoricalResponseResultInner>>`] on success.
1151    ///
1152    /// # Errors
1153    ///
1154    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1155    ///
1156    ///
1157    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#block-trades-historical).
1158    ///
1159    pub async fn block_trades_historical(
1160        &self,
1161        params: BlockTradesHistoricalParams,
1162    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::BlockTradesHistoricalResponseResultInner>>>
1163    {
1164        self.market_api_client.block_trades_historical(params).await
1165    }
1166
1167    /// Order book
1168    ///
1169    /// Get current order book.
1170    ///
1171    /// Note that this request returns limited market depth.
1172    ///
1173    /// If you need to continuously monitor order book updates, please consider using WebSocket Streams:
1174    /// * `<symbol>@depth<levels>`
1175    /// * `<symbol>@depth`
1176    ///
1177    /// You can use `depth` request together with `<symbol>@depth` streams to [maintain a local order book](/products/spot/web-socket-streams#how-to-manage-a-local-order-book-correctly).
1178    ///
1179    /// Weight: Adjusted based on the limit:
1180    ///
1181    /// |Limit|Request Weight
1182    /// ------|-------
1183    /// 1-100|  5
1184    /// 101-500| 25
1185    /// 501-1000| 50
1186    /// 1001-5000| 250
1187    ///
1188    /// Security Type: NONE
1189    ///
1190    /// Notes:
1191    /// **Data Source:** Memory
1192    ///
1193    /// # Arguments
1194    ///
1195    /// - `params`: [`DepthParams`]
1196    ///   The parameters for this operation.
1197    ///
1198    /// # Returns
1199    ///
1200    /// [`WebsocketApiResponse<Box<models::DepthResponseResult>>`] on success.
1201    ///
1202    /// # Errors
1203    ///
1204    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1205    ///
1206    ///
1207    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#depth).
1208    ///
1209    pub async fn depth(
1210        &self,
1211        params: DepthParams,
1212    ) -> anyhow::Result<WebsocketApiResponse<Box<models::DepthResponseResult>>> {
1213        self.market_api_client.depth(params).await
1214    }
1215
1216    /// Klines
1217    ///
1218    /// Get klines (candlestick bars).
1219    ///
1220    /// Klines are uniquely identified by their open & close time.
1221    ///
1222    /// If you need access to real-time kline updates, please consider using WebSocket Streams:
1223    /// * `<symbol>@kline_<interval>`
1224    ///
1225    /// If you need historical kline data, please consider using [data.binance.vision](https://github.com/binance/binance-public-data/#klines).
1226    ///
1227    /// Weight(IP): 2
1228    ///
1229    /// Security Type: NONE
1230    ///
1231    /// Notes:
1232    /// **Data Source:** Database
1233    ///
1234    /// Supported kline intervals (case-sensitive):
1235    ///
1236    /// Interval  | `interval` value
1237    /// --------- | ----------------
1238    /// seconds   | `1s`
1239    /// minutes   | `1m`, `3m`, `5m`, `15m`, `30m`
1240    /// hours     | `1h`, `2h`, `4h`, `6h`, `8h`, `12h`
1241    /// days      | `1d`, `3d`
1242    /// weeks     | `1w`
1243    /// months    | `1M`
1244    ///
1245    /// **Notes:**
1246    ///
1247    /// * If `startTime` and `endTime` are not sent, the most recent klines are returned.
1248    /// * Supported values for `timeZone`:
1249    /// * Hours and minutes (e.g. `-1:00`, `05:45`)
1250    /// * Only hours (e.g. `0`, `8`, `4`)
1251    /// * Accepted range is strictly [-12:00 to +14:00] inclusive
1252    /// * If `timeZone` provided, kline intervals are interpreted in that timezone instead of UTC.
1253    /// * Note that `startTime` and `endTime` are always interpreted in UTC, regardless of `timeZone`.
1254    ///
1255    /// # Arguments
1256    ///
1257    /// - `params`: [`KlinesParams`]
1258    ///   The parameters for this operation.
1259    ///
1260    /// # Returns
1261    ///
1262    /// [`WebsocketApiResponse<Vec<Vec<models::KlinesResponseResultInnerInner>>>`] on success.
1263    ///
1264    /// # Errors
1265    ///
1266    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1267    ///
1268    ///
1269    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#klines).
1270    ///
1271    pub async fn klines(
1272        &self,
1273        params: KlinesParams,
1274    ) -> anyhow::Result<WebsocketApiResponse<Vec<Vec<models::KlinesResponseResultInnerInner>>>>
1275    {
1276        self.market_api_client.klines(params).await
1277    }
1278
1279    /// Query Reference Price
1280    ///
1281    /// Query Reference Price
1282    ///
1283    /// Weight(IP): 2
1284    ///
1285    /// Security Type: NONE
1286    ///
1287    /// Notes:
1288    /// **Data Source:** Memory
1289    ///
1290    /// # Arguments
1291    ///
1292    /// - `params`: [`ReferencePriceParams`]
1293    ///   The parameters for this operation.
1294    ///
1295    /// # Returns
1296    ///
1297    /// [`WebsocketApiResponse<Box<models::ReferencePriceResponseResult>>`] on success.
1298    ///
1299    /// # Errors
1300    ///
1301    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1302    ///
1303    ///
1304    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#reference-price).
1305    ///
1306    pub async fn reference_price(
1307        &self,
1308        params: ReferencePriceParams,
1309    ) -> anyhow::Result<WebsocketApiResponse<Box<models::ReferencePriceResponseResult>>> {
1310        self.market_api_client.reference_price(params).await
1311    }
1312
1313    /// Query Reference Price Calculation
1314    ///
1315    /// Query Reference Price Calculation
1316    ///
1317    /// Weight(IP): 2
1318    ///
1319    /// Security Type: NONE
1320    ///
1321    /// Notes:
1322    /// **Data Source:** Memory
1323    ///
1324    /// # Arguments
1325    ///
1326    /// - `params`: [`ReferencePriceCalculationParams`]
1327    ///   The parameters for this operation.
1328    ///
1329    /// # Returns
1330    ///
1331    /// [`WebsocketApiResponse<Box<models::ReferencePriceCalculationResponseResult>>`] on success.
1332    ///
1333    /// # Errors
1334    ///
1335    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1336    ///
1337    ///
1338    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#reference-price-calculation).
1339    ///
1340    pub async fn reference_price_calculation(
1341        &self,
1342        params: ReferencePriceCalculationParams,
1343    ) -> anyhow::Result<WebsocketApiResponse<Box<models::ReferencePriceCalculationResponseResult>>>
1344    {
1345        self.market_api_client
1346            .reference_price_calculation(params)
1347            .await
1348    }
1349
1350    /// Rolling window price change statistics
1351    ///
1352    /// Get rolling window price change statistics with a custom window.
1353    ///
1354    /// This request is similar to `ticker.24hr` but statistics are computed on demand using the arbitrary window you specify.
1355    ///
1356    /// **Note:** Window size precision is limited to 1 minute.
1357    /// While the `closeTime` is the current time of the request, `openTime` always start on a minute boundary.
1358    /// As such, the effective window might be up to 59999 ms wider than the requested `windowSize`.
1359    ///
1360    /// <details>
1361    /// <summary>Window computation example</summary>
1362    ///
1363    /// For example, a request for `"windowSize": "7d"` might result in the following window:
1364    ///
1365    /// ```javascript
1366    /// {
1367    /// "openTime": 1659580020000,
1368    /// "closeTime": 1660184865291
1369    /// }
1370    /// ```
1371    ///
1372    /// Time of the request – `closeTime` – is 1660184865291 (August 11, 2022 02:27:45.291).
1373    /// Requested window size should put the `openTime` 7 days before that – August 4, 02:27:45.291 –
1374    /// but due to limited precision it ends up a bit earlier: 1659580020000 (August 4, 2022 02:27:00),
1375    /// exactly at the start of a minute.
1376    /// </details>
1377    ///
1378    /// If you need to continuously monitor trading statistics, please consider using WebSocket Streams:
1379    /// * `<symbol>@ticker_<window_size>` or `!ticker_<window-size>@arr`
1380    ///
1381    /// Weight: Adjusted based on the number of requested symbols:
1382    ///
1383    /// | Symbols | Weight |
1384    /// |:-------:|:------:|
1385    /// |    1–50 | 4 per symbol |
1386    /// |  51–100 |    200 |
1387    ///
1388    /// Security Type: NONE
1389    ///
1390    /// Notes:
1391    /// **Data Source:** Database
1392    ///
1393    /// Supported window sizes:
1394    ///
1395    /// Unit    | `windowSize` value
1396    /// ------- | ------------------
1397    /// minutes | `1m`, `2m` ... `59m`
1398    /// hours   | `1h`, `2h` ... `23h`
1399    /// days    | `1d`, `2d` ... `7d`
1400    ///
1401    /// Notes:
1402    ///
1403    /// * Either `symbol` or `symbols` must be specified.
1404    ///
1405    /// * Maximum number of symbols in one request: 200.
1406    ///
1407    /// * Window size units cannot be combined.
1408    /// E.g., <code>1d 2h</code> is not supported.
1409    ///
1410    /// # Arguments
1411    ///
1412    /// - `params`: [`TickerParams`]
1413    ///   The parameters for this operation.
1414    ///
1415    /// # Returns
1416    ///
1417    /// [`WebsocketApiResponse<models::TickerResponse>`] on success.
1418    ///
1419    /// # Errors
1420    ///
1421    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1422    ///
1423    ///
1424    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ticker).
1425    ///
1426    pub async fn ticker(
1427        &self,
1428        params: TickerParams,
1429    ) -> anyhow::Result<WebsocketApiResponse<models::TickerResponse>> {
1430        self.market_api_client.ticker(params).await
1431    }
1432
1433    /// 24hr ticker price change statistics
1434    ///
1435    /// Get 24-hour rolling window price change statistics.
1436    ///
1437    /// If you need to continuously monitor trading statistics, please consider using WebSocket Streams:
1438    ///
1439    /// * `<symbol>@ticker` or `!ticker@arr`
1440    ///
1441    /// * `<symbol>@miniTicker` or `!miniTicker@arr`
1442    ///
1443    /// If you need different window sizes,
1444    ///
1445    /// use the `ticker` request.
1446    ///
1447    /// Weight: Adjusted based on the number of requested symbols:
1448    ///
1449    /// |Parameter|Symbols Provided|Weight|
1450    /// |---|---|---|
1451    /// |symbol| 1 |2|
1452    /// | |omitted| 80|
1453    /// |symbols| 1-20 |2|
1454    /// | | 21-100 |40|
1455    /// | | 101+ |80|
1456    /// | |omitted| 80|
1457    ///
1458    /// Security Type: NONE
1459    ///
1460    /// Notes:
1461    /// **Data Source:** Memory
1462    ///
1463    /// Notes:
1464    ///
1465    /// * `symbol` and `symbols` cannot be used together.
1466    ///
1467    /// * If no symbol is specified, returns information about all symbols currently trading on the exchange.
1468    ///
1469    /// # Arguments
1470    ///
1471    /// - `params`: [`Ticker24hrParams`]
1472    ///   The parameters for this operation.
1473    ///
1474    /// # Returns
1475    ///
1476    /// [`WebsocketApiResponse<models::Ticker24hrResponse>`] on success.
1477    ///
1478    /// # Errors
1479    ///
1480    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1481    ///
1482    ///
1483    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ticker24hr).
1484    ///
1485    pub async fn ticker24hr(
1486        &self,
1487        params: Ticker24hrParams,
1488    ) -> anyhow::Result<WebsocketApiResponse<models::Ticker24hrResponse>> {
1489        self.market_api_client.ticker24hr(params).await
1490    }
1491
1492    /// Symbol order book ticker
1493    ///
1494    /// Get the current best price and quantity on the order book.
1495    ///
1496    /// If you need access to real-time order book ticker updates, please
1497    /// consider using WebSocket Streams:
1498    ///
1499    /// * `<symbol>@bookTicker`
1500    ///
1501    /// Weight: Adjusted based on the number of requested symbols:
1502    ///
1503    /// |Parameter|Symbols Provided|Weight|
1504    /// |---|---|---|
1505    /// |symbol| 1 |2|
1506    /// | |omitted| 4|
1507    /// |symbols| Any |4|
1508    ///
1509    /// Security Type: NONE
1510    ///
1511    /// Notes:
1512    /// **Data Source:** Memory
1513    ///
1514    /// Notes:
1515    ///
1516    /// * `symbol` and `symbols` cannot be used together.
1517    ///
1518    /// * If no symbol is specified, returns information about all symbols currently trading on the exchange.
1519    ///
1520    /// # Arguments
1521    ///
1522    /// - `params`: [`TickerBookParams`]
1523    ///   The parameters for this operation.
1524    ///
1525    /// # Returns
1526    ///
1527    /// [`WebsocketApiResponse<models::TickerBookResponse>`] on success.
1528    ///
1529    /// # Errors
1530    ///
1531    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1532    ///
1533    ///
1534    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ticker-book).
1535    ///
1536    pub async fn ticker_book(
1537        &self,
1538        params: TickerBookParams,
1539    ) -> anyhow::Result<WebsocketApiResponse<models::TickerBookResponse>> {
1540        self.market_api_client.ticker_book(params).await
1541    }
1542
1543    /// Symbol price ticker
1544    ///
1545    /// Get the latest market price for a symbol.
1546    ///
1547    /// If you need access to real-time price updates, please consider using
1548    /// WebSocket Streams:
1549    ///
1550    /// * `<symbol>@aggTrade`
1551    ///
1552    /// * `<symbol>@trade`
1553    ///
1554    /// Weight: Adjusted based on the number of requested symbols:
1555    ///
1556    /// |Parameter|Symbols Provided|Weight|
1557    /// |---|---|---|
1558    /// |symbol| 1 |2|
1559    /// | |omitted| 4|
1560    /// |symbols| Any |4|
1561    ///
1562    /// Security Type: NONE
1563    ///
1564    /// Notes:
1565    /// **Data Source:** Memory
1566    ///
1567    /// Notes:
1568    ///
1569    /// * `symbol` and `symbols` cannot be used together.
1570    ///
1571    /// * If no symbol is specified, returns information about all symbols currently trading on the exchange.
1572    ///
1573    /// # Arguments
1574    ///
1575    /// - `params`: [`TickerPriceParams`]
1576    ///   The parameters for this operation.
1577    ///
1578    /// # Returns
1579    ///
1580    /// [`WebsocketApiResponse<models::TickerPriceResponse>`] on success.
1581    ///
1582    /// # Errors
1583    ///
1584    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1585    ///
1586    ///
1587    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ticker-price).
1588    ///
1589    pub async fn ticker_price(
1590        &self,
1591        params: TickerPriceParams,
1592    ) -> anyhow::Result<WebsocketApiResponse<models::TickerPriceResponse>> {
1593        self.market_api_client.ticker_price(params).await
1594    }
1595
1596    /// Trading Day Ticker
1597    ///
1598    /// Price change statistics for a trading day.
1599    ///
1600    /// Weight: 4 for each requested symbol regardless of windowSize. The weight for this request will cap at 200 once the number of symbols in the request is more than 50.
1601    ///
1602    /// Security Type: NONE
1603    ///
1604    /// Notes:
1605    /// **Data Source:** Database
1606    ///
1607    /// **Notes:**
1608    ///
1609    /// * Supported values for `timeZone`:
1610    /// * Hours and minutes (e.g. `-1:00`, `05:45`)
1611    /// * Only hours (e.g. `0`, `8`, `4`)
1612    ///
1613    ///
1614    /// # Arguments
1615    ///
1616    /// - `params`: [`TickerTradingDayParams`]
1617    ///   The parameters for this operation.
1618    ///
1619    /// # Returns
1620    ///
1621    /// [`WebsocketApiResponse<Vec<models::TickerTradingDayResponseResultInner>>`] on success.
1622    ///
1623    /// # Errors
1624    ///
1625    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1626    ///
1627    ///
1628    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ticker-trading-day).
1629    ///
1630    pub async fn ticker_trading_day(
1631        &self,
1632        params: TickerTradingDayParams,
1633    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::TickerTradingDayResponseResultInner>>>
1634    {
1635        self.market_api_client.ticker_trading_day(params).await
1636    }
1637
1638    /// Aggregate trades
1639    ///
1640    /// Get aggregate trades.
1641    ///
1642    /// An *aggregate trade* (aggtrade) represents one or more individual
1643    /// trades.
1644    ///
1645    /// Trades that fill at the same time, from the same taker order, with the
1646    /// same price –
1647    ///
1648    /// those trades are collected into an aggregate trade with total quantity
1649    /// of the individual trades.
1650    ///
1651    /// If you need access to real-time trading activity, please consider using
1652    /// WebSocket Streams:
1653    ///
1654    /// * `<symbol>@aggTrade`
1655    ///
1656    /// If you need historical aggregate trade data, please consider using [data.binance.vision](https://github.com/binance/binance-public-data/#aggtrades).
1657    ///
1658    /// Weight(IP): 4
1659    ///
1660    /// Security Type: NONE
1661    ///
1662    /// Notes:
1663    /// **Data Source:** Database
1664    ///
1665    /// - If `fromId` is specified, return aggtrades with aggregate trade ID >= `fromId`. Use `fromId` and `limit` to page through all aggtrades.
1666    /// - If `startTime` and/or `endTime` are specified, aggtrades are filtered by execution time (`T`). `fromId` cannot be used together with `startTime` and `endTime`.
1667    /// - If no condition is specified, the most recent aggregate trades are returned.
1668    ///
1669    /// # Arguments
1670    ///
1671    /// - `params`: [`TradesAggregateParams`]
1672    ///   The parameters for this operation.
1673    ///
1674    /// # Returns
1675    ///
1676    /// [`WebsocketApiResponse<Vec<models::TradesAggregateResponseResultInner>>`] on success.
1677    ///
1678    /// # Errors
1679    ///
1680    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1681    ///
1682    ///
1683    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#trades-aggregate).
1684    ///
1685    pub async fn trades_aggregate(
1686        &self,
1687        params: TradesAggregateParams,
1688    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::TradesAggregateResponseResultInner>>> {
1689        self.market_api_client.trades_aggregate(params).await
1690    }
1691
1692    /// Historical trades
1693    ///
1694    /// Get historical trades.
1695    ///
1696    /// Weight(IP): 25
1697    ///
1698    /// Security Type: NONE
1699    ///
1700    /// Notes:
1701    /// **Data Source:** Database
1702    ///
1703    /// Notes:
1704    ///
1705    /// * If `fromId` is not specified, the most recent trades are returned.
1706    ///
1707    /// # Arguments
1708    ///
1709    /// - `params`: [`TradesHistoricalParams`]
1710    ///   The parameters for this operation.
1711    ///
1712    /// # Returns
1713    ///
1714    /// [`WebsocketApiResponse<Vec<models::TradesHistoricalResponseResultInner>>`] on success.
1715    ///
1716    /// # Errors
1717    ///
1718    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1719    ///
1720    ///
1721    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#trades-historical).
1722    ///
1723    pub async fn trades_historical(
1724        &self,
1725        params: TradesHistoricalParams,
1726    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::TradesHistoricalResponseResultInner>>>
1727    {
1728        self.market_api_client.trades_historical(params).await
1729    }
1730
1731    /// Recent trades
1732    ///
1733    /// Get recent trades.
1734    ///
1735    /// If you need access to real-time trading activity, please consider using
1736    /// WebSocket Streams:
1737    ///
1738    /// * `<symbol>@trade`
1739    ///
1740    /// Weight(IP): 25
1741    ///
1742    /// Security Type: NONE
1743    ///
1744    /// Notes:
1745    /// **Data Source:** Memory
1746    ///
1747    /// # Arguments
1748    ///
1749    /// - `params`: [`TradesRecentParams`]
1750    ///   The parameters for this operation.
1751    ///
1752    /// # Returns
1753    ///
1754    /// [`WebsocketApiResponse<Vec<models::TradesRecentResponseResultInner>>`] on success.
1755    ///
1756    /// # Errors
1757    ///
1758    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1759    ///
1760    ///
1761    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#trades-recent).
1762    ///
1763    pub async fn trades_recent(
1764        &self,
1765        params: TradesRecentParams,
1766    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::TradesRecentResponseResultInner>>> {
1767        self.market_api_client.trades_recent(params).await
1768    }
1769
1770    /// UI Klines
1771    ///
1772    /// Get klines (candlestick bars) optimized for presentation.
1773    ///
1774    /// This request is similar to `klines`, having the same parameters and response. `uiKlines` return modified kline data, optimized for presentation of candlestick charts.
1775    ///
1776    /// Weight(IP): 2
1777    ///
1778    /// Security Type: NONE
1779    ///
1780    /// Notes:
1781    /// **Data Source:** Database
1782    ///
1783    /// - If `startTime` and `endTime` are not sent, the most recent klines are returned.
1784    /// - Supported values for `timeZone`:
1785    /// - Hours and minutes (e.g. `-1:00`, `05:45`)
1786    /// - Only hours (e.g. `0`, `8`, `4`)
1787    /// - Accepted range is strictly [-12:00 to +14:00] inclusive
1788    /// - If `timeZone` provided, kline intervals are interpreted in that timezone instead of UTC.
1789    /// - Note that `startTime` and `endTime` are always interpreted in UTC, regardless of `timeZone`.
1790    ///
1791    /// # Arguments
1792    ///
1793    /// - `params`: [`UiKlinesParams`]
1794    ///   The parameters for this operation.
1795    ///
1796    /// # Returns
1797    ///
1798    /// [`WebsocketApiResponse<Vec<Vec<models::KlinesResponseResultInnerInner>>>`] on success.
1799    ///
1800    /// # Errors
1801    ///
1802    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1803    ///
1804    ///
1805    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/market#ui-klines).
1806    ///
1807    pub async fn ui_klines(
1808        &self,
1809        params: UiKlinesParams,
1810    ) -> anyhow::Result<WebsocketApiResponse<Vec<Vec<models::KlinesResponseResultInnerInner>>>>
1811    {
1812        self.market_api_client.ui_klines(params).await
1813    }
1814
1815    /// Cancel open orders (TRADE)
1816    ///
1817    /// Cancel all open orders on a symbol.
1818    /// This includes orders that are part of an order list.
1819    ///
1820    /// Weight(IP): 1
1821    ///
1822    /// Security Type: TRADE
1823    ///
1824    /// Notes:
1825    /// **Data Source:** Matching Engine
1826    ///
1827    /// # Arguments
1828    ///
1829    /// - `params`: [`OpenOrdersCancelAllParams`]
1830    ///   The parameters for this operation.
1831    ///
1832    /// # Returns
1833    ///
1834    /// [`WebsocketApiResponse<Vec<models::OpenOrdersCancelAllResponseResultInner>>`] on success.
1835    ///
1836    /// # Errors
1837    ///
1838    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1839    ///
1840    ///
1841    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#open-orders-cancel-all).
1842    ///
1843    pub async fn open_orders_cancel_all(
1844        &self,
1845        params: OpenOrdersCancelAllParams,
1846    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::OpenOrdersCancelAllResponseResultInner>>>
1847    {
1848        self.trade_api_client.open_orders_cancel_all(params).await
1849    }
1850
1851    /// Order Amend Keep Priority (TRADE)
1852    ///
1853    /// Reduce the quantity of an existing open order.
1854    ///
1855    /// This adds 0 orders to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
1856    ///
1857    /// Read [Order Amend Keep Priority FAQ](/products/spot/faqs/order_amend_keep_priority) to learn more.
1858    ///
1859    /// Weight(IP): 4
1860    ///
1861    /// Unfilled Order Count: 0
1862    ///
1863    /// Security Type: TRADE
1864    ///
1865    /// Notes:
1866    /// **Data Source:** Matching Engine
1867    ///
1868    /// # Arguments
1869    ///
1870    /// - `params`: [`OrderAmendKeepPriorityParams`]
1871    ///   The parameters for this operation.
1872    ///
1873    /// # Returns
1874    ///
1875    /// [`WebsocketApiResponse<Box<models::OrderAmendKeepPriorityResponseResult>>`] on success.
1876    ///
1877    /// # Errors
1878    ///
1879    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1880    ///
1881    ///
1882    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#order-amend-keep-priority).
1883    ///
1884    pub async fn order_amend_keep_priority(
1885        &self,
1886        params: OrderAmendKeepPriorityParams,
1887    ) -> anyhow::Result<WebsocketApiResponse<Box<models::OrderAmendKeepPriorityResponseResult>>>
1888    {
1889        self.trade_api_client
1890            .order_amend_keep_priority(params)
1891            .await
1892    }
1893
1894    /// Cancel order (TRADE)
1895    ///
1896    /// Cancel an active order.
1897    ///
1898    /// Weight(IP): 1
1899    ///
1900    /// Security Type: TRADE
1901    ///
1902    /// Notes:
1903    /// **Data Source:** Matching Engine
1904    ///
1905    /// Notes:
1906    ///
1907    /// * If both `orderId` and `origClientOrderId` parameters are provided, the `orderId` is searched first, then the `origClientOrderId` from that result is checked against that order. If both conditions are not met the request will be rejected.
1908    ///
1909    /// * `newClientOrderId` will replace `clientOrderId` of the canceled order, freeing it up for new orders.
1910    ///
1911    /// * If you cancel an order that is a part of an order list, the entire order list is canceled.
1912    ///
1913    /// * The performance for canceling an order (single cancel or as part of a cancel-replace) is always better when only `orderId` is sent. Sending `origClientOrderId` or both `orderId` + `origClientOrderId` will be slower.
1914    ///
1915    /// # Arguments
1916    ///
1917    /// - `params`: [`OrderCancelParams`]
1918    ///   The parameters for this operation.
1919    ///
1920    /// # Returns
1921    ///
1922    /// [`WebsocketApiResponse<Box<models::OrderCancelResponseResult>>`] on success.
1923    ///
1924    /// # Errors
1925    ///
1926    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
1927    ///
1928    ///
1929    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#order-cancel).
1930    ///
1931    pub async fn order_cancel(
1932        &self,
1933        params: OrderCancelParams,
1934    ) -> anyhow::Result<WebsocketApiResponse<Box<models::OrderCancelResponseResult>>> {
1935        self.trade_api_client.order_cancel(params).await
1936    }
1937
1938    /// Cancel and replace order (TRADE)
1939    ///
1940    /// * Cancel an existing order and immediately place a new order instead of the canceled one.
1941    /// * A new order that was not attempted (i.e. when `newOrderResult: NOT_ATTEMPTED`), will still increase the unfilled order count by 1.
1942    /// * You can only cancel an individual order from an orderList using this method, but the result is the same as canceling the entire orderList.not attempted (i.e. when `newOrderResult: NOT_ATTEMPTED`), will still increase the unfilled order count by 1.
1943    ///
1944    /// Weight(IP): 1
1945    ///
1946    /// Unfilled Order Count: 1
1947    ///
1948    /// Security Type: TRADE
1949    ///
1950    /// Notes:
1951    /// **Data Source:** Matching Engine
1952    ///
1953    /// Similar to the [`order.place`](#order-place) request,
1954    /// additional mandatory parameters (*) are determined by the new order `type`.
1955    ///
1956    /// Available `cancelReplaceMode` options:
1957    ///
1958    /// * `STOP_ON_FAILURE` – if cancellation request fails, new order placement will not be attempted.
1959    /// * `ALLOW_FAILURE` – new order placement will be attempted even if the cancel request fails.
1960    ///
1961    /// <table>
1962    /// <thead>
1963    /// <tr>
1964    /// <th colspan=3 align=left>Request</th>
1965    /// <th colspan=3 align=left>Response</th>
1966    /// </tr>
1967    /// <tr>
1968    /// <th><code>cancelReplaceMode</code></th>
1969    /// <th><code>orderRateLimitExceededMode</code></th>
1970    /// <th>Unfilled Order Count</th>
1971    /// <th><code>cancelResult</code></th>
1972    /// <th><code>newOrderResult</code></th>
1973    /// <th><code>status</code></th>
1974    /// </tr>
1975    /// </thead>
1976    /// <tbody>
1977    /// <tr>
1978    /// <td rowspan="11"><code>STOP_ON_FAILURE</code></td>
1979    /// <td rowspan="6"><code>DO_NOTHING</code></td>
1980    /// <td rowspan="3">Within Limits</td>
1981    /// <td>✅ <code>SUCCESS</code></td>
1982    /// <td>✅ <code>SUCCESS</code></td>
1983    /// <td align=right><code>200</code></td>
1984    /// </tr>
1985    /// <tr>
1986    /// <td>❌ <code>FAILURE</code></td>
1987    /// <td>➖ <code>NOT_ATTEMPTED</code></td>
1988    /// <td align=right><code>400</code></td>
1989    /// </tr>
1990    /// <tr>
1991    /// <td>✅ <code>SUCCESS</code></td>
1992    /// <td>❌ <code>FAILURE</code></td>
1993    /// <td align=right><code>409</code></td>
1994    /// </tr>
1995    /// <tr>
1996    /// <td rowspan="3">Exceeds Limits</td>
1997    /// <td>✅ <code>SUCCESS</code></td>
1998    /// <td>✅ <code>SUCCESS</code></td>
1999    /// <td align=right>N/A</td>
2000    /// </tr>
2001    /// <tr>
2002    /// <td>❌ <code>FAILURE</code></td>
2003    /// <td>➖ <code>NOT_ATTEMPTED</code></td>
2004    /// <td align=right>N/A</td>
2005    /// </tr>
2006    /// <tr>
2007    /// <td>✅ <code>SUCCESS</code></td>
2008    /// <td>❌ <code>FAILURE</code></td>
2009    /// <td align=right>N/A</td>
2010    /// </tr>
2011    /// <tr>
2012    /// <td rowspan="5"><code>CANCEL_ONLY</code></td>
2013    /// <td rowspan="3">Within Limits</td>
2014    /// <td>✅ <code>SUCCESS</code></td>
2015    /// <td>✅ <code>SUCCESS</code></td>
2016    /// <td align=right><code>200</code></td>
2017    /// </tr>
2018    /// <tr>
2019    /// <td>❌ <code>FAILURE</code></td>
2020    /// <td>➖ <code>NOT_ATTEMPTED</code></td>
2021    /// <td align=right><code>400</code></td>
2022    /// </tr>
2023    /// <tr>
2024    /// <td>✅ <code>SUCCESS</code></td>
2025    /// <td>❌ <code>FAILURE</code></td>
2026    /// <td align=right><code>409</code></td>
2027    /// </tr>
2028    /// <tr>
2029    /// <td rowspan="2">Exceeds Limits</td>
2030    /// <td>❌ <code>FAILURE</code></td>
2031    /// <td>➖ <code>NOT_ATTEMPTED</code></td>
2032    /// <td align=right><code>429</code></td>
2033    /// </tr>
2034    /// <tr>
2035    /// <td>✅ <code>SUCCESS</code></td>
2036    /// <td>❌ <code>FAILURE</code></td>
2037    /// <td align=right><code>429</code></td>
2038    /// </tr>
2039    /// <tr>
2040    /// <td rowspan="16"><code>ALLOW_FAILURE</code></td>
2041    /// <td rowspan="8"><code>DO_NOTHING</code></td>
2042    /// <td rowspan="4">Within Limits</td>
2043    /// <td>✅ <code>SUCCESS</code></td>
2044    /// <td>✅ <code>SUCCESS</code></td>
2045    /// <td align=right><code>200</code></td>
2046    /// </tr>
2047    /// <tr>
2048    /// <td>❌ <code>FAILURE</code></td>
2049    /// <td>❌ <code>FAILURE</code></td>
2050    /// <td align=right><code>400</code></td>
2051    /// </tr>
2052    /// <tr>
2053    /// <td>❌ <code>FAILURE</code></td>
2054    /// <td>✅ <code>SUCCESS</code></td>
2055    /// <td align=right><code>409</code></td>
2056    /// </tr>
2057    /// <tr>
2058    /// <td>✅ <code>SUCCESS</code></td>
2059    /// <td>❌ <code>FAILURE</code></td>
2060    /// <td align=right><code>409</code></td>
2061    /// </tr>
2062    /// <tr>
2063    /// <td rowspan="4">Exceeds Limits</td>
2064    /// <td>✅ <code>SUCCESS</code></td>
2065    /// <td>✅ <code>SUCCESS</code></td>
2066    /// <td align=right>N/A</td>
2067    /// </tr>
2068    /// <tr>
2069    /// <td>❌ <code>FAILURE</code></td>
2070    /// <td>❌ <code>FAILURE</code></td>
2071    /// <td align=right>N/A</td>
2072    /// </tr>
2073    /// <tr>
2074    /// <td>❌ <code>FAILURE</code></td>
2075    /// <td>✅ <code>SUCCESS</code></td>
2076    /// <td align=right>N/A</td>
2077    /// </tr>
2078    /// <tr>
2079    /// <td>✅ <code>SUCCESS</code></td>
2080    /// <td>❌ <code>FAILURE</code></td>
2081    /// <td align=right>N/A</td>
2082    /// </tr>
2083    /// <tr>
2084    /// <td rowspan="8"><CODE>CANCEL_ONLY</CODE></td>
2085    /// <td rowspan="4">Within Limits</td>
2086    /// <td>✅ <code>SUCCESS</code></td>
2087    /// <td>✅ <code>SUCCESS</code></td>
2088    /// <td align=right><code>200</code></td>
2089    /// </tr>
2090    /// <tr>
2091    /// <td>❌ <code>FAILURE</code></td>
2092    /// <td>❌ <code>FAILURE</code></td>
2093    /// <td align=right><code>400</code></td>
2094    /// </tr>
2095    /// <tr>
2096    /// <td>❌ <code>FAILURE</code></td>
2097    /// <td>✅ <code>SUCCESS</code></td>
2098    /// <td align=right><code>409</code></td>
2099    /// </tr>
2100    /// <tr>
2101    /// <td>✅ <code>SUCCESS</code></td>
2102    /// <td>❌ <code>FAILURE</code></td>
2103    /// <td align=right><code>409</code></td>
2104    /// </tr>
2105    /// <tr>
2106    /// <td rowspan="4">Exceeds Limits</td>
2107    /// <td>✅ <code>SUCCESS</code></td>
2108    /// <td>✅ <code>SUCCESS</code></td>
2109    /// <td align=right><code>200</code></td>
2110    /// </tr>
2111    /// <tr>
2112    /// <td>❌ <code>FAILURE</code></td>
2113    /// <td>❌ <code>FAILURE</code></td>
2114    /// <td align=right><code>400</code></td>
2115    /// </tr>
2116    /// <tr>
2117    /// <td>❌ <code>FAILURE</code></td>
2118    /// <td>✅ <code>SUCCESS</code></td>
2119    /// <td align=right>N/A</td>
2120    /// </tr>
2121    /// <tr>
2122    /// <td>✅ <code>SUCCESS</code></td>
2123    /// <td>❌ <code>FAILURE</code></td>
2124    /// <td align=right><code>409</code></td>
2125    /// </tr>
2126    /// </tbody>
2127    /// </table>
2128    ///
2129    /// Notes:
2130    ///
2131    /// * If both `cancelOrderId` and `cancelOrigClientOrderId` parameters are provided, the `cancelOrderId` is searched first, then the `cancelOrigClientOrderId` from that result is checked against that order. If both conditions are not met the request will be rejected.
2132    ///
2133    /// * `cancelNewClientOrderId` will replace `clientOrderId` of the canceled order, freeing it up for new orders.
2134    ///
2135    /// * `newClientOrderId` specifies `clientOrderId` value for the placed order.
2136    ///
2137    /// A new order with the same `clientOrderId` is accepted only when the previous one is filled or expired.
2138    ///
2139    /// The new order can reuse old `clientOrderId` of the canceled order.
2140    ///
2141    /// * This cancel-replace operation is **not transactional**.
2142    ///
2143    /// If one operation succeeds but the other one fails, the successful operation is still executed.
2144    ///
2145    /// For example, in `STOP_ON_FAILURE` mode, if the new order placement fails, the old order is still canceled.
2146    ///
2147    /// * Filters and order count limits are evaluated before cancellation and order placement occurs.
2148    ///
2149    /// * If new order placement is not attempted, your order count is still incremented.
2150    ///
2151    /// * Like [`order.cancel`](#order-cancel), if you cancel an individual order from an order list, the entire order list is canceled.
2152    ///
2153    /// * The performance for canceling an order (single cancel or as part of a cancel-replace) is always better when only `orderId` is sent. Sending `origClientOrderId` or both `orderId` + `origClientOrderId` will be slower.
2154    ///
2155    /// # Arguments
2156    ///
2157    /// - `params`: [`OrderCancelReplaceParams`]
2158    ///   The parameters for this operation.
2159    ///
2160    /// # Returns
2161    ///
2162    /// [`WebsocketApiResponse<Box<models::OrderCancelReplaceResponseResult>>`] on success.
2163    ///
2164    /// # Errors
2165    ///
2166    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
2167    ///
2168    ///
2169    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#order-cancel-replace).
2170    ///
2171    pub async fn order_cancel_replace(
2172        &self,
2173        params: OrderCancelReplaceParams,
2174    ) -> anyhow::Result<WebsocketApiResponse<Box<models::OrderCancelReplaceResponseResult>>> {
2175        self.trade_api_client.order_cancel_replace(params).await
2176    }
2177
2178    /// Cancel Order list (TRADE)
2179    ///
2180    /// Cancel an active order list.
2181    ///
2182    /// Weight(IP): 1
2183    ///
2184    /// Security Type: TRADE
2185    ///
2186    /// Notes:
2187    /// **Data Source:** Matching Engine
2188    ///
2189    /// Notes:
2190    ///
2191    /// * If both `orderListId` and `listClientOrderId` parameters are provided, the `orderListId` is searched first, then the `listClientOrderId` from that result is checked against that order. If both conditions are not met the request will be rejected.
2192    ///
2193    /// * Canceling an individual order with [`order.cancel`](#order-cancel) will cancel the entire order list as well.
2194    ///
2195    /// # Arguments
2196    ///
2197    /// - `params`: [`OrderListCancelParams`]
2198    ///   The parameters for this operation.
2199    ///
2200    /// # Returns
2201    ///
2202    /// [`WebsocketApiResponse<Box<models::OrderListCancelResponseResult>>`] on success.
2203    ///
2204    /// # Errors
2205    ///
2206    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
2207    ///
2208    ///
2209    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#order-list-cancel).
2210    ///
2211    pub async fn order_list_cancel(
2212        &self,
2213        params: OrderListCancelParams,
2214    ) -> anyhow::Result<WebsocketApiResponse<Box<models::OrderListCancelResponseResult>>> {
2215        self.trade_api_client.order_list_cancel(params).await
2216    }
2217
2218    /// Place new OCO - Deprecated (TRADE)
2219    ///
2220    /// Send in a new one-cancels-the-other (OCO) pair:
2221    /// `LIMIT_MAKER` + `STOP_LOSS`/`STOP_LOSS_LIMIT` orders (called *legs*),
2222    /// where activation of one order immediately cancels the other.
2223    ///
2224    /// This adds 1 order to `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter
2225    ///
2226    /// Weight(IP): 1
2227    ///
2228    /// Unfilled Order Count: 1
2229    ///
2230    /// Security Type: TRADE
2231    ///
2232    /// Notes:
2233    /// **Data Source:** Matching Engine
2234    ///
2235    /// Notes:
2236    ///
2237    /// * `listClientOrderId` parameter specifies `listClientOrderId` for the OCO pair.
2238    ///
2239    /// A new OCO with the same `listClientOrderId` is accepted only when the previous one is filled or completely expired.
2240    ///
2241    /// `listClientOrderId` is distinct from `clientOrderId` of individual orders.
2242    ///
2243    /// * `limitClientOrderId` and `stopClientOrderId` specify `clientOrderId` values for both legs of the OCO.
2244    ///
2245    /// A new order with the same `clientOrderId` is accepted only when the previous one is filled or expired.
2246    ///
2247    /// * Price restrictions on the legs:
2248    ///
2249    /// | `side` | Price relation |
2250    /// | ------ | -------------- |
2251    /// | `BUY`  | `price` < market price < `stopPrice` |
2252    /// | `SELL` | `price` > market price > `stopPrice` |
2253    ///
2254    /// * Both legs have the same `quantity`.
2255    ///
2256    /// However, you can set different iceberg quantity for individual legs.
2257    ///
2258    /// If `stopIcebergQty` is used, `stopLimitTimeInForce` must be `GTC`.
2259    ///
2260    /// * `trailingDelta` applies only to the `STOP_LOSS`/`STOP_LOSS_LIMIT` leg of the OCO.
2261    ///
2262    /// # Arguments
2263    ///
2264    /// - `params`: [`OrderListPlaceParams`]
2265    ///   The parameters for this operation.
2266    ///
2267    /// # Returns
2268    ///
2269    /// [`WebsocketApiResponse<Box<models::OrderListPlaceResponseResult>>`] on success.
2270    ///
2271    /// # Errors
2272    ///
2273    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
2274    ///
2275    ///
2276    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#order-list-place).
2277    ///
2278    /// # Deprecation
2279    ///
2280    /// **Deprecated:** This method may be removed in a future version.
2281    #[deprecated]
2282    pub async fn order_list_place(
2283        &self,
2284        params: OrderListPlaceParams,
2285    ) -> anyhow::Result<WebsocketApiResponse<Box<models::OrderListPlaceResponseResult>>> {
2286        self.trade_api_client.order_list_place(params).await
2287    }
2288
2289    /// Place new Order list - OCO (TRADE)
2290    ///
2291    /// Send in an one-cancels-the-other (OCO) pair, where activation of one order immediately cancels the other.
2292    ///
2293    /// * An OCO has 2 orders called the **above order** and **below order**.
2294    ///
2295    /// * One of the orders must be a `LIMIT_MAKER/TAKE_PROFIT/TAKE_PROFIT_LIMIT` order and the other must be
2296    /// `STOP_LOSS` or `STOP_LOSS_LIMIT` order.
2297    ///
2298    /// * Price restrictions:
2299    /// * If the OCO is on the `SELL` side:
2300    /// * `LIMIT_MAKER/TAKE_PROFIT_LIMIT` `price` > Last Traded Price > `STOP_LOSS/STOP_LOSS_LIMIT`
2301    /// `stopPrice`
2302    /// * `TAKE_PROFIT stopPrice` > Last Traded Price > `STOP_LOSS/STOP_LOSS_LIMIT
2303    /// stopPrice`
2304    /// * If the OCO is on the `BUY` side:
2305    /// * `LIMIT_MAKER` `price` < Last Traded Price < `STOP_LOSS/STOP_LOSS_LIMIT` `stopPrice`
2306    /// * `TAKE_PROFIT stopPrice` > Last Traded Price > `STOP_LOSS/STOP_LOSS_LIMIT stopPrice`
2307    /// *  OCOs add **2 orders** to the `EXCHANGE_MAX_ORDERS` filter and `MAX_NUM_ORDERS` filter.
2308    ///
2309    /// Weight(IP): 1
2310    ///
2311    /// Unfilled Order Count: 2
2312    ///
2313    /// Security Type: TRADE
2314    ///
2315    /// Notes:
2316    /// **Data Source:** Matching Engine
2317    ///
2318    /// # Arguments
2319    ///
2320    /// - `params`: [`OrderListPlaceOcoParams`]
2321    ///   The parameters for this operation.
2322    ///
2323    /// # Returns
2324    ///
2325    /// [`WebsocketApiResponse<Box<models::OrderListPlaceOcoResponseResult>>`] on success.
2326    ///
2327    /// # Errors
2328    ///
2329    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
2330    ///
2331    ///
2332    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#order-list-place-oco).
2333    ///
2334    pub async fn order_list_place_oco(
2335        &self,
2336        params: OrderListPlaceOcoParams,
2337    ) -> anyhow::Result<WebsocketApiResponse<Box<models::OrderListPlaceOcoResponseResult>>> {
2338        self.trade_api_client.order_list_place_oco(params).await
2339    }
2340
2341    /// OPO (TRADE)
2342    ///
2343    /// Place an [OPO](/products/spot/faqs/opo).
2344    ///
2345    /// * OPOs add 2 orders to the `EXCHANGE_MAX_NUM_ORDERS` filter and `MAX_NUM_ORDERS` filter.
2346    ///
2347    /// Weight(IP): 1
2348    ///
2349    /// Unfilled Order Count: 2
2350    ///
2351    /// Security Type: TRADE
2352    ///
2353    /// Notes:
2354    /// **Data Source:** Matching Engine
2355    ///
2356    /// # Arguments
2357    ///
2358    /// - `params`: [`OrderListPlaceOpoParams`]
2359    ///   The parameters for this operation.
2360    ///
2361    /// # Returns
2362    ///
2363    /// [`WebsocketApiResponse<Box<models::OrderListPlaceOpoResponseResult>>`] on success.
2364    ///
2365    /// # Errors
2366    ///
2367    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
2368    ///
2369    ///
2370    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#order-list-place-opo).
2371    ///
2372    pub async fn order_list_place_opo(
2373        &self,
2374        params: OrderListPlaceOpoParams,
2375    ) -> anyhow::Result<WebsocketApiResponse<Box<models::OrderListPlaceOpoResponseResult>>> {
2376        self.trade_api_client.order_list_place_opo(params).await
2377    }
2378
2379    /// OPOCO (TRADE)
2380    ///
2381    /// Place an [OPOCO](/products/spot/faqs/opo).
2382    ///
2383    /// Weight(IP): 1
2384    ///
2385    /// Unfilled Order Count: 3
2386    ///
2387    /// Security Type: TRADE
2388    ///
2389    /// Notes:
2390    /// **Data Source:** Matching Engine
2391    ///
2392    /// # Arguments
2393    ///
2394    /// - `params`: [`OrderListPlaceOpocoParams`]
2395    ///   The parameters for this operation.
2396    ///
2397    /// # Returns
2398    ///
2399    /// [`WebsocketApiResponse<Box<models::OrderListPlaceOpocoResponseResult>>`] on success.
2400    ///
2401    /// # Errors
2402    ///
2403    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
2404    ///
2405    ///
2406    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#order-list-place-opoco).
2407    ///
2408    pub async fn order_list_place_opoco(
2409        &self,
2410        params: OrderListPlaceOpocoParams,
2411    ) -> anyhow::Result<WebsocketApiResponse<Box<models::OrderListPlaceOpocoResponseResult>>> {
2412        self.trade_api_client.order_list_place_opoco(params).await
2413    }
2414
2415    /// Place new Order list - OTO (TRADE)
2416    ///
2417    /// Places an OTO.
2418    ///
2419    /// * An OTO (One-Triggers-the-Other) is an order list comprised of 2 orders.
2420    ///
2421    /// * The first order is called the **working order** and must be `LIMIT` or `LIMIT_MAKER`. Initially, only the
2422    /// working order goes on the order book.
2423    ///
2424    /// * The second order is called the **pending order**. It can be any order type except for `MARKET` orders using
2425    /// parameter `quoteOrderQty`. The pending order is only placed on the order book when the working order gets
2426    /// **fully filled**.
2427    ///
2428    /// * If either the working order or the pending order is cancelled individually, the other order in the order list
2429    /// will also be canceled or expired.
2430    ///
2431    /// * When the order list is placed, if the working order gets **immediately fully filled**, the placement response
2432    /// will show the working order as `FILLED` but the pending order will still appear as `PENDING_NEW`. You need to
2433    /// query the status of the pending order again to see its updated status.
2434    ///
2435    /// * OTOs add **2 orders** to the `EXCHANGE_MAX_NUM_ORDERS` filter and `MAX_NUM_ORDERS` filter.
2436    ///
2437    /// Weight(IP): 1
2438    ///
2439    /// Unfilled Order Count: 2
2440    ///
2441    /// Security Type: TRADE
2442    ///
2443    /// Notes:
2444    /// **Data Source:** Matching Engine
2445    ///
2446    /// **Mandatory parameters based on `pendingType` or `workingType`**
2447    ///
2448    /// Depending on the `pendingType` or `workingType`, some optional parameters will become mandatory.
2449    ///
2450    /// |Type                                                  |Additional mandatory parameters|Additional information|
2451    /// |----                                                  |----                           |------
2452    /// |`workingType` = `LIMIT`                               |`workingTimeInForce`           |
2453    /// |`pendingType` = `LIMIT`                                |`pendingPrice`, `pendingTimeInForce`          |
2454    /// |`pendingType` = `STOP_LOSS` or `TAKE_PROFIT`           |`pendingStopPrice` and/or `pendingTrailingDelta`|
2455    /// |`pendingType` =`STOP_LOSS_LIMIT` or `TAKE_PROFIT_LIMIT`|`pendingPrice`, `pendingStopPrice` and/or `pendingTrailingDelta`, `pendingTimeInForce`|
2456    ///
2457    /// # Arguments
2458    ///
2459    /// - `params`: [`OrderListPlaceOtoParams`]
2460    ///   The parameters for this operation.
2461    ///
2462    /// # Returns
2463    ///
2464    /// [`WebsocketApiResponse<Box<models::OrderListPlaceOtoResponseResult>>`] on success.
2465    ///
2466    /// # Errors
2467    ///
2468    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
2469    ///
2470    ///
2471    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#order-list-place-oto).
2472    ///
2473    pub async fn order_list_place_oto(
2474        &self,
2475        params: OrderListPlaceOtoParams,
2476    ) -> anyhow::Result<WebsocketApiResponse<Box<models::OrderListPlaceOtoResponseResult>>> {
2477        self.trade_api_client.order_list_place_oto(params).await
2478    }
2479
2480    /// Place new Order list - OTOCO (TRADE)
2481    ///
2482    /// Place an OTOCO.
2483    ///
2484    /// * An OTOCO (One-Triggers-One-Cancels-the-Other) is an order list comprised of 3 orders.
2485    /// * The first order is called the **working order** and must be `LIMIT` or `LIMIT_MAKER`. Initially, only the working order goes on the order book.
2486    /// * The behavior of the working order is the same as the [OTO](#order-list-place-oto).
2487    /// * OTOCO has 2 pending orders (pending above and pending below), forming an OCO pair. The pending orders are only placed on the order book when the working order gets **fully filled**.
2488    /// * The rules of the pending above and pending below follow the same rules as the [Order list OCO](#order-list-place-oco).
2489    /// * OTOCOs add **3 orders** to the `EXCHANGE_MAX_NUM_ORDERS` filter and `MAX_NUM_ORDERS` filter.
2490    ///
2491    /// Weight(IP): 1
2492    ///
2493    /// Unfilled Order Count: 3
2494    ///
2495    /// Security Type: TRADE
2496    ///
2497    /// Notes:
2498    /// **Data Source:** Matching Engine
2499    ///
2500    /// **Mandatory parameters based on `pendingAboveType`, `pendingBelowType` or `workingType`**
2501    ///
2502    /// Depending on the `pendingAboveType`/`pendingBelowType` or `workingType`, some optional parameters will become mandatory.
2503    ///
2504    /// |Type                                                       |Additional mandatory parameters|Additional information|
2505    /// |----                                                       |----                           |------
2506    /// |`workingType` = `LIMIT`                                    |`workingTimeInForce`           |
2507    /// |`pendingAboveType`= `LIMIT_MAKER`                                |`pendingAbovePrice`          |
2508    /// |`pendingAboveType` = `STOP_LOSS/TAKE_PROFIT`         |`pendingAboveStopPrice` and/or `pendingAboveTrailingDelta`|
2509    /// |`pendingAboveType=STOP_LOSS_LIMIT/TAKE_PROFIT_LIMIT`|`pendingAbovePrice`, `pendingAboveStopPrice` and/or `pendingAboveTrailingDelta`, `pendingAboveTimeInForce`|
2510    /// |`pendingBelowType`= `LIMIT_MAKER`                                |`pendingBelowPrice`          |
2511    /// `pendingBelowType= STOP_LOSS/TAKE_PROFIT`         |`pendingBelowStopPrice` and/or `pendingBelowTrailingDelta`|
2512    /// |`pendingBelowType=STOP_LOSS_LIMIT/TAKE_PROFIT_LIMIT`|`pendingBelowPrice`, `pendingBelowStopPrice` and/or `pendingBelowTrailingDelta`, `pendingBelowTimeInForce`|
2513    ///
2514    /// # Arguments
2515    ///
2516    /// - `params`: [`OrderListPlaceOtocoParams`]
2517    ///   The parameters for this operation.
2518    ///
2519    /// # Returns
2520    ///
2521    /// [`WebsocketApiResponse<Box<models::OrderListPlaceOtocoResponseResult>>`] on success.
2522    ///
2523    /// # Errors
2524    ///
2525    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
2526    ///
2527    ///
2528    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#order-list-place-otoco).
2529    ///
2530    pub async fn order_list_place_otoco(
2531        &self,
2532        params: OrderListPlaceOtocoParams,
2533    ) -> anyhow::Result<WebsocketApiResponse<Box<models::OrderListPlaceOtocoResponseResult>>> {
2534        self.trade_api_client.order_list_place_otoco(params).await
2535    }
2536
2537    /// Place new order (TRADE)
2538    ///
2539    /// Send in a new order.
2540    ///
2541    /// This adds 1 order to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
2542    ///
2543    /// Weight(IP): 1
2544    ///
2545    /// Unfilled Order Count: 1
2546    ///
2547    /// Security Type: TRADE
2548    ///
2549    /// Notes:
2550    /// **Data Source:** Matching Engine
2551    ///
2552    /// <a id="order-type">Certain parameters (*)</a> become mandatory based on the order `type`:
2553    ///
2554    /// <table>
2555    /// <thead>
2556    /// <tr>
2557    /// <th>Order <code>type</code></th>
2558    /// <th>Mandatory parameters</th>
2559    /// </tr>
2560    /// </thead>
2561    /// <tbody>
2562    /// <tr>
2563    /// <td><code>LIMIT</code></td>
2564    /// <td>
2565    /// <ul>
2566    /// <li><code>timeInForce</code></li>
2567    /// <li><code>price</code></li>
2568    /// <li><code>quantity</code></li>
2569    /// </ul>
2570    /// </td>
2571    /// </tr>
2572    /// <tr>
2573    /// <td><code>LIMIT_MAKER</code></td>
2574    /// <td>
2575    /// <ul>
2576    /// <li><code>price</code></li>
2577    /// <li><code>quantity</code></li>
2578    /// </ul>
2579    /// </td>
2580    /// </tr>
2581    /// <tr>
2582    /// <td><code>MARKET</code></td>
2583    /// <td>
2584    /// <ul>
2585    /// <li><code>quantity</code> or <code>quoteOrderQty</code></li>
2586    /// </ul>
2587    /// </td>
2588    /// </tr>
2589    /// <tr>
2590    /// <td><code>STOP_LOSS</code></td>
2591    /// <td>
2592    /// <ul>
2593    /// <li><code>quantity</code></li>
2594    /// <li><code>stopPrice</code> or <code>trailingDelta</code></li>
2595    /// </ul>
2596    /// </td>
2597    /// </tr>
2598    /// <tr>
2599    /// <td><code>STOP_LOSS_LIMIT</code></td>
2600    /// <td>
2601    /// <ul>
2602    /// <li><code>timeInForce</code></li>
2603    /// <li><code>price</code></li>
2604    /// <li><code>quantity</code></li>
2605    /// <li><code>stopPrice</code> or <code>trailingDelta</code></li>
2606    /// </ul>
2607    /// </td>
2608    /// </tr>
2609    /// <tr>
2610    /// <td><code>TAKE_PROFIT</code></td>
2611    /// <td>
2612    /// <ul>
2613    /// <li><code>quantity</code></li>
2614    /// <li><code>stopPrice</code> or <code>trailingDelta</code></li>
2615    /// </ul>
2616    /// </td>
2617    /// </tr>
2618    /// <tr>
2619    /// <td><code>TAKE_PROFIT_LIMIT</code></td>
2620    /// <td>
2621    /// <ul>
2622    /// <li><code>timeInForce</code></li>
2623    /// <li><code>price</code></li>
2624    /// <li><code>quantity</code></li>
2625    /// <li><code>stopPrice</code> or <code>trailingDelta</code></li>
2626    /// </ul>
2627    /// </td>
2628    /// </tr>
2629    /// </tbody>
2630    /// </table>
2631    ///
2632    /// Supported order types:
2633    ///
2634    /// <table>
2635    /// <thead>
2636    /// <tr>
2637    /// <th>Order <code>type</code></th>
2638    /// <th>Description</th>
2639    /// </tr>
2640    /// </thead>
2641    /// <tbody>
2642    /// <tr>
2643    /// <td><code>LIMIT</code></td>
2644    /// <td>
2645    /// <p>
2646    /// Buy or sell <code>quantity</code> at the specified <code>price</code> or better.
2647    /// </p>
2648    /// </td>
2649    /// </tr>
2650    /// <tr>
2651    /// <td><code>LIMIT_MAKER</code></td>
2652    /// <td>
2653    /// <p>
2654    /// <code>LIMIT</code> order that will be rejected if it immediately matches and trades as a taker.
2655    /// </p>
2656    /// <p>
2657    /// This order type is also known as a POST-ONLY order.
2658    /// </p>
2659    /// </td>
2660    /// </tr>
2661    /// <tr>
2662    /// <td><code>MARKET</code></td>
2663    /// <td>
2664    /// <p>
2665    /// Buy or sell at the best available market price.
2666    /// </p>
2667    /// <ul>
2668    /// <li>
2669    /// <p>
2670    /// <code>MARKET</code> order with <code>quantity</code> parameter
2671    /// specifies the amount of the <em>base asset</em> you want to buy or sell.
2672    /// Actually executed quantity of the quote asset will be determined by available market liquidity.
2673    /// </p>
2674    /// <p>
2675    /// E.g., a MARKET BUY order on BTCUSDT for <code>"quantity": "0.1000"</code>
2676    /// specifies that you want to buy 0.1 BTC at the best available price.
2677    /// If there is not enough BTC at the best price, keep buying at the next best price,
2678    /// until either your order is filled, or you run out of USDT, or market runs out of BTC.
2679    /// </p>
2680    /// </li>
2681    /// <li>
2682    /// <p>
2683    /// <code>MARKET</code> order with <code>quoteOrderQty</code> parameter
2684    /// specifies the amount of the <em>quote asset</em> you want to spend (when buying) or receive (when selling).
2685    /// Actually executed quantity of the base asset will be determined by available market liquidity.
2686    /// </p>
2687    /// <p>
2688    /// E.g., a MARKET BUY on BTCUSDT for <code>"quoteOrderQty": "100.00"</code>
2689    /// specifies that you want to buy as much BTC as you can for 100 USDT at the best available price.
2690    /// Similarly, a SELL order will sell as much available BTC as needed for you to receive 100 USDT
2691    /// (before commission).
2692    /// </p>
2693    /// </li>
2694    /// </ul>
2695    /// </td>
2696    /// </tr>
2697    /// <tr>
2698    /// <td><code>STOP_LOSS</code></td>
2699    /// <td>
2700    /// <p>
2701    /// Execute a <code>MARKET</code> order for given <code>quantity</code> when specified conditions are met.
2702    /// </p>
2703    /// <p>
2704    /// I.e., when <code>stopPrice</code> is reached, or when <code>trailingDelta</code> is activated.
2705    /// </p>
2706    /// </td>
2707    /// </tr>
2708    /// <tr>
2709    /// <td><code>STOP_LOSS_LIMIT</code></td>
2710    /// <td>
2711    /// <p>
2712    /// Place a <code>LIMIT</code> order with given parameters when specified conditions are met.
2713    /// </p>
2714    /// </td>
2715    /// </tr>
2716    /// <tr>
2717    /// <td><code>TAKE_PROFIT</code></td>
2718    /// <td>
2719    /// <p>
2720    /// Like <code>STOP_LOSS</code> but activates when market price moves in the favorable direction.
2721    /// </p>
2722    /// </td>
2723    /// </tr>
2724    /// <tr>
2725    /// <td><code>TAKE_PROFIT_LIMIT</code></td>
2726    /// <td>
2727    /// <p>
2728    /// Like <code>STOP_LOSS_LIMIT</code> but activates when market price moves in the favorable direction.
2729    /// </p>
2730    /// </td>
2731    /// </tr>
2732    /// </tbody>
2733    /// </table>
2734    ///
2735    /// <a id="pegged-orders-info"></a>
2736    /// Notes on using parameters for Pegged Orders:
2737    ///
2738    /// * These parameters are allowed for `LIMIT`, `LIMIT_MAKER`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT_LIMIT` orders.
2739    /// * If `pegPriceType` is specified, `price` becomes optional. Otherwise, it is still mandatory.
2740    /// * `pegPriceType=PRIMARY_PEG` means the primary peg, that is the best price on the same side of the order book as your order.
2741    /// * `pegPriceType=MARKET_PEG` means the market peg, that is the best price on the opposite side of the order book from your order.
2742    /// * Use `pegOffsetType` and `pegOffsetValue` to request a price level other than the best one. These parameters must be specified together.
2743    ///
2744    /// <a id="timeInForce"></a>
2745    ///
2746    /// Available `timeInForce` options,
2747    /// setting how long the order should be active before expiration:
2748    ///
2749    /// TIF  | Description
2750    /// ----- | --------------
2751    /// `GTC` | **Good 'til Canceled** – the order will remain on the book until you cancel it, or the order is completely filled.
2752    /// `IOC` | **Immediate or Cancel** – the order will be filled for as much as possible, the unfilled quantity immediately expires.
2753    /// `FOK` | **Fill or Kill** – the order will expire unless it cannot be immediately filled for the entire quantity.
2754    ///
2755    /// Notes:
2756    ///
2757    /// * `newClientOrderId` specifies `clientOrderId` value for the order.
2758    ///
2759    /// A new order with the same `clientOrderId` is accepted only when the previous one is filled or expired.
2760    ///
2761    /// * Any `LIMIT` or `LIMIT_MAKER` order can be made into an iceberg order by specifying the `icebergQty`.
2762    ///
2763    /// An order with an `icebergQty` must have `timeInForce` set to `GTC`.
2764    ///
2765    /// * Trigger order price rules for `STOP_LOSS`/`TAKE_PROFIT` orders:
2766    ///
2767    /// * `stopPrice` must be above market price: `STOP_LOSS BUY`, `TAKE_PROFIT SELL`
2768    /// * `stopPrice` must be below market price: `STOP_LOSS SELL`, `TAKE_PROFIT BUY`
2769    ///
2770    /// * `MARKET` orders using `quoteOrderQty` follow [`LOT_SIZE`](/products/spot/filters#lot_size) filter rules.
2771    ///
2772    /// The order will execute a quantity that has notional value as close as possible to requested `quoteOrderQty`.
2773    ///
2774    /// # Arguments
2775    ///
2776    /// - `params`: [`OrderPlaceParams`]
2777    ///   The parameters for this operation.
2778    ///
2779    /// # Returns
2780    ///
2781    /// [`WebsocketApiResponse<Box<models::OrderPlaceResponseResult>>`] on success.
2782    ///
2783    /// # Errors
2784    ///
2785    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
2786    ///
2787    ///
2788    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#order-place).
2789    ///
2790    pub async fn order_place(
2791        &self,
2792        params: OrderPlaceParams,
2793    ) -> anyhow::Result<WebsocketApiResponse<Box<models::OrderPlaceResponseResult>>> {
2794        self.trade_api_client.order_place(params).await
2795    }
2796
2797    /// Test new order (TRADE)
2798    ///
2799    /// Test order placement.
2800    ///
2801    /// Validates new order parameters and verifies your signature
2802    /// but does not send the order into the matching engine.
2803    ///
2804    /// Weight: | Condition | Request Weight |
2805    /// | --- | --- |
2806    /// | Without `computeCommissionRates` | 1 |
2807    /// | With `computeCommissionRates` | 20 |
2808    ///
2809    /// Security Type: TRADE
2810    ///
2811    /// Notes:
2812    /// **Data Source:** Memory
2813    ///
2814    /// # Arguments
2815    ///
2816    /// - `params`: [`OrderTestParams`]
2817    ///   The parameters for this operation.
2818    ///
2819    /// # Returns
2820    ///
2821    /// [`WebsocketApiResponse<Box<models::OrderTestResponseResult>>`] on success.
2822    ///
2823    /// # Errors
2824    ///
2825    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
2826    ///
2827    ///
2828    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#order-test).
2829    ///
2830    pub async fn order_test(
2831        &self,
2832        params: OrderTestParams,
2833    ) -> anyhow::Result<WebsocketApiResponse<Box<models::OrderTestResponseResult>>> {
2834        self.trade_api_client.order_test(params).await
2835    }
2836
2837    /// Place new order using SOR (TRADE)
2838    ///
2839    /// Places an order using smart order routing (SOR).
2840    ///
2841    /// This adds 1 order to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
2842    ///
2843    /// Read [SOR FAQ](/products/spot/faqs/sor_faq) to learn more.
2844    ///
2845    /// Weight(IP): 1
2846    ///
2847    /// Unfilled Order Count: 1
2848    ///
2849    /// Security Type: TRADE
2850    ///
2851    /// Notes:
2852    /// **Data Source:** Matching Engine
2853    ///
2854    /// **Note:** `sor.order.place` only supports `LIMIT` and `MARKET` orders. `quoteOrderQty` is not supported.
2855    ///
2856    /// # Arguments
2857    ///
2858    /// - `params`: [`SorOrderPlaceParams`]
2859    ///   The parameters for this operation.
2860    ///
2861    /// # Returns
2862    ///
2863    /// [`WebsocketApiResponse<Vec<models::SorOrderPlaceResponseResultInner>>`] on success.
2864    ///
2865    /// # Errors
2866    ///
2867    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
2868    ///
2869    ///
2870    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#sor-order-place).
2871    ///
2872    pub async fn sor_order_place(
2873        &self,
2874        params: SorOrderPlaceParams,
2875    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::SorOrderPlaceResponseResultInner>>> {
2876        self.trade_api_client.sor_order_place(params).await
2877    }
2878
2879    /// Test new order using SOR (TRADE)
2880    ///
2881    /// Test new order creation and signature/recvWindow using smart order routing (SOR).
2882    /// Creates and validates a new order but does not send it into the matching engine.
2883    ///
2884    /// Weight: | Condition | Request Weight |
2885    /// | --- | --- |
2886    /// | Without `computeCommissionRates` | 1 |
2887    /// | With `computeCommissionRates` | 20 |
2888    ///
2889    /// Security Type: TRADE
2890    ///
2891    /// Notes:
2892    /// **Data Source:** Memory
2893    ///
2894    /// # Arguments
2895    ///
2896    /// - `params`: [`SorOrderTestParams`]
2897    ///   The parameters for this operation.
2898    ///
2899    /// # Returns
2900    ///
2901    /// [`WebsocketApiResponse<Box<models::SorOrderTestResponseResult>>`] on success.
2902    ///
2903    /// # Errors
2904    ///
2905    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
2906    ///
2907    ///
2908    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/trade#sor-order-test).
2909    ///
2910    pub async fn sor_order_test(
2911        &self,
2912        params: SorOrderTestParams,
2913    ) -> anyhow::Result<WebsocketApiResponse<Box<models::SorOrderTestResponseResult>>> {
2914        self.trade_api_client.sor_order_test(params).await
2915    }
2916
2917    /// Listing all subscriptions
2918    ///
2919    /// **Note:**
2920    ///
2921    /// * Users should track the corresponding subscription status of related accounts as needed.
2922    ///
2923    /// Weight(IP): 2
2924    ///
2925    /// Security Type: NONE
2926    ///
2927    /// Notes:
2928    /// **Data Source:** Memory
2929    ///
2930    /// # Arguments
2931    ///
2932    /// - `params`: [`SessionSubscriptionsParams`]
2933    ///   The parameters for this operation.
2934    ///
2935    /// # Returns
2936    ///
2937    /// [`WebsocketApiResponse<Vec<models::SessionSubscriptionsResponseResultInner>>`] on success.
2938    ///
2939    /// # Errors
2940    ///
2941    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
2942    ///
2943    ///
2944    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/user-data-stream#session-subscriptions).
2945    ///
2946    pub async fn session_subscriptions(
2947        &self,
2948        params: SessionSubscriptionsParams,
2949    ) -> anyhow::Result<WebsocketApiResponse<Vec<models::SessionSubscriptionsResponseResultInner>>>
2950    {
2951        self.user_data_stream_api_client
2952            .session_subscriptions(params)
2953            .await
2954    }
2955
2956    /// Subscribe to User Data Stream
2957    ///
2958    /// Subscribe to the User Data Stream in the current WebSocket connection.
2959    ///
2960    /// **Notes:**
2961    /// - This method requires an authenticated WebSocket connection using Ed25519 keys. Please refer to [`session.logon`](/catalog/core-trading-spot-trading/api/ws-api/auth#session-logon).
2962    /// - To check the subscription status, use [`session.status`](/catalog/core-trading-spot-trading/api/ws-api/auth#session-status), see the `userDataStream` flag indicating you have have an active subscription.
2963    /// - User Data Stream events are available in both JSON and [SBE](/products/spot/faqs/sbe_faq) sessions.
2964    /// - Please refer to [User Data Streams](/products/spot/user-data-stream) for the event format details.
2965    /// - For SBE, only SBE schema 2:1 or later is supported.
2966    ///
2967    /// Weight(IP): 2
2968    ///
2969    /// Security Type: NONE
2970    ///
2971    /// # Arguments
2972    ///
2973    /// - `params`: [`UserDataStreamSubscribeParams`]
2974    ///   The parameters for this operation.
2975    ///
2976    /// # Returns
2977    ///
2978    /// [`WebsocketApiResponse<Box<models::UserDataStreamSubscribeResponseResult>>`] on success.
2979    ///
2980    /// # Errors
2981    ///
2982    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
2983    ///
2984    ///
2985    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/user-data-stream#user-data-stream-subscribe).
2986    ///
2987    pub async fn user_data_stream_subscribe(
2988        &self,
2989        params: UserDataStreamSubscribeParams,
2990    ) -> anyhow::Result<(
2991        WebsocketApiResponse<Box<models::UserDataStreamSubscribeResponseResult>>,
2992        Arc<WebsocketStream<UserDataStreamEventsResponse>>,
2993    )> {
2994        let response = self
2995            .user_data_stream_api_client
2996            .user_data_stream_subscribe(params)
2997            .await?;
2998        let stream = create_stream_handler::<UserDataStreamEventsResponse>(
2999            WebsocketBase::WebsocketApi(self.websocket_api_base.clone()),
3000            random_string(),
3001            None,
3002            None,
3003        )
3004        .await;
3005
3006        Ok((response, stream))
3007    }
3008
3009    /// Subscribe to User Data Stream through signature subscription (`USER_STREAM`)
3010    ///
3011    /// Weight(IP): 2
3012    ///
3013    /// Security Type: `USER_STREAM`
3014    ///
3015    /// Notes:
3016    /// **Data Source:** Memory
3017    ///
3018    /// # Arguments
3019    ///
3020    /// - `params`: [`UserDataStreamSubscribeSignatureParams`]
3021    ///   The parameters for this operation.
3022    ///
3023    /// # Returns
3024    ///
3025    /// [`WebsocketApiResponse<Box<models::UserDataStreamSubscribeResponseResult>>`] on success.
3026    ///
3027    /// # Errors
3028    ///
3029    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
3030    ///
3031    ///
3032    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/user-data-stream#user-data-stream-subscribe-signature).
3033    ///
3034    pub async fn user_data_stream_subscribe_signature(
3035        &self,
3036        params: UserDataStreamSubscribeSignatureParams,
3037    ) -> anyhow::Result<(
3038        WebsocketApiResponse<Box<models::UserDataStreamSubscribeResponseResult>>,
3039        Arc<WebsocketStream<UserDataStreamEventsResponse>>,
3040    )> {
3041        let response = self
3042            .user_data_stream_api_client
3043            .user_data_stream_subscribe_signature(params)
3044            .await?;
3045        let stream = create_stream_handler::<UserDataStreamEventsResponse>(
3046            WebsocketBase::WebsocketApi(self.websocket_api_base.clone()),
3047            random_string(),
3048            None,
3049            None,
3050        )
3051        .await;
3052
3053        Ok((response, stream))
3054    }
3055
3056    /// WebSocket Unsubscribe from User Data Stream
3057    ///
3058    /// Stop listening to the User Data Stream in the current WebSocket
3059    /// connection.
3060    ///
3061    /// Note that `session.logout` will only close the subscription created with `userDataStream.subscribe` but not subscriptions opened with `userDataStream.subscribe.signature`.
3062    ///
3063    /// Weight(IP): 2
3064    ///
3065    /// # Arguments
3066    ///
3067    /// - `params`: [`UserDataStreamUnsubscribeParams`]
3068    ///   The parameters for this operation.
3069    ///
3070    /// # Returns
3071    ///
3072    /// [`WebsocketApiResponse<serde_json::Value>`] on success.
3073    ///
3074    /// # Errors
3075    ///
3076    /// Returns an [`anyhow::Error`] if the WebSocket request fails, if parameters are invalid, or if parsing the response fails.
3077    ///
3078    ///
3079    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-api/user-data-stream#user-data-stream-unsubscribe).
3080    ///
3081    pub async fn user_data_stream_unsubscribe(
3082        &self,
3083        params: UserDataStreamUnsubscribeParams,
3084    ) -> anyhow::Result<WebsocketApiResponse<serde_json::Value>> {
3085        self.user_data_stream_api_client
3086            .user_data_stream_unsubscribe(params)
3087            .await
3088    }
3089}