binance_sdk/spot/rest_api/mod.rs
1/*
2 * Binance Spot REST API
3 *
4 * OpenAPI Specifications for the Binance Spot REST API
5 *
6 * API documents:
7 * - [Github rest-api documentation file](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md)
8 * - [General API information for rest-api on website](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-api-information)
9 *
10 *
11 * The version of the OpenAPI document: 1.0.0
12 *
13 *
14 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
15 * https://openapi-generator.tech
16 * Do not edit the class manually.
17 */
18
19#![allow(unused_imports)]
20use http::Method;
21use serde::de::DeserializeOwned;
22use serde_json::Value;
23use std::collections::BTreeMap;
24
25use crate::common::{config::ConfigurationRestApi, models::RestApiResponse, utils::send_request};
26
27mod apis;
28mod models;
29
30pub use apis::*;
31pub use models::*;
32
33#[derive(Debug, Clone)]
34pub struct RestApi {
35 configuration: ConfigurationRestApi,
36 account_api_client: AccountApiClient,
37 general_api_client: GeneralApiClient,
38 market_api_client: MarketApiClient,
39 trade_api_client: TradeApiClient,
40}
41
42impl RestApi {
43 pub fn new(configuration: ConfigurationRestApi) -> Self {
44 let account_api_client = AccountApiClient::new(configuration.clone());
45 let general_api_client = GeneralApiClient::new(configuration.clone());
46 let market_api_client = MarketApiClient::new(configuration.clone());
47 let trade_api_client = TradeApiClient::new(configuration.clone());
48
49 Self {
50 configuration,
51 account_api_client,
52 general_api_client,
53 market_api_client,
54 trade_api_client,
55 }
56 }
57
58 /// Send an unsigned request to the API
59 ///
60 /// # Arguments
61 ///
62 /// * `endpoint` - The API endpoint to send the request to
63 /// * `method` - The HTTP method to use for the request
64 /// * `query_params` - A map of query parameters to send with the request
65 /// * `body_params` - A map of body parameters to send with the request
66 ///
67 /// # Returns
68 ///
69 /// A `RestApiResponse` containing the deserialized response data on success, or an error if the request fails
70 ///
71 /// # Errors
72 ///
73 /// Returns an `anyhow::Error` if the HTTP request fails or if parsing the response fails
74 pub async fn send_request<R: DeserializeOwned + Send + 'static>(
75 &self,
76 endpoint: &str,
77 method: Method,
78 query_params: BTreeMap<String, Value>,
79 body_params: BTreeMap<String, Value>,
80 ) -> anyhow::Result<RestApiResponse<R>> {
81 send_request::<R>(
82 &self.configuration,
83 endpoint,
84 method,
85 query_params,
86 body_params,
87 None,
88 false,
89 )
90 .await
91 }
92
93 /// Send a signed request to the API
94 ///
95 /// # Arguments
96 ///
97 /// * `endpoint` - The API endpoint to send the request to
98 /// * `method` - The HTTP method to use for the request
99 /// * `query_params` - A map of query parameters to send with the request
100 /// * `body_params` - A map of body parameters to send with the request
101 ///
102 /// # Returns
103 ///
104 /// A `RestApiResponse` containing the deserialized response data on success, or an error if the request fails
105 ///
106 /// # Errors
107 ///
108 /// Returns an `anyhow::Error` if the HTTP request fails or if parsing the response fails
109 pub async fn send_signed_request<R: DeserializeOwned + Send + 'static>(
110 &self,
111 endpoint: &str,
112 method: Method,
113 query_params: BTreeMap<String, Value>,
114 body_params: BTreeMap<String, Value>,
115 ) -> anyhow::Result<RestApiResponse<R>> {
116 send_request::<R>(
117 &self.configuration,
118 endpoint,
119 method,
120 query_params,
121 body_params,
122 None,
123 true,
124 )
125 .await
126 }
127
128 /// Query Commission Rates
129 ///
130 /// Get current account commission rates.
131 /// Weight: 20
132 ///
133 /// # Arguments
134 ///
135 /// - `params`: [`AccountCommissionParams`]
136 /// The parameters for this operation.
137 ///
138 /// # Returns
139 ///
140 /// [`RestApiResponse<models::AccountCommissionResponse>`] on success.
141 ///
142 /// # Errors
143 ///
144 /// This function will return an [`anyhow::Error`] if:
145 /// - the HTTP request fails
146 /// - any parameter is invalid
147 /// - the response cannot be parsed
148 /// - or one of the following occurs:
149 /// - `RequiredError`
150 /// - `ConnectorClientError`
151 /// - `UnauthorizedError`
152 /// - `ForbiddenError`
153 /// - `TooManyRequestsError`
154 /// - `RateLimitBanError`
155 /// - `ServerError`
156 /// - `NotFoundError`
157 /// - `NetworkError`
158 /// - `BadRequestError`
159 ///
160 ///
161 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-commission-rates-user_data).
162 ///
163 pub async fn account_commission(
164 &self,
165 params: AccountCommissionParams,
166 ) -> anyhow::Result<RestApiResponse<models::AccountCommissionResponse>> {
167 self.account_api_client.account_commission(params).await
168 }
169
170 /// Query all Order lists
171 ///
172 /// Retrieves all order lists based on provided optional parameters.
173 ///
174 /// Note that the time between `startTime` and `endTime` can't be longer than 24 hours.
175 /// Weight: 20
176 ///
177 /// # Arguments
178 ///
179 /// - `params`: [`AllOrderListParams`]
180 /// The parameters for this operation.
181 ///
182 /// # Returns
183 ///
184 /// [`RestApiResponse<Vec<models::AllOrderListResponseInner>>`] on success.
185 ///
186 /// # Errors
187 ///
188 /// This function will return an [`anyhow::Error`] if:
189 /// - the HTTP request fails
190 /// - any parameter is invalid
191 /// - the response cannot be parsed
192 /// - or one of the following occurs:
193 /// - `RequiredError`
194 /// - `ConnectorClientError`
195 /// - `UnauthorizedError`
196 /// - `ForbiddenError`
197 /// - `TooManyRequestsError`
198 /// - `RateLimitBanError`
199 /// - `ServerError`
200 /// - `NotFoundError`
201 /// - `NetworkError`
202 /// - `BadRequestError`
203 ///
204 ///
205 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-all-order-lists-user_data).
206 ///
207 pub async fn all_order_list(
208 &self,
209 params: AllOrderListParams,
210 ) -> anyhow::Result<RestApiResponse<Vec<models::AllOrderListResponseInner>>> {
211 self.account_api_client.all_order_list(params).await
212 }
213
214 /// All orders
215 ///
216 /// Get all account orders; active, canceled, or filled.
217 /// Weight: 20
218 ///
219 /// # Arguments
220 ///
221 /// - `params`: [`AllOrdersParams`]
222 /// The parameters for this operation.
223 ///
224 /// # Returns
225 ///
226 /// [`RestApiResponse<Vec<models::AllOrdersResponseInner>>`] on success.
227 ///
228 /// # Errors
229 ///
230 /// This function will return an [`anyhow::Error`] if:
231 /// - the HTTP request fails
232 /// - any parameter is invalid
233 /// - the response cannot be parsed
234 /// - or one of the following occurs:
235 /// - `RequiredError`
236 /// - `ConnectorClientError`
237 /// - `UnauthorizedError`
238 /// - `ForbiddenError`
239 /// - `TooManyRequestsError`
240 /// - `RateLimitBanError`
241 /// - `ServerError`
242 /// - `NotFoundError`
243 /// - `NetworkError`
244 /// - `BadRequestError`
245 ///
246 ///
247 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#all-orders-user_data).
248 ///
249 pub async fn all_orders(
250 &self,
251 params: AllOrdersParams,
252 ) -> anyhow::Result<RestApiResponse<Vec<models::AllOrdersResponseInner>>> {
253 self.account_api_client.all_orders(params).await
254 }
255
256 /// Account information
257 ///
258 /// Get current account information.
259 /// Weight: 20
260 ///
261 /// # Arguments
262 ///
263 /// - `params`: [`GetAccountParams`]
264 /// The parameters for this operation.
265 ///
266 /// # Returns
267 ///
268 /// [`RestApiResponse<models::GetAccountResponse>`] on success.
269 ///
270 /// # Errors
271 ///
272 /// This function will return an [`anyhow::Error`] if:
273 /// - the HTTP request fails
274 /// - any parameter is invalid
275 /// - the response cannot be parsed
276 /// - or one of the following occurs:
277 /// - `RequiredError`
278 /// - `ConnectorClientError`
279 /// - `UnauthorizedError`
280 /// - `ForbiddenError`
281 /// - `TooManyRequestsError`
282 /// - `RateLimitBanError`
283 /// - `ServerError`
284 /// - `NotFoundError`
285 /// - `NetworkError`
286 /// - `BadRequestError`
287 ///
288 ///
289 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-information-user_data).
290 ///
291 pub async fn get_account(
292 &self,
293 params: GetAccountParams,
294 ) -> anyhow::Result<RestApiResponse<models::GetAccountResponse>> {
295 self.account_api_client.get_account(params).await
296 }
297
298 /// Current open orders
299 ///
300 /// Get all open orders on a symbol. **Careful** when accessing this with no symbol.
301 /// Weight: 6 for a single symbol; **80** when the symbol parameter is omitted
302 ///
303 /// # Arguments
304 ///
305 /// - `params`: [`GetOpenOrdersParams`]
306 /// The parameters for this operation.
307 ///
308 /// # Returns
309 ///
310 /// [`RestApiResponse<Vec<models::AllOrdersResponseInner>>`] on success.
311 ///
312 /// # Errors
313 ///
314 /// This function will return an [`anyhow::Error`] if:
315 /// - the HTTP request fails
316 /// - any parameter is invalid
317 /// - the response cannot be parsed
318 /// - or one of the following occurs:
319 /// - `RequiredError`
320 /// - `ConnectorClientError`
321 /// - `UnauthorizedError`
322 /// - `ForbiddenError`
323 /// - `TooManyRequestsError`
324 /// - `RateLimitBanError`
325 /// - `ServerError`
326 /// - `NotFoundError`
327 /// - `NetworkError`
328 /// - `BadRequestError`
329 ///
330 ///
331 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#current-open-orders-user_data).
332 ///
333 pub async fn get_open_orders(
334 &self,
335 params: GetOpenOrdersParams,
336 ) -> anyhow::Result<RestApiResponse<Vec<models::AllOrdersResponseInner>>> {
337 self.account_api_client.get_open_orders(params).await
338 }
339
340 /// Query order
341 ///
342 /// Check an order's status.
343 /// Weight: 4
344 ///
345 /// # Arguments
346 ///
347 /// - `params`: [`GetOrderParams`]
348 /// The parameters for this operation.
349 ///
350 /// # Returns
351 ///
352 /// [`RestApiResponse<models::GetOrderResponse>`] on success.
353 ///
354 /// # Errors
355 ///
356 /// This function will return an [`anyhow::Error`] if:
357 /// - the HTTP request fails
358 /// - any parameter is invalid
359 /// - the response cannot be parsed
360 /// - or one of the following occurs:
361 /// - `RequiredError`
362 /// - `ConnectorClientError`
363 /// - `UnauthorizedError`
364 /// - `ForbiddenError`
365 /// - `TooManyRequestsError`
366 /// - `RateLimitBanError`
367 /// - `ServerError`
368 /// - `NotFoundError`
369 /// - `NetworkError`
370 /// - `BadRequestError`
371 ///
372 ///
373 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-order-user_data).
374 ///
375 pub async fn get_order(
376 &self,
377 params: GetOrderParams,
378 ) -> anyhow::Result<RestApiResponse<models::GetOrderResponse>> {
379 self.account_api_client.get_order(params).await
380 }
381
382 /// Query Order list
383 ///
384 /// Retrieves a specific order list based on provided optional parameters.
385 /// Weight: 4
386 ///
387 /// # Arguments
388 ///
389 /// - `params`: [`GetOrderListParams`]
390 /// The parameters for this operation.
391 ///
392 /// # Returns
393 ///
394 /// [`RestApiResponse<models::GetOrderListResponse>`] on success.
395 ///
396 /// # Errors
397 ///
398 /// This function will return an [`anyhow::Error`] if:
399 /// - the HTTP request fails
400 /// - any parameter is invalid
401 /// - the response cannot be parsed
402 /// - or one of the following occurs:
403 /// - `RequiredError`
404 /// - `ConnectorClientError`
405 /// - `UnauthorizedError`
406 /// - `ForbiddenError`
407 /// - `TooManyRequestsError`
408 /// - `RateLimitBanError`
409 /// - `ServerError`
410 /// - `NotFoundError`
411 /// - `NetworkError`
412 /// - `BadRequestError`
413 ///
414 ///
415 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-order-list-user_data).
416 ///
417 pub async fn get_order_list(
418 &self,
419 params: GetOrderListParams,
420 ) -> anyhow::Result<RestApiResponse<models::GetOrderListResponse>> {
421 self.account_api_client.get_order_list(params).await
422 }
423
424 /// Query Allocations
425 ///
426 /// Retrieves allocations resulting from SOR order placement.
427 /// Weight: 20
428 ///
429 /// # Arguments
430 ///
431 /// - `params`: [`MyAllocationsParams`]
432 /// The parameters for this operation.
433 ///
434 /// # Returns
435 ///
436 /// [`RestApiResponse<Vec<models::MyAllocationsResponseInner>>`] on success.
437 ///
438 /// # Errors
439 ///
440 /// This function will return an [`anyhow::Error`] if:
441 /// - the HTTP request fails
442 /// - any parameter is invalid
443 /// - the response cannot be parsed
444 /// - or one of the following occurs:
445 /// - `RequiredError`
446 /// - `ConnectorClientError`
447 /// - `UnauthorizedError`
448 /// - `ForbiddenError`
449 /// - `TooManyRequestsError`
450 /// - `RateLimitBanError`
451 /// - `ServerError`
452 /// - `NotFoundError`
453 /// - `NetworkError`
454 /// - `BadRequestError`
455 ///
456 ///
457 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-allocations-user_data).
458 ///
459 pub async fn my_allocations(
460 &self,
461 params: MyAllocationsParams,
462 ) -> anyhow::Result<RestApiResponse<Vec<models::MyAllocationsResponseInner>>> {
463 self.account_api_client.my_allocations(params).await
464 }
465
466 /// Query relevant filters
467 ///
468 /// Retrieves the list of [filters](filters.md) relevant to an account on a given symbol. This is the only endpoint that shows if an account has `MAX_ASSET` filters applied to it.
469 /// Weight: 40
470 ///
471 /// # Arguments
472 ///
473 /// - `params`: [`MyFiltersParams`]
474 /// The parameters for this operation.
475 ///
476 /// # Returns
477 ///
478 /// [`RestApiResponse<models::MyFiltersResponse>`] on success.
479 ///
480 /// # Errors
481 ///
482 /// This function will return an [`anyhow::Error`] if:
483 /// - the HTTP request fails
484 /// - any parameter is invalid
485 /// - the response cannot be parsed
486 /// - or one of the following occurs:
487 /// - `RequiredError`
488 /// - `ConnectorClientError`
489 /// - `UnauthorizedError`
490 /// - `ForbiddenError`
491 /// - `TooManyRequestsError`
492 /// - `RateLimitBanError`
493 /// - `ServerError`
494 /// - `NotFoundError`
495 /// - `NetworkError`
496 /// - `BadRequestError`
497 ///
498 ///
499 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-relevant-filters-user_data).
500 ///
501 pub async fn my_filters(
502 &self,
503 params: MyFiltersParams,
504 ) -> anyhow::Result<RestApiResponse<models::MyFiltersResponse>> {
505 self.account_api_client.my_filters(params).await
506 }
507
508 /// Query Prevented Matches
509 ///
510 /// Displays the list of orders that were expired due to STP.
511 ///
512 /// These are the combinations supported:
513 ///
514 /// * `symbol` + `preventedMatchId`
515 /// * `symbol` + `orderId`
516 /// * `symbol` + `orderId` + `fromPreventedMatchId` (`limit` will default to 500)
517 /// * `symbol` + `orderId` + `fromPreventedMatchId` + `limit`
518 /// Weight: Case | Weight
519 /// ---- | -----
520 /// If `symbol` is invalid | 2
521 /// Querying by `preventedMatchId` | 2
522 /// Querying by `orderId` | 20
523 ///
524 /// # Arguments
525 ///
526 /// - `params`: [`MyPreventedMatchesParams`]
527 /// The parameters for this operation.
528 ///
529 /// # Returns
530 ///
531 /// [`RestApiResponse<Vec<models::MyPreventedMatchesResponseInner>>`] on success.
532 ///
533 /// # Errors
534 ///
535 /// This function will return an [`anyhow::Error`] if:
536 /// - the HTTP request fails
537 /// - any parameter is invalid
538 /// - the response cannot be parsed
539 /// - or one of the following occurs:
540 /// - `RequiredError`
541 /// - `ConnectorClientError`
542 /// - `UnauthorizedError`
543 /// - `ForbiddenError`
544 /// - `TooManyRequestsError`
545 /// - `RateLimitBanError`
546 /// - `ServerError`
547 /// - `NotFoundError`
548 /// - `NetworkError`
549 /// - `BadRequestError`
550 ///
551 ///
552 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-prevented-matches-user_data).
553 ///
554 pub async fn my_prevented_matches(
555 &self,
556 params: MyPreventedMatchesParams,
557 ) -> anyhow::Result<RestApiResponse<Vec<models::MyPreventedMatchesResponseInner>>> {
558 self.account_api_client.my_prevented_matches(params).await
559 }
560
561 /// Account trade list
562 ///
563 /// Get trades for a specific account and symbol.
564 /// Weight: Condition| Weight|
565 /// ---| ---
566 /// |Without orderId|20|
567 /// |With orderId|5|
568 ///
569 /// # Arguments
570 ///
571 /// - `params`: [`MyTradesParams`]
572 /// The parameters for this operation.
573 ///
574 /// # Returns
575 ///
576 /// [`RestApiResponse<Vec<models::MyTradesResponseInner>>`] on success.
577 ///
578 /// # Errors
579 ///
580 /// This function will return an [`anyhow::Error`] if:
581 /// - the HTTP request fails
582 /// - any parameter is invalid
583 /// - the response cannot be parsed
584 /// - or one of the following occurs:
585 /// - `RequiredError`
586 /// - `ConnectorClientError`
587 /// - `UnauthorizedError`
588 /// - `ForbiddenError`
589 /// - `TooManyRequestsError`
590 /// - `RateLimitBanError`
591 /// - `ServerError`
592 /// - `NotFoundError`
593 /// - `NetworkError`
594 /// - `BadRequestError`
595 ///
596 ///
597 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-trade-list-user_data).
598 ///
599 pub async fn my_trades(
600 &self,
601 params: MyTradesParams,
602 ) -> anyhow::Result<RestApiResponse<Vec<models::MyTradesResponseInner>>> {
603 self.account_api_client.my_trades(params).await
604 }
605
606 /// Query Open Order lists
607 ///
608 ///
609 /// Weight: 6
610 ///
611 /// # Arguments
612 ///
613 /// - `params`: [`OpenOrderListParams`]
614 /// The parameters for this operation.
615 ///
616 /// # Returns
617 ///
618 /// [`RestApiResponse<Vec<models::OpenOrderListResponseInner>>`] on success.
619 ///
620 /// # Errors
621 ///
622 /// This function will return an [`anyhow::Error`] if:
623 /// - the HTTP request fails
624 /// - any parameter is invalid
625 /// - the response cannot be parsed
626 /// - or one of the following occurs:
627 /// - `RequiredError`
628 /// - `ConnectorClientError`
629 /// - `UnauthorizedError`
630 /// - `ForbiddenError`
631 /// - `TooManyRequestsError`
632 /// - `RateLimitBanError`
633 /// - `ServerError`
634 /// - `NotFoundError`
635 /// - `NetworkError`
636 /// - `BadRequestError`
637 ///
638 ///
639 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-open-order-lists-user_data).
640 ///
641 pub async fn open_order_list(
642 &self,
643 params: OpenOrderListParams,
644 ) -> anyhow::Result<RestApiResponse<Vec<models::OpenOrderListResponseInner>>> {
645 self.account_api_client.open_order_list(params).await
646 }
647
648 /// Query Order Amendments
649 ///
650 /// Queries all amendments of a single order.
651 /// Weight: 4
652 ///
653 /// # Arguments
654 ///
655 /// - `params`: [`OrderAmendmentsParams`]
656 /// The parameters for this operation.
657 ///
658 /// # Returns
659 ///
660 /// [`RestApiResponse<Vec<models::OrderAmendmentsResponseInner>>`] on success.
661 ///
662 /// # Errors
663 ///
664 /// This function will return an [`anyhow::Error`] if:
665 /// - the HTTP request fails
666 /// - any parameter is invalid
667 /// - the response cannot be parsed
668 /// - or one of the following occurs:
669 /// - `RequiredError`
670 /// - `ConnectorClientError`
671 /// - `UnauthorizedError`
672 /// - `ForbiddenError`
673 /// - `TooManyRequestsError`
674 /// - `RateLimitBanError`
675 /// - `ServerError`
676 /// - `NotFoundError`
677 /// - `NetworkError`
678 /// - `BadRequestError`
679 ///
680 ///
681 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-order-amendments-user_data).
682 ///
683 pub async fn order_amendments(
684 &self,
685 params: OrderAmendmentsParams,
686 ) -> anyhow::Result<RestApiResponse<Vec<models::OrderAmendmentsResponseInner>>> {
687 self.account_api_client.order_amendments(params).await
688 }
689
690 /// Query Unfilled Order Count
691 ///
692 /// Displays the user's unfilled order count for all intervals.
693 /// Weight: 40
694 ///
695 /// # Arguments
696 ///
697 /// - `params`: [`RateLimitOrderParams`]
698 /// The parameters for this operation.
699 ///
700 /// # Returns
701 ///
702 /// [`RestApiResponse<Vec<models::RateLimitOrderResponseInner>>`] on success.
703 ///
704 /// # Errors
705 ///
706 /// This function will return an [`anyhow::Error`] if:
707 /// - the HTTP request fails
708 /// - any parameter is invalid
709 /// - the response cannot be parsed
710 /// - or one of the following occurs:
711 /// - `RequiredError`
712 /// - `ConnectorClientError`
713 /// - `UnauthorizedError`
714 /// - `ForbiddenError`
715 /// - `TooManyRequestsError`
716 /// - `RateLimitBanError`
717 /// - `ServerError`
718 /// - `NotFoundError`
719 /// - `NetworkError`
720 /// - `BadRequestError`
721 ///
722 ///
723 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#query-unfilled-order-count-user_data).
724 ///
725 pub async fn rate_limit_order(
726 &self,
727 params: RateLimitOrderParams,
728 ) -> anyhow::Result<RestApiResponse<Vec<models::RateLimitOrderResponseInner>>> {
729 self.account_api_client.rate_limit_order(params).await
730 }
731
732 /// Exchange information
733 ///
734 /// Current exchange trading rules and symbol information
735 /// Weight: 20
736 ///
737 /// # Arguments
738 ///
739 /// - `params`: [`ExchangeInfoParams`]
740 /// The parameters for this operation.
741 ///
742 /// # Returns
743 ///
744 /// [`RestApiResponse<models::ExchangeInfoResponse>`] on success.
745 ///
746 /// # Errors
747 ///
748 /// This function will return an [`anyhow::Error`] if:
749 /// - the HTTP request fails
750 /// - any parameter is invalid
751 /// - the response cannot be parsed
752 /// - or one of the following occurs:
753 /// - `RequiredError`
754 /// - `ConnectorClientError`
755 /// - `UnauthorizedError`
756 /// - `ForbiddenError`
757 /// - `TooManyRequestsError`
758 /// - `RateLimitBanError`
759 /// - `ServerError`
760 /// - `NotFoundError`
761 /// - `NetworkError`
762 /// - `BadRequestError`
763 ///
764 ///
765 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#exchange-information).
766 ///
767 pub async fn exchange_info(
768 &self,
769 params: ExchangeInfoParams,
770 ) -> anyhow::Result<RestApiResponse<models::ExchangeInfoResponse>> {
771 self.general_api_client.exchange_info(params).await
772 }
773
774 /// Query Execution Rules
775 ///
776 ///
777 /// Weight: Parameter | Weight|
778 /// --- | ---
779 /// `symbol` | 2
780 /// `symbols` | 2 for each `symbol`, capped at a max of 40|
781 /// `symbolStatus` |40|
782 /// None |40|
783 ///
784 /// # Arguments
785 ///
786 /// - `params`: [`ExecutionRulesParams`]
787 /// The parameters for this operation.
788 ///
789 /// # Returns
790 ///
791 /// [`RestApiResponse<models::ExecutionRulesResponse>`] on success.
792 ///
793 /// # Errors
794 ///
795 /// This function will return an [`anyhow::Error`] if:
796 /// - the HTTP request fails
797 /// - any parameter is invalid
798 /// - the response cannot be parsed
799 /// - or one of the following occurs:
800 /// - `RequiredError`
801 /// - `ConnectorClientError`
802 /// - `UnauthorizedError`
803 /// - `ForbiddenError`
804 /// - `TooManyRequestsError`
805 /// - `RateLimitBanError`
806 /// - `ServerError`
807 /// - `NotFoundError`
808 /// - `NetworkError`
809 /// - `BadRequestError`
810 ///
811 ///
812 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#query-execution-rules).
813 ///
814 pub async fn execution_rules(
815 &self,
816 params: ExecutionRulesParams,
817 ) -> anyhow::Result<RestApiResponse<models::ExecutionRulesResponse>> {
818 self.general_api_client.execution_rules(params).await
819 }
820
821 /// Test connectivity
822 ///
823 /// Test connectivity to the Rest API.
824 /// Weight: 1
825 ///
826 /// # Arguments
827 ///
828 /// - `params`: [`PingParams`]
829 /// The parameters for this operation.
830 ///
831 /// # Returns
832 ///
833 /// [`RestApiResponse<Value>`] on success.
834 ///
835 /// # Errors
836 ///
837 /// This function will return an [`anyhow::Error`] if:
838 /// - the HTTP request fails
839 /// - any parameter is invalid
840 /// - the response cannot be parsed
841 /// - or one of the following occurs:
842 /// - `RequiredError`
843 /// - `ConnectorClientError`
844 /// - `UnauthorizedError`
845 /// - `ForbiddenError`
846 /// - `TooManyRequestsError`
847 /// - `RateLimitBanError`
848 /// - `ServerError`
849 /// - `NotFoundError`
850 /// - `NetworkError`
851 /// - `BadRequestError`
852 ///
853 ///
854 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#test-connectivity).
855 ///
856 pub async fn ping(&self) -> anyhow::Result<RestApiResponse<Value>> {
857 self.general_api_client.ping().await
858 }
859
860 /// Check server time
861 ///
862 /// Test connectivity to the Rest API and get the current server time.
863 /// Weight: 1
864 ///
865 /// # Arguments
866 ///
867 /// - `params`: [`TimeParams`]
868 /// The parameters for this operation.
869 ///
870 /// # Returns
871 ///
872 /// [`RestApiResponse<models::TimeResponse>`] on success.
873 ///
874 /// # Errors
875 ///
876 /// This function will return an [`anyhow::Error`] if:
877 /// - the HTTP request fails
878 /// - any parameter is invalid
879 /// - the response cannot be parsed
880 /// - or one of the following occurs:
881 /// - `RequiredError`
882 /// - `ConnectorClientError`
883 /// - `UnauthorizedError`
884 /// - `ForbiddenError`
885 /// - `TooManyRequestsError`
886 /// - `RateLimitBanError`
887 /// - `ServerError`
888 /// - `NotFoundError`
889 /// - `NetworkError`
890 /// - `BadRequestError`
891 ///
892 ///
893 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#check-server-time).
894 ///
895 pub async fn time(&self) -> anyhow::Result<RestApiResponse<models::TimeResponse>> {
896 self.general_api_client.time().await
897 }
898
899 /// Compressed/Aggregate trades list
900 ///
901 /// Get compressed, aggregate trades. Trades that fill at the time, from the same taker order, with the same price will have the quantity aggregated.
902 /// Weight: 4
903 ///
904 /// # Arguments
905 ///
906 /// - `params`: [`AggTradesParams`]
907 /// The parameters for this operation.
908 ///
909 /// # Returns
910 ///
911 /// [`RestApiResponse<Vec<models::AggTradesResponseInner>>`] on success.
912 ///
913 /// # Errors
914 ///
915 /// This function will return an [`anyhow::Error`] if:
916 /// - the HTTP request fails
917 /// - any parameter is invalid
918 /// - the response cannot be parsed
919 /// - or one of the following occurs:
920 /// - `RequiredError`
921 /// - `ConnectorClientError`
922 /// - `UnauthorizedError`
923 /// - `ForbiddenError`
924 /// - `TooManyRequestsError`
925 /// - `RateLimitBanError`
926 /// - `ServerError`
927 /// - `NotFoundError`
928 /// - `NetworkError`
929 /// - `BadRequestError`
930 ///
931 ///
932 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#compressedaggregate-trades-list).
933 ///
934 pub async fn agg_trades(
935 &self,
936 params: AggTradesParams,
937 ) -> anyhow::Result<RestApiResponse<Vec<models::AggTradesResponseInner>>> {
938 self.market_api_client.agg_trades(params).await
939 }
940
941 /// Current average price
942 ///
943 /// Current average price for a symbol.
944 /// Weight: 2
945 ///
946 /// # Arguments
947 ///
948 /// - `params`: [`AvgPriceParams`]
949 /// The parameters for this operation.
950 ///
951 /// # Returns
952 ///
953 /// [`RestApiResponse<models::AvgPriceResponse>`] on success.
954 ///
955 /// # Errors
956 ///
957 /// This function will return an [`anyhow::Error`] if:
958 /// - the HTTP request fails
959 /// - any parameter is invalid
960 /// - the response cannot be parsed
961 /// - or one of the following occurs:
962 /// - `RequiredError`
963 /// - `ConnectorClientError`
964 /// - `UnauthorizedError`
965 /// - `ForbiddenError`
966 /// - `TooManyRequestsError`
967 /// - `RateLimitBanError`
968 /// - `ServerError`
969 /// - `NotFoundError`
970 /// - `NetworkError`
971 /// - `BadRequestError`
972 ///
973 ///
974 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#current-average-price).
975 ///
976 pub async fn avg_price(
977 &self,
978 params: AvgPriceParams,
979 ) -> anyhow::Result<RestApiResponse<models::AvgPriceResponse>> {
980 self.market_api_client.avg_price(params).await
981 }
982
983 /// Order book
984 ///
985 ///
986 /// Weight: Adjusted based on the limit:
987 ///
988 /// |Limit|Request Weight
989 /// ------|-------
990 /// 1-100| 5
991 /// 101-500| 25
992 /// 501-1000| 50
993 /// 1001-5000| 250
994 ///
995 /// # Arguments
996 ///
997 /// - `params`: [`DepthParams`]
998 /// The parameters for this operation.
999 ///
1000 /// # Returns
1001 ///
1002 /// [`RestApiResponse<models::DepthResponse>`] on success.
1003 ///
1004 /// # Errors
1005 ///
1006 /// This function will return an [`anyhow::Error`] if:
1007 /// - the HTTP request fails
1008 /// - any parameter is invalid
1009 /// - the response cannot be parsed
1010 /// - or one of the following occurs:
1011 /// - `RequiredError`
1012 /// - `ConnectorClientError`
1013 /// - `UnauthorizedError`
1014 /// - `ForbiddenError`
1015 /// - `TooManyRequestsError`
1016 /// - `RateLimitBanError`
1017 /// - `ServerError`
1018 /// - `NotFoundError`
1019 /// - `NetworkError`
1020 /// - `BadRequestError`
1021 ///
1022 ///
1023 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#order-book).
1024 ///
1025 pub async fn depth(
1026 &self,
1027 params: DepthParams,
1028 ) -> anyhow::Result<RestApiResponse<models::DepthResponse>> {
1029 self.market_api_client.depth(params).await
1030 }
1031
1032 /// Recent trades list
1033 ///
1034 /// Get recent trades.
1035 /// Weight: 25
1036 ///
1037 /// # Arguments
1038 ///
1039 /// - `params`: [`GetTradesParams`]
1040 /// The parameters for this operation.
1041 ///
1042 /// # Returns
1043 ///
1044 /// [`RestApiResponse<Vec<models::HistoricalTradesResponseInner>>`] on success.
1045 ///
1046 /// # Errors
1047 ///
1048 /// This function will return an [`anyhow::Error`] if:
1049 /// - the HTTP request fails
1050 /// - any parameter is invalid
1051 /// - the response cannot be parsed
1052 /// - or one of the following occurs:
1053 /// - `RequiredError`
1054 /// - `ConnectorClientError`
1055 /// - `UnauthorizedError`
1056 /// - `ForbiddenError`
1057 /// - `TooManyRequestsError`
1058 /// - `RateLimitBanError`
1059 /// - `ServerError`
1060 /// - `NotFoundError`
1061 /// - `NetworkError`
1062 /// - `BadRequestError`
1063 ///
1064 ///
1065 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#recent-trades-list).
1066 ///
1067 pub async fn get_trades(
1068 &self,
1069 params: GetTradesParams,
1070 ) -> anyhow::Result<RestApiResponse<Vec<models::HistoricalTradesResponseInner>>> {
1071 self.market_api_client.get_trades(params).await
1072 }
1073
1074 /// Historical Block Trades
1075 ///
1076 /// Get block trades.
1077 /// Weight: 25
1078 ///
1079 /// # Arguments
1080 ///
1081 /// - `params`: [`HistoricalBlockTradesParams`]
1082 /// The parameters for this operation.
1083 ///
1084 /// # Returns
1085 ///
1086 /// [`RestApiResponse<Vec<models::HistoricalBlockTradesResponseInner>>`] on success.
1087 ///
1088 /// # Errors
1089 ///
1090 /// This function will return an [`anyhow::Error`] if:
1091 /// - the HTTP request fails
1092 /// - any parameter is invalid
1093 /// - the response cannot be parsed
1094 /// - or one of the following occurs:
1095 /// - `RequiredError`
1096 /// - `ConnectorClientError`
1097 /// - `UnauthorizedError`
1098 /// - `ForbiddenError`
1099 /// - `TooManyRequestsError`
1100 /// - `RateLimitBanError`
1101 /// - `ServerError`
1102 /// - `NotFoundError`
1103 /// - `NetworkError`
1104 /// - `BadRequestError`
1105 ///
1106 ///
1107 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#historical-block-trades).
1108 ///
1109 pub async fn historical_block_trades(
1110 &self,
1111 params: HistoricalBlockTradesParams,
1112 ) -> anyhow::Result<RestApiResponse<Vec<models::HistoricalBlockTradesResponseInner>>> {
1113 self.market_api_client.historical_block_trades(params).await
1114 }
1115
1116 /// Old trade lookup
1117 ///
1118 /// Get older trades.
1119 /// Weight: 25
1120 ///
1121 /// # Arguments
1122 ///
1123 /// - `params`: [`HistoricalTradesParams`]
1124 /// The parameters for this operation.
1125 ///
1126 /// # Returns
1127 ///
1128 /// [`RestApiResponse<Vec<models::HistoricalTradesResponseInner>>`] on success.
1129 ///
1130 /// # Errors
1131 ///
1132 /// This function will return an [`anyhow::Error`] if:
1133 /// - the HTTP request fails
1134 /// - any parameter is invalid
1135 /// - the response cannot be parsed
1136 /// - or one of the following occurs:
1137 /// - `RequiredError`
1138 /// - `ConnectorClientError`
1139 /// - `UnauthorizedError`
1140 /// - `ForbiddenError`
1141 /// - `TooManyRequestsError`
1142 /// - `RateLimitBanError`
1143 /// - `ServerError`
1144 /// - `NotFoundError`
1145 /// - `NetworkError`
1146 /// - `BadRequestError`
1147 ///
1148 ///
1149 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#old-trade-lookup).
1150 ///
1151 pub async fn historical_trades(
1152 &self,
1153 params: HistoricalTradesParams,
1154 ) -> anyhow::Result<RestApiResponse<Vec<models::HistoricalTradesResponseInner>>> {
1155 self.market_api_client.historical_trades(params).await
1156 }
1157
1158 /// Kline/Candlestick data
1159 ///
1160 /// Kline/candlestick bars for a symbol.
1161 /// Klines are uniquely identified by their open time.
1162 /// Weight: 2
1163 ///
1164 /// # Arguments
1165 ///
1166 /// - `params`: [`KlinesParams`]
1167 /// The parameters for this operation.
1168 ///
1169 /// # Returns
1170 ///
1171 /// [`RestApiResponse<Vec<Vec<models::KlinesItemInner>>>`] on success.
1172 ///
1173 /// # Errors
1174 ///
1175 /// This function will return an [`anyhow::Error`] if:
1176 /// - the HTTP request fails
1177 /// - any parameter is invalid
1178 /// - the response cannot be parsed
1179 /// - or one of the following occurs:
1180 /// - `RequiredError`
1181 /// - `ConnectorClientError`
1182 /// - `UnauthorizedError`
1183 /// - `ForbiddenError`
1184 /// - `TooManyRequestsError`
1185 /// - `RateLimitBanError`
1186 /// - `ServerError`
1187 /// - `NotFoundError`
1188 /// - `NetworkError`
1189 /// - `BadRequestError`
1190 ///
1191 ///
1192 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#klinecandlestick-data).
1193 ///
1194 pub async fn klines(
1195 &self,
1196 params: KlinesParams,
1197 ) -> anyhow::Result<RestApiResponse<Vec<Vec<models::KlinesItemInner>>>> {
1198 self.market_api_client.klines(params).await
1199 }
1200
1201 /// Query Reference Price
1202 ///
1203 ///
1204 /// Weight: 2
1205 ///
1206 /// # Arguments
1207 ///
1208 /// - `params`: [`ReferencePriceParams`]
1209 /// The parameters for this operation.
1210 ///
1211 /// # Returns
1212 ///
1213 /// [`RestApiResponse<models::ReferencePriceResponse>`] on success.
1214 ///
1215 /// # Errors
1216 ///
1217 /// This function will return an [`anyhow::Error`] if:
1218 /// - the HTTP request fails
1219 /// - any parameter is invalid
1220 /// - the response cannot be parsed
1221 /// - or one of the following occurs:
1222 /// - `RequiredError`
1223 /// - `ConnectorClientError`
1224 /// - `UnauthorizedError`
1225 /// - `ForbiddenError`
1226 /// - `TooManyRequestsError`
1227 /// - `RateLimitBanError`
1228 /// - `ServerError`
1229 /// - `NotFoundError`
1230 /// - `NetworkError`
1231 /// - `BadRequestError`
1232 ///
1233 ///
1234 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#query-reference-price).
1235 ///
1236 pub async fn reference_price(
1237 &self,
1238 params: ReferencePriceParams,
1239 ) -> anyhow::Result<RestApiResponse<models::ReferencePriceResponse>> {
1240 self.market_api_client.reference_price(params).await
1241 }
1242
1243 /// Query Reference Price Calculation
1244 ///
1245 /// Describes how reference price is calculated for a given symbol.
1246 /// Weight: 2
1247 ///
1248 /// # Arguments
1249 ///
1250 /// - `params`: [`ReferencePriceCalculationParams`]
1251 /// The parameters for this operation.
1252 ///
1253 /// # Returns
1254 ///
1255 /// [`RestApiResponse<models::ReferencePriceCalculationResponse>`] on success.
1256 ///
1257 /// # Errors
1258 ///
1259 /// This function will return an [`anyhow::Error`] if:
1260 /// - the HTTP request fails
1261 /// - any parameter is invalid
1262 /// - the response cannot be parsed
1263 /// - or one of the following occurs:
1264 /// - `RequiredError`
1265 /// - `ConnectorClientError`
1266 /// - `UnauthorizedError`
1267 /// - `ForbiddenError`
1268 /// - `TooManyRequestsError`
1269 /// - `RateLimitBanError`
1270 /// - `ServerError`
1271 /// - `NotFoundError`
1272 /// - `NetworkError`
1273 /// - `BadRequestError`
1274 ///
1275 ///
1276 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#query-reference-price-calculation).
1277 ///
1278 pub async fn reference_price_calculation(
1279 &self,
1280 params: ReferencePriceCalculationParams,
1281 ) -> anyhow::Result<RestApiResponse<models::ReferencePriceCalculationResponse>> {
1282 self.market_api_client
1283 .reference_price_calculation(params)
1284 .await
1285 }
1286
1287 /// Rolling window price change statistics
1288 ///
1289 ///
1290 /// Weight: 4 for each requested <tt>symbol</tt> regardless of <tt>windowSize</tt>. <br/><br/> The weight for this request will cap at 200 once the number of `symbols` in the request is more than 50.
1291 ///
1292 /// # Arguments
1293 ///
1294 /// - `params`: [`TickerParams`]
1295 /// The parameters for this operation.
1296 ///
1297 /// # Returns
1298 ///
1299 /// [`RestApiResponse<models::TickerResponse>`] on success.
1300 ///
1301 /// # Errors
1302 ///
1303 /// This function will return an [`anyhow::Error`] if:
1304 /// - the HTTP request fails
1305 /// - any parameter is invalid
1306 /// - the response cannot be parsed
1307 /// - or one of the following occurs:
1308 /// - `RequiredError`
1309 /// - `ConnectorClientError`
1310 /// - `UnauthorizedError`
1311 /// - `ForbiddenError`
1312 /// - `TooManyRequestsError`
1313 /// - `RateLimitBanError`
1314 /// - `ServerError`
1315 /// - `NotFoundError`
1316 /// - `NetworkError`
1317 /// - `BadRequestError`
1318 ///
1319 ///
1320 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#rolling-window-price-change-statistics).
1321 ///
1322 pub async fn ticker(
1323 &self,
1324 params: TickerParams,
1325 ) -> anyhow::Result<RestApiResponse<models::TickerResponse>> {
1326 self.market_api_client.ticker(params).await
1327 }
1328
1329 /// 24hr ticker price change statistics
1330 ///
1331 /// 24 hour rolling window price change statistics. **Careful** when accessing this with no symbol.
1332 /// Weight: <table>
1333 /// <thead>
1334 /// <tr>
1335 /// <th>Parameter</th>
1336 /// <th>Symbols Provided</th>
1337 /// <th>Weight</th>
1338 /// </tr>
1339 /// </thead>
1340 /// <tbody>
1341 /// <tr>
1342 /// <td rowspan="2">symbol</td>
1343 /// <td>1</td>
1344 /// <td>2</td>
1345 /// </tr>
1346 /// <tr>
1347 /// <td>symbol parameter is omitted</td>
1348 /// <td>80</td>
1349 /// </tr>
1350 /// <tr>
1351 /// <td rowspan="4">symbols</td>
1352 /// <td>1-20</td>
1353 /// <td>2</td>
1354 /// </tr>
1355 /// <tr>
1356 /// <td>21-100</td>
1357 /// <td>40</td>
1358 /// </tr>
1359 /// <tr>
1360 /// <td>101 or more</td>
1361 /// <td>80</td>
1362 /// </tr>
1363 /// <tr>
1364 /// <td>symbols parameter is omitted</td>
1365 /// <td>80</td>
1366 /// </tr>
1367 /// </tbody>
1368 /// </table>
1369 ///
1370 /// # Arguments
1371 ///
1372 /// - `params`: [`Ticker24hrParams`]
1373 /// The parameters for this operation.
1374 ///
1375 /// # Returns
1376 ///
1377 /// [`RestApiResponse<models::Ticker24hrResponse>`] on success.
1378 ///
1379 /// # Errors
1380 ///
1381 /// This function will return an [`anyhow::Error`] if:
1382 /// - the HTTP request fails
1383 /// - any parameter is invalid
1384 /// - the response cannot be parsed
1385 /// - or one of the following occurs:
1386 /// - `RequiredError`
1387 /// - `ConnectorClientError`
1388 /// - `UnauthorizedError`
1389 /// - `ForbiddenError`
1390 /// - `TooManyRequestsError`
1391 /// - `RateLimitBanError`
1392 /// - `ServerError`
1393 /// - `NotFoundError`
1394 /// - `NetworkError`
1395 /// - `BadRequestError`
1396 ///
1397 ///
1398 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#24hr-ticker-price-change-statistics).
1399 ///
1400 pub async fn ticker24hr(
1401 &self,
1402 params: Ticker24hrParams,
1403 ) -> anyhow::Result<RestApiResponse<models::Ticker24hrResponse>> {
1404 self.market_api_client.ticker24hr(params).await
1405 }
1406
1407 /// Symbol order book ticker
1408 ///
1409 /// Best price/qty on the order book for a symbol or symbols.
1410 /// Weight: <table>
1411 /// <thead>
1412 /// <tr>
1413 /// <th>Parameter</th>
1414 /// <th>Symbols Provided</th>
1415 /// <th>Weight</th>
1416 /// </tr>
1417 /// </thead>
1418 /// <tbody>
1419 /// <tr>
1420 /// <td rowspan="2">symbol</td>
1421 /// <td>1</td>
1422 /// <td>2</td>
1423 /// </tr>
1424 /// <tr>
1425 /// <td>symbol parameter is omitted</td>
1426 /// <td>4</td>
1427 /// </tr>
1428 /// <tr>
1429 /// <td>symbols</td>
1430 /// <td>Any</td>
1431 /// <td>4</td>
1432 /// </tr>
1433 /// </tbody>
1434 /// </table>
1435 ///
1436 /// # Arguments
1437 ///
1438 /// - `params`: [`TickerBookTickerParams`]
1439 /// The parameters for this operation.
1440 ///
1441 /// # Returns
1442 ///
1443 /// [`RestApiResponse<models::TickerBookTickerResponse>`] on success.
1444 ///
1445 /// # Errors
1446 ///
1447 /// This function will return an [`anyhow::Error`] if:
1448 /// - the HTTP request fails
1449 /// - any parameter is invalid
1450 /// - the response cannot be parsed
1451 /// - or one of the following occurs:
1452 /// - `RequiredError`
1453 /// - `ConnectorClientError`
1454 /// - `UnauthorizedError`
1455 /// - `ForbiddenError`
1456 /// - `TooManyRequestsError`
1457 /// - `RateLimitBanError`
1458 /// - `ServerError`
1459 /// - `NotFoundError`
1460 /// - `NetworkError`
1461 /// - `BadRequestError`
1462 ///
1463 ///
1464 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#symbol-order-book-ticker).
1465 ///
1466 pub async fn ticker_book_ticker(
1467 &self,
1468 params: TickerBookTickerParams,
1469 ) -> anyhow::Result<RestApiResponse<models::TickerBookTickerResponse>> {
1470 self.market_api_client.ticker_book_ticker(params).await
1471 }
1472
1473 /// Symbol price ticker
1474 ///
1475 /// Latest price for a symbol or symbols.
1476 /// Weight: <table>
1477 /// <thead>
1478 /// <tr>
1479 /// <th>Parameter</th>
1480 /// <th>Symbols Provided</th>
1481 /// <th>Weight</th>
1482 /// </tr>
1483 /// </thead>
1484 /// <tbody>
1485 /// <tr>
1486 /// <td rowspan="2">symbol</td>
1487 /// <td>1</td>
1488 /// <td>2</td>
1489 /// </tr>
1490 /// <tr>
1491 /// <td>symbol parameter is omitted</td>
1492 /// <td>4</td>
1493 /// </tr>
1494 /// <tr>
1495 /// <td>symbols</td>
1496 /// <td>Any</td>
1497 /// <td>4</td>
1498 /// </tr>
1499 /// </tbody>
1500 /// </table>
1501 ///
1502 /// # Arguments
1503 ///
1504 /// - `params`: [`TickerPriceParams`]
1505 /// The parameters for this operation.
1506 ///
1507 /// # Returns
1508 ///
1509 /// [`RestApiResponse<models::TickerPriceResponse>`] on success.
1510 ///
1511 /// # Errors
1512 ///
1513 /// This function will return an [`anyhow::Error`] if:
1514 /// - the HTTP request fails
1515 /// - any parameter is invalid
1516 /// - the response cannot be parsed
1517 /// - or one of the following occurs:
1518 /// - `RequiredError`
1519 /// - `ConnectorClientError`
1520 /// - `UnauthorizedError`
1521 /// - `ForbiddenError`
1522 /// - `TooManyRequestsError`
1523 /// - `RateLimitBanError`
1524 /// - `ServerError`
1525 /// - `NotFoundError`
1526 /// - `NetworkError`
1527 /// - `BadRequestError`
1528 ///
1529 ///
1530 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#symbol-price-ticker).
1531 ///
1532 pub async fn ticker_price(
1533 &self,
1534 params: TickerPriceParams,
1535 ) -> anyhow::Result<RestApiResponse<models::TickerPriceResponse>> {
1536 self.market_api_client.ticker_price(params).await
1537 }
1538
1539 /// Trading Day Ticker
1540 ///
1541 /// Price change statistics for a trading day.
1542 /// Weight: 4 for each requested <tt>symbol</tt>. <br/><br/> The weight for this request will cap at 200 once the number of `symbols` in the request is more than 50.
1543 ///
1544 /// # Arguments
1545 ///
1546 /// - `params`: [`TickerTradingDayParams`]
1547 /// The parameters for this operation.
1548 ///
1549 /// # Returns
1550 ///
1551 /// [`RestApiResponse<models::TickerTradingDayResponse>`] on success.
1552 ///
1553 /// # Errors
1554 ///
1555 /// This function will return an [`anyhow::Error`] if:
1556 /// - the HTTP request fails
1557 /// - any parameter is invalid
1558 /// - the response cannot be parsed
1559 /// - or one of the following occurs:
1560 /// - `RequiredError`
1561 /// - `ConnectorClientError`
1562 /// - `UnauthorizedError`
1563 /// - `ForbiddenError`
1564 /// - `TooManyRequestsError`
1565 /// - `RateLimitBanError`
1566 /// - `ServerError`
1567 /// - `NotFoundError`
1568 /// - `NetworkError`
1569 /// - `BadRequestError`
1570 ///
1571 ///
1572 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#trading-day-ticker).
1573 ///
1574 pub async fn ticker_trading_day(
1575 &self,
1576 params: TickerTradingDayParams,
1577 ) -> anyhow::Result<RestApiResponse<models::TickerTradingDayResponse>> {
1578 self.market_api_client.ticker_trading_day(params).await
1579 }
1580
1581 /// `UIKlines`
1582 ///
1583 /// The request is similar to klines having the same parameters and response.
1584 ///
1585 /// `uiKlines` return modified kline data, optimized for presentation of candlestick charts.
1586 /// Weight: 2
1587 ///
1588 /// # Arguments
1589 ///
1590 /// - `params`: [`UiKlinesParams`]
1591 /// The parameters for this operation.
1592 ///
1593 /// # Returns
1594 ///
1595 /// [`RestApiResponse<Vec<Vec<models::KlinesItemInner>>>`] on success.
1596 ///
1597 /// # Errors
1598 ///
1599 /// This function will return an [`anyhow::Error`] if:
1600 /// - the HTTP request fails
1601 /// - any parameter is invalid
1602 /// - the response cannot be parsed
1603 /// - or one of the following occurs:
1604 /// - `RequiredError`
1605 /// - `ConnectorClientError`
1606 /// - `UnauthorizedError`
1607 /// - `ForbiddenError`
1608 /// - `TooManyRequestsError`
1609 /// - `RateLimitBanError`
1610 /// - `ServerError`
1611 /// - `NotFoundError`
1612 /// - `NetworkError`
1613 /// - `BadRequestError`
1614 ///
1615 ///
1616 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#uiklines).
1617 ///
1618 pub async fn ui_klines(
1619 &self,
1620 params: UiKlinesParams,
1621 ) -> anyhow::Result<RestApiResponse<Vec<Vec<models::KlinesItemInner>>>> {
1622 self.market_api_client.ui_klines(params).await
1623 }
1624
1625 /// Cancel All Open Orders on a Symbol
1626 ///
1627 /// Cancels all active orders on a symbol.
1628 /// This includes orders that are part of an order list.
1629 /// Weight: 1
1630 ///
1631 /// # Arguments
1632 ///
1633 /// - `params`: [`DeleteOpenOrdersParams`]
1634 /// The parameters for this operation.
1635 ///
1636 /// # Returns
1637 ///
1638 /// [`RestApiResponse<Vec<models::DeleteOpenOrdersResponseInner>>`] on success.
1639 ///
1640 /// # Errors
1641 ///
1642 /// This function will return an [`anyhow::Error`] if:
1643 /// - the HTTP request fails
1644 /// - any parameter is invalid
1645 /// - the response cannot be parsed
1646 /// - or one of the following occurs:
1647 /// - `RequiredError`
1648 /// - `ConnectorClientError`
1649 /// - `UnauthorizedError`
1650 /// - `ForbiddenError`
1651 /// - `TooManyRequestsError`
1652 /// - `RateLimitBanError`
1653 /// - `ServerError`
1654 /// - `NotFoundError`
1655 /// - `NetworkError`
1656 /// - `BadRequestError`
1657 ///
1658 ///
1659 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#cancel-all-open-orders-on-a-symbol-trade).
1660 ///
1661 pub async fn delete_open_orders(
1662 &self,
1663 params: DeleteOpenOrdersParams,
1664 ) -> anyhow::Result<RestApiResponse<Vec<models::DeleteOpenOrdersResponseInner>>> {
1665 self.trade_api_client.delete_open_orders(params).await
1666 }
1667
1668 /// Cancel order
1669 ///
1670 /// Cancel an active order.
1671 /// Weight: 1
1672 ///
1673 /// # Arguments
1674 ///
1675 /// - `params`: [`DeleteOrderParams`]
1676 /// The parameters for this operation.
1677 ///
1678 /// # Returns
1679 ///
1680 /// [`RestApiResponse<models::DeleteOrderResponse>`] on success.
1681 ///
1682 /// # Errors
1683 ///
1684 /// This function will return an [`anyhow::Error`] if:
1685 /// - the HTTP request fails
1686 /// - any parameter is invalid
1687 /// - the response cannot be parsed
1688 /// - or one of the following occurs:
1689 /// - `RequiredError`
1690 /// - `ConnectorClientError`
1691 /// - `UnauthorizedError`
1692 /// - `ForbiddenError`
1693 /// - `TooManyRequestsError`
1694 /// - `RateLimitBanError`
1695 /// - `ServerError`
1696 /// - `NotFoundError`
1697 /// - `NetworkError`
1698 /// - `BadRequestError`
1699 ///
1700 ///
1701 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#cancel-order-trade).
1702 ///
1703 pub async fn delete_order(
1704 &self,
1705 params: DeleteOrderParams,
1706 ) -> anyhow::Result<RestApiResponse<models::DeleteOrderResponse>> {
1707 self.trade_api_client.delete_order(params).await
1708 }
1709
1710 /// Cancel Order list
1711 ///
1712 /// Cancel an entire Order list
1713 /// Weight: 1
1714 ///
1715 /// # Arguments
1716 ///
1717 /// - `params`: [`DeleteOrderListParams`]
1718 /// The parameters for this operation.
1719 ///
1720 /// # Returns
1721 ///
1722 /// [`RestApiResponse<models::DeleteOrderListResponse>`] on success.
1723 ///
1724 /// # Errors
1725 ///
1726 /// This function will return an [`anyhow::Error`] if:
1727 /// - the HTTP request fails
1728 /// - any parameter is invalid
1729 /// - the response cannot be parsed
1730 /// - or one of the following occurs:
1731 /// - `RequiredError`
1732 /// - `ConnectorClientError`
1733 /// - `UnauthorizedError`
1734 /// - `ForbiddenError`
1735 /// - `TooManyRequestsError`
1736 /// - `RateLimitBanError`
1737 /// - `ServerError`
1738 /// - `NotFoundError`
1739 /// - `NetworkError`
1740 /// - `BadRequestError`
1741 ///
1742 ///
1743 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#cancel-order-list-trade).
1744 ///
1745 pub async fn delete_order_list(
1746 &self,
1747 params: DeleteOrderListParams,
1748 ) -> anyhow::Result<RestApiResponse<models::DeleteOrderListResponse>> {
1749 self.trade_api_client.delete_order_list(params).await
1750 }
1751
1752 /// New order
1753 ///
1754 /// Send in a new order.
1755 ///
1756 /// This adds 1 order to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
1757 /// Weight: 1
1758 ///
1759 /// # Arguments
1760 ///
1761 /// - `params`: [`NewOrderParams`]
1762 /// The parameters for this operation.
1763 ///
1764 /// # Returns
1765 ///
1766 /// [`RestApiResponse<models::NewOrderResponse>`] on success.
1767 ///
1768 /// # Errors
1769 ///
1770 /// This function will return an [`anyhow::Error`] if:
1771 /// - the HTTP request fails
1772 /// - any parameter is invalid
1773 /// - the response cannot be parsed
1774 /// - or one of the following occurs:
1775 /// - `RequiredError`
1776 /// - `ConnectorClientError`
1777 /// - `UnauthorizedError`
1778 /// - `ForbiddenError`
1779 /// - `TooManyRequestsError`
1780 /// - `RateLimitBanError`
1781 /// - `ServerError`
1782 /// - `NotFoundError`
1783 /// - `NetworkError`
1784 /// - `BadRequestError`
1785 ///
1786 ///
1787 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade).
1788 ///
1789 pub async fn new_order(
1790 &self,
1791 params: NewOrderParams,
1792 ) -> anyhow::Result<RestApiResponse<models::NewOrderResponse>> {
1793 self.trade_api_client.new_order(params).await
1794 }
1795
1796 /// Order Amend Keep Priority
1797 ///
1798 /// Reduce the quantity of an existing open order.
1799 ///
1800 /// This adds 0 orders to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
1801 ///
1802 /// Read [Order Amend Keep Priority FAQ](faqs/order_amend_keep_priority.md) to learn more.
1803 /// Weight: 4
1804 ///
1805 /// # Arguments
1806 ///
1807 /// - `params`: [`OrderAmendKeepPriorityParams`]
1808 /// The parameters for this operation.
1809 ///
1810 /// # Returns
1811 ///
1812 /// [`RestApiResponse<models::OrderAmendKeepPriorityResponse>`] on success.
1813 ///
1814 /// # Errors
1815 ///
1816 /// This function will return an [`anyhow::Error`] if:
1817 /// - the HTTP request fails
1818 /// - any parameter is invalid
1819 /// - the response cannot be parsed
1820 /// - or one of the following occurs:
1821 /// - `RequiredError`
1822 /// - `ConnectorClientError`
1823 /// - `UnauthorizedError`
1824 /// - `ForbiddenError`
1825 /// - `TooManyRequestsError`
1826 /// - `RateLimitBanError`
1827 /// - `ServerError`
1828 /// - `NotFoundError`
1829 /// - `NetworkError`
1830 /// - `BadRequestError`
1831 ///
1832 ///
1833 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#order-amend-keep-priority-trade).
1834 ///
1835 pub async fn order_amend_keep_priority(
1836 &self,
1837 params: OrderAmendKeepPriorityParams,
1838 ) -> anyhow::Result<RestApiResponse<models::OrderAmendKeepPriorityResponse>> {
1839 self.trade_api_client
1840 .order_amend_keep_priority(params)
1841 .await
1842 }
1843
1844 /// Cancel an Existing Order and Send a New Order
1845 ///
1846 /// * Cancels an existing order and places a new order on the same symbol.
1847 /// * Filters and Order Count are evaluated before the processing of the cancellation and order placement occurs.
1848 /// * A new order that was not attempted (i.e. when `newOrderResult: NOT_ATTEMPTED`), will still increase the unfilled order count by 1.
1849 /// * You can only cancel an individual order from an orderList using this endpoint, but the result is the same as canceling the entire orderList.
1850 /// Weight: 1
1851 ///
1852 /// # Arguments
1853 ///
1854 /// - `params`: [`OrderCancelReplaceParams`]
1855 /// The parameters for this operation.
1856 ///
1857 /// # Returns
1858 ///
1859 /// [`RestApiResponse<models::OrderCancelReplaceResponse>`] on success.
1860 ///
1861 /// # Errors
1862 ///
1863 /// This function will return an [`anyhow::Error`] if:
1864 /// - the HTTP request fails
1865 /// - any parameter is invalid
1866 /// - the response cannot be parsed
1867 /// - or one of the following occurs:
1868 /// - `RequiredError`
1869 /// - `ConnectorClientError`
1870 /// - `UnauthorizedError`
1871 /// - `ForbiddenError`
1872 /// - `TooManyRequestsError`
1873 /// - `RateLimitBanError`
1874 /// - `ServerError`
1875 /// - `NotFoundError`
1876 /// - `NetworkError`
1877 /// - `BadRequestError`
1878 ///
1879 ///
1880 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#cancel-an-existing-order-and-send-a-new-order-trade).
1881 ///
1882 pub async fn order_cancel_replace(
1883 &self,
1884 params: OrderCancelReplaceParams,
1885 ) -> anyhow::Result<RestApiResponse<models::OrderCancelReplaceResponse>> {
1886 self.trade_api_client.order_cancel_replace(params).await
1887 }
1888
1889 /// New Order list - OCO
1890 ///
1891 /// Send in an one-cancels-the-other (OCO) pair, where activation of one order immediately cancels the other.
1892 ///
1893 /// * An OCO has 2 orders called the **above order** and **below order**.
1894 /// * One of the orders must be a `LIMIT_MAKER/TAKE_PROFIT/TAKE_PROFIT_LIMIT` order and the other must be `STOP_LOSS` or `STOP_LOSS_LIMIT` order.
1895 /// * Price restrictions
1896 /// * If the OCO is on the `SELL` side:
1897 /// * `LIMIT_MAKER/TAKE_PROFIT_LIMIT` `price` > Last Traded Price > `STOP_LOSS/STOP_LOSS_LIMIT` `stopPrice`
1898 /// * `TAKE_PROFIT stopPrice` > Last Traded Price > `STOP_LOSS/STOP_LOSS_LIMIT stopPrice`
1899 /// * If the OCO is on the `BUY` side:
1900 /// * `LIMIT_MAKER/TAKE_PROFIT_LIMIT price` < Last Traded Price < `stopPrice`
1901 /// * `TAKE_PROFIT stopPrice` < Last Traded Price < `STOP_LOSS/STOP_LOSS_LIMIT stopPrice`
1902 /// * OCOs add **2 orders** to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
1903 /// Weight: 1
1904 ///
1905 /// Unfilled Order Count: 2
1906 ///
1907 /// # Arguments
1908 ///
1909 /// - `params`: [`OrderListOcoParams`]
1910 /// The parameters for this operation.
1911 ///
1912 /// # Returns
1913 ///
1914 /// [`RestApiResponse<models::OrderListOcoResponse>`] on success.
1915 ///
1916 /// # Errors
1917 ///
1918 /// This function will return an [`anyhow::Error`] if:
1919 /// - the HTTP request fails
1920 /// - any parameter is invalid
1921 /// - the response cannot be parsed
1922 /// - or one of the following occurs:
1923 /// - `RequiredError`
1924 /// - `ConnectorClientError`
1925 /// - `UnauthorizedError`
1926 /// - `ForbiddenError`
1927 /// - `TooManyRequestsError`
1928 /// - `RateLimitBanError`
1929 /// - `ServerError`
1930 /// - `NotFoundError`
1931 /// - `NetworkError`
1932 /// - `BadRequestError`
1933 ///
1934 ///
1935 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-list---oco-trade).
1936 ///
1937 pub async fn order_list_oco(
1938 &self,
1939 params: OrderListOcoParams,
1940 ) -> anyhow::Result<RestApiResponse<models::OrderListOcoResponse>> {
1941 self.trade_api_client.order_list_oco(params).await
1942 }
1943
1944 /// New Order List - OPO
1945 ///
1946 /// Place an [OPO](./faqs/opo.md).
1947 ///
1948 /// * OPOs add 2 orders to the `EXCHANGE_MAX_NUM_ORDERS` filter and `MAX_NUM_ORDERS` filter.
1949 /// Weight: 1
1950 ///
1951 /// Unfilled Order Count: 2
1952 ///
1953 /// # Arguments
1954 ///
1955 /// - `params`: [`OrderListOpoParams`]
1956 /// The parameters for this operation.
1957 ///
1958 /// # Returns
1959 ///
1960 /// [`RestApiResponse<models::OrderListOpoResponse>`] on success.
1961 ///
1962 /// # Errors
1963 ///
1964 /// This function will return an [`anyhow::Error`] if:
1965 /// - the HTTP request fails
1966 /// - any parameter is invalid
1967 /// - the response cannot be parsed
1968 /// - or one of the following occurs:
1969 /// - `RequiredError`
1970 /// - `ConnectorClientError`
1971 /// - `UnauthorizedError`
1972 /// - `ForbiddenError`
1973 /// - `TooManyRequestsError`
1974 /// - `RateLimitBanError`
1975 /// - `ServerError`
1976 /// - `NotFoundError`
1977 /// - `NetworkError`
1978 /// - `BadRequestError`
1979 ///
1980 ///
1981 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-list---opo-trade).
1982 ///
1983 pub async fn order_list_opo(
1984 &self,
1985 params: OrderListOpoParams,
1986 ) -> anyhow::Result<RestApiResponse<models::OrderListOpoResponse>> {
1987 self.trade_api_client.order_list_opo(params).await
1988 }
1989
1990 /// New Order List - OPOCO
1991 ///
1992 /// Place an [OPOCO](./faqs/opo.md).
1993 /// Weight: 1
1994 ///
1995 /// Unfilled Order Count: 3
1996 ///
1997 /// # Arguments
1998 ///
1999 /// - `params`: [`OrderListOpocoParams`]
2000 /// The parameters for this operation.
2001 ///
2002 /// # Returns
2003 ///
2004 /// [`RestApiResponse<models::OrderListOpocoResponse>`] on success.
2005 ///
2006 /// # Errors
2007 ///
2008 /// This function will return an [`anyhow::Error`] if:
2009 /// - the HTTP request fails
2010 /// - any parameter is invalid
2011 /// - the response cannot be parsed
2012 /// - or one of the following occurs:
2013 /// - `RequiredError`
2014 /// - `ConnectorClientError`
2015 /// - `UnauthorizedError`
2016 /// - `ForbiddenError`
2017 /// - `TooManyRequestsError`
2018 /// - `RateLimitBanError`
2019 /// - `ServerError`
2020 /// - `NotFoundError`
2021 /// - `NetworkError`
2022 /// - `BadRequestError`
2023 ///
2024 ///
2025 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-list---opoco-trade).
2026 ///
2027 pub async fn order_list_opoco(
2028 &self,
2029 params: OrderListOpocoParams,
2030 ) -> anyhow::Result<RestApiResponse<models::OrderListOpocoResponse>> {
2031 self.trade_api_client.order_list_opoco(params).await
2032 }
2033
2034 /// New Order list - OTO
2035 ///
2036 /// Place an OTO.
2037 ///
2038 /// * An OTO (One-Triggers-the-Other) is an order list comprised of 2 orders.
2039 /// * 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.
2040 /// * The second order is called the **pending order**. It can be any order type except for `MARKET` orders using parameter `quoteOrderQty`. The pending order is only placed on the order book when the working order gets **fully filled**.
2041 /// * If either the working order or the pending order is cancelled individually, the other order in the order list will also be canceled or expired.
2042 /// * When the order list is placed, if the working order gets **immediately fully filled**, the placement response will show the working order as `FILLED` but the pending order will still appear as `PENDING_NEW`. You need to query the status of the pending order again to see its updated status.
2043 /// * OTOs add **2 orders** to the `EXCHANGE_MAX_NUM_ORDERS` filter and `MAX_NUM_ORDERS` filter.
2044 /// Weight: 1
2045 ///
2046 /// Unfilled Order Count: 2
2047 ///
2048 /// # Arguments
2049 ///
2050 /// - `params`: [`OrderListOtoParams`]
2051 /// The parameters for this operation.
2052 ///
2053 /// # Returns
2054 ///
2055 /// [`RestApiResponse<models::OrderListOtoResponse>`] on success.
2056 ///
2057 /// # Errors
2058 ///
2059 /// This function will return an [`anyhow::Error`] if:
2060 /// - the HTTP request fails
2061 /// - any parameter is invalid
2062 /// - the response cannot be parsed
2063 /// - or one of the following occurs:
2064 /// - `RequiredError`
2065 /// - `ConnectorClientError`
2066 /// - `UnauthorizedError`
2067 /// - `ForbiddenError`
2068 /// - `TooManyRequestsError`
2069 /// - `RateLimitBanError`
2070 /// - `ServerError`
2071 /// - `NotFoundError`
2072 /// - `NetworkError`
2073 /// - `BadRequestError`
2074 ///
2075 ///
2076 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-list---oto-trade).
2077 ///
2078 pub async fn order_list_oto(
2079 &self,
2080 params: OrderListOtoParams,
2081 ) -> anyhow::Result<RestApiResponse<models::OrderListOtoResponse>> {
2082 self.trade_api_client.order_list_oto(params).await
2083 }
2084
2085 /// New Order list - OTOCO
2086 ///
2087 /// Place an OTOCO.
2088 ///
2089 /// * An OTOCO (One-Triggers-One-Cancels-the-Other) is an order list comprised of 3 orders.
2090 /// * 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.
2091 /// * The behavior of the working order is the same as the [OTO](#new-order-list---oto-trade).
2092 /// * 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**.
2093 /// * The rules of the pending above and pending below follow the same rules as the [Order list OCO](#new-order-list---oco-trade).
2094 /// * OTOCOs add **3 orders** to the `EXCHANGE_MAX_NUM_ORDERS` filter and `MAX_NUM_ORDERS` filter.
2095 /// Weight: 1
2096 ///
2097 /// Unfilled Order Count: 3
2098 ///
2099 /// # Arguments
2100 ///
2101 /// - `params`: [`OrderListOtocoParams`]
2102 /// The parameters for this operation.
2103 ///
2104 /// # Returns
2105 ///
2106 /// [`RestApiResponse<models::OrderListOtocoResponse>`] on success.
2107 ///
2108 /// # Errors
2109 ///
2110 /// This function will return an [`anyhow::Error`] if:
2111 /// - the HTTP request fails
2112 /// - any parameter is invalid
2113 /// - the response cannot be parsed
2114 /// - or one of the following occurs:
2115 /// - `RequiredError`
2116 /// - `ConnectorClientError`
2117 /// - `UnauthorizedError`
2118 /// - `ForbiddenError`
2119 /// - `TooManyRequestsError`
2120 /// - `RateLimitBanError`
2121 /// - `ServerError`
2122 /// - `NotFoundError`
2123 /// - `NetworkError`
2124 /// - `BadRequestError`
2125 ///
2126 ///
2127 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-list---otoco-trade).
2128 ///
2129 pub async fn order_list_otoco(
2130 &self,
2131 params: OrderListOtocoParams,
2132 ) -> anyhow::Result<RestApiResponse<models::OrderListOtocoResponse>> {
2133 self.trade_api_client.order_list_otoco(params).await
2134 }
2135
2136 /// New OCO - Deprecated
2137 ///
2138 /// Send in a new OCO.
2139 ///
2140 /// * Price Restrictions:
2141 /// * `SELL`: Limit Price > Last Price > Stop Price
2142 /// * `BUY`: Limit Price < Last Price < Stop Price
2143 /// * Quantity Restrictions:
2144 /// * Both legs must have the same quantity.
2145 /// * `ICEBERG` quantities however do not have to be the same
2146 /// * `OCO` adds **2 orders** to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
2147 /// Weight: 1
2148 ///
2149 /// Unfilled Order Count: 2
2150 ///
2151 /// # Arguments
2152 ///
2153 /// - `params`: [`OrderOcoParams`]
2154 /// The parameters for this operation.
2155 ///
2156 /// # Returns
2157 ///
2158 /// [`RestApiResponse<models::OrderOcoResponse>`] on success.
2159 ///
2160 /// # Errors
2161 ///
2162 /// This function will return an [`anyhow::Error`] if:
2163 /// - the HTTP request fails
2164 /// - any parameter is invalid
2165 /// - the response cannot be parsed
2166 /// - or one of the following occurs:
2167 /// - `RequiredError`
2168 /// - `ConnectorClientError`
2169 /// - `UnauthorizedError`
2170 /// - `ForbiddenError`
2171 /// - `TooManyRequestsError`
2172 /// - `RateLimitBanError`
2173 /// - `ServerError`
2174 /// - `NotFoundError`
2175 /// - `NetworkError`
2176 /// - `BadRequestError`
2177 ///
2178 ///
2179 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-oco---deprecated-trade).
2180 ///
2181 /// # Deprecation
2182 ///
2183 /// **Deprecated:** This method may be removed in a future version.
2184 #[deprecated]
2185 pub async fn order_oco(
2186 &self,
2187 params: OrderOcoParams,
2188 ) -> anyhow::Result<RestApiResponse<models::OrderOcoResponse>> {
2189 self.trade_api_client.order_oco(params).await
2190 }
2191
2192 /// Test new order
2193 ///
2194 /// Test new order creation and signature/recvWindow long.
2195 /// Creates and validates a new order but does not send it into the matching engine.
2196 /// Weight: |Condition| Request Weight|
2197 /// |------------ | ------------ |
2198 /// |Without `computeCommissionRates`| 1|
2199 /// |With `computeCommissionRates`|20|
2200 ///
2201 /// # Arguments
2202 ///
2203 /// - `params`: [`OrderTestParams`]
2204 /// The parameters for this operation.
2205 ///
2206 /// # Returns
2207 ///
2208 /// [`RestApiResponse<models::OrderTestResponse>`] on success.
2209 ///
2210 /// # Errors
2211 ///
2212 /// This function will return an [`anyhow::Error`] if:
2213 /// - the HTTP request fails
2214 /// - any parameter is invalid
2215 /// - the response cannot be parsed
2216 /// - or one of the following occurs:
2217 /// - `RequiredError`
2218 /// - `ConnectorClientError`
2219 /// - `UnauthorizedError`
2220 /// - `ForbiddenError`
2221 /// - `TooManyRequestsError`
2222 /// - `RateLimitBanError`
2223 /// - `ServerError`
2224 /// - `NotFoundError`
2225 /// - `NetworkError`
2226 /// - `BadRequestError`
2227 ///
2228 ///
2229 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#test-new-order-trade).
2230 ///
2231 pub async fn order_test(
2232 &self,
2233 params: OrderTestParams,
2234 ) -> anyhow::Result<RestApiResponse<models::OrderTestResponse>> {
2235 self.trade_api_client.order_test(params).await
2236 }
2237
2238 /// New order using SOR
2239 ///
2240 /// Places an order using smart order routing (SOR).
2241 ///
2242 /// This adds 1 order to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
2243 ///
2244 /// Read [SOR FAQ](faqs/sor_faq.md) to learn more.
2245 /// Weight: 1
2246 ///
2247 /// Unfilled Order Count: 1
2248 ///
2249 /// # Arguments
2250 ///
2251 /// - `params`: [`SorOrderParams`]
2252 /// The parameters for this operation.
2253 ///
2254 /// # Returns
2255 ///
2256 /// [`RestApiResponse<models::SorOrderResponse>`] on success.
2257 ///
2258 /// # Errors
2259 ///
2260 /// This function will return an [`anyhow::Error`] if:
2261 /// - the HTTP request fails
2262 /// - any parameter is invalid
2263 /// - the response cannot be parsed
2264 /// - or one of the following occurs:
2265 /// - `RequiredError`
2266 /// - `ConnectorClientError`
2267 /// - `UnauthorizedError`
2268 /// - `ForbiddenError`
2269 /// - `TooManyRequestsError`
2270 /// - `RateLimitBanError`
2271 /// - `ServerError`
2272 /// - `NotFoundError`
2273 /// - `NetworkError`
2274 /// - `BadRequestError`
2275 ///
2276 ///
2277 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-using-sor-trade).
2278 ///
2279 pub async fn sor_order(
2280 &self,
2281 params: SorOrderParams,
2282 ) -> anyhow::Result<RestApiResponse<models::SorOrderResponse>> {
2283 self.trade_api_client.sor_order(params).await
2284 }
2285
2286 /// Test new order using SOR
2287 ///
2288 /// Test new order creation and signature/recvWindow using smart order routing (SOR).
2289 /// Creates and validates a new order but does not send it into the matching engine.
2290 /// Weight: | Condition | Request Weight |
2291 /// | --------- | -------------- |
2292 /// | Without `computeCommissionRates` | 1 |
2293 /// | With `computeCommissionRates` | 20 |
2294 ///
2295 /// # Arguments
2296 ///
2297 /// - `params`: [`SorOrderTestParams`]
2298 /// The parameters for this operation.
2299 ///
2300 /// # Returns
2301 ///
2302 /// [`RestApiResponse<models::SorOrderTestResponse>`] on success.
2303 ///
2304 /// # Errors
2305 ///
2306 /// This function will return an [`anyhow::Error`] if:
2307 /// - the HTTP request fails
2308 /// - any parameter is invalid
2309 /// - the response cannot be parsed
2310 /// - or one of the following occurs:
2311 /// - `RequiredError`
2312 /// - `ConnectorClientError`
2313 /// - `UnauthorizedError`
2314 /// - `ForbiddenError`
2315 /// - `TooManyRequestsError`
2316 /// - `RateLimitBanError`
2317 /// - `ServerError`
2318 /// - `NotFoundError`
2319 /// - `NetworkError`
2320 /// - `BadRequestError`
2321 ///
2322 ///
2323 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#test-new-order-using-sor-trade).
2324 ///
2325 pub async fn sor_order_test(
2326 &self,
2327 params: SorOrderTestParams,
2328 ) -> anyhow::Result<RestApiResponse<models::SorOrderTestResponse>> {
2329 self.trade_api_client.sor_order_test(params).await
2330 }
2331}