binance_sdk/spot/rest_api/mod.rs
1/*
2 * Spot REST 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 http::Method;
16use serde::de::DeserializeOwned;
17use serde_json::Value;
18use std::collections::BTreeMap;
19
20use crate::common::{config::ConfigurationRestApi, models::RestApiResponse, utils::send_request};
21
22mod apis;
23mod models;
24
25pub use apis::*;
26pub use models::*;
27
28#[derive(Debug, Clone)]
29pub struct RestApi {
30 configuration: ConfigurationRestApi,
31 account_api_client: AccountApiClient,
32 general_api_client: GeneralApiClient,
33 market_api_client: MarketApiClient,
34 trade_api_client: TradeApiClient,
35}
36
37impl RestApi {
38 pub fn new(configuration: ConfigurationRestApi) -> Self {
39 let account_api_client = AccountApiClient::new(configuration.clone());
40 let general_api_client = GeneralApiClient::new(configuration.clone());
41 let market_api_client = MarketApiClient::new(configuration.clone());
42 let trade_api_client = TradeApiClient::new(configuration.clone());
43
44 Self {
45 configuration,
46 account_api_client,
47 general_api_client,
48 market_api_client,
49 trade_api_client,
50 }
51 }
52
53 /// Send an unsigned request to the API
54 ///
55 /// # Arguments
56 ///
57 /// * `endpoint` - The API endpoint to send the request to
58 /// * `method` - The HTTP method to use for the request
59 /// * `query_params` - A map of query parameters to send with the request
60 /// * `body_params` - A map of body parameters to send with the request
61 ///
62 /// # Returns
63 ///
64 /// A `RestApiResponse` containing the deserialized response data on success, or an error if the request fails
65 ///
66 /// # Errors
67 ///
68 /// Returns an `anyhow::Error` if the HTTP request fails or if parsing the response fails
69 pub async fn send_request<R: DeserializeOwned + Send + 'static>(
70 &self,
71 endpoint: &str,
72 method: Method,
73 query_params: BTreeMap<String, Value>,
74 body_params: BTreeMap<String, Value>,
75 ) -> anyhow::Result<RestApiResponse<R>> {
76 send_request::<R>(
77 &self.configuration,
78 endpoint,
79 method,
80 query_params,
81 body_params,
82 None,
83 false,
84 )
85 .await
86 }
87
88 /// Send a signed request to the API
89 ///
90 /// # Arguments
91 ///
92 /// * `endpoint` - The API endpoint to send the request to
93 /// * `method` - The HTTP method to use for the request
94 /// * `query_params` - A map of query parameters to send with the request
95 /// * `body_params` - A map of body parameters to send with the request
96 ///
97 /// # Returns
98 ///
99 /// A `RestApiResponse` containing the deserialized response data on success, or an error if the request fails
100 ///
101 /// # Errors
102 ///
103 /// Returns an `anyhow::Error` if the HTTP request fails or if parsing the response fails
104 pub async fn send_signed_request<R: DeserializeOwned + Send + 'static>(
105 &self,
106 endpoint: &str,
107 method: Method,
108 query_params: BTreeMap<String, Value>,
109 body_params: BTreeMap<String, Value>,
110 ) -> anyhow::Result<RestApiResponse<R>> {
111 send_request::<R>(
112 &self.configuration,
113 endpoint,
114 method,
115 query_params,
116 body_params,
117 None,
118 true,
119 )
120 .await
121 }
122
123 /// Query Commission Rates (`USER_DATA`)
124 ///
125 /// Get current account commission rates.
126 ///
127 /// Weight(IP): 20
128 ///
129 /// Security Type: `USER_DATA`
130 ///
131 /// Notes:
132 /// **Data Source:** Database
133 ///
134 /// # Arguments
135 ///
136 /// - `params`: [`AccountCommissionParams`]
137 /// The parameters for this operation.
138 ///
139 /// # Returns
140 ///
141 /// [`RestApiResponse<models::AccountCommissionResponse>`] on success.
142 ///
143 /// # Errors
144 ///
145 /// This function will return an [`anyhow::Error`] if:
146 /// - the HTTP request fails
147 /// - any parameter is invalid
148 /// - the response cannot be parsed
149 /// - or one of the following occurs:
150 /// - `RequiredError`
151 /// - `ConnectorClientError`
152 /// - `UnauthorizedError`
153 /// - `ForbiddenError`
154 /// - `TooManyRequestsError`
155 /// - `RateLimitBanError`
156 /// - `ServerError`
157 /// - `NotFoundError`
158 /// - `NetworkError`
159 /// - `BadRequestError`
160 ///
161 ///
162 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account#account-commission).
163 ///
164 pub async fn account_commission(
165 &self,
166 params: AccountCommissionParams,
167 ) -> anyhow::Result<RestApiResponse<models::AccountCommissionResponse>> {
168 self.account_api_client.account_commission(params).await
169 }
170
171 /// Query all Order lists (`USER_DATA`)
172 ///
173 /// Retrieves all order lists based on provided optional parameters.
174 ///
175 /// Note that the time between `startTime` and `endTime` can't be longer
176 /// than 24 hours.
177 ///
178 /// Weight(IP): 20
179 ///
180 /// Security Type: `USER_DATA`
181 ///
182 /// Notes:
183 /// **Data Source:** Database
184 ///
185 /// # Arguments
186 ///
187 /// - `params`: [`AllOrderListParams`]
188 /// The parameters for this operation.
189 ///
190 /// # Returns
191 ///
192 /// [`RestApiResponse<Vec<models::AllOrderListResponseInner>>`] on success.
193 ///
194 /// # Errors
195 ///
196 /// This function will return an [`anyhow::Error`] if:
197 /// - the HTTP request fails
198 /// - any parameter is invalid
199 /// - the response cannot be parsed
200 /// - or one of the following occurs:
201 /// - `RequiredError`
202 /// - `ConnectorClientError`
203 /// - `UnauthorizedError`
204 /// - `ForbiddenError`
205 /// - `TooManyRequestsError`
206 /// - `RateLimitBanError`
207 /// - `ServerError`
208 /// - `NotFoundError`
209 /// - `NetworkError`
210 /// - `BadRequestError`
211 ///
212 ///
213 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account#all-order-list).
214 ///
215 pub async fn all_order_list(
216 &self,
217 params: AllOrderListParams,
218 ) -> anyhow::Result<RestApiResponse<Vec<models::AllOrderListResponseInner>>> {
219 self.account_api_client.all_order_list(params).await
220 }
221
222 /// All orders (`USER_DATA`)
223 ///
224 /// Get all account orders; active, canceled, or filled.
225 ///
226 /// Weight(IP): 20
227 ///
228 /// Security Type: `USER_DATA`
229 ///
230 /// Notes:
231 /// **Data Source:** Database
232 ///
233 /// - If `orderId` is set, it will get orders >= that `orderId`. Otherwise most recent orders are returned.
234 /// - For some historical orders `cummulativeQuoteQty` will be < 0, meaning the data is not available at this time.
235 /// - If `startTime` and/or `endTime` provided, `orderId` is not required.
236 /// - The time between `startTime` and `endTime` can't be longer than 24 hours.
237 ///
238 /// # Arguments
239 ///
240 /// - `params`: [`AllOrdersParams`]
241 /// The parameters for this operation.
242 ///
243 /// # Returns
244 ///
245 /// [`RestApiResponse<Vec<models::AllOrdersResponseInner>>`] on success.
246 ///
247 /// # Errors
248 ///
249 /// This function will return an [`anyhow::Error`] if:
250 /// - the HTTP request fails
251 /// - any parameter is invalid
252 /// - the response cannot be parsed
253 /// - or one of the following occurs:
254 /// - `RequiredError`
255 /// - `ConnectorClientError`
256 /// - `UnauthorizedError`
257 /// - `ForbiddenError`
258 /// - `TooManyRequestsError`
259 /// - `RateLimitBanError`
260 /// - `ServerError`
261 /// - `NotFoundError`
262 /// - `NetworkError`
263 /// - `BadRequestError`
264 ///
265 ///
266 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account#all-orders).
267 ///
268 pub async fn all_orders(
269 &self,
270 params: AllOrdersParams,
271 ) -> anyhow::Result<RestApiResponse<Vec<models::AllOrdersResponseInner>>> {
272 self.account_api_client.all_orders(params).await
273 }
274
275 /// Account information (`USER_DATA`)
276 ///
277 /// Get current account information.
278 ///
279 /// Weight(IP): 20
280 ///
281 /// Security Type: `USER_DATA`
282 ///
283 /// Notes:
284 /// **Data Source:** Memory => Database
285 ///
286 /// # Arguments
287 ///
288 /// - `params`: [`GetAccountParams`]
289 /// The parameters for this operation.
290 ///
291 /// # Returns
292 ///
293 /// [`RestApiResponse<models::GetAccountResponse>`] on success.
294 ///
295 /// # Errors
296 ///
297 /// This function will return an [`anyhow::Error`] if:
298 /// - the HTTP request fails
299 /// - any parameter is invalid
300 /// - the response cannot be parsed
301 /// - or one of the following occurs:
302 /// - `RequiredError`
303 /// - `ConnectorClientError`
304 /// - `UnauthorizedError`
305 /// - `ForbiddenError`
306 /// - `TooManyRequestsError`
307 /// - `RateLimitBanError`
308 /// - `ServerError`
309 /// - `NotFoundError`
310 /// - `NetworkError`
311 /// - `BadRequestError`
312 ///
313 ///
314 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account#get-account).
315 ///
316 pub async fn get_account(
317 &self,
318 params: GetAccountParams,
319 ) -> anyhow::Result<RestApiResponse<models::GetAccountResponse>> {
320 self.account_api_client.get_account(params).await
321 }
322
323 /// Current open orders (`USER_DATA`)
324 ///
325 /// Get all open orders on a symbol. **Careful** when accessing this with no symbol.
326 ///
327 /// Weight: 6 for a single symbol; 80 when the symbol parameter is omitted
328 ///
329 /// Security Type: `USER_DATA`
330 ///
331 /// Notes:
332 /// **Data Source:** Memory => Database
333 ///
334 /// - If the symbol is not sent, orders for all symbols will be returned in an array.
335 ///
336 /// # Arguments
337 ///
338 /// - `params`: [`GetOpenOrdersParams`]
339 /// The parameters for this operation.
340 ///
341 /// # Returns
342 ///
343 /// [`RestApiResponse<Vec<models::GetOpenOrdersResponseInner>>`] on success.
344 ///
345 /// # Errors
346 ///
347 /// This function will return an [`anyhow::Error`] if:
348 /// - the HTTP request fails
349 /// - any parameter is invalid
350 /// - the response cannot be parsed
351 /// - or one of the following occurs:
352 /// - `RequiredError`
353 /// - `ConnectorClientError`
354 /// - `UnauthorizedError`
355 /// - `ForbiddenError`
356 /// - `TooManyRequestsError`
357 /// - `RateLimitBanError`
358 /// - `ServerError`
359 /// - `NotFoundError`
360 /// - `NetworkError`
361 /// - `BadRequestError`
362 ///
363 ///
364 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account#get-open-orders).
365 ///
366 pub async fn get_open_orders(
367 &self,
368 params: GetOpenOrdersParams,
369 ) -> anyhow::Result<RestApiResponse<Vec<models::GetOpenOrdersResponseInner>>> {
370 self.account_api_client.get_open_orders(params).await
371 }
372
373 /// Query order (`USER_DATA`)
374 ///
375 /// Check an order's status.
376 ///
377 /// Weight(IP): 4
378 ///
379 /// Security Type: `USER_DATA`
380 ///
381 /// Notes:
382 /// **Data Source:** Memory => Database
383 ///
384 /// - Either `orderId` or `origClientOrderId` must be sent.
385 /// - 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.
386 /// - For some historical orders `cummulativeQuoteQty` will be < 0, meaning the data is not available at this time.
387 ///
388 /// # Arguments
389 ///
390 /// - `params`: [`GetOrderParams`]
391 /// The parameters for this operation.
392 ///
393 /// # Returns
394 ///
395 /// [`RestApiResponse<models::GetOrderResponse>`] on success.
396 ///
397 /// # Errors
398 ///
399 /// This function will return an [`anyhow::Error`] if:
400 /// - the HTTP request fails
401 /// - any parameter is invalid
402 /// - the response cannot be parsed
403 /// - or one of the following occurs:
404 /// - `RequiredError`
405 /// - `ConnectorClientError`
406 /// - `UnauthorizedError`
407 /// - `ForbiddenError`
408 /// - `TooManyRequestsError`
409 /// - `RateLimitBanError`
410 /// - `ServerError`
411 /// - `NotFoundError`
412 /// - `NetworkError`
413 /// - `BadRequestError`
414 ///
415 ///
416 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account#get-order).
417 ///
418 pub async fn get_order(
419 &self,
420 params: GetOrderParams,
421 ) -> anyhow::Result<RestApiResponse<models::GetOrderResponse>> {
422 self.account_api_client.get_order(params).await
423 }
424
425 /// Query Order list (`USER_DATA`)
426 ///
427 /// Retrieves a specific order list based on provided optional parameters.
428 ///
429 /// Weight(IP): 4
430 ///
431 /// Security Type: `USER_DATA`
432 ///
433 /// Notes:
434 /// **Data Source:** Database
435 ///
436 /// # Arguments
437 ///
438 /// - `params`: [`GetOrderListParams`]
439 /// The parameters for this operation.
440 ///
441 /// # Returns
442 ///
443 /// [`RestApiResponse<models::GetOrderListResponse>`] on success.
444 ///
445 /// # Errors
446 ///
447 /// This function will return an [`anyhow::Error`] if:
448 /// - the HTTP request fails
449 /// - any parameter is invalid
450 /// - the response cannot be parsed
451 /// - or one of the following occurs:
452 /// - `RequiredError`
453 /// - `ConnectorClientError`
454 /// - `UnauthorizedError`
455 /// - `ForbiddenError`
456 /// - `TooManyRequestsError`
457 /// - `RateLimitBanError`
458 /// - `ServerError`
459 /// - `NotFoundError`
460 /// - `NetworkError`
461 /// - `BadRequestError`
462 ///
463 ///
464 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account#get-order-list).
465 ///
466 pub async fn get_order_list(
467 &self,
468 params: GetOrderListParams,
469 ) -> anyhow::Result<RestApiResponse<models::GetOrderListResponse>> {
470 self.account_api_client.get_order_list(params).await
471 }
472
473 /// Query Allocations (`USER_DATA`)
474 ///
475 /// Retrieves allocations resulting from SOR order placement.
476 ///
477 /// Weight(IP): 20
478 ///
479 /// Security Type: `USER_DATA`
480 ///
481 /// Notes:
482 /// **Data Source:** Database"
483 ///
484 /// Supported parameter combinations:
485 ///
486 /// Parameters | Response |
487 /// ------------------------------------------- | -------- |
488 /// `symbol` | allocations from oldest to newest |
489 /// `symbol` + `startTime` | oldest allocations since `startTime` |
490 /// `symbol` + `endTime` | newest allocations until `endTime` |
491 /// `symbol` + `startTime` + `endTime` | allocations within the time range |
492 /// `symbol` + `fromAllocationId` | allocations by allocation ID |
493 /// `symbol` + `orderId` | allocations related to an order starting with oldest |
494 /// `symbol` + `orderId` + `fromAllocationId` | allocations related to an order by allocation ID |
495 ///
496 /// **Note:** The time between `startTime` and `endTime` can't be longer than 24 hours.
497 ///
498 /// # Arguments
499 ///
500 /// - `params`: [`MyAllocationsParams`]
501 /// The parameters for this operation.
502 ///
503 /// # Returns
504 ///
505 /// [`RestApiResponse<Vec<models::MyAllocationsResponseInner>>`] on success.
506 ///
507 /// # Errors
508 ///
509 /// This function will return an [`anyhow::Error`] if:
510 /// - the HTTP request fails
511 /// - any parameter is invalid
512 /// - the response cannot be parsed
513 /// - or one of the following occurs:
514 /// - `RequiredError`
515 /// - `ConnectorClientError`
516 /// - `UnauthorizedError`
517 /// - `ForbiddenError`
518 /// - `TooManyRequestsError`
519 /// - `RateLimitBanError`
520 /// - `ServerError`
521 /// - `NotFoundError`
522 /// - `NetworkError`
523 /// - `BadRequestError`
524 ///
525 ///
526 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account#my-allocations).
527 ///
528 pub async fn my_allocations(
529 &self,
530 params: MyAllocationsParams,
531 ) -> anyhow::Result<RestApiResponse<Vec<models::MyAllocationsResponseInner>>> {
532 self.account_api_client.my_allocations(params).await
533 }
534
535 /// Query relevant filters (`USER_DATA`)
536 ///
537 /// Retrieves the list of filters 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.
538 ///
539 /// Weight(IP): 40
540 ///
541 /// Security Type: `USER_DATA`
542 ///
543 /// Notes:
544 /// **Data Source:** Memory
545 ///
546 /// # Arguments
547 ///
548 /// - `params`: [`MyFiltersParams`]
549 /// The parameters for this operation.
550 ///
551 /// # Returns
552 ///
553 /// [`RestApiResponse<models::MyFiltersResponse>`] on success.
554 ///
555 /// # Errors
556 ///
557 /// This function will return an [`anyhow::Error`] if:
558 /// - the HTTP request fails
559 /// - any parameter is invalid
560 /// - the response cannot be parsed
561 /// - or one of the following occurs:
562 /// - `RequiredError`
563 /// - `ConnectorClientError`
564 /// - `UnauthorizedError`
565 /// - `ForbiddenError`
566 /// - `TooManyRequestsError`
567 /// - `RateLimitBanError`
568 /// - `ServerError`
569 /// - `NotFoundError`
570 /// - `NetworkError`
571 /// - `BadRequestError`
572 ///
573 ///
574 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account#my-filters).
575 ///
576 pub async fn my_filters(
577 &self,
578 params: MyFiltersParams,
579 ) -> anyhow::Result<RestApiResponse<models::MyFiltersResponse>> {
580 self.account_api_client.my_filters(params).await
581 }
582
583 /// Query Prevented Matches (`USER_DATA`)
584 ///
585 /// Displays the list of orders that were expired due to STP.
586 ///
587 /// These are the combinations supported:
588 /// - `symbol` + `preventedMatchId`
589 /// - `symbol` + `orderId`
590 /// - `symbol` + `orderId` + `fromPreventedMatchId` (`limit` will default to 500)
591 /// - `symbol` + `orderId` + `fromPreventedMatchId` + `limit`
592 ///
593 /// Weight: Case | Weight
594 /// ---- | -----
595 /// If `symbol` is invalid | 2
596 /// Querying by `preventedMatchId` | 2
597 /// Querying by `orderId` | 20
598 ///
599 /// Security Type: `USER_DATA`
600 ///
601 /// Notes:
602 /// **Data Source:** Database
603 ///
604 /// # Arguments
605 ///
606 /// - `params`: [`MyPreventedMatchesParams`]
607 /// The parameters for this operation.
608 ///
609 /// # Returns
610 ///
611 /// [`RestApiResponse<Vec<models::MyPreventedMatchesResponseInner>>`] on success.
612 ///
613 /// # Errors
614 ///
615 /// This function will return an [`anyhow::Error`] if:
616 /// - the HTTP request fails
617 /// - any parameter is invalid
618 /// - the response cannot be parsed
619 /// - or one of the following occurs:
620 /// - `RequiredError`
621 /// - `ConnectorClientError`
622 /// - `UnauthorizedError`
623 /// - `ForbiddenError`
624 /// - `TooManyRequestsError`
625 /// - `RateLimitBanError`
626 /// - `ServerError`
627 /// - `NotFoundError`
628 /// - `NetworkError`
629 /// - `BadRequestError`
630 ///
631 ///
632 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account#my-prevented-matches).
633 ///
634 pub async fn my_prevented_matches(
635 &self,
636 params: MyPreventedMatchesParams,
637 ) -> anyhow::Result<RestApiResponse<Vec<models::MyPreventedMatchesResponseInner>>> {
638 self.account_api_client.my_prevented_matches(params).await
639 }
640
641 /// Account trade list (`USER_DATA`)
642 ///
643 /// Get trades for a specific account and symbol.
644 ///
645 /// Weight: Condition| Weight|
646 /// ---| ---
647 /// |Without orderId|20|
648 /// |With orderId|5|
649 ///
650 /// Security Type: `USER_DATA`
651 ///
652 /// Notes:
653 /// **Data Source:** Memory => Database
654 ///
655 /// **Notes:**:
656 /// - If `fromId` is set, it will get trades >= that `fromId`. Otherwise most recent trades are returned.
657 /// - The time between `startTime` and `endTime` can't be longer than 24 hours.
658 /// - These are the supported combinations of all parameters:
659 /// - `symbol`
660 /// - `symbol` + `orderId`
661 /// - `symbol` + `startTime`
662 /// - `symbol` + `endTime`
663 /// - `symbol` + `fromId`
664 /// - `symbol` + `startTime` + `endTime`
665 /// - `symbol`+ `orderId` + `fromId`
666 ///
667 /// # Arguments
668 ///
669 /// - `params`: [`MyTradesParams`]
670 /// The parameters for this operation.
671 ///
672 /// # Returns
673 ///
674 /// [`RestApiResponse<Vec<models::MyTradesResponseInner>>`] on success.
675 ///
676 /// # Errors
677 ///
678 /// This function will return an [`anyhow::Error`] if:
679 /// - the HTTP request fails
680 /// - any parameter is invalid
681 /// - the response cannot be parsed
682 /// - or one of the following occurs:
683 /// - `RequiredError`
684 /// - `ConnectorClientError`
685 /// - `UnauthorizedError`
686 /// - `ForbiddenError`
687 /// - `TooManyRequestsError`
688 /// - `RateLimitBanError`
689 /// - `ServerError`
690 /// - `NotFoundError`
691 /// - `NetworkError`
692 /// - `BadRequestError`
693 ///
694 ///
695 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account#my-trades).
696 ///
697 pub async fn my_trades(
698 &self,
699 params: MyTradesParams,
700 ) -> anyhow::Result<RestApiResponse<Vec<models::MyTradesResponseInner>>> {
701 self.account_api_client.my_trades(params).await
702 }
703
704 /// Query Open Order lists (`USER_DATA`)
705 ///
706 /// Query Open Order lists
707 ///
708 /// Weight(IP): 6
709 ///
710 /// Security Type: `USER_DATA`
711 ///
712 /// Notes:
713 /// **Data Source:** Memory -> Database
714 ///
715 /// # Arguments
716 ///
717 /// - `params`: [`OpenOrderListParams`]
718 /// The parameters for this operation.
719 ///
720 /// # Returns
721 ///
722 /// [`RestApiResponse<Vec<models::OpenOrderListResponseInner>>`] on success.
723 ///
724 /// # Errors
725 ///
726 /// This function will return an [`anyhow::Error`] if:
727 /// - the HTTP request fails
728 /// - any parameter is invalid
729 /// - the response cannot be parsed
730 /// - or one of the following occurs:
731 /// - `RequiredError`
732 /// - `ConnectorClientError`
733 /// - `UnauthorizedError`
734 /// - `ForbiddenError`
735 /// - `TooManyRequestsError`
736 /// - `RateLimitBanError`
737 /// - `ServerError`
738 /// - `NotFoundError`
739 /// - `NetworkError`
740 /// - `BadRequestError`
741 ///
742 ///
743 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account#open-order-list).
744 ///
745 pub async fn open_order_list(
746 &self,
747 params: OpenOrderListParams,
748 ) -> anyhow::Result<RestApiResponse<Vec<models::OpenOrderListResponseInner>>> {
749 self.account_api_client.open_order_list(params).await
750 }
751
752 /// Query Order Amendments (`USER_DATA`)
753 ///
754 /// Queries all amendments of a single order.
755 ///
756 /// Weight(IP): 4
757 ///
758 /// Security Type: `USER_DATA`
759 ///
760 /// Notes:
761 /// **Data Source:** Database
762 ///
763 /// # Arguments
764 ///
765 /// - `params`: [`OrderAmendmentsParams`]
766 /// The parameters for this operation.
767 ///
768 /// # Returns
769 ///
770 /// [`RestApiResponse<Vec<models::OrderAmendmentsResponseInner>>`] on success.
771 ///
772 /// # Errors
773 ///
774 /// This function will return an [`anyhow::Error`] if:
775 /// - the HTTP request fails
776 /// - any parameter is invalid
777 /// - the response cannot be parsed
778 /// - or one of the following occurs:
779 /// - `RequiredError`
780 /// - `ConnectorClientError`
781 /// - `UnauthorizedError`
782 /// - `ForbiddenError`
783 /// - `TooManyRequestsError`
784 /// - `RateLimitBanError`
785 /// - `ServerError`
786 /// - `NotFoundError`
787 /// - `NetworkError`
788 /// - `BadRequestError`
789 ///
790 ///
791 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account#order-amendments).
792 ///
793 pub async fn order_amendments(
794 &self,
795 params: OrderAmendmentsParams,
796 ) -> anyhow::Result<RestApiResponse<Vec<models::OrderAmendmentsResponseInner>>> {
797 self.account_api_client.order_amendments(params).await
798 }
799
800 /// Query Unfilled Order Count (`USER_DATA`)
801 ///
802 /// Displays the user's unfilled order count for all intervals.
803 ///
804 /// Weight(IP): 40
805 ///
806 /// Security Type: `USER_DATA`
807 ///
808 /// Notes:
809 /// **Data Source:** Memory
810 ///
811 /// # Arguments
812 ///
813 /// - `params`: [`RateLimitOrderParams`]
814 /// The parameters for this operation.
815 ///
816 /// # Returns
817 ///
818 /// [`RestApiResponse<Vec<models::RateLimitOrderResponseInner>>`] on success.
819 ///
820 /// # Errors
821 ///
822 /// This function will return an [`anyhow::Error`] if:
823 /// - the HTTP request fails
824 /// - any parameter is invalid
825 /// - the response cannot be parsed
826 /// - or one of the following occurs:
827 /// - `RequiredError`
828 /// - `ConnectorClientError`
829 /// - `UnauthorizedError`
830 /// - `ForbiddenError`
831 /// - `TooManyRequestsError`
832 /// - `RateLimitBanError`
833 /// - `ServerError`
834 /// - `NotFoundError`
835 /// - `NetworkError`
836 /// - `BadRequestError`
837 ///
838 ///
839 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account#rate-limit-order).
840 ///
841 pub async fn rate_limit_order(
842 &self,
843 params: RateLimitOrderParams,
844 ) -> anyhow::Result<RestApiResponse<Vec<models::RateLimitOrderResponseInner>>> {
845 self.account_api_client.rate_limit_order(params).await
846 }
847
848 /// Exchange information
849 ///
850 /// Current exchange trading rules and symbol information
851 ///
852 /// Weight(IP): 20
853 ///
854 /// Security Type: NONE
855 ///
856 /// Notes:
857 /// **Data Source:** Memory
858 ///
859 /// **Notes:**
860 /// * If the value provided to `symbol` or `symbols` do not exist, the endpoint will throw an error saying the symbol is invalid.
861 /// * All parameters are optional.
862 /// * `permissions` can support single or multiple values (e.g. `SPOT`, `["MARGIN","LEVERAGED"]`). This cannot be used in combination with `symbol` or `symbols`.
863 /// * If `permissions` parameter not provided, all symbols that have either `SPOT`, `MARGIN`, or `LEVERAGED` permission will be exposed.
864 /// * To display symbols with any permission you need to specify them explicitly in `permissions`: (e.g. `["SPOT","MARGIN",...]`.). See Account and Symbol Permissions for the full list.
865 ///
866 /// **Examples of Symbol Permissions Interpretation from the Response:**
867 ///
868 /// * `[["A","B"]]` means you may place an order if your account has either permission "A" **or** permission "B".
869 /// * `[["A"],["B"]]` means you can place an order if your account has permission "A" **and** permission "B".
870 /// * `[["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".)
871 ///
872 /// # Arguments
873 ///
874 /// - `params`: [`ExchangeInfoParams`]
875 /// The parameters for this operation.
876 ///
877 /// # Returns
878 ///
879 /// [`RestApiResponse<models::ExchangeInfoResponse>`] on success.
880 ///
881 /// # Errors
882 ///
883 /// This function will return an [`anyhow::Error`] if:
884 /// - the HTTP request fails
885 /// - any parameter is invalid
886 /// - the response cannot be parsed
887 /// - or one of the following occurs:
888 /// - `RequiredError`
889 /// - `ConnectorClientError`
890 /// - `UnauthorizedError`
891 /// - `ForbiddenError`
892 /// - `TooManyRequestsError`
893 /// - `RateLimitBanError`
894 /// - `ServerError`
895 /// - `NotFoundError`
896 /// - `NetworkError`
897 /// - `BadRequestError`
898 ///
899 ///
900 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/general#exchange-info).
901 ///
902 pub async fn exchange_info(
903 &self,
904 params: ExchangeInfoParams,
905 ) -> anyhow::Result<RestApiResponse<models::ExchangeInfoResponse>> {
906 self.general_api_client.exchange_info(params).await
907 }
908
909 /// Query Execution Rules
910 ///
911 /// Query execution rules for symbols.
912 ///
913 /// Weight: Parameter | Weight
914 /// --- | ---
915 /// `symbol` | 2
916 /// `symbols` | 2 for each `symbol`, capped at a max of 40
917 /// `symbolStatus` | 40
918 /// None | 40
919 ///
920 /// Security Type: NONE
921 ///
922 /// Notes:
923 /// **Data Source:** Memory
924 ///
925 /// **Note:**: No combination of multiple parameters is allowed.
926 ///
927 /// # Arguments
928 ///
929 /// - `params`: [`ExecutionRulesParams`]
930 /// The parameters for this operation.
931 ///
932 /// # Returns
933 ///
934 /// [`RestApiResponse<models::ExecutionRulesResponse>`] on success.
935 ///
936 /// # Errors
937 ///
938 /// This function will return an [`anyhow::Error`] if:
939 /// - the HTTP request fails
940 /// - any parameter is invalid
941 /// - the response cannot be parsed
942 /// - or one of the following occurs:
943 /// - `RequiredError`
944 /// - `ConnectorClientError`
945 /// - `UnauthorizedError`
946 /// - `ForbiddenError`
947 /// - `TooManyRequestsError`
948 /// - `RateLimitBanError`
949 /// - `ServerError`
950 /// - `NotFoundError`
951 /// - `NetworkError`
952 /// - `BadRequestError`
953 ///
954 ///
955 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/general#execution-rules).
956 ///
957 pub async fn execution_rules(
958 &self,
959 params: ExecutionRulesParams,
960 ) -> anyhow::Result<RestApiResponse<models::ExecutionRulesResponse>> {
961 self.general_api_client.execution_rules(params).await
962 }
963
964 /// Test connectivity
965 ///
966 /// Test connectivity to the Rest API.
967 ///
968 /// Weight(IP): 1
969 ///
970 /// Security Type: NONE
971 ///
972 /// # Arguments
973 ///
974 /// - `params`: [`PingParams`]
975 /// The parameters for this operation.
976 ///
977 /// # Returns
978 ///
979 /// [`RestApiResponse<Value>`] on success.
980 ///
981 /// # Errors
982 ///
983 /// This function will return an [`anyhow::Error`] if:
984 /// - the HTTP request fails
985 /// - any parameter is invalid
986 /// - the response cannot be parsed
987 /// - or one of the following occurs:
988 /// - `RequiredError`
989 /// - `ConnectorClientError`
990 /// - `UnauthorizedError`
991 /// - `ForbiddenError`
992 /// - `TooManyRequestsError`
993 /// - `RateLimitBanError`
994 /// - `ServerError`
995 /// - `NotFoundError`
996 /// - `NetworkError`
997 /// - `BadRequestError`
998 ///
999 ///
1000 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/general#ping).
1001 ///
1002 pub async fn ping(&self) -> anyhow::Result<RestApiResponse<Value>> {
1003 self.general_api_client.ping().await
1004 }
1005
1006 /// Check server time
1007 ///
1008 /// Test connectivity to the Rest API and get the current server time.
1009 ///
1010 /// Weight(IP): 1
1011 ///
1012 /// Security Type: NONE
1013 ///
1014 /// # Arguments
1015 ///
1016 /// - `params`: [`TimeParams`]
1017 /// The parameters for this operation.
1018 ///
1019 /// # Returns
1020 ///
1021 /// [`RestApiResponse<models::TimeResponse>`] on success.
1022 ///
1023 /// # Errors
1024 ///
1025 /// This function will return an [`anyhow::Error`] if:
1026 /// - the HTTP request fails
1027 /// - any parameter is invalid
1028 /// - the response cannot be parsed
1029 /// - or one of the following occurs:
1030 /// - `RequiredError`
1031 /// - `ConnectorClientError`
1032 /// - `UnauthorizedError`
1033 /// - `ForbiddenError`
1034 /// - `TooManyRequestsError`
1035 /// - `RateLimitBanError`
1036 /// - `ServerError`
1037 /// - `NotFoundError`
1038 /// - `NetworkError`
1039 /// - `BadRequestError`
1040 ///
1041 ///
1042 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/general#time).
1043 ///
1044 pub async fn time(&self) -> anyhow::Result<RestApiResponse<models::TimeResponse>> {
1045 self.general_api_client.time().await
1046 }
1047
1048 /// Compressed/Aggregate trades list
1049 ///
1050 /// Get compressed, aggregate trades. Trades that fill at the time, from the same taker order, with the same price will have the quantity aggregated.
1051 ///
1052 /// Weight(IP): 4
1053 ///
1054 /// Security Type: NONE
1055 ///
1056 /// Notes:
1057 /// **Data Source:** Database
1058 ///
1059 /// - If fromId, startTime, and endTime are not sent, the most recent aggregate trades will be returned.
1060 ///
1061 /// # Arguments
1062 ///
1063 /// - `params`: [`AggTradesParams`]
1064 /// The parameters for this operation.
1065 ///
1066 /// # Returns
1067 ///
1068 /// [`RestApiResponse<Vec<models::AggTradesResponseInner>>`] on success.
1069 ///
1070 /// # Errors
1071 ///
1072 /// This function will return an [`anyhow::Error`] if:
1073 /// - the HTTP request fails
1074 /// - any parameter is invalid
1075 /// - the response cannot be parsed
1076 /// - or one of the following occurs:
1077 /// - `RequiredError`
1078 /// - `ConnectorClientError`
1079 /// - `UnauthorizedError`
1080 /// - `ForbiddenError`
1081 /// - `TooManyRequestsError`
1082 /// - `RateLimitBanError`
1083 /// - `ServerError`
1084 /// - `NotFoundError`
1085 /// - `NetworkError`
1086 /// - `BadRequestError`
1087 ///
1088 ///
1089 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#agg-trades).
1090 ///
1091 pub async fn agg_trades(
1092 &self,
1093 params: AggTradesParams,
1094 ) -> anyhow::Result<RestApiResponse<Vec<models::AggTradesResponseInner>>> {
1095 self.market_api_client.agg_trades(params).await
1096 }
1097
1098 /// Current average price
1099 ///
1100 /// 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 /// [`RestApiResponse<models::AvgPriceResponse>`] on success.
1117 ///
1118 /// # Errors
1119 ///
1120 /// This function will return an [`anyhow::Error`] if:
1121 /// - the HTTP request fails
1122 /// - any parameter is invalid
1123 /// - the response cannot be parsed
1124 /// - or one of the following occurs:
1125 /// - `RequiredError`
1126 /// - `ConnectorClientError`
1127 /// - `UnauthorizedError`
1128 /// - `ForbiddenError`
1129 /// - `TooManyRequestsError`
1130 /// - `RateLimitBanError`
1131 /// - `ServerError`
1132 /// - `NotFoundError`
1133 /// - `NetworkError`
1134 /// - `BadRequestError`
1135 ///
1136 ///
1137 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#avg-price).
1138 ///
1139 pub async fn avg_price(
1140 &self,
1141 params: AvgPriceParams,
1142 ) -> anyhow::Result<RestApiResponse<models::AvgPriceResponse>> {
1143 self.market_api_client.avg_price(params).await
1144 }
1145
1146 /// Order book
1147 ///
1148 /// Order book
1149 ///
1150 /// Weight: Adjusted based on the limit:
1151 ///
1152 /// |Limit|Request Weight
1153 /// ------|-------
1154 /// 1-100| 5
1155 /// 101-500| 25
1156 /// 501-1000| 50
1157 /// 1001-5000| 250
1158 ///
1159 /// Security Type: NONE
1160 ///
1161 /// Notes:
1162 /// **Data Source:** Memory
1163 ///
1164 /// # Arguments
1165 ///
1166 /// - `params`: [`DepthParams`]
1167 /// The parameters for this operation.
1168 ///
1169 /// # Returns
1170 ///
1171 /// [`RestApiResponse<models::DepthResponse>`] 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/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#depth).
1193 ///
1194 pub async fn depth(
1195 &self,
1196 params: DepthParams,
1197 ) -> anyhow::Result<RestApiResponse<models::DepthResponse>> {
1198 self.market_api_client.depth(params).await
1199 }
1200
1201 /// Recent trades list
1202 ///
1203 /// Get recent trades.
1204 ///
1205 /// Weight(IP): 25
1206 ///
1207 /// Security Type: NONE
1208 ///
1209 /// Notes:
1210 /// **Data Source:** Memory
1211 ///
1212 /// # Arguments
1213 ///
1214 /// - `params`: [`GetTradesParams`]
1215 /// The parameters for this operation.
1216 ///
1217 /// # Returns
1218 ///
1219 /// [`RestApiResponse<Vec<models::GetTradesResponseInner>>`] on success.
1220 ///
1221 /// # Errors
1222 ///
1223 /// This function will return an [`anyhow::Error`] if:
1224 /// - the HTTP request fails
1225 /// - any parameter is invalid
1226 /// - the response cannot be parsed
1227 /// - or one of the following occurs:
1228 /// - `RequiredError`
1229 /// - `ConnectorClientError`
1230 /// - `UnauthorizedError`
1231 /// - `ForbiddenError`
1232 /// - `TooManyRequestsError`
1233 /// - `RateLimitBanError`
1234 /// - `ServerError`
1235 /// - `NotFoundError`
1236 /// - `NetworkError`
1237 /// - `BadRequestError`
1238 ///
1239 ///
1240 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#get-trades).
1241 ///
1242 pub async fn get_trades(
1243 &self,
1244 params: GetTradesParams,
1245 ) -> anyhow::Result<RestApiResponse<Vec<models::GetTradesResponseInner>>> {
1246 self.market_api_client.get_trades(params).await
1247 }
1248
1249 /// Historical Block Trades (`MARKET_DATA`)
1250 ///
1251 /// Get block trades.
1252 ///
1253 /// Weight(IP): 25
1254 ///
1255 /// Security Type: `MARKET_DATA`
1256 ///
1257 /// Notes:
1258 /// - Data Source: Database
1259 ///
1260 /// # Arguments
1261 ///
1262 /// - `params`: [`HistoricalBlockTradesParams`]
1263 /// The parameters for this operation.
1264 ///
1265 /// # Returns
1266 ///
1267 /// [`RestApiResponse<Vec<models::HistoricalBlockTradesResponseInner>>`] on success.
1268 ///
1269 /// # Errors
1270 ///
1271 /// This function will return an [`anyhow::Error`] if:
1272 /// - the HTTP request fails
1273 /// - any parameter is invalid
1274 /// - the response cannot be parsed
1275 /// - or one of the following occurs:
1276 /// - `RequiredError`
1277 /// - `ConnectorClientError`
1278 /// - `UnauthorizedError`
1279 /// - `ForbiddenError`
1280 /// - `TooManyRequestsError`
1281 /// - `RateLimitBanError`
1282 /// - `ServerError`
1283 /// - `NotFoundError`
1284 /// - `NetworkError`
1285 /// - `BadRequestError`
1286 ///
1287 ///
1288 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#historical-block-trades).
1289 ///
1290 pub async fn historical_block_trades(
1291 &self,
1292 params: HistoricalBlockTradesParams,
1293 ) -> anyhow::Result<RestApiResponse<Vec<models::HistoricalBlockTradesResponseInner>>> {
1294 self.market_api_client.historical_block_trades(params).await
1295 }
1296
1297 /// Old trade lookup
1298 ///
1299 /// Get older trades.
1300 ///
1301 /// Weight(IP): 25
1302 ///
1303 /// Security Type: NONE
1304 ///
1305 /// Notes:
1306 /// **Data Source:** Database
1307 ///
1308 /// # Arguments
1309 ///
1310 /// - `params`: [`HistoricalTradesParams`]
1311 /// The parameters for this operation.
1312 ///
1313 /// # Returns
1314 ///
1315 /// [`RestApiResponse<Vec<models::GetTradesResponseInner>>`] on success.
1316 ///
1317 /// # Errors
1318 ///
1319 /// This function will return an [`anyhow::Error`] if:
1320 /// - the HTTP request fails
1321 /// - any parameter is invalid
1322 /// - the response cannot be parsed
1323 /// - or one of the following occurs:
1324 /// - `RequiredError`
1325 /// - `ConnectorClientError`
1326 /// - `UnauthorizedError`
1327 /// - `ForbiddenError`
1328 /// - `TooManyRequestsError`
1329 /// - `RateLimitBanError`
1330 /// - `ServerError`
1331 /// - `NotFoundError`
1332 /// - `NetworkError`
1333 /// - `BadRequestError`
1334 ///
1335 ///
1336 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#historical-trades).
1337 ///
1338 pub async fn historical_trades(
1339 &self,
1340 params: HistoricalTradesParams,
1341 ) -> anyhow::Result<RestApiResponse<Vec<models::GetTradesResponseInner>>> {
1342 self.market_api_client.historical_trades(params).await
1343 }
1344
1345 /// Kline/Candlestick data
1346 ///
1347 /// Kline/candlestick bars for a symbol.
1348 /// Klines are uniquely identified by their open time.
1349 ///
1350 /// Weight(IP): 2
1351 ///
1352 /// Security Type: NONE
1353 ///
1354 /// Notes:
1355 /// **Data Source:** Database
1356 ///
1357 /// Supported kline intervals (case-sensitive):
1358 ///
1359 /// Interval | `interval` value
1360 /// --------- | ----------------
1361 /// seconds | `1s`
1362 /// minutes | `1m`, `3m`, `5m`, `15m`, `30m`
1363 /// hours | `1h`, `2h`, `4h`, `6h`, `8h`, `12h`
1364 /// days | `1d`, `3d`
1365 /// weeks | `1w`
1366 /// months | `1M`
1367 ///
1368 /// **Notes:**
1369 ///
1370 /// * If `startTime` and `endTime` are not sent, the most recent klines are returned.
1371 /// * Supported values for `timeZone`:
1372 /// * Hours and minutes (e.g. `-1:00`, `05:45`)
1373 /// * Only hours (e.g. `0`, `8`, `4`)
1374 /// * Accepted range is strictly [-12:00 to +14:00] inclusive
1375 /// * If `timeZone` provided, kline intervals are interpreted in that timezone instead of UTC.
1376 /// * Note that `startTime` and `endTime` are always interpreted in UTC, regardless of `timeZone`.
1377 ///
1378 /// # Arguments
1379 ///
1380 /// - `params`: [`KlinesParams`]
1381 /// The parameters for this operation.
1382 ///
1383 /// # Returns
1384 ///
1385 /// [`RestApiResponse<Vec<Vec<models::KlinesItemInner>>>`] on success.
1386 ///
1387 /// # Errors
1388 ///
1389 /// This function will return an [`anyhow::Error`] if:
1390 /// - the HTTP request fails
1391 /// - any parameter is invalid
1392 /// - the response cannot be parsed
1393 /// - or one of the following occurs:
1394 /// - `RequiredError`
1395 /// - `ConnectorClientError`
1396 /// - `UnauthorizedError`
1397 /// - `ForbiddenError`
1398 /// - `TooManyRequestsError`
1399 /// - `RateLimitBanError`
1400 /// - `ServerError`
1401 /// - `NotFoundError`
1402 /// - `NetworkError`
1403 /// - `BadRequestError`
1404 ///
1405 ///
1406 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#klines).
1407 ///
1408 pub async fn klines(
1409 &self,
1410 params: KlinesParams,
1411 ) -> anyhow::Result<RestApiResponse<Vec<Vec<models::KlinesItemInner>>>> {
1412 self.market_api_client.klines(params).await
1413 }
1414
1415 /// Query Reference Price
1416 ///
1417 /// Query the reference price for a symbol.
1418 ///
1419 /// Weight(IP): 2
1420 ///
1421 /// Security Type: NONE
1422 ///
1423 /// Notes:
1424 /// **Data Source:** Memory
1425 ///
1426 /// # Arguments
1427 ///
1428 /// - `params`: [`ReferencePriceParams`]
1429 /// The parameters for this operation.
1430 ///
1431 /// # Returns
1432 ///
1433 /// [`RestApiResponse<models::ReferencePriceResponse>`] on success.
1434 ///
1435 /// # Errors
1436 ///
1437 /// This function will return an [`anyhow::Error`] if:
1438 /// - the HTTP request fails
1439 /// - any parameter is invalid
1440 /// - the response cannot be parsed
1441 /// - or one of the following occurs:
1442 /// - `RequiredError`
1443 /// - `ConnectorClientError`
1444 /// - `UnauthorizedError`
1445 /// - `ForbiddenError`
1446 /// - `TooManyRequestsError`
1447 /// - `RateLimitBanError`
1448 /// - `ServerError`
1449 /// - `NotFoundError`
1450 /// - `NetworkError`
1451 /// - `BadRequestError`
1452 ///
1453 ///
1454 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#reference-price).
1455 ///
1456 pub async fn reference_price(
1457 &self,
1458 params: ReferencePriceParams,
1459 ) -> anyhow::Result<RestApiResponse<models::ReferencePriceResponse>> {
1460 self.market_api_client.reference_price(params).await
1461 }
1462
1463 /// Query Reference Price Calculation
1464 ///
1465 /// Describes how reference price is calculated for a given symbol.
1466 ///
1467 /// Weight(IP): 2
1468 ///
1469 /// Security Type: NONE
1470 ///
1471 /// Notes:
1472 /// **Data Source:** Memory
1473 ///
1474 /// # Arguments
1475 ///
1476 /// - `params`: [`ReferencePriceCalculationParams`]
1477 /// The parameters for this operation.
1478 ///
1479 /// # Returns
1480 ///
1481 /// [`RestApiResponse<models::ReferencePriceCalculationResponse>`] on success.
1482 ///
1483 /// # Errors
1484 ///
1485 /// This function will return an [`anyhow::Error`] if:
1486 /// - the HTTP request fails
1487 /// - any parameter is invalid
1488 /// - the response cannot be parsed
1489 /// - or one of the following occurs:
1490 /// - `RequiredError`
1491 /// - `ConnectorClientError`
1492 /// - `UnauthorizedError`
1493 /// - `ForbiddenError`
1494 /// - `TooManyRequestsError`
1495 /// - `RateLimitBanError`
1496 /// - `ServerError`
1497 /// - `NotFoundError`
1498 /// - `NetworkError`
1499 /// - `BadRequestError`
1500 ///
1501 ///
1502 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#reference-price-calculation).
1503 ///
1504 pub async fn reference_price_calculation(
1505 &self,
1506 params: ReferencePriceCalculationParams,
1507 ) -> anyhow::Result<RestApiResponse<models::ReferencePriceCalculationResponse>> {
1508 self.market_api_client
1509 .reference_price_calculation(params)
1510 .await
1511 }
1512
1513 /// Rolling window price change statistics
1514 ///
1515 /// **Note:** This endpoint differs from `GET /api/v3/ticker/24hr`.
1516 ///
1517 /// The statistical time range of this endpoint can be up to 59999ms longer
1518 /// than the requested `windowSize`.
1519 ///
1520 /// `openTime` starts at the beginning of a minute, while the end time is
1521 /// the current time. Therefore, the actual interval can be up to 59999ms
1522 /// longer than the requested window.
1523 ///
1524 /// For example, if `closeTime` is 1641287867099 (January 04, 2022
1525 /// 09:17:47:099 UTC) and `windowSize` is `1d`, then `openTime` is
1526 /// 1641201420000 (January 3, 2022, 09:17:00 UTC).
1527 ///
1528 /// Weight: 4 for each requested symbol regardless of windowSize.
1529 ///
1530 /// The weight for this request will cap at 200 once the number of `symbols` in the request is more than 50.
1531 ///
1532 /// Security Type: NONE
1533 ///
1534 /// Notes:
1535 /// **Data Source:** Database
1536 ///
1537 /// # Arguments
1538 ///
1539 /// - `params`: [`TickerParams`]
1540 /// The parameters for this operation.
1541 ///
1542 /// # Returns
1543 ///
1544 /// [`RestApiResponse<models::TickerResponse>`] on success.
1545 ///
1546 /// # Errors
1547 ///
1548 /// This function will return an [`anyhow::Error`] if:
1549 /// - the HTTP request fails
1550 /// - any parameter is invalid
1551 /// - the response cannot be parsed
1552 /// - or one of the following occurs:
1553 /// - `RequiredError`
1554 /// - `ConnectorClientError`
1555 /// - `UnauthorizedError`
1556 /// - `ForbiddenError`
1557 /// - `TooManyRequestsError`
1558 /// - `RateLimitBanError`
1559 /// - `ServerError`
1560 /// - `NotFoundError`
1561 /// - `NetworkError`
1562 /// - `BadRequestError`
1563 ///
1564 ///
1565 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#ticker).
1566 ///
1567 pub async fn ticker(
1568 &self,
1569 params: TickerParams,
1570 ) -> anyhow::Result<RestApiResponse<models::TickerResponse>> {
1571 self.market_api_client.ticker(params).await
1572 }
1573
1574 /// 24hr ticker price change statistics
1575 ///
1576 /// 24 hour rolling window price change statistics. **Careful** when accessing this with no symbol.
1577 ///
1578 /// Weight: <table>
1579 /// <thead>
1580 /// <tr>
1581 /// <th>Parameter</th>
1582 /// <th>Symbols Provided</th>
1583 /// <th>Weight</th>
1584 /// </tr>
1585 /// </thead>
1586 /// <tbody>
1587 /// <tr>
1588 /// <td rowspan="2">symbol</td>
1589 /// <td>1</td>
1590 /// <td>2</td>
1591 /// </tr>
1592 /// <tr>
1593 /// <td>symbol parameter is omitted</td>
1594 /// <td>80</td>
1595 /// </tr>
1596 /// <tr>
1597 /// <td rowspan="4">symbols</td>
1598 /// <td>1-20</td>
1599 /// <td>2</td>
1600 /// </tr>
1601 /// <tr>
1602 /// <td>21-100</td>
1603 /// <td>40</td>
1604 /// </tr>
1605 /// <tr>
1606 /// <td>101 or more</td>
1607 /// <td>80</td>
1608 /// </tr>
1609 /// <tr>
1610 /// <td>symbols parameter is omitted</td>
1611 /// <td>80</td>
1612 /// </tr>
1613 /// </tbody>
1614 /// </table>
1615 ///
1616 /// Security Type: NONE
1617 ///
1618 /// Notes:
1619 /// **Data Source:** Memory
1620 ///
1621 /// # Arguments
1622 ///
1623 /// - `params`: [`Ticker24hrParams`]
1624 /// The parameters for this operation.
1625 ///
1626 /// # Returns
1627 ///
1628 /// [`RestApiResponse<models::Ticker24hrResponse>`] on success.
1629 ///
1630 /// # Errors
1631 ///
1632 /// This function will return an [`anyhow::Error`] if:
1633 /// - the HTTP request fails
1634 /// - any parameter is invalid
1635 /// - the response cannot be parsed
1636 /// - or one of the following occurs:
1637 /// - `RequiredError`
1638 /// - `ConnectorClientError`
1639 /// - `UnauthorizedError`
1640 /// - `ForbiddenError`
1641 /// - `TooManyRequestsError`
1642 /// - `RateLimitBanError`
1643 /// - `ServerError`
1644 /// - `NotFoundError`
1645 /// - `NetworkError`
1646 /// - `BadRequestError`
1647 ///
1648 ///
1649 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#ticker24hr).
1650 ///
1651 pub async fn ticker24hr(
1652 &self,
1653 params: Ticker24hrParams,
1654 ) -> anyhow::Result<RestApiResponse<models::Ticker24hrResponse>> {
1655 self.market_api_client.ticker24hr(params).await
1656 }
1657
1658 /// Symbol order book ticker
1659 ///
1660 /// Best price/qty on the order book for a symbol or symbols.
1661 ///
1662 /// Weight: |Parameter|Symbols Provided|Weight|
1663 /// |---|---|---|
1664 /// |symbol| 1 |2|
1665 /// | |omitted| 4|
1666 /// |symbols| Any |4|
1667 ///
1668 /// Security Type: NONE
1669 ///
1670 /// Notes:
1671 /// **Data Source:** Memory
1672 ///
1673 /// # Arguments
1674 ///
1675 /// - `params`: [`TickerBookTickerParams`]
1676 /// The parameters for this operation.
1677 ///
1678 /// # Returns
1679 ///
1680 /// [`RestApiResponse<models::TickerBookTickerResponse>`] 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/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#ticker-book-ticker).
1702 ///
1703 pub async fn ticker_book_ticker(
1704 &self,
1705 params: TickerBookTickerParams,
1706 ) -> anyhow::Result<RestApiResponse<models::TickerBookTickerResponse>> {
1707 self.market_api_client.ticker_book_ticker(params).await
1708 }
1709
1710 /// Symbol price ticker
1711 ///
1712 /// Latest price for a symbol or symbols.
1713 ///
1714 /// Weight: |Parameter|Symbols Provided|Weight|
1715 /// |---|---|---|
1716 /// |symbol| 1 |2|
1717 /// | |omitted| 4|
1718 /// |symbols| Any |4|
1719 ///
1720 /// Security Type: NONE
1721 ///
1722 /// Notes:
1723 /// **Data Source:** Memory
1724 ///
1725 /// # Arguments
1726 ///
1727 /// - `params`: [`TickerPriceParams`]
1728 /// The parameters for this operation.
1729 ///
1730 /// # Returns
1731 ///
1732 /// [`RestApiResponse<models::TickerPriceResponse>`] on success.
1733 ///
1734 /// # Errors
1735 ///
1736 /// This function will return an [`anyhow::Error`] if:
1737 /// - the HTTP request fails
1738 /// - any parameter is invalid
1739 /// - the response cannot be parsed
1740 /// - or one of the following occurs:
1741 /// - `RequiredError`
1742 /// - `ConnectorClientError`
1743 /// - `UnauthorizedError`
1744 /// - `ForbiddenError`
1745 /// - `TooManyRequestsError`
1746 /// - `RateLimitBanError`
1747 /// - `ServerError`
1748 /// - `NotFoundError`
1749 /// - `NetworkError`
1750 /// - `BadRequestError`
1751 ///
1752 ///
1753 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#ticker-price).
1754 ///
1755 pub async fn ticker_price(
1756 &self,
1757 params: TickerPriceParams,
1758 ) -> anyhow::Result<RestApiResponse<models::TickerPriceResponse>> {
1759 self.market_api_client.ticker_price(params).await
1760 }
1761
1762 /// Trading Day Ticker
1763 ///
1764 /// Price change statistics for a trading day.
1765 ///
1766 /// Weight: 4 for each requested symbol. The weight for this request will cap at 200 once the number of symbols in the request is more than 50.
1767 ///
1768 /// Security Type: NONE
1769 ///
1770 /// Notes:
1771 /// **Data Source:** Database
1772 ///
1773 /// **Notes:**:
1774 /// - Supported values for `timeZone`:
1775 /// - Hours and minutes (e.g. `-1:00`, `05:45`)
1776 /// - Only hours (e.g. `0`, `8`, `4`)
1777 ///
1778 /// # Arguments
1779 ///
1780 /// - `params`: [`TickerTradingDayParams`]
1781 /// The parameters for this operation.
1782 ///
1783 /// # Returns
1784 ///
1785 /// [`RestApiResponse<models::TickerTradingDayResponse>`] on success.
1786 ///
1787 /// # Errors
1788 ///
1789 /// This function will return an [`anyhow::Error`] if:
1790 /// - the HTTP request fails
1791 /// - any parameter is invalid
1792 /// - the response cannot be parsed
1793 /// - or one of the following occurs:
1794 /// - `RequiredError`
1795 /// - `ConnectorClientError`
1796 /// - `UnauthorizedError`
1797 /// - `ForbiddenError`
1798 /// - `TooManyRequestsError`
1799 /// - `RateLimitBanError`
1800 /// - `ServerError`
1801 /// - `NotFoundError`
1802 /// - `NetworkError`
1803 /// - `BadRequestError`
1804 ///
1805 ///
1806 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#ticker-trading-day).
1807 ///
1808 pub async fn ticker_trading_day(
1809 &self,
1810 params: TickerTradingDayParams,
1811 ) -> anyhow::Result<RestApiResponse<models::TickerTradingDayResponse>> {
1812 self.market_api_client.ticker_trading_day(params).await
1813 }
1814
1815 /// `UIKlines`
1816 ///
1817 /// The request is similar to klines having the same parameters and
1818 /// response.
1819 ///
1820 /// `uiKlines` return modified kline data, optimized for presentation of
1821 /// candlestick charts.
1822 ///
1823 /// Weight(IP): 2
1824 ///
1825 /// Security Type: NONE
1826 ///
1827 /// Notes:
1828 /// **Data Source:** Database
1829 ///
1830 /// - If `startTime` and `endTime` are not sent, the most recent klines are returned.
1831 /// - Supported values for `timeZone`:
1832 /// - Hours and minutes (e.g. `-1:00`, `05:45`)
1833 /// - Only hours (e.g. `0`, `8`, `4`)
1834 /// - Accepted range is strictly [-12:00 to +14:00] inclusive
1835 /// - If `timeZone` provided, kline intervals are interpreted in that timezone instead of UTC.
1836 /// - Note that `startTime` and `endTime` are always interpreted in UTC, regardless of `timeZone`.
1837 ///
1838 /// # Arguments
1839 ///
1840 /// - `params`: [`UiKlinesParams`]
1841 /// The parameters for this operation.
1842 ///
1843 /// # Returns
1844 ///
1845 /// [`RestApiResponse<Vec<Vec<models::KlinesItemInner>>>`] on success.
1846 ///
1847 /// # Errors
1848 ///
1849 /// This function will return an [`anyhow::Error`] if:
1850 /// - the HTTP request fails
1851 /// - any parameter is invalid
1852 /// - the response cannot be parsed
1853 /// - or one of the following occurs:
1854 /// - `RequiredError`
1855 /// - `ConnectorClientError`
1856 /// - `UnauthorizedError`
1857 /// - `ForbiddenError`
1858 /// - `TooManyRequestsError`
1859 /// - `RateLimitBanError`
1860 /// - `ServerError`
1861 /// - `NotFoundError`
1862 /// - `NetworkError`
1863 /// - `BadRequestError`
1864 ///
1865 ///
1866 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market#ui-klines).
1867 ///
1868 pub async fn ui_klines(
1869 &self,
1870 params: UiKlinesParams,
1871 ) -> anyhow::Result<RestApiResponse<Vec<Vec<models::KlinesItemInner>>>> {
1872 self.market_api_client.ui_klines(params).await
1873 }
1874
1875 /// Cancel All Open Orders on a Symbol (TRADE)
1876 ///
1877 /// Cancels all active orders on a symbol.
1878 /// This includes orders that are part of an order list.
1879 ///
1880 /// Weight(IP): 1
1881 ///
1882 /// Security Type: TRADE
1883 ///
1884 /// Notes:
1885 /// **Data Source:** Matching Engine
1886 ///
1887 /// # Arguments
1888 ///
1889 /// - `params`: [`DeleteOpenOrdersParams`]
1890 /// The parameters for this operation.
1891 ///
1892 /// # Returns
1893 ///
1894 /// [`RestApiResponse<Vec<models::DeleteOpenOrdersResponseInner>>`] on success.
1895 ///
1896 /// # Errors
1897 ///
1898 /// This function will return an [`anyhow::Error`] if:
1899 /// - the HTTP request fails
1900 /// - any parameter is invalid
1901 /// - the response cannot be parsed
1902 /// - or one of the following occurs:
1903 /// - `RequiredError`
1904 /// - `ConnectorClientError`
1905 /// - `UnauthorizedError`
1906 /// - `ForbiddenError`
1907 /// - `TooManyRequestsError`
1908 /// - `RateLimitBanError`
1909 /// - `ServerError`
1910 /// - `NotFoundError`
1911 /// - `NetworkError`
1912 /// - `BadRequestError`
1913 ///
1914 ///
1915 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#delete-open-orders).
1916 ///
1917 pub async fn delete_open_orders(
1918 &self,
1919 params: DeleteOpenOrdersParams,
1920 ) -> anyhow::Result<RestApiResponse<Vec<models::DeleteOpenOrdersResponseInner>>> {
1921 self.trade_api_client.delete_open_orders(params).await
1922 }
1923
1924 /// Cancel order (TRADE)
1925 ///
1926 /// Cancel an active order.
1927 ///
1928 /// Weight(IP): 1
1929 ///
1930 /// Security Type: TRADE
1931 ///
1932 /// Notes:
1933 /// **Data Source:** Matching Engine
1934 ///
1935 /// - Either `orderId` or `origClientOrderId` must be sent.
1936 /// - 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.
1937 /// - 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.
1938 ///
1939 /// # Arguments
1940 ///
1941 /// - `params`: [`DeleteOrderParams`]
1942 /// The parameters for this operation.
1943 ///
1944 /// # Returns
1945 ///
1946 /// [`RestApiResponse<models::DeleteOrderResponse>`] on success.
1947 ///
1948 /// # Errors
1949 ///
1950 /// This function will return an [`anyhow::Error`] if:
1951 /// - the HTTP request fails
1952 /// - any parameter is invalid
1953 /// - the response cannot be parsed
1954 /// - or one of the following occurs:
1955 /// - `RequiredError`
1956 /// - `ConnectorClientError`
1957 /// - `UnauthorizedError`
1958 /// - `ForbiddenError`
1959 /// - `TooManyRequestsError`
1960 /// - `RateLimitBanError`
1961 /// - `ServerError`
1962 /// - `NotFoundError`
1963 /// - `NetworkError`
1964 /// - `BadRequestError`
1965 ///
1966 ///
1967 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#delete-order).
1968 ///
1969 pub async fn delete_order(
1970 &self,
1971 params: DeleteOrderParams,
1972 ) -> anyhow::Result<RestApiResponse<models::DeleteOrderResponse>> {
1973 self.trade_api_client.delete_order(params).await
1974 }
1975
1976 /// Cancel Order list (TRADE)
1977 ///
1978 /// Cancel an entire Order list
1979 ///
1980 /// Weight(IP): 1
1981 ///
1982 /// Security Type: TRADE
1983 ///
1984 /// Notes:
1985 /// **Data Source:** Matching Engine
1986 ///
1987 /// **Notes:**
1988 /// - Canceling an individual order from an order list will cancel the entire order list.
1989 /// - 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.
1990 ///
1991 /// # Arguments
1992 ///
1993 /// - `params`: [`DeleteOrderListParams`]
1994 /// The parameters for this operation.
1995 ///
1996 /// # Returns
1997 ///
1998 /// [`RestApiResponse<models::DeleteOrderListResponse>`] on success.
1999 ///
2000 /// # Errors
2001 ///
2002 /// This function will return an [`anyhow::Error`] if:
2003 /// - the HTTP request fails
2004 /// - any parameter is invalid
2005 /// - the response cannot be parsed
2006 /// - or one of the following occurs:
2007 /// - `RequiredError`
2008 /// - `ConnectorClientError`
2009 /// - `UnauthorizedError`
2010 /// - `ForbiddenError`
2011 /// - `TooManyRequestsError`
2012 /// - `RateLimitBanError`
2013 /// - `ServerError`
2014 /// - `NotFoundError`
2015 /// - `NetworkError`
2016 /// - `BadRequestError`
2017 ///
2018 ///
2019 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#delete-order-list).
2020 ///
2021 pub async fn delete_order_list(
2022 &self,
2023 params: DeleteOrderListParams,
2024 ) -> anyhow::Result<RestApiResponse<models::DeleteOrderListResponse>> {
2025 self.trade_api_client.delete_order_list(params).await
2026 }
2027
2028 /// New order (TRADE)
2029 ///
2030 /// Send in a new order.
2031 ///
2032 /// This adds 1 order to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
2033 ///
2034 /// Weight(IP): 1
2035 ///
2036 /// Unfilled Order Count: 1
2037 ///
2038 /// Security Type: TRADE
2039 ///
2040 /// Notes:
2041 /// **Data Source:** Matching Engine
2042 ///
2043 /// Some additional mandatory parameters based on order `type`:
2044 ///
2045 /// Type | Additional mandatory parameters | Additional Information
2046 /// ------------ | ------------| ------
2047 /// `LIMIT` | `timeInForce`, `quantity`, `price`|
2048 /// `MARKET` | `quantity` or `quoteOrderQty`| `MARKET` orders using the `quantity` field specifies the amount of the `base asset` the user wants to buy or sell at the market price. <br/> E.g. MARKET order on BTCUSDT will specify how much BTC the user is buying or selling. <br/><br/> `MARKET` orders using `quoteOrderQty` specifies the amount the user wants to spend (when buying) or receive (when selling) the `quote` asset; the correct `quantity` will be determined based on the market liquidity and `quoteOrderQty`. <br/> E.g. Using the symbol BTCUSDT: <br/> `BUY` side, the order will buy as many BTC as `quoteOrderQty` USDT can. <br/> `SELL` side, the order will sell as much BTC needed to receive `quoteOrderQty` USDT.
2049 /// `STOP_LOSS` | `quantity`, `stopPrice` or `trailingDelta`| This will execute a `MARKET` order when the conditions are met. (e.g. `stopPrice` is met or `trailingDelta` is activated)
2050 /// `STOP_LOSS_LIMIT` | `timeInForce`, `quantity`, `price`, `stopPrice` or `trailingDelta`
2051 /// `TAKE_PROFIT` | `quantity`, `stopPrice` or `trailingDelta` | This will execute a `MARKET` order when the conditions are met. (e.g. `stopPrice` is met or `trailingDelta` is activated)
2052 /// `TAKE_PROFIT_LIMIT` | `timeInForce`, `quantity`, `price`, `stopPrice` or `trailingDelta` |
2053 /// `LIMIT_MAKER` | `quantity`, `price`| This is a `LIMIT` order that will be rejected if the order immediately matches and trades as a taker. <br/> This is also known as a POST-ONLY order.
2054 ///
2055 ///
2056 /// Notes on using parameters for Pegged Orders:
2057 /// * These parameters are allowed for `LIMIT`, `LIMIT_MAKER`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT_LIMIT` orders.
2058 /// * If `pegPriceType` is specified, `price` becomes optional. Otherwise, it is still mandatory.
2059 /// * `pegPriceType=PRIMARY_PEG` means the primary peg, that is the best price on the same side of the order book as your order.
2060 /// * `pegPriceType=MARKET_PEG` means the market peg, that is the best price on the opposite side of the order book from your order.
2061 /// * Use `pegOffsetType` and `pegOffsetValue` to request a price level other than the best one. These parameters must be specified together.
2062 ///
2063 /// Other info:
2064 /// * Any `LIMIT` or `LIMIT_MAKER` type order can be made an iceberg order by sending an `icebergQty`.
2065 /// * Any order with an `icebergQty` MUST have `timeInForce` set to `GTC`.
2066 /// * For `STOP_LOSS`, `STOP_LOSS_LIMIT`, `TAKE_PROFIT_LIMIT` and `TAKE_PROFIT` orders, `trailingDelta` can be combined with `stopPrice`.
2067 /// * `MARKET` orders using `quoteOrderQty` will not break `LOT_SIZE` filter rules; the order will execute a `quantity` that will have the notional value as close as possible to `quoteOrderQty`. Trigger order price rules against market price for both MARKET and LIMIT versions:
2068 /// * Price above market price: `STOP_LOSS` `BUY`, `TAKE_PROFIT` `SELL`
2069 /// * Price below market price: `STOP_LOSS` `SELL`, `TAKE_PROFIT` `BUY`
2070 ///
2071 /// # Arguments
2072 ///
2073 /// - `params`: [`NewOrderParams`]
2074 /// The parameters for this operation.
2075 ///
2076 /// # Returns
2077 ///
2078 /// [`RestApiResponse<models::NewOrderResponse>`] on success.
2079 ///
2080 /// # Errors
2081 ///
2082 /// This function will return an [`anyhow::Error`] if:
2083 /// - the HTTP request fails
2084 /// - any parameter is invalid
2085 /// - the response cannot be parsed
2086 /// - or one of the following occurs:
2087 /// - `RequiredError`
2088 /// - `ConnectorClientError`
2089 /// - `UnauthorizedError`
2090 /// - `ForbiddenError`
2091 /// - `TooManyRequestsError`
2092 /// - `RateLimitBanError`
2093 /// - `ServerError`
2094 /// - `NotFoundError`
2095 /// - `NetworkError`
2096 /// - `BadRequestError`
2097 ///
2098 ///
2099 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#new-order).
2100 ///
2101 pub async fn new_order(
2102 &self,
2103 params: NewOrderParams,
2104 ) -> anyhow::Result<RestApiResponse<models::NewOrderResponse>> {
2105 self.trade_api_client.new_order(params).await
2106 }
2107
2108 /// Order Amend Keep Priority (TRADE)
2109 ///
2110 /// Reduce the quantity of an existing open order.
2111 ///
2112 /// This adds 0 orders to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
2113 ///
2114 /// Read Order Amend Keep Priority FAQ to learn more.
2115 ///
2116 /// Weight(IP): 4
2117 ///
2118 /// Unfilled Order Count: 0
2119 ///
2120 /// Security Type: TRADE
2121 ///
2122 /// Notes:
2123 /// **Data Source:** Matching Engine
2124 ///
2125 /// # Arguments
2126 ///
2127 /// - `params`: [`OrderAmendKeepPriorityParams`]
2128 /// The parameters for this operation.
2129 ///
2130 /// # Returns
2131 ///
2132 /// [`RestApiResponse<models::OrderAmendKeepPriorityResponse>`] on success.
2133 ///
2134 /// # Errors
2135 ///
2136 /// This function will return an [`anyhow::Error`] if:
2137 /// - the HTTP request fails
2138 /// - any parameter is invalid
2139 /// - the response cannot be parsed
2140 /// - or one of the following occurs:
2141 /// - `RequiredError`
2142 /// - `ConnectorClientError`
2143 /// - `UnauthorizedError`
2144 /// - `ForbiddenError`
2145 /// - `TooManyRequestsError`
2146 /// - `RateLimitBanError`
2147 /// - `ServerError`
2148 /// - `NotFoundError`
2149 /// - `NetworkError`
2150 /// - `BadRequestError`
2151 ///
2152 ///
2153 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#order-amend-keep-priority).
2154 ///
2155 pub async fn order_amend_keep_priority(
2156 &self,
2157 params: OrderAmendKeepPriorityParams,
2158 ) -> anyhow::Result<RestApiResponse<models::OrderAmendKeepPriorityResponse>> {
2159 self.trade_api_client
2160 .order_amend_keep_priority(params)
2161 .await
2162 }
2163
2164 /// Cancel an Existing Order and Send a New Order (TRADE)
2165 ///
2166 /// - Cancels an existing order and places a new order on the same symbol.
2167 /// - Filters and Order Count are evaluated before the processing of the cancellation and order placement occurs.
2168 /// - A new order that was not attempted (i.e. when `newOrderResult: NOT_ATTEMPTED`), will still increase the unfilled order count by 1.
2169 /// - You can only cancel an individual order from an orderList using this endpoint, but the result is the same as canceling the entire orderList.
2170 ///
2171 /// Weight(IP): 1
2172 ///
2173 /// Unfilled Order Count: 1
2174 ///
2175 /// Security Type: TRADE
2176 ///
2177 /// Notes:
2178 /// **Data Source:** Matching Engine
2179 ///
2180 /// Similar to `POST /api/v3/order`, additional mandatory parameters are determined by `type`.
2181 /// Response format varies depending on whether the processing of the message succeeded, partially succeeded, or failed.
2182 ///
2183 /// <table>
2184 /// <thead>
2185 /// <tr>
2186 /// <th colspan=3 align=left>Request</th>
2187 /// <th colspan=3 align=left>Response</th>
2188 /// </tr>
2189 /// <tr>
2190 /// <th><code>cancelReplaceMode</code></th>
2191 /// <th><code>orderRateLimitExceededMode</code></th>
2192 /// <th>Unfilled Order Count</th>
2193 /// <th><code>cancelResult</code></th>
2194 /// <th><code>newOrderResult</code></th>
2195 /// <th><code>status</code></th>
2196 /// </tr>
2197 /// </thead>
2198 /// <tbody>
2199 /// <tr>
2200 /// <td rowspan="11"><code>STOP_ON_FAILURE</code></td>
2201 /// <td rowspan="6"><code>DO_NOTHING</code></td>
2202 /// <td rowspan="3">Within Limits</td>
2203 /// <td>✅ <code>SUCCESS</code></td>
2204 /// <td>✅ <code>SUCCESS</code></td>
2205 /// <td align=right><code>200</code></td>
2206 /// </tr>
2207 /// <tr>
2208 /// <td>❌ <code>FAILURE</code></td>
2209 /// <td>➖ <code>NOT_ATTEMPTED</code></td>
2210 /// <td align=right><code>400</code></td>
2211 /// </tr>
2212 /// <tr>
2213 /// <td>✅ <code>SUCCESS</code></td>
2214 /// <td>❌ <code>FAILURE</code></td>
2215 /// <td align=right><code>409</code></td>
2216 /// </tr>
2217 /// <tr>
2218 /// <td rowspan="3">Exceeds Limits</td>
2219 /// <td>✅ <code>SUCCESS</code></td>
2220 /// <td>✅ <code>SUCCESS</code></td>
2221 /// <td align=right>N/A</td>
2222 /// </tr>
2223 /// <tr>
2224 /// <td>❌ <code>FAILURE</code></td>
2225 /// <td>➖ <code>NOT_ATTEMPTED</code></td>
2226 /// <td align=right>N/A</td>
2227 /// </tr>
2228 /// <tr>
2229 /// <td>✅ <code>SUCCESS</code></td>
2230 /// <td>❌ <code>FAILURE</code></td>
2231 /// <td align=right>N/A</td>
2232 /// </tr>
2233 /// <tr>
2234 /// <td rowspan="5"><code>CANCEL_ONLY</code></td>
2235 /// <td rowspan="3">Within Limits</td>
2236 /// <td>✅ <code>SUCCESS</code></td>
2237 /// <td>✅ <code>SUCCESS</code></td>
2238 /// <td align=right><code>200</code></td>
2239 /// </tr>
2240 /// <tr>
2241 /// <td>❌ <code>FAILURE</code></td>
2242 /// <td>➖ <code>NOT_ATTEMPTED</code></td>
2243 /// <td align=right><code>400</code></td>
2244 /// </tr>
2245 /// <tr>
2246 /// <td>✅ <code>SUCCESS</code></td>
2247 /// <td>❌ <code>FAILURE</code></td>
2248 /// <td align=right><code>409</code></td>
2249 /// </tr>
2250 /// <tr>
2251 /// <td rowspan="2">Exceeds Limits</td>
2252 /// <td>❌ <code>FAILURE</code></td>
2253 /// <td>➖ <code>NOT_ATTEMPTED</code></td>
2254 /// <td align=right><code>429</code></td>
2255 /// </tr>
2256 /// <tr>
2257 /// <td>✅ <code>SUCCESS</code></td>
2258 /// <td>❌ <code>FAILURE</code></td>
2259 /// <td align=right><code>429</code></td>
2260 /// </tr>
2261 /// <tr>
2262 /// <td rowspan="16"><code>ALLOW_FAILURE</code></td>
2263 /// <td rowspan="8"><code>DO_NOTHING</code></td>
2264 /// <td rowspan="4">Within Limits</td>
2265 /// <td>✅ <code>SUCCESS</code></td>
2266 /// <td>✅ <code>SUCCESS</code></td>
2267 /// <td align=right><code>200</code></td>
2268 /// </tr>
2269 /// <tr>
2270 /// <td>❌ <code>FAILURE</code></td>
2271 /// <td>❌ <code>FAILURE</code></td>
2272 /// <td align=right><code>400</code></td>
2273 /// </tr>
2274 /// <tr>
2275 /// <td>❌ <code>FAILURE</code></td>
2276 /// <td>✅ <code>SUCCESS</code></td>
2277 /// <td align=right><code>409</code></td>
2278 /// </tr>
2279 /// <tr>
2280 /// <td>✅ <code>SUCCESS</code></td>
2281 /// <td>❌ <code>FAILURE</code></td>
2282 /// <td align=right><code>409</code></td>
2283 /// </tr>
2284 /// <tr>
2285 /// <td rowspan="4">Exceeds Limits</td>
2286 /// <td>✅ <code>SUCCESS</code></td>
2287 /// <td>✅ <code>SUCCESS</code></td>
2288 /// <td align=right>N/A</td>
2289 /// </tr>
2290 /// <tr>
2291 /// <td>❌ <code>FAILURE</code></td>
2292 /// <td>❌ <code>FAILURE</code></td>
2293 /// <td align=right>N/A</td>
2294 /// </tr>
2295 /// <tr>
2296 /// <td>❌ <code>FAILURE</code></td>
2297 /// <td>✅ <code>SUCCESS</code></td>
2298 /// <td align=right>N/A</td>
2299 /// </tr>
2300 /// <tr>
2301 /// <td>✅ <code>SUCCESS</code></td>
2302 /// <td>❌ <code>FAILURE</code></td>
2303 /// <td align=right>N/A</td>
2304 /// </tr>
2305 /// <tr>
2306 /// <td rowspan="8"><CODE>CANCEL_ONLY</CODE></td>
2307 /// <td rowspan="4">Within Limits</td>
2308 /// <td>✅ <code>SUCCESS</code></td>
2309 /// <td>✅ <code>SUCCESS</code></td>
2310 /// <td align=right><code>200</code></td>
2311 /// </tr>
2312 /// <tr>
2313 /// <td>❌ <code>FAILURE</code></td>
2314 /// <td>❌ <code>FAILURE</code></td>
2315 /// <td align=right><code>400</code></td>
2316 /// </tr>
2317 /// <tr>
2318 /// <td>❌ <code>FAILURE</code></td>
2319 /// <td>✅ <code>SUCCESS</code></td>
2320 /// <td align=right><code>409</code></td>
2321 /// </tr>
2322 /// <tr>
2323 /// <td>✅ <code>SUCCESS</code></td>
2324 /// <td>❌ <code>FAILURE</code></td>
2325 /// <td align=right><code>409</code></td>
2326 /// </tr>
2327 /// <tr>
2328 /// <td rowspan="4">Exceeds Limits</td>
2329 /// <td>✅ <code>SUCCESS</code></td>
2330 /// <td>✅ <code>SUCCESS</code></td>
2331 /// <td align=right><code>N/A</code></td>
2332 /// </tr>
2333 /// <tr>
2334 /// <td>❌ <code>FAILURE</code></td>
2335 /// <td>❌ <code>FAILURE</code></td>
2336 /// <td align=right><code>400</code></td>
2337 /// </tr>
2338 /// <tr>
2339 /// <td>❌ <code>FAILURE</code></td>
2340 /// <td>✅ <code>SUCCESS</code></td>
2341 /// <td align=right>N/A</td>
2342 /// </tr>
2343 /// <tr>
2344 /// <td>✅ <code>SUCCESS</code></td>
2345 /// <td>❌ <code>FAILURE</code></td>
2346 /// <td align=right><code>409</code></td>
2347 /// </tr>
2348 /// </tbody>
2349 /// </table>
2350 ///
2351 /// **Notes:**
2352 /// - 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.
2353 ///
2354 /// # Arguments
2355 ///
2356 /// - `params`: [`OrderCancelReplaceParams`]
2357 /// The parameters for this operation.
2358 ///
2359 /// # Returns
2360 ///
2361 /// [`RestApiResponse<models::OrderCancelReplaceResponse>`] on success.
2362 ///
2363 /// # Errors
2364 ///
2365 /// This function will return an [`anyhow::Error`] if:
2366 /// - the HTTP request fails
2367 /// - any parameter is invalid
2368 /// - the response cannot be parsed
2369 /// - or one of the following occurs:
2370 /// - `RequiredError`
2371 /// - `ConnectorClientError`
2372 /// - `UnauthorizedError`
2373 /// - `ForbiddenError`
2374 /// - `TooManyRequestsError`
2375 /// - `RateLimitBanError`
2376 /// - `ServerError`
2377 /// - `NotFoundError`
2378 /// - `NetworkError`
2379 /// - `BadRequestError`
2380 ///
2381 ///
2382 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#order-cancel-replace).
2383 ///
2384 pub async fn order_cancel_replace(
2385 &self,
2386 params: OrderCancelReplaceParams,
2387 ) -> anyhow::Result<RestApiResponse<models::OrderCancelReplaceResponse>> {
2388 self.trade_api_client.order_cancel_replace(params).await
2389 }
2390
2391 /// New Order list - OCO (TRADE)
2392 ///
2393 /// Send in an one-cancels-the-other (OCO) pair, where activation of one
2394 /// order immediately cancels the other.
2395 ///
2396 /// - An OCO has 2 orders called the **above order** and **below order**.
2397 /// - 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.
2398 /// - Price restrictions
2399 /// - If the OCO is on the `SELL` side:
2400 /// - `LIMIT_MAKER/TAKE_PROFIT_LIMIT` `price` > Last Traded Price > `STOP_LOSS/STOP_LOSS_LIMIT` `stopPrice`
2401 /// - `TAKE_PROFIT stopPrice` > Last Traded Price > `STOP_LOSS/STOP_LOSS_LIMIT stopPrice`
2402 /// - If the OCO is on the `BUY` side:
2403 /// - `LIMIT_MAKER/TAKE_PROFIT_LIMIT price` < Last Traded Price < `stopPrice`
2404 /// - `TAKE_PROFIT stopPrice` < Last Traded Price < `STOP_LOSS/STOP_LOSS_LIMIT stopPrice` * OCOs add **2 orders** to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
2405 /// - OCOs add 2 orders to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
2406 ///
2407 /// Weight(IP): 1
2408 ///
2409 /// Unfilled Order Count: 2
2410 ///
2411 /// Security Type: TRADE
2412 ///
2413 /// Notes:
2414 /// **Data Source:** Matching Engine
2415 ///
2416 /// # Arguments
2417 ///
2418 /// - `params`: [`OrderListOcoParams`]
2419 /// The parameters for this operation.
2420 ///
2421 /// # Returns
2422 ///
2423 /// [`RestApiResponse<models::OrderListOcoResponse>`] on success.
2424 ///
2425 /// # Errors
2426 ///
2427 /// This function will return an [`anyhow::Error`] if:
2428 /// - the HTTP request fails
2429 /// - any parameter is invalid
2430 /// - the response cannot be parsed
2431 /// - or one of the following occurs:
2432 /// - `RequiredError`
2433 /// - `ConnectorClientError`
2434 /// - `UnauthorizedError`
2435 /// - `ForbiddenError`
2436 /// - `TooManyRequestsError`
2437 /// - `RateLimitBanError`
2438 /// - `ServerError`
2439 /// - `NotFoundError`
2440 /// - `NetworkError`
2441 /// - `BadRequestError`
2442 ///
2443 ///
2444 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#order-list-oco).
2445 ///
2446 pub async fn order_list_oco(
2447 &self,
2448 params: OrderListOcoParams,
2449 ) -> anyhow::Result<RestApiResponse<models::OrderListOcoResponse>> {
2450 self.trade_api_client.order_list_oco(params).await
2451 }
2452
2453 /// New Order List - OPO (TRADE)
2454 ///
2455 /// Place an [OPO](/products/spot/faqs/opo).
2456 ///
2457 /// - OPOs add 2 orders to the `EXCHANGE_MAX_NUM_ORDERS`` filter and `MAX_NUM_ORDERS`` filter.
2458 ///
2459 /// Weight(IP): 1
2460 ///
2461 /// Unfilled Order Count: 2
2462 ///
2463 /// Security Type: TRADE
2464 ///
2465 /// Notes:
2466 /// **Data Source:** Matching Engine
2467 ///
2468 /// # Arguments
2469 ///
2470 /// - `params`: [`OrderListOpoParams`]
2471 /// The parameters for this operation.
2472 ///
2473 /// # Returns
2474 ///
2475 /// [`RestApiResponse<models::OrderListOpoResponse>`] on success.
2476 ///
2477 /// # Errors
2478 ///
2479 /// This function will return an [`anyhow::Error`] if:
2480 /// - the HTTP request fails
2481 /// - any parameter is invalid
2482 /// - the response cannot be parsed
2483 /// - or one of the following occurs:
2484 /// - `RequiredError`
2485 /// - `ConnectorClientError`
2486 /// - `UnauthorizedError`
2487 /// - `ForbiddenError`
2488 /// - `TooManyRequestsError`
2489 /// - `RateLimitBanError`
2490 /// - `ServerError`
2491 /// - `NotFoundError`
2492 /// - `NetworkError`
2493 /// - `BadRequestError`
2494 ///
2495 ///
2496 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#order-list-opo).
2497 ///
2498 pub async fn order_list_opo(
2499 &self,
2500 params: OrderListOpoParams,
2501 ) -> anyhow::Result<RestApiResponse<models::OrderListOpoResponse>> {
2502 self.trade_api_client.order_list_opo(params).await
2503 }
2504
2505 /// New Order List - OPOCO (TRADE)
2506 ///
2507 /// Place an [OPOCO](/products/spot/faqs/opo).
2508 ///
2509 /// Weight(IP): 1
2510 ///
2511 /// Unfilled Order Count: 3
2512 ///
2513 /// Security Type: TRADE
2514 ///
2515 /// Notes:
2516 /// **Data Source:** Matching Engine
2517 ///
2518 /// # Arguments
2519 ///
2520 /// - `params`: [`OrderListOpocoParams`]
2521 /// The parameters for this operation.
2522 ///
2523 /// # Returns
2524 ///
2525 /// [`RestApiResponse<models::OrderListOpocoResponse>`] on success.
2526 ///
2527 /// # Errors
2528 ///
2529 /// This function will return an [`anyhow::Error`] if:
2530 /// - the HTTP request fails
2531 /// - any parameter is invalid
2532 /// - the response cannot be parsed
2533 /// - or one of the following occurs:
2534 /// - `RequiredError`
2535 /// - `ConnectorClientError`
2536 /// - `UnauthorizedError`
2537 /// - `ForbiddenError`
2538 /// - `TooManyRequestsError`
2539 /// - `RateLimitBanError`
2540 /// - `ServerError`
2541 /// - `NotFoundError`
2542 /// - `NetworkError`
2543 /// - `BadRequestError`
2544 ///
2545 ///
2546 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#order-list-opoco).
2547 ///
2548 pub async fn order_list_opoco(
2549 &self,
2550 params: OrderListOpocoParams,
2551 ) -> anyhow::Result<RestApiResponse<models::OrderListOpocoResponse>> {
2552 self.trade_api_client.order_list_opoco(params).await
2553 }
2554
2555 /// New Order list - OTO (TRADE)
2556 ///
2557 /// Place an OTO.
2558 ///
2559 /// - An OTO (One-Triggers-the-Other) is an order list comprised of 2 orders.
2560 /// - 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.
2561 /// - 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**.
2562 /// - 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.
2563 /// - 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.
2564 /// - OTOs add **2 orders** to the `EXCHANGE_MAX_NUM_ORDERS` filter and `MAX_NUM_ORDERS` filter.
2565 ///
2566 /// Weight(IP): 1
2567 ///
2568 /// Unfilled Order Count: 2
2569 ///
2570 /// Security Type: TRADE
2571 ///
2572 /// Notes:
2573 /// **Data Source:** Matching Engine
2574 ///
2575 /// **Mandatory parameters based on `pendingType` or `workingType`**
2576 ///
2577 /// Depending on the `pendingType` or `workingType`, some optional parameters will become mandatory.
2578 ///
2579 /// |Type |Additional mandatory parameters|Additional information|
2580 /// |---- |---- |------
2581 /// |`workingType` = `LIMIT` |`workingTimeInForce` |
2582 /// |`pendingType` = `LIMIT` |`pendingPrice`, `pendingTimeInForce` |
2583 /// |`pendingType` = `STOP_LOSS` or `TAKE_PROFIT` |`pendingStopPrice` and/or `pendingTrailingDelta`|
2584 /// |`pendingType` = `STOP_LOSS_LIMIT` or `TAKE_PROFIT_LIMIT`|`pendingPrice`, `pendingStopPrice` and/or `pendingTrailingDelta`, `pendingTimeInForce`|
2585 ///
2586 /// # Arguments
2587 ///
2588 /// - `params`: [`OrderListOtoParams`]
2589 /// The parameters for this operation.
2590 ///
2591 /// # Returns
2592 ///
2593 /// [`RestApiResponse<models::OrderListOtoResponse>`] on success.
2594 ///
2595 /// # Errors
2596 ///
2597 /// This function will return an [`anyhow::Error`] if:
2598 /// - the HTTP request fails
2599 /// - any parameter is invalid
2600 /// - the response cannot be parsed
2601 /// - or one of the following occurs:
2602 /// - `RequiredError`
2603 /// - `ConnectorClientError`
2604 /// - `UnauthorizedError`
2605 /// - `ForbiddenError`
2606 /// - `TooManyRequestsError`
2607 /// - `RateLimitBanError`
2608 /// - `ServerError`
2609 /// - `NotFoundError`
2610 /// - `NetworkError`
2611 /// - `BadRequestError`
2612 ///
2613 ///
2614 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#order-list-oto).
2615 ///
2616 pub async fn order_list_oto(
2617 &self,
2618 params: OrderListOtoParams,
2619 ) -> anyhow::Result<RestApiResponse<models::OrderListOtoResponse>> {
2620 self.trade_api_client.order_list_oto(params).await
2621 }
2622
2623 /// New Order list - OTOCO (TRADE)
2624 ///
2625 /// Place an OTOCO.
2626 ///
2627 /// - An OTOCO (One-Triggers-One-Cancels-the-Other) is an order list comprised of 3 orders.
2628 /// - 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.
2629 /// - The behavior of the working order is the same as the [OTO](#order-list-oto).
2630 /// - 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**.
2631 /// - The rules of the pending above and pending below follow the same rules as the [Order list OCO](#order-list-oco).
2632 /// - OTOCOs add **3 orders** to the `EXCHANGE_MAX_NUM_ORDERS` filter and `MAX_NUM_ORDERS` filter.
2633 ///
2634 /// Weight(IP): 1
2635 ///
2636 /// Unfilled Order Count: 3
2637 ///
2638 /// Security Type: TRADE
2639 ///
2640 /// Notes:
2641 /// **Data Source:** Matching Engine
2642 ///
2643 /// **Mandatory parameters based on `pendingAboveType`, `pendingBelowType` or `workingType`**
2644 ///
2645 /// Depending on the `pendingAboveType`/`pendingBelowType` or `workingType`, some optional parameters will become mandatory.
2646 ///
2647 /// |Type |Additional mandatory parameters|Additional information|
2648 /// |---- |---- |------
2649 /// |`workingType` = `LIMIT` |`workingTimeInForce` |
2650 /// |`pendingAboveType`= `LIMIT_MAKER` |`pendingAbovePrice` |
2651 /// |`pendingAboveType` = `STOP_LOSS/TAKE_PROFIT` |`pendingAboveStopPrice` and/or `pendingAboveTrailingDelta`|
2652 /// |`pendingAboveType=STOP_LOSS_LIMIT/TAKE_PROFIT_LIMIT` |`pendingAbovePrice`, `pendingAboveStopPrice` and/or `pendingAboveTrailingDelta`, `pendingAboveTimeInForce`|
2653 /// |`pendingBelowType`= `LIMIT_MAKER` |`pendingBelowPrice` |
2654 /// |`pendingBelowType= STOP_LOSS/TAKE_PROFIT` |`pendingBelowStopPrice` and/or `pendingBelowTrailingDelta`|
2655 /// |`pendingBelowType=STOP_LOSS_LIMIT/TAKE_PROFIT_LIMIT` |`pendingBelowPrice`, `pendingBelowStopPrice` and/or `pendingBelowTrailingDelta`, `pendingBelowTimeInForce`|
2656 ///
2657 /// # Arguments
2658 ///
2659 /// - `params`: [`OrderListOtocoParams`]
2660 /// The parameters for this operation.
2661 ///
2662 /// # Returns
2663 ///
2664 /// [`RestApiResponse<models::OrderListOtocoResponse>`] on success.
2665 ///
2666 /// # Errors
2667 ///
2668 /// This function will return an [`anyhow::Error`] if:
2669 /// - the HTTP request fails
2670 /// - any parameter is invalid
2671 /// - the response cannot be parsed
2672 /// - or one of the following occurs:
2673 /// - `RequiredError`
2674 /// - `ConnectorClientError`
2675 /// - `UnauthorizedError`
2676 /// - `ForbiddenError`
2677 /// - `TooManyRequestsError`
2678 /// - `RateLimitBanError`
2679 /// - `ServerError`
2680 /// - `NotFoundError`
2681 /// - `NetworkError`
2682 /// - `BadRequestError`
2683 ///
2684 ///
2685 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#order-list-otoco).
2686 ///
2687 pub async fn order_list_otoco(
2688 &self,
2689 params: OrderListOtocoParams,
2690 ) -> anyhow::Result<RestApiResponse<models::OrderListOtocoResponse>> {
2691 self.trade_api_client.order_list_otoco(params).await
2692 }
2693
2694 /// New OCO - Deprecated (TRADE)
2695 ///
2696 /// Send in a new OCO.
2697 ///
2698 /// - Price Restrictions:
2699 /// - `SELL`: Limit Price > Last Price > Stop Price
2700 /// - `BUY`: Limit Price < Last Price < Stop Price
2701 /// - Quantity Restrictions:
2702 /// - Both legs must have the same quantity.
2703 /// - `ICEBERG` quantities however do not have to be the same
2704 /// - `OCO` adds **2 orders** to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
2705 ///
2706 /// Weight(IP): 1
2707 ///
2708 /// Unfilled Order Count: 2
2709 ///
2710 /// Security Type: TRADE
2711 ///
2712 /// Notes:
2713 /// **Data Source:** Matching Engine
2714 ///
2715 /// # Arguments
2716 ///
2717 /// - `params`: [`OrderOcoParams`]
2718 /// The parameters for this operation.
2719 ///
2720 /// # Returns
2721 ///
2722 /// [`RestApiResponse<models::OrderOcoResponse>`] on success.
2723 ///
2724 /// # Errors
2725 ///
2726 /// This function will return an [`anyhow::Error`] if:
2727 /// - the HTTP request fails
2728 /// - any parameter is invalid
2729 /// - the response cannot be parsed
2730 /// - or one of the following occurs:
2731 /// - `RequiredError`
2732 /// - `ConnectorClientError`
2733 /// - `UnauthorizedError`
2734 /// - `ForbiddenError`
2735 /// - `TooManyRequestsError`
2736 /// - `RateLimitBanError`
2737 /// - `ServerError`
2738 /// - `NotFoundError`
2739 /// - `NetworkError`
2740 /// - `BadRequestError`
2741 ///
2742 ///
2743 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#order-oco).
2744 ///
2745 /// # Deprecation
2746 ///
2747 /// **Deprecated:** This method may be removed in a future version.
2748 #[deprecated]
2749 pub async fn order_oco(
2750 &self,
2751 params: OrderOcoParams,
2752 ) -> anyhow::Result<RestApiResponse<models::OrderOcoResponse>> {
2753 self.trade_api_client.order_oco(params).await
2754 }
2755
2756 /// Test new order (TRADE)
2757 ///
2758 /// Test new order creation and signature/recvWindow long.
2759 ///
2760 /// Creates and validates a new order but does not send it into the matching
2761 /// engine.
2762 ///
2763 /// Weight: |Condition|Weight|
2764 /// |---|---|
2765 /// |Without `computeCommissionRates`|1|
2766 /// |With `computeCommissionRates`|20|
2767 ///
2768 /// Security Type: TRADE
2769 ///
2770 /// Notes:
2771 /// **Data Source:** Memory
2772 ///
2773 /// # Arguments
2774 ///
2775 /// - `params`: [`OrderTestParams`]
2776 /// The parameters for this operation.
2777 ///
2778 /// # Returns
2779 ///
2780 /// [`RestApiResponse<models::OrderTestResponse>`] on success.
2781 ///
2782 /// # Errors
2783 ///
2784 /// This function will return an [`anyhow::Error`] if:
2785 /// - the HTTP request fails
2786 /// - any parameter is invalid
2787 /// - the response cannot be parsed
2788 /// - or one of the following occurs:
2789 /// - `RequiredError`
2790 /// - `ConnectorClientError`
2791 /// - `UnauthorizedError`
2792 /// - `ForbiddenError`
2793 /// - `TooManyRequestsError`
2794 /// - `RateLimitBanError`
2795 /// - `ServerError`
2796 /// - `NotFoundError`
2797 /// - `NetworkError`
2798 /// - `BadRequestError`
2799 ///
2800 ///
2801 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#order-test).
2802 ///
2803 pub async fn order_test(
2804 &self,
2805 params: OrderTestParams,
2806 ) -> anyhow::Result<RestApiResponse<models::OrderTestResponse>> {
2807 self.trade_api_client.order_test(params).await
2808 }
2809
2810 /// New order using SOR (TRADE)
2811 ///
2812 /// Places an order using smart order routing (SOR).
2813 ///
2814 /// This adds 1 order to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.
2815 ///
2816 /// Read [SOR FAQ](/products/spot/faqs/sor_faq) to learn more.
2817 ///
2818 /// Weight(IP): 1
2819 ///
2820 /// Unfilled Order Count: 1
2821 ///
2822 /// Security Type: TRADE
2823 ///
2824 /// Notes:
2825 /// **Data Source:** Matching Engine
2826 ///
2827 /// **Note:** `POST /api/v3/sor/order` only supports `LIMIT` and `MARKET` orders. `quoteOrderQty` is not supported.
2828 ///
2829 /// # Arguments
2830 ///
2831 /// - `params`: [`SorOrderParams`]
2832 /// The parameters for this operation.
2833 ///
2834 /// # Returns
2835 ///
2836 /// [`RestApiResponse<models::SorOrderResponse>`] on success.
2837 ///
2838 /// # Errors
2839 ///
2840 /// This function will return an [`anyhow::Error`] if:
2841 /// - the HTTP request fails
2842 /// - any parameter is invalid
2843 /// - the response cannot be parsed
2844 /// - or one of the following occurs:
2845 /// - `RequiredError`
2846 /// - `ConnectorClientError`
2847 /// - `UnauthorizedError`
2848 /// - `ForbiddenError`
2849 /// - `TooManyRequestsError`
2850 /// - `RateLimitBanError`
2851 /// - `ServerError`
2852 /// - `NotFoundError`
2853 /// - `NetworkError`
2854 /// - `BadRequestError`
2855 ///
2856 ///
2857 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#sor-order).
2858 ///
2859 pub async fn sor_order(
2860 &self,
2861 params: SorOrderParams,
2862 ) -> anyhow::Result<RestApiResponse<models::SorOrderResponse>> {
2863 self.trade_api_client.sor_order(params).await
2864 }
2865
2866 /// Test new order using SOR (TRADE)
2867 ///
2868 /// Test new order creation and signature/recvWindow using smart order routing (SOR).
2869 /// Creates and validates a new order but does not send it into the matching engine.
2870 ///
2871 /// Weight: |Condition|Weight|
2872 /// |---|---|
2873 /// |Without `computeCommissionRates`|1|
2874 /// |With `computeCommissionRates`|20|
2875 ///
2876 /// Security Type: TRADE
2877 ///
2878 /// Notes:
2879 /// **Data Source:** Memory
2880 ///
2881 /// # Arguments
2882 ///
2883 /// - `params`: [`SorOrderTestParams`]
2884 /// The parameters for this operation.
2885 ///
2886 /// # Returns
2887 ///
2888 /// [`RestApiResponse<models::SorOrderTestResponse>`] on success.
2889 ///
2890 /// # Errors
2891 ///
2892 /// This function will return an [`anyhow::Error`] if:
2893 /// - the HTTP request fails
2894 /// - any parameter is invalid
2895 /// - the response cannot be parsed
2896 /// - or one of the following occurs:
2897 /// - `RequiredError`
2898 /// - `ConnectorClientError`
2899 /// - `UnauthorizedError`
2900 /// - `ForbiddenError`
2901 /// - `TooManyRequestsError`
2902 /// - `RateLimitBanError`
2903 /// - `ServerError`
2904 /// - `NotFoundError`
2905 /// - `NetworkError`
2906 /// - `BadRequestError`
2907 ///
2908 ///
2909 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/trade#sor-order-test).
2910 ///
2911 pub async fn sor_order_test(
2912 &self,
2913 params: SorOrderTestParams,
2914 ) -> anyhow::Result<RestApiResponse<models::SorOrderTestResponse>> {
2915 self.trade_api_client.sor_order_test(params).await
2916 }
2917}