binance_sdk/margin_trading/rest_api/mod.rs
1/*
2 * Margin REST API
3 *
4 * Access account information, borrow and repay assets, and trade with Binance Margin.
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 borrow_repay_api_client: BorrowRepayApiClient,
33 market_data_api_client: MarketDataApiClient,
34 trade_api_client: TradeApiClient,
35 transfer_api_client: TransferApiClient,
36 user_data_stream_api_client: UserDataStreamApiClient,
37}
38
39impl RestApi {
40 pub fn new(configuration: ConfigurationRestApi) -> Self {
41 let account_api_client = AccountApiClient::new(configuration.clone());
42 let borrow_repay_api_client = BorrowRepayApiClient::new(configuration.clone());
43 let market_data_api_client = MarketDataApiClient::new(configuration.clone());
44 let trade_api_client = TradeApiClient::new(configuration.clone());
45 let transfer_api_client = TransferApiClient::new(configuration.clone());
46 let user_data_stream_api_client = UserDataStreamApiClient::new(configuration.clone());
47
48 Self {
49 configuration,
50 account_api_client,
51 borrow_repay_api_client,
52 market_data_api_client,
53 trade_api_client,
54 transfer_api_client,
55 user_data_stream_api_client,
56 }
57 }
58
59 /// Send an unsigned request to the API
60 ///
61 /// # Arguments
62 ///
63 /// * `endpoint` - The API endpoint to send the request to
64 /// * `method` - The HTTP method to use for the request
65 /// * `query_params` - A map of query parameters to send with the request
66 /// * `body_params` - A map of body parameters to send with the request
67 ///
68 /// # Returns
69 ///
70 /// A `RestApiResponse` containing the deserialized response data on success, or an error if the request fails
71 ///
72 /// # Errors
73 ///
74 /// Returns an `anyhow::Error` if the HTTP request fails or if parsing the response fails
75 pub async fn send_request<R: DeserializeOwned + Send + 'static>(
76 &self,
77 endpoint: &str,
78 method: Method,
79 query_params: BTreeMap<String, Value>,
80 body_params: BTreeMap<String, Value>,
81 ) -> anyhow::Result<RestApiResponse<R>> {
82 send_request::<R>(
83 &self.configuration,
84 endpoint,
85 method,
86 query_params,
87 body_params,
88 None,
89 false,
90 )
91 .await
92 }
93
94 /// Send a signed request to the API
95 ///
96 /// # Arguments
97 ///
98 /// * `endpoint` - The API endpoint to send the request to
99 /// * `method` - The HTTP method to use for the request
100 /// * `query_params` - A map of query parameters to send with the request
101 /// * `body_params` - A map of body parameters to send with the request
102 ///
103 /// # Returns
104 ///
105 /// A `RestApiResponse` containing the deserialized response data on success, or an error if the request fails
106 ///
107 /// # Errors
108 ///
109 /// Returns an `anyhow::Error` if the HTTP request fails or if parsing the response fails
110 pub async fn send_signed_request<R: DeserializeOwned + Send + 'static>(
111 &self,
112 endpoint: &str,
113 method: Method,
114 query_params: BTreeMap<String, Value>,
115 body_params: BTreeMap<String, Value>,
116 ) -> anyhow::Result<RestApiResponse<R>> {
117 send_request::<R>(
118 &self.configuration,
119 endpoint,
120 method,
121 query_params,
122 body_params,
123 None,
124 true,
125 )
126 .await
127 }
128
129 /// Adjust cross margin max leverage (`USER_DATA`)
130 ///
131 /// Adjust cross margin max leverage
132 ///
133 /// Weight(UID): 3000, 1 times/min per IP
134 ///
135 /// Security Type: `USER_DATA`
136 ///
137 /// Notes:
138 /// - The margin level need higher than the initial risk ratio of adjusted leverage, the initial risk ratio of 3x is 1.5 , the initial risk ratio of 5x is 1.25; The detail conditions on how to switch between Cross Margin Classic and Cross Margin Pro can refer to [the FAQ](https://www.binance.com/en/support/faq/how-to-activate-the-cross-margin-pro-mode-on-binance-e27786da05e743a694b8c625b3bc475d).
139 ///
140 /// # Arguments
141 ///
142 /// - `params`: [`AdjustCrossMarginMaxLeverageParams`]
143 /// The parameters for this operation.
144 ///
145 /// # Returns
146 ///
147 /// [`RestApiResponse<models::AdjustCrossMarginMaxLeverageResponse>`] on success.
148 ///
149 /// # Errors
150 ///
151 /// This function will return an [`anyhow::Error`] if:
152 /// - the HTTP request fails
153 /// - any parameter is invalid
154 /// - the response cannot be parsed
155 /// - or one of the following occurs:
156 /// - `RequiredError`
157 /// - `ConnectorClientError`
158 /// - `UnauthorizedError`
159 /// - `ForbiddenError`
160 /// - `TooManyRequestsError`
161 /// - `RateLimitBanError`
162 /// - `ServerError`
163 /// - `NotFoundError`
164 /// - `NetworkError`
165 /// - `BadRequestError`
166 ///
167 ///
168 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/account#adjust-cross-margin-max-leverage).
169 ///
170 pub async fn adjust_cross_margin_max_leverage(
171 &self,
172 params: AdjustCrossMarginMaxLeverageParams,
173 ) -> anyhow::Result<RestApiResponse<models::AdjustCrossMarginMaxLeverageResponse>> {
174 self.account_api_client
175 .adjust_cross_margin_max_leverage(params)
176 .await
177 }
178
179 /// Disable Isolated Margin Account (TRADE)
180 ///
181 /// Disable isolated margin account for a specific symbol. Each trading pair can only be deactivated once every 24 hours.
182 ///
183 /// Weight(UID): 300
184 ///
185 /// Security Type: TRADE
186 ///
187 /// # Arguments
188 ///
189 /// - `params`: [`DisableIsolatedMarginAccountParams`]
190 /// The parameters for this operation.
191 ///
192 /// # Returns
193 ///
194 /// [`RestApiResponse<models::DisableIsolatedMarginAccountResponse>`] on success.
195 ///
196 /// # Errors
197 ///
198 /// This function will return an [`anyhow::Error`] if:
199 /// - the HTTP request fails
200 /// - any parameter is invalid
201 /// - the response cannot be parsed
202 /// - or one of the following occurs:
203 /// - `RequiredError`
204 /// - `ConnectorClientError`
205 /// - `UnauthorizedError`
206 /// - `ForbiddenError`
207 /// - `TooManyRequestsError`
208 /// - `RateLimitBanError`
209 /// - `ServerError`
210 /// - `NotFoundError`
211 /// - `NetworkError`
212 /// - `BadRequestError`
213 ///
214 ///
215 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/account#disable-isolated-margin-account).
216 ///
217 pub async fn disable_isolated_margin_account(
218 &self,
219 params: DisableIsolatedMarginAccountParams,
220 ) -> anyhow::Result<RestApiResponse<models::DisableIsolatedMarginAccountResponse>> {
221 self.account_api_client
222 .disable_isolated_margin_account(params)
223 .await
224 }
225
226 /// Enable Isolated Margin Account (TRADE)
227 ///
228 /// Enable isolated margin account for a specific symbol(Only supports activation of previously disabled accounts).
229 ///
230 /// Weight(UID): 300
231 ///
232 /// Security Type: TRADE
233 ///
234 /// # Arguments
235 ///
236 /// - `params`: [`EnableIsolatedMarginAccountParams`]
237 /// The parameters for this operation.
238 ///
239 /// # Returns
240 ///
241 /// [`RestApiResponse<models::EnableIsolatedMarginAccountResponse>`] on success.
242 ///
243 /// # Errors
244 ///
245 /// This function will return an [`anyhow::Error`] if:
246 /// - the HTTP request fails
247 /// - any parameter is invalid
248 /// - the response cannot be parsed
249 /// - or one of the following occurs:
250 /// - `RequiredError`
251 /// - `ConnectorClientError`
252 /// - `UnauthorizedError`
253 /// - `ForbiddenError`
254 /// - `TooManyRequestsError`
255 /// - `RateLimitBanError`
256 /// - `ServerError`
257 /// - `NotFoundError`
258 /// - `NetworkError`
259 /// - `BadRequestError`
260 ///
261 ///
262 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/account#enable-isolated-margin-account).
263 ///
264 pub async fn enable_isolated_margin_account(
265 &self,
266 params: EnableIsolatedMarginAccountParams,
267 ) -> anyhow::Result<RestApiResponse<models::EnableIsolatedMarginAccountResponse>> {
268 self.account_api_client
269 .enable_isolated_margin_account(params)
270 .await
271 }
272
273 /// Get BNB Burn Status (`USER_DATA`)
274 ///
275 /// Get BNB Burn Status
276 ///
277 /// Weight(IP): 1
278 ///
279 /// Security Type: `USER_DATA`
280 ///
281 /// # Arguments
282 ///
283 /// - `params`: [`GetBnbBurnStatusParams`]
284 /// The parameters for this operation.
285 ///
286 /// # Returns
287 ///
288 /// [`RestApiResponse<models::GetBnbBurnStatusResponse>`] on success.
289 ///
290 /// # Errors
291 ///
292 /// This function will return an [`anyhow::Error`] if:
293 /// - the HTTP request fails
294 /// - any parameter is invalid
295 /// - the response cannot be parsed
296 /// - or one of the following occurs:
297 /// - `RequiredError`
298 /// - `ConnectorClientError`
299 /// - `UnauthorizedError`
300 /// - `ForbiddenError`
301 /// - `TooManyRequestsError`
302 /// - `RateLimitBanError`
303 /// - `ServerError`
304 /// - `NotFoundError`
305 /// - `NetworkError`
306 /// - `BadRequestError`
307 ///
308 ///
309 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/account#get-bnb-burn-status).
310 ///
311 pub async fn get_bnb_burn_status(
312 &self,
313 params: GetBnbBurnStatusParams,
314 ) -> anyhow::Result<RestApiResponse<models::GetBnbBurnStatusResponse>> {
315 self.account_api_client.get_bnb_burn_status(params).await
316 }
317
318 /// Get Summary of Margin account (`USER_DATA`)
319 ///
320 /// Get personal margin level information
321 ///
322 /// Weight(IP): 10
323 ///
324 /// Security Type: `USER_DATA`
325 ///
326 /// # Arguments
327 ///
328 /// - `params`: [`GetSummaryOfMarginAccountParams`]
329 /// The parameters for this operation.
330 ///
331 /// # Returns
332 ///
333 /// [`RestApiResponse<models::GetSummaryOfMarginAccountResponse>`] on success.
334 ///
335 /// # Errors
336 ///
337 /// This function will return an [`anyhow::Error`] if:
338 /// - the HTTP request fails
339 /// - any parameter is invalid
340 /// - the response cannot be parsed
341 /// - or one of the following occurs:
342 /// - `RequiredError`
343 /// - `ConnectorClientError`
344 /// - `UnauthorizedError`
345 /// - `ForbiddenError`
346 /// - `TooManyRequestsError`
347 /// - `RateLimitBanError`
348 /// - `ServerError`
349 /// - `NotFoundError`
350 /// - `NetworkError`
351 /// - `BadRequestError`
352 ///
353 ///
354 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/account#get-summary-of-margin-account).
355 ///
356 pub async fn get_summary_of_margin_account(
357 &self,
358 params: GetSummaryOfMarginAccountParams,
359 ) -> anyhow::Result<RestApiResponse<models::GetSummaryOfMarginAccountResponse>> {
360 self.account_api_client
361 .get_summary_of_margin_account(params)
362 .await
363 }
364
365 /// Query Cross Isolated Margin Capital Flow (`USER_DATA`)
366 ///
367 /// Query Cross Isolated Margin Capital Flow
368 ///
369 /// Weight(IP): 100
370 ///
371 /// Security Type: `USER_DATA`
372 ///
373 /// Notes:
374 /// - Only supports querying the data of the last 90 days
375 ///
376 /// - The time between startTime and endTime cannot be longer than 7 days.
377 ///
378 /// - If fromId is set, the data with id > fromId will be returned.
379 /// Otherwise the latest data will be returned
380 ///
381 /// - To query isolated data, Symbol needs to be entered.
382 ///
383 /// # Arguments
384 ///
385 /// - `params`: [`QueryCrossIsolatedMarginCapitalFlowParams`]
386 /// The parameters for this operation.
387 ///
388 /// # Returns
389 ///
390 /// [`RestApiResponse<Vec<models::QueryCrossIsolatedMarginCapitalFlowResponseInner>>`] on success.
391 ///
392 /// # Errors
393 ///
394 /// This function will return an [`anyhow::Error`] if:
395 /// - the HTTP request fails
396 /// - any parameter is invalid
397 /// - the response cannot be parsed
398 /// - or one of the following occurs:
399 /// - `RequiredError`
400 /// - `ConnectorClientError`
401 /// - `UnauthorizedError`
402 /// - `ForbiddenError`
403 /// - `TooManyRequestsError`
404 /// - `RateLimitBanError`
405 /// - `ServerError`
406 /// - `NotFoundError`
407 /// - `NetworkError`
408 /// - `BadRequestError`
409 ///
410 ///
411 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/account#query-cross-isolated-margin-capital-flow).
412 ///
413 pub async fn query_cross_isolated_margin_capital_flow(
414 &self,
415 params: QueryCrossIsolatedMarginCapitalFlowParams,
416 ) -> anyhow::Result<
417 RestApiResponse<Vec<models::QueryCrossIsolatedMarginCapitalFlowResponseInner>>,
418 > {
419 self.account_api_client
420 .query_cross_isolated_margin_capital_flow(params)
421 .await
422 }
423
424 /// Query Cross Margin Account Details (`USER_DATA`)
425 ///
426 /// Query Cross Margin Account Details
427 ///
428 /// Weight(IP): 10
429 ///
430 /// Security Type: `USER_DATA`
431 ///
432 /// # Arguments
433 ///
434 /// - `params`: [`QueryCrossMarginAccountDetailsParams`]
435 /// The parameters for this operation.
436 ///
437 /// # Returns
438 ///
439 /// [`RestApiResponse<models::QueryCrossMarginAccountDetailsResponse>`] on success.
440 ///
441 /// # Errors
442 ///
443 /// This function will return an [`anyhow::Error`] if:
444 /// - the HTTP request fails
445 /// - any parameter is invalid
446 /// - the response cannot be parsed
447 /// - or one of the following occurs:
448 /// - `RequiredError`
449 /// - `ConnectorClientError`
450 /// - `UnauthorizedError`
451 /// - `ForbiddenError`
452 /// - `TooManyRequestsError`
453 /// - `RateLimitBanError`
454 /// - `ServerError`
455 /// - `NotFoundError`
456 /// - `NetworkError`
457 /// - `BadRequestError`
458 ///
459 ///
460 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/account#query-cross-margin-account-details).
461 ///
462 pub async fn query_cross_margin_account_details(
463 &self,
464 params: QueryCrossMarginAccountDetailsParams,
465 ) -> anyhow::Result<RestApiResponse<models::QueryCrossMarginAccountDetailsResponse>> {
466 self.account_api_client
467 .query_cross_margin_account_details(params)
468 .await
469 }
470
471 /// Query Cross Margin Fee Data (`USER_DATA`)
472 ///
473 /// Get cross margin fee data collection with any vip level or user's current specific data as <https://www.binance.com/en/margin-fee>
474 ///
475 /// Weight: 1 when coin is specified;(IP) 5 when the coin parameter is omitted(IP)
476 ///
477 /// Security Type: `USER_DATA`
478 ///
479 /// # Arguments
480 ///
481 /// - `params`: [`QueryCrossMarginFeeDataParams`]
482 /// The parameters for this operation.
483 ///
484 /// # Returns
485 ///
486 /// [`RestApiResponse<Vec<models::QueryCrossMarginFeeDataResponseInner>>`] on success.
487 ///
488 /// # Errors
489 ///
490 /// This function will return an [`anyhow::Error`] if:
491 /// - the HTTP request fails
492 /// - any parameter is invalid
493 /// - the response cannot be parsed
494 /// - or one of the following occurs:
495 /// - `RequiredError`
496 /// - `ConnectorClientError`
497 /// - `UnauthorizedError`
498 /// - `ForbiddenError`
499 /// - `TooManyRequestsError`
500 /// - `RateLimitBanError`
501 /// - `ServerError`
502 /// - `NotFoundError`
503 /// - `NetworkError`
504 /// - `BadRequestError`
505 ///
506 ///
507 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/account#query-cross-margin-fee-data).
508 ///
509 pub async fn query_cross_margin_fee_data(
510 &self,
511 params: QueryCrossMarginFeeDataParams,
512 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryCrossMarginFeeDataResponseInner>>> {
513 self.account_api_client
514 .query_cross_margin_fee_data(params)
515 .await
516 }
517
518 /// Query Enabled Isolated Margin Account Limit (`USER_DATA`)
519 ///
520 /// Query enabled isolated margin account limit.
521 ///
522 /// Weight(IP): 1
523 ///
524 /// Security Type: `USER_DATA`
525 ///
526 /// # Arguments
527 ///
528 /// - `params`: [`QueryEnabledIsolatedMarginAccountLimitParams`]
529 /// The parameters for this operation.
530 ///
531 /// # Returns
532 ///
533 /// [`RestApiResponse<models::QueryEnabledIsolatedMarginAccountLimitResponse>`] on success.
534 ///
535 /// # Errors
536 ///
537 /// This function will return an [`anyhow::Error`] if:
538 /// - the HTTP request fails
539 /// - any parameter is invalid
540 /// - the response cannot be parsed
541 /// - or one of the following occurs:
542 /// - `RequiredError`
543 /// - `ConnectorClientError`
544 /// - `UnauthorizedError`
545 /// - `ForbiddenError`
546 /// - `TooManyRequestsError`
547 /// - `RateLimitBanError`
548 /// - `ServerError`
549 /// - `NotFoundError`
550 /// - `NetworkError`
551 /// - `BadRequestError`
552 ///
553 ///
554 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/account#query-enabled-isolated-margin-account-limit).
555 ///
556 pub async fn query_enabled_isolated_margin_account_limit(
557 &self,
558 params: QueryEnabledIsolatedMarginAccountLimitParams,
559 ) -> anyhow::Result<RestApiResponse<models::QueryEnabledIsolatedMarginAccountLimitResponse>>
560 {
561 self.account_api_client
562 .query_enabled_isolated_margin_account_limit(params)
563 .await
564 }
565
566 /// Query Isolated Margin Account Info (`USER_DATA`)
567 ///
568 /// Query Isolated Margin Account Info
569 ///
570 /// Weight(IP): 10
571 ///
572 /// Security Type: `USER_DATA`
573 ///
574 /// Notes:
575 /// - If "symbols" is not sent, all isolated assets will be returned.
576 ///
577 /// - If "symbols" is sent, only the isolated assets of the sent symbols
578 /// will be returned.
579 ///
580 /// # Arguments
581 ///
582 /// - `params`: [`QueryIsolatedMarginAccountInfoParams`]
583 /// The parameters for this operation.
584 ///
585 /// # Returns
586 ///
587 /// [`RestApiResponse<models::QueryIsolatedMarginAccountInfoResponse>`] on success.
588 ///
589 /// # Errors
590 ///
591 /// This function will return an [`anyhow::Error`] if:
592 /// - the HTTP request fails
593 /// - any parameter is invalid
594 /// - the response cannot be parsed
595 /// - or one of the following occurs:
596 /// - `RequiredError`
597 /// - `ConnectorClientError`
598 /// - `UnauthorizedError`
599 /// - `ForbiddenError`
600 /// - `TooManyRequestsError`
601 /// - `RateLimitBanError`
602 /// - `ServerError`
603 /// - `NotFoundError`
604 /// - `NetworkError`
605 /// - `BadRequestError`
606 ///
607 ///
608 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/account#query-isolated-margin-account-info).
609 ///
610 pub async fn query_isolated_margin_account_info(
611 &self,
612 params: QueryIsolatedMarginAccountInfoParams,
613 ) -> anyhow::Result<RestApiResponse<models::QueryIsolatedMarginAccountInfoResponse>> {
614 self.account_api_client
615 .query_isolated_margin_account_info(params)
616 .await
617 }
618
619 /// Query Isolated Margin Fee Data (`USER_DATA`)
620 ///
621 /// Get isolated margin fee data collection with any vip level or user's current specific data as <https://www.binance.com/en/margin-fee>
622 ///
623 /// Weight: 1 when a single is specified;(IP) 10 when the symbol parameter is omitted(IP)
624 ///
625 /// Security Type: `USER_DATA`
626 ///
627 /// # Arguments
628 ///
629 /// - `params`: [`QueryIsolatedMarginFeeDataParams`]
630 /// The parameters for this operation.
631 ///
632 /// # Returns
633 ///
634 /// [`RestApiResponse<Vec<models::QueryIsolatedMarginFeeDataResponseInner>>`] on success.
635 ///
636 /// # Errors
637 ///
638 /// This function will return an [`anyhow::Error`] if:
639 /// - the HTTP request fails
640 /// - any parameter is invalid
641 /// - the response cannot be parsed
642 /// - or one of the following occurs:
643 /// - `RequiredError`
644 /// - `ConnectorClientError`
645 /// - `UnauthorizedError`
646 /// - `ForbiddenError`
647 /// - `TooManyRequestsError`
648 /// - `RateLimitBanError`
649 /// - `ServerError`
650 /// - `NotFoundError`
651 /// - `NetworkError`
652 /// - `BadRequestError`
653 ///
654 ///
655 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/account#query-isolated-margin-fee-data).
656 ///
657 pub async fn query_isolated_margin_fee_data(
658 &self,
659 params: QueryIsolatedMarginFeeDataParams,
660 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryIsolatedMarginFeeDataResponseInner>>> {
661 self.account_api_client
662 .query_isolated_margin_fee_data(params)
663 .await
664 }
665
666 /// Get future hourly interest rate (`USER_DATA`)
667 ///
668 /// Get future hourly interest rate
669 ///
670 /// Weight(IP): 100
671 ///
672 /// Security Type: `USER_DATA`
673 ///
674 /// # Arguments
675 ///
676 /// - `params`: [`GetFutureHourlyInterestRateParams`]
677 /// The parameters for this operation.
678 ///
679 /// # Returns
680 ///
681 /// [`RestApiResponse<Vec<models::GetFutureHourlyInterestRateResponseInner>>`] on success.
682 ///
683 /// # Errors
684 ///
685 /// This function will return an [`anyhow::Error`] if:
686 /// - the HTTP request fails
687 /// - any parameter is invalid
688 /// - the response cannot be parsed
689 /// - or one of the following occurs:
690 /// - `RequiredError`
691 /// - `ConnectorClientError`
692 /// - `UnauthorizedError`
693 /// - `ForbiddenError`
694 /// - `TooManyRequestsError`
695 /// - `RateLimitBanError`
696 /// - `ServerError`
697 /// - `NotFoundError`
698 /// - `NetworkError`
699 /// - `BadRequestError`
700 ///
701 ///
702 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/borrow-repay#get-future-hourly-interest-rate).
703 ///
704 pub async fn get_future_hourly_interest_rate(
705 &self,
706 params: GetFutureHourlyInterestRateParams,
707 ) -> anyhow::Result<RestApiResponse<Vec<models::GetFutureHourlyInterestRateResponseInner>>>
708 {
709 self.borrow_repay_api_client
710 .get_future_hourly_interest_rate(params)
711 .await
712 }
713
714 /// Get Interest History (`USER_DATA`)
715 ///
716 /// Get Interest History
717 ///
718 /// Weight(IP): 1
719 ///
720 /// Security Type: `USER_DATA`
721 ///
722 /// Notes:
723 /// - Response in descending order
724 ///
725 /// - If isolatedSymbol is not sent, crossed margin data will be returned
726 ///
727 /// - The max interval between `startTime` and `endTime` is 30 days. It is a
728 /// MUST to ensure data correctness.
729 ///
730 /// - If `startTime`and `endTime` not sent, return records of the last 7
731 /// days by default.
732 ///
733 /// - If `startTime` is sent and `endTime` is not sent, return records of
734 /// [max(`startTime`, now-30d), now].
735 ///
736 /// - If `startTime` is not sent and `endTime` is sent, return records of
737 /// [`endTime`-7, `endTime`]
738 ///
739 /// - `type` in response has 4 enums:
740 ///
741 /// - `PERIODIC` interest charged per hour
742 ///
743 /// - `ON_BORROW` first interest charged on borrow
744 ///
745 /// - `PERIODIC_CONVERTED` interest charged per hour converted into BNB
746 ///
747 /// - `ON_BORROW_CONVERTED` first interest charged on borrow converted into
748 /// BNB
749 ///
750 /// - `PORTFOLIO` interest charged daily on the portfolio margin negative
751 /// balance
752 ///
753 /// # Arguments
754 ///
755 /// - `params`: [`GetInterestHistoryParams`]
756 /// The parameters for this operation.
757 ///
758 /// # Returns
759 ///
760 /// [`RestApiResponse<models::GetInterestHistoryResponse>`] on success.
761 ///
762 /// # Errors
763 ///
764 /// This function will return an [`anyhow::Error`] if:
765 /// - the HTTP request fails
766 /// - any parameter is invalid
767 /// - the response cannot be parsed
768 /// - or one of the following occurs:
769 /// - `RequiredError`
770 /// - `ConnectorClientError`
771 /// - `UnauthorizedError`
772 /// - `ForbiddenError`
773 /// - `TooManyRequestsError`
774 /// - `RateLimitBanError`
775 /// - `ServerError`
776 /// - `NotFoundError`
777 /// - `NetworkError`
778 /// - `BadRequestError`
779 ///
780 ///
781 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/borrow-repay#get-interest-history).
782 ///
783 pub async fn get_interest_history(
784 &self,
785 params: GetInterestHistoryParams,
786 ) -> anyhow::Result<RestApiResponse<models::GetInterestHistoryResponse>> {
787 self.borrow_repay_api_client
788 .get_interest_history(params)
789 .await
790 }
791
792 /// Margin account borrow/repay (`USER_DATA`)
793 ///
794 /// Margin account borrow/repay
795 ///
796 /// Weight(UID): 1500
797 ///
798 /// Security Type: `USER_DATA`
799 ///
800 /// Notes:
801 /// - `-3045 INSUFFICIENT_INVENTORY`: returned when system borrowable inventory is below the requested amount, or when inventory is severely insufficient (all borrow requests rejected regardless of size). Monitor system asset availability and adjust borrow strategy accordingly.
802 /// - `-3006 EXCEED_MAX_BORROWABLE`: borrow amount exceeds your current max borrowable limit. Query `GET /sapi/v1/margin/maxBorrowable` and adjust the request.
803 /// - `-3012 ASSET_ADMIN_BAN_BORROW`: this asset does not currently support borrowing. Query `GET /sapi/v1/margin/allAssets` for asset borrow availability.
804 /// - `-3015 REPAY_EXCEED_LIABILITY`: returned in two scenarios — (1) repay amount exceeds your outstanding liability, or (2) the remaining unpaid debt after this repayment would fall below Binance's minimum threshold. Adjust the repay amount accordingly.
805 /// - `-3007 HAS_PENDING_TRANSACTION`: a borrow/repay transaction is already in progress on this account. Requests are processed in submission order across all assets, and an in-flight request briefly blocks subsequent ones. Typical processing time is ~100ms; space consecutive requests by at least 100ms. Auto-repay orders can also fail silently for this reason — verify outstanding liability after an auto-repay executes.
806 ///
807 /// # Arguments
808 ///
809 /// - `params`: [`MarginAccountBorrowRepayParams`]
810 /// The parameters for this operation.
811 ///
812 /// # Returns
813 ///
814 /// [`RestApiResponse<models::MarginAccountBorrowRepayResponse>`] on success.
815 ///
816 /// # Errors
817 ///
818 /// This function will return an [`anyhow::Error`] if:
819 /// - the HTTP request fails
820 /// - any parameter is invalid
821 /// - the response cannot be parsed
822 /// - or one of the following occurs:
823 /// - `RequiredError`
824 /// - `ConnectorClientError`
825 /// - `UnauthorizedError`
826 /// - `ForbiddenError`
827 /// - `TooManyRequestsError`
828 /// - `RateLimitBanError`
829 /// - `ServerError`
830 /// - `NotFoundError`
831 /// - `NetworkError`
832 /// - `BadRequestError`
833 ///
834 ///
835 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/borrow-repay#margin-account-borrow-repay).
836 ///
837 pub async fn margin_account_borrow_repay(
838 &self,
839 params: MarginAccountBorrowRepayParams,
840 ) -> anyhow::Result<RestApiResponse<models::MarginAccountBorrowRepayResponse>> {
841 self.borrow_repay_api_client
842 .margin_account_borrow_repay(params)
843 .await
844 }
845
846 /// Query borrow/repay records in Margin account (`USER_DATA`)
847 ///
848 /// Query borrow/repay records in Margin account
849 ///
850 /// Weight(IP): 10
851 ///
852 /// Security Type: `USER_DATA`
853 ///
854 /// Notes:
855 /// - `txId` or `startTime` must be sent. `txId` takes precedence.
856 ///
857 /// - Response in descending order
858 ///
859 /// - If an asset is sent, data within 30 days before `endTime`; If an asset is not sent, data within 7 days before `endTime`
860 ///
861 /// - If neither `startTime` nor `endTime` is sent, the recent 7-day data will be returned.
862 ///
863 /// - `startTime` set as `endTime` - 7 days by default, `endTime` set as current time by default
864 ///
865 /// # Arguments
866 ///
867 /// - `params`: [`QueryBorrowRepayRecordsInMarginAccountParams`]
868 /// The parameters for this operation.
869 ///
870 /// # Returns
871 ///
872 /// [`RestApiResponse<models::QueryBorrowRepayRecordsInMarginAccountResponse>`] on success.
873 ///
874 /// # Errors
875 ///
876 /// This function will return an [`anyhow::Error`] if:
877 /// - the HTTP request fails
878 /// - any parameter is invalid
879 /// - the response cannot be parsed
880 /// - or one of the following occurs:
881 /// - `RequiredError`
882 /// - `ConnectorClientError`
883 /// - `UnauthorizedError`
884 /// - `ForbiddenError`
885 /// - `TooManyRequestsError`
886 /// - `RateLimitBanError`
887 /// - `ServerError`
888 /// - `NotFoundError`
889 /// - `NetworkError`
890 /// - `BadRequestError`
891 ///
892 ///
893 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/borrow-repay#query-borrow-repay-records-in-margin-account).
894 ///
895 pub async fn query_borrow_repay_records_in_margin_account(
896 &self,
897 params: QueryBorrowRepayRecordsInMarginAccountParams,
898 ) -> anyhow::Result<RestApiResponse<models::QueryBorrowRepayRecordsInMarginAccountResponse>>
899 {
900 self.borrow_repay_api_client
901 .query_borrow_repay_records_in_margin_account(params)
902 .await
903 }
904
905 /// Query Margin Interest Rate History (`USER_DATA`)
906 ///
907 /// Query Margin Interest Rate History
908 ///
909 /// Weight(IP): 1
910 ///
911 /// Security Type: `USER_DATA`
912 ///
913 /// # Arguments
914 ///
915 /// - `params`: [`QueryMarginInterestRateHistoryParams`]
916 /// The parameters for this operation.
917 ///
918 /// # Returns
919 ///
920 /// [`RestApiResponse<Vec<models::QueryMarginInterestRateHistoryResponseInner>>`] on success.
921 ///
922 /// # Errors
923 ///
924 /// This function will return an [`anyhow::Error`] if:
925 /// - the HTTP request fails
926 /// - any parameter is invalid
927 /// - the response cannot be parsed
928 /// - or one of the following occurs:
929 /// - `RequiredError`
930 /// - `ConnectorClientError`
931 /// - `UnauthorizedError`
932 /// - `ForbiddenError`
933 /// - `TooManyRequestsError`
934 /// - `RateLimitBanError`
935 /// - `ServerError`
936 /// - `NotFoundError`
937 /// - `NetworkError`
938 /// - `BadRequestError`
939 ///
940 ///
941 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/borrow-repay#query-margin-interest-rate-history).
942 ///
943 pub async fn query_margin_interest_rate_history(
944 &self,
945 params: QueryMarginInterestRateHistoryParams,
946 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginInterestRateHistoryResponseInner>>>
947 {
948 self.borrow_repay_api_client
949 .query_margin_interest_rate_history(params)
950 .await
951 }
952
953 /// Query Max Borrow (`USER_DATA`)
954 ///
955 /// Query Max Borrow
956 ///
957 /// Weight(IP): 50
958 ///
959 /// Security Type: `USER_DATA`
960 ///
961 /// Notes:
962 /// - If isolatedSymbol is not sent, crossed margin data will be sent.
963 /// - `borrowLimit` is also available from [https://www.binance.com/en/margin-fee](https://www.binance.com/en/margin-fee)
964 ///
965 /// # Arguments
966 ///
967 /// - `params`: [`QueryMaxBorrowParams`]
968 /// The parameters for this operation.
969 ///
970 /// # Returns
971 ///
972 /// [`RestApiResponse<models::QueryMaxBorrowResponse>`] on success.
973 ///
974 /// # Errors
975 ///
976 /// This function will return an [`anyhow::Error`] if:
977 /// - the HTTP request fails
978 /// - any parameter is invalid
979 /// - the response cannot be parsed
980 /// - or one of the following occurs:
981 /// - `RequiredError`
982 /// - `ConnectorClientError`
983 /// - `UnauthorizedError`
984 /// - `ForbiddenError`
985 /// - `TooManyRequestsError`
986 /// - `RateLimitBanError`
987 /// - `ServerError`
988 /// - `NotFoundError`
989 /// - `NetworkError`
990 /// - `BadRequestError`
991 ///
992 ///
993 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/borrow-repay#query-max-borrow).
994 ///
995 pub async fn query_max_borrow(
996 &self,
997 params: QueryMaxBorrowParams,
998 ) -> anyhow::Result<RestApiResponse<models::QueryMaxBorrowResponse>> {
999 self.borrow_repay_api_client.query_max_borrow(params).await
1000 }
1001
1002 /// Cross margin collateral ratio (`MARKET_DATA`)
1003 ///
1004 /// Cross margin collateral ratio
1005 ///
1006 /// Weight(IP): 100
1007 ///
1008 /// Security Type: `MARKET_DATA`
1009 ///
1010 /// # Arguments
1011 ///
1012 /// - `params`: [`CrossMarginCollateralRatioParams`]
1013 /// The parameters for this operation.
1014 ///
1015 /// # Returns
1016 ///
1017 /// [`RestApiResponse<Vec<models::CrossMarginCollateralRatioResponseInner>>`] on success.
1018 ///
1019 /// # Errors
1020 ///
1021 /// This function will return an [`anyhow::Error`] if:
1022 /// - the HTTP request fails
1023 /// - any parameter is invalid
1024 /// - the response cannot be parsed
1025 /// - or one of the following occurs:
1026 /// - `RequiredError`
1027 /// - `ConnectorClientError`
1028 /// - `UnauthorizedError`
1029 /// - `ForbiddenError`
1030 /// - `TooManyRequestsError`
1031 /// - `RateLimitBanError`
1032 /// - `ServerError`
1033 /// - `NotFoundError`
1034 /// - `NetworkError`
1035 /// - `BadRequestError`
1036 ///
1037 ///
1038 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/market-data#cross-margin-collateral-ratio).
1039 ///
1040 pub async fn cross_margin_collateral_ratio(
1041 &self,
1042 ) -> anyhow::Result<RestApiResponse<Vec<models::CrossMarginCollateralRatioResponseInner>>> {
1043 self.market_data_api_client
1044 .cross_margin_collateral_ratio()
1045 .await
1046 }
1047
1048 /// Get All Cross Margin Pairs (`MARKET_DATA`)
1049 ///
1050 /// Get All Cross Margin Pairs
1051 ///
1052 /// Weight(IP): 1
1053 ///
1054 /// Security Type: `MARKET_DATA`
1055 ///
1056 /// # Arguments
1057 ///
1058 /// - `params`: [`GetAllCrossMarginPairsParams`]
1059 /// The parameters for this operation.
1060 ///
1061 /// # Returns
1062 ///
1063 /// [`RestApiResponse<Vec<models::GetAllCrossMarginPairsResponseInner>>`] on success.
1064 ///
1065 /// # Errors
1066 ///
1067 /// This function will return an [`anyhow::Error`] if:
1068 /// - the HTTP request fails
1069 /// - any parameter is invalid
1070 /// - the response cannot be parsed
1071 /// - or one of the following occurs:
1072 /// - `RequiredError`
1073 /// - `ConnectorClientError`
1074 /// - `UnauthorizedError`
1075 /// - `ForbiddenError`
1076 /// - `TooManyRequestsError`
1077 /// - `RateLimitBanError`
1078 /// - `ServerError`
1079 /// - `NotFoundError`
1080 /// - `NetworkError`
1081 /// - `BadRequestError`
1082 ///
1083 ///
1084 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/market-data#get-all-cross-margin-pairs).
1085 ///
1086 pub async fn get_all_cross_margin_pairs(
1087 &self,
1088 params: GetAllCrossMarginPairsParams,
1089 ) -> anyhow::Result<RestApiResponse<Vec<models::GetAllCrossMarginPairsResponseInner>>> {
1090 self.market_data_api_client
1091 .get_all_cross_margin_pairs(params)
1092 .await
1093 }
1094
1095 /// Get All Isolated Margin Symbol (`MARKET_DATA`)
1096 ///
1097 /// Get All Isolated Margin Symbol
1098 ///
1099 /// Weight(IP): 10
1100 ///
1101 /// Security Type: `MARKET_DATA`
1102 ///
1103 /// # Arguments
1104 ///
1105 /// - `params`: [`GetAllIsolatedMarginSymbolParams`]
1106 /// The parameters for this operation.
1107 ///
1108 /// # Returns
1109 ///
1110 /// [`RestApiResponse<Vec<models::GetAllIsolatedMarginSymbolResponseInner>>`] on success.
1111 ///
1112 /// # Errors
1113 ///
1114 /// This function will return an [`anyhow::Error`] if:
1115 /// - the HTTP request fails
1116 /// - any parameter is invalid
1117 /// - the response cannot be parsed
1118 /// - or one of the following occurs:
1119 /// - `RequiredError`
1120 /// - `ConnectorClientError`
1121 /// - `UnauthorizedError`
1122 /// - `ForbiddenError`
1123 /// - `TooManyRequestsError`
1124 /// - `RateLimitBanError`
1125 /// - `ServerError`
1126 /// - `NotFoundError`
1127 /// - `NetworkError`
1128 /// - `BadRequestError`
1129 ///
1130 ///
1131 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/market-data#get-all-isolated-margin-symbol).
1132 ///
1133 pub async fn get_all_isolated_margin_symbol(
1134 &self,
1135 params: GetAllIsolatedMarginSymbolParams,
1136 ) -> anyhow::Result<RestApiResponse<Vec<models::GetAllIsolatedMarginSymbolResponseInner>>> {
1137 self.market_data_api_client
1138 .get_all_isolated_margin_symbol(params)
1139 .await
1140 }
1141
1142 /// Get All Margin Assets (`MARKET_DATA`)
1143 ///
1144 /// Get All Margin Assets.
1145 ///
1146 /// Weight(IP): 1
1147 ///
1148 /// Security Type: `MARKET_DATA`
1149 ///
1150 /// # Arguments
1151 ///
1152 /// - `params`: [`GetAllMarginAssetsParams`]
1153 /// The parameters for this operation.
1154 ///
1155 /// # Returns
1156 ///
1157 /// [`RestApiResponse<Vec<models::GetAllMarginAssetsResponseInner>>`] on success.
1158 ///
1159 /// # Errors
1160 ///
1161 /// This function will return an [`anyhow::Error`] if:
1162 /// - the HTTP request fails
1163 /// - any parameter is invalid
1164 /// - the response cannot be parsed
1165 /// - or one of the following occurs:
1166 /// - `RequiredError`
1167 /// - `ConnectorClientError`
1168 /// - `UnauthorizedError`
1169 /// - `ForbiddenError`
1170 /// - `TooManyRequestsError`
1171 /// - `RateLimitBanError`
1172 /// - `ServerError`
1173 /// - `NotFoundError`
1174 /// - `NetworkError`
1175 /// - `BadRequestError`
1176 ///
1177 ///
1178 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/market-data#get-all-margin-assets).
1179 ///
1180 pub async fn get_all_margin_assets(
1181 &self,
1182 params: GetAllMarginAssetsParams,
1183 ) -> anyhow::Result<RestApiResponse<Vec<models::GetAllMarginAssetsResponseInner>>> {
1184 self.market_data_api_client
1185 .get_all_margin_assets(params)
1186 .await
1187 }
1188
1189 /// Get Delist Schedule (`MARKET_DATA`)
1190 ///
1191 /// Get tokens or symbols delist schedule for cross margin and isolated margin
1192 ///
1193 /// Weight(IP): 100
1194 ///
1195 /// Security Type: `MARKET_DATA`
1196 ///
1197 /// # Arguments
1198 ///
1199 /// - `params`: [`GetDelistScheduleParams`]
1200 /// The parameters for this operation.
1201 ///
1202 /// # Returns
1203 ///
1204 /// [`RestApiResponse<Vec<models::GetDelistScheduleResponseInner>>`] on success.
1205 ///
1206 /// # Errors
1207 ///
1208 /// This function will return an [`anyhow::Error`] if:
1209 /// - the HTTP request fails
1210 /// - any parameter is invalid
1211 /// - the response cannot be parsed
1212 /// - or one of the following occurs:
1213 /// - `RequiredError`
1214 /// - `ConnectorClientError`
1215 /// - `UnauthorizedError`
1216 /// - `ForbiddenError`
1217 /// - `TooManyRequestsError`
1218 /// - `RateLimitBanError`
1219 /// - `ServerError`
1220 /// - `NotFoundError`
1221 /// - `NetworkError`
1222 /// - `BadRequestError`
1223 ///
1224 ///
1225 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/market-data#get-delist-schedule).
1226 ///
1227 pub async fn get_delist_schedule(
1228 &self,
1229 params: GetDelistScheduleParams,
1230 ) -> anyhow::Result<RestApiResponse<Vec<models::GetDelistScheduleResponseInner>>> {
1231 self.market_data_api_client
1232 .get_delist_schedule(params)
1233 .await
1234 }
1235
1236 /// Get Limit Price Pairs (`MARKET_DATA`)
1237 ///
1238 /// Query trading pairs with restriction on limit price range.
1239 ///
1240 /// In margin trading, you can place orders with limit price. Limit price
1241 /// should be within (-15%, 15%) of current index price for a list of margin
1242 /// trading pairs. This rule only impacts limit sell orders with limit price
1243 /// that is lower than current index price and limit buy orders with limit
1244 /// price that is higher than current index price.
1245 ///
1246 /// - Buy order: Your order will be rejected with an error message
1247 /// notification if the limit price is 15% above the index price.
1248 ///
1249 /// - Sell order: Your order will be rejected with an error message
1250 /// notification if the limit price is 15% below the index price.
1251 ///
1252 /// Please review the limit price order placing strategy, backtest and
1253 /// calibrate the planned order size with the trading volume and order book
1254 /// depth to prevent trading loss.
1255 ///
1256 /// Weight(IP): 1
1257 ///
1258 /// Security Type: `MARKET_DATA`
1259 ///
1260 /// # Arguments
1261 ///
1262 /// - `params`: [`GetLimitPricePairsParams`]
1263 /// The parameters for this operation.
1264 ///
1265 /// # Returns
1266 ///
1267 /// [`RestApiResponse<models::GetLimitPricePairsResponse>`] 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-margin-trading/api/rest-api/market-data#get-limit-price-pairs).
1289 ///
1290 pub async fn get_limit_price_pairs(
1291 &self,
1292 ) -> anyhow::Result<RestApiResponse<models::GetLimitPricePairsResponse>> {
1293 self.market_data_api_client.get_limit_price_pairs().await
1294 }
1295
1296 /// Get list Schedule (`MARKET_DATA`)
1297 ///
1298 /// Get the upcoming tokens or symbols listing schedule for Cross Margin and Isolated Margin.
1299 ///
1300 /// Weight(IP): 100
1301 ///
1302 /// Security Type: `MARKET_DATA`
1303 ///
1304 /// # Arguments
1305 ///
1306 /// - `params`: [`GetListScheduleParams`]
1307 /// The parameters for this operation.
1308 ///
1309 /// # Returns
1310 ///
1311 /// [`RestApiResponse<Vec<models::GetListScheduleResponseInner>>`] on success.
1312 ///
1313 /// # Errors
1314 ///
1315 /// This function will return an [`anyhow::Error`] if:
1316 /// - the HTTP request fails
1317 /// - any parameter is invalid
1318 /// - the response cannot be parsed
1319 /// - or one of the following occurs:
1320 /// - `RequiredError`
1321 /// - `ConnectorClientError`
1322 /// - `UnauthorizedError`
1323 /// - `ForbiddenError`
1324 /// - `TooManyRequestsError`
1325 /// - `RateLimitBanError`
1326 /// - `ServerError`
1327 /// - `NotFoundError`
1328 /// - `NetworkError`
1329 /// - `BadRequestError`
1330 ///
1331 ///
1332 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/market-data#get-list-schedule).
1333 ///
1334 pub async fn get_list_schedule(
1335 &self,
1336 params: GetListScheduleParams,
1337 ) -> anyhow::Result<RestApiResponse<Vec<models::GetListScheduleResponseInner>>> {
1338 self.market_data_api_client.get_list_schedule(params).await
1339 }
1340
1341 /// Get Margin Asset Risk-Based Liquidation Ratio (`MARKET_DATA`)
1342 ///
1343 /// Get Margin Asset Risk-Based Liquidation Ratio
1344 ///
1345 /// Weight(IP): 1
1346 ///
1347 /// Security Type: `MARKET_DATA`
1348 ///
1349 /// # Arguments
1350 ///
1351 /// - `params`: [`GetMarginAssetRiskBasedLiquidationRatioParams`]
1352 /// The parameters for this operation.
1353 ///
1354 /// # Returns
1355 ///
1356 /// [`RestApiResponse<Vec<models::GetMarginAssetRiskBasedLiquidationRatioResponseInner>>`] on success.
1357 ///
1358 /// # Errors
1359 ///
1360 /// This function will return an [`anyhow::Error`] if:
1361 /// - the HTTP request fails
1362 /// - any parameter is invalid
1363 /// - the response cannot be parsed
1364 /// - or one of the following occurs:
1365 /// - `RequiredError`
1366 /// - `ConnectorClientError`
1367 /// - `UnauthorizedError`
1368 /// - `ForbiddenError`
1369 /// - `TooManyRequestsError`
1370 /// - `RateLimitBanError`
1371 /// - `ServerError`
1372 /// - `NotFoundError`
1373 /// - `NetworkError`
1374 /// - `BadRequestError`
1375 ///
1376 ///
1377 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/market-data#get-margin-asset-risk-based-liquidation-ratio).
1378 ///
1379 pub async fn get_margin_asset_risk_based_liquidation_ratio(
1380 &self,
1381 ) -> anyhow::Result<
1382 RestApiResponse<Vec<models::GetMarginAssetRiskBasedLiquidationRatioResponseInner>>,
1383 > {
1384 self.market_data_api_client
1385 .get_margin_asset_risk_based_liquidation_ratio()
1386 .await
1387 }
1388
1389 /// Get Margin Restricted Assets (`MARKET_DATA`)
1390 ///
1391 /// Get the list of margin-restricted assets.
1392 ///
1393 /// Weight(IP): 1
1394 ///
1395 /// Security Type: `MARKET_DATA`
1396 ///
1397 /// # Arguments
1398 ///
1399 /// - `params`: [`GetMarginRestrictedAssetsParams`]
1400 /// The parameters for this operation.
1401 ///
1402 /// # Returns
1403 ///
1404 /// [`RestApiResponse<models::GetMarginRestrictedAssetsResponse>`] on success.
1405 ///
1406 /// # Errors
1407 ///
1408 /// This function will return an [`anyhow::Error`] if:
1409 /// - the HTTP request fails
1410 /// - any parameter is invalid
1411 /// - the response cannot be parsed
1412 /// - or one of the following occurs:
1413 /// - `RequiredError`
1414 /// - `ConnectorClientError`
1415 /// - `UnauthorizedError`
1416 /// - `ForbiddenError`
1417 /// - `TooManyRequestsError`
1418 /// - `RateLimitBanError`
1419 /// - `ServerError`
1420 /// - `NotFoundError`
1421 /// - `NetworkError`
1422 /// - `BadRequestError`
1423 ///
1424 ///
1425 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/market-data#get-margin-restricted-assets).
1426 ///
1427 pub async fn get_margin_restricted_assets(
1428 &self,
1429 ) -> anyhow::Result<RestApiResponse<models::GetMarginRestrictedAssetsResponse>> {
1430 self.market_data_api_client
1431 .get_margin_restricted_assets()
1432 .await
1433 }
1434
1435 /// Query Isolated Margin Tier Data (`USER_DATA`)
1436 ///
1437 /// Get isolated margin tier data collection with any tier as <https://www.binance.com/en/margin-data>
1438 ///
1439 /// Weight(IP): 1
1440 ///
1441 /// Security Type: `USER_DATA`
1442 ///
1443 /// # Arguments
1444 ///
1445 /// - `params`: [`QueryIsolatedMarginTierDataParams`]
1446 /// The parameters for this operation.
1447 ///
1448 /// # Returns
1449 ///
1450 /// [`RestApiResponse<Vec<models::QueryIsolatedMarginTierDataResponseInner>>`] on success.
1451 ///
1452 /// # Errors
1453 ///
1454 /// This function will return an [`anyhow::Error`] if:
1455 /// - the HTTP request fails
1456 /// - any parameter is invalid
1457 /// - the response cannot be parsed
1458 /// - or one of the following occurs:
1459 /// - `RequiredError`
1460 /// - `ConnectorClientError`
1461 /// - `UnauthorizedError`
1462 /// - `ForbiddenError`
1463 /// - `TooManyRequestsError`
1464 /// - `RateLimitBanError`
1465 /// - `ServerError`
1466 /// - `NotFoundError`
1467 /// - `NetworkError`
1468 /// - `BadRequestError`
1469 ///
1470 ///
1471 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/market-data#query-isolated-margin-tier-data).
1472 ///
1473 pub async fn query_isolated_margin_tier_data(
1474 &self,
1475 params: QueryIsolatedMarginTierDataParams,
1476 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryIsolatedMarginTierDataResponseInner>>>
1477 {
1478 self.market_data_api_client
1479 .query_isolated_margin_tier_data(params)
1480 .await
1481 }
1482
1483 /// Query Liability Coin Leverage Bracket in Cross Margin Pro Mode (`MARKET_DATA`)
1484 ///
1485 /// Liability Coin Leverage Bracket in Cross Margin Pro Mode
1486 ///
1487 /// Weight(IP): 1
1488 ///
1489 /// Security Type: `MARKET_DATA`
1490 ///
1491 /// # Arguments
1492 ///
1493 /// - `params`: [`QueryLiabilityCoinLeverageBracketInCrossMarginProModeParams`]
1494 /// The parameters for this operation.
1495 ///
1496 /// # Returns
1497 ///
1498 /// [`RestApiResponse<Vec<models::QueryLiabilityCoinLeverageBracketInCrossMarginProModeResponseInner>>`] on success.
1499 ///
1500 /// # Errors
1501 ///
1502 /// This function will return an [`anyhow::Error`] if:
1503 /// - the HTTP request fails
1504 /// - any parameter is invalid
1505 /// - the response cannot be parsed
1506 /// - or one of the following occurs:
1507 /// - `RequiredError`
1508 /// - `ConnectorClientError`
1509 /// - `UnauthorizedError`
1510 /// - `ForbiddenError`
1511 /// - `TooManyRequestsError`
1512 /// - `RateLimitBanError`
1513 /// - `ServerError`
1514 /// - `NotFoundError`
1515 /// - `NetworkError`
1516 /// - `BadRequestError`
1517 ///
1518 ///
1519 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/market-data#query-liability-coin-leverage-bracket-in-cross-margin-pro-mode).
1520 ///
1521 pub async fn query_liability_coin_leverage_bracket_in_cross_margin_pro_mode(
1522 &self,
1523 ) -> anyhow::Result<
1524 RestApiResponse<
1525 Vec<models::QueryLiabilityCoinLeverageBracketInCrossMarginProModeResponseInner>,
1526 >,
1527 > {
1528 self.market_data_api_client
1529 .query_liability_coin_leverage_bracket_in_cross_margin_pro_mode()
1530 .await
1531 }
1532
1533 /// Query Margin Available Inventory (`USER_DATA`)
1534 ///
1535 /// Margin available Inventory query
1536 ///
1537 /// Weight(UID): 50
1538 ///
1539 /// Security Type: `USER_DATA`
1540 ///
1541 /// # Arguments
1542 ///
1543 /// - `params`: [`QueryMarginAvailableInventoryParams`]
1544 /// The parameters for this operation.
1545 ///
1546 /// # Returns
1547 ///
1548 /// [`RestApiResponse<models::QueryMarginAvailableInventoryResponse>`] on success.
1549 ///
1550 /// # Errors
1551 ///
1552 /// This function will return an [`anyhow::Error`] if:
1553 /// - the HTTP request fails
1554 /// - any parameter is invalid
1555 /// - the response cannot be parsed
1556 /// - or one of the following occurs:
1557 /// - `RequiredError`
1558 /// - `ConnectorClientError`
1559 /// - `UnauthorizedError`
1560 /// - `ForbiddenError`
1561 /// - `TooManyRequestsError`
1562 /// - `RateLimitBanError`
1563 /// - `ServerError`
1564 /// - `NotFoundError`
1565 /// - `NetworkError`
1566 /// - `BadRequestError`
1567 ///
1568 ///
1569 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/market-data#query-margin-available-inventory).
1570 ///
1571 pub async fn query_margin_available_inventory(
1572 &self,
1573 params: QueryMarginAvailableInventoryParams,
1574 ) -> anyhow::Result<RestApiResponse<models::QueryMarginAvailableInventoryResponse>> {
1575 self.market_data_api_client
1576 .query_margin_available_inventory(params)
1577 .await
1578 }
1579
1580 /// Query Margin `PriceIndex` (`MARKET_DATA`)
1581 ///
1582 /// Query Margin `PriceIndex`
1583 ///
1584 /// Weight(IP): 10
1585 ///
1586 /// Security Type: `MARKET_DATA`
1587 ///
1588 /// # Arguments
1589 ///
1590 /// - `params`: [`QueryMarginPriceindexParams`]
1591 /// The parameters for this operation.
1592 ///
1593 /// # Returns
1594 ///
1595 /// [`RestApiResponse<models::QueryMarginPriceindexResponse>`] on success.
1596 ///
1597 /// # Errors
1598 ///
1599 /// This function will return an [`anyhow::Error`] if:
1600 /// - the HTTP request fails
1601 /// - any parameter is invalid
1602 /// - the response cannot be parsed
1603 /// - or one of the following occurs:
1604 /// - `RequiredError`
1605 /// - `ConnectorClientError`
1606 /// - `UnauthorizedError`
1607 /// - `ForbiddenError`
1608 /// - `TooManyRequestsError`
1609 /// - `RateLimitBanError`
1610 /// - `ServerError`
1611 /// - `NotFoundError`
1612 /// - `NetworkError`
1613 /// - `BadRequestError`
1614 ///
1615 ///
1616 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/market-data#query-margin-priceindex).
1617 ///
1618 pub async fn query_margin_priceindex(
1619 &self,
1620 params: QueryMarginPriceindexParams,
1621 ) -> anyhow::Result<RestApiResponse<models::QueryMarginPriceindexResponse>> {
1622 self.market_data_api_client
1623 .query_margin_priceindex(params)
1624 .await
1625 }
1626
1627 /// Create Special Key(Low-Latency Trading) (TRADE)
1628 ///
1629 /// **Eligibility**
1630 ///
1631 /// - Binance Margin offers low-latency trading through a [special key](https://www.binance.com/en/support/faq/frequently-asked-questions-on-margin-special-api-key-3208663e900d4d2e9fec4140e1832f4e), available exclusively to users with VIP level 7 or higher.
1632 /// - If you are VIP level 6 or below, please contact your VIP manager for eligibility criterias.
1633 /// - All new Margin Special Key users are required to read, understand, and agree to the Margin Special Key Supplemental Product Terms at the master account level before creating a Margin Special Key.
1634 /// - Once signed at the master account level, the agreement applies to all sub-accounts. The master account and all sub-accounts (Cross Margin Classic and Portfolio Margin Pro) are authorized to create a Margin Special Key and are subject to the `LiquidationLoan` policy.
1635 ///
1636 /// For more information, please refer to [FAQ](https://www.binance.com/en/support/faq/detail/3208663e900d4d2e9fec4140e1832f4e).
1637 ///
1638 /// **Supported Products:**
1639 ///
1640 /// - Cross Margin
1641 /// - Isolated Margin
1642 /// - Portfolio Margin Pro
1643 ///
1644 /// **Unsupported Products:**
1645 ///
1646 /// - Portfolio Margin
1647 ///
1648 /// We support several types of API keys:
1649 ///
1650 /// * Ed25519 (recommended)
1651 /// * HMAC
1652 /// * RSA
1653 ///
1654 /// We recommend to **use Ed25519 API keys** as it should provide the best performance and security out of all supported key types. We accept PKCS#8 (BEGIN PUBLIC KEY). For how to generate an RSA key pair to send API requests on Binance. Please refer to the document below [FAQ](https://www.binance.com/en/support/faq/how-to-generate-an-rsa-key-pair-to-send-api-requests-on-binance-2b79728f331e43079b27440d9d15c5db) .
1655 ///
1656 /// **How to use the Margin Special Key**
1657 /// - Use the below `sapi` endpoint to create your margin special API Key.
1658 /// - For accessing the Cross Margin account, do not send the `symbol` parameter.
1659 /// - For accessing the Isolated Margin account(s), pass the relevant `symbol` parameter in the API Key creation request.
1660 /// - Use the generated API Key (and Secret key, if applicable) to perform margin trading and listenKey generation via **Spot** REST API (`https://api.binance.com/api/v3/*`) endpoints.
1661 ///
1662 /// Read [REST API](/products/spot/rest-api#signed-trade-and-user_data-endpoint-security) or [WebSocket API](/products/spot/web-socket-api#request-security) documentation to learn how to use different API keys
1663 ///
1664 /// You need to enable Permits “Enable Spot & Margin Trading” option for the API Key which requests this endpoint.
1665 ///
1666 /// Weight(UID): 1
1667 ///
1668 /// Security Type: TRADE
1669 ///
1670 /// Response Notes:
1671 /// - Error Code Description
1672 ///
1673 /// - **`UNSUPPORTED_OPERATION`** : Portfolio Margin is an unsupported
1674 /// product, please change the account type to a supported margin product.
1675 ///
1676 /// - **Forbidden**: Cross Margin Pro accounts require additional
1677 /// agreements, please contact your relationship manager.
1678 ///
1679 /// # Arguments
1680 ///
1681 /// - `params`: [`CreateSpecialKeyParams`]
1682 /// The parameters for this operation.
1683 ///
1684 /// # Returns
1685 ///
1686 /// [`RestApiResponse<models::CreateSpecialKeyResponse>`] on success.
1687 ///
1688 /// # Errors
1689 ///
1690 /// This function will return an [`anyhow::Error`] if:
1691 /// - the HTTP request fails
1692 /// - any parameter is invalid
1693 /// - the response cannot be parsed
1694 /// - or one of the following occurs:
1695 /// - `RequiredError`
1696 /// - `ConnectorClientError`
1697 /// - `UnauthorizedError`
1698 /// - `ForbiddenError`
1699 /// - `TooManyRequestsError`
1700 /// - `RateLimitBanError`
1701 /// - `ServerError`
1702 /// - `NotFoundError`
1703 /// - `NetworkError`
1704 /// - `BadRequestError`
1705 ///
1706 ///
1707 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#create-special-key).
1708 ///
1709 pub async fn create_special_key(
1710 &self,
1711 params: CreateSpecialKeyParams,
1712 ) -> anyhow::Result<RestApiResponse<models::CreateSpecialKeyResponse>> {
1713 self.trade_api_client.create_special_key(params).await
1714 }
1715
1716 /// Delete Special Key(Low-Latency Trading) (TRADE)
1717 ///
1718 /// Deleting your Margin Special Key alone does not exit you from the Margin Special Key framework or discharge your obligations under the Margin Special Key Supplemental Product Terms. To fully exit, you must:
1719 ///
1720 /// 1. Delete your Margin Special Key.
1721 /// 2. Ensure there are no outstanding liabilities on the account.
1722 /// 3. Call the Exit Margin Special Key API endpoint.
1723 /// 4. Confirm the exit status via the API response.
1724 ///
1725 /// Only after step 4 is completed and the exit status is confirmed by Binance will your account revert to standard liquidation logic and no longer be subject to the Margin Special Key Supplemental Product Terms.
1726 ///
1727 /// If apiKey is given, apiName will be ignored. If apiName is given with no
1728 /// apiKey, all apikeys with given apiName will be deleted.
1729 ///
1730 /// You need to enable Permits “Enable Spot & Margin” option for the API Key
1731 /// which requests this endpoint.
1732 ///
1733 /// Weight(UID): 1
1734 ///
1735 /// Security Type: TRADE
1736 ///
1737 /// # Arguments
1738 ///
1739 /// - `params`: [`DeleteSpecialKeyParams`]
1740 /// The parameters for this operation.
1741 ///
1742 /// # Returns
1743 ///
1744 /// [`RestApiResponse<Value>`] on success.
1745 ///
1746 /// # Errors
1747 ///
1748 /// This function will return an [`anyhow::Error`] if:
1749 /// - the HTTP request fails
1750 /// - any parameter is invalid
1751 /// - the response cannot be parsed
1752 /// - or one of the following occurs:
1753 /// - `RequiredError`
1754 /// - `ConnectorClientError`
1755 /// - `UnauthorizedError`
1756 /// - `ForbiddenError`
1757 /// - `TooManyRequestsError`
1758 /// - `RateLimitBanError`
1759 /// - `ServerError`
1760 /// - `NotFoundError`
1761 /// - `NetworkError`
1762 /// - `BadRequestError`
1763 ///
1764 ///
1765 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#delete-special-key).
1766 ///
1767 pub async fn delete_special_key(
1768 &self,
1769 params: DeleteSpecialKeyParams,
1770 ) -> anyhow::Result<RestApiResponse<Value>> {
1771 self.trade_api_client.delete_special_key(params).await
1772 }
1773
1774 /// Edit ip for Special Key(Low-Latency Trading) (TRADE)
1775 ///
1776 /// Edit ip restriction. This only applies to Special Key for Low Latency
1777 /// Trading.
1778 ///
1779 /// You need to enable Permits “Enable Spot & Margin” option for the API Key
1780 /// which requests this endpoint.
1781 ///
1782 /// Weight(UID): 1
1783 ///
1784 /// Security Type: TRADE
1785 ///
1786 /// # Arguments
1787 ///
1788 /// - `params`: [`EditIpForSpecialKeyParams`]
1789 /// The parameters for this operation.
1790 ///
1791 /// # Returns
1792 ///
1793 /// [`RestApiResponse<Value>`] on success.
1794 ///
1795 /// # Errors
1796 ///
1797 /// This function will return an [`anyhow::Error`] if:
1798 /// - the HTTP request fails
1799 /// - any parameter is invalid
1800 /// - the response cannot be parsed
1801 /// - or one of the following occurs:
1802 /// - `RequiredError`
1803 /// - `ConnectorClientError`
1804 /// - `UnauthorizedError`
1805 /// - `ForbiddenError`
1806 /// - `TooManyRequestsError`
1807 /// - `RateLimitBanError`
1808 /// - `ServerError`
1809 /// - `NotFoundError`
1810 /// - `NetworkError`
1811 /// - `BadRequestError`
1812 ///
1813 ///
1814 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#edit-ip-for-special-key).
1815 ///
1816 pub async fn edit_ip_for_special_key(
1817 &self,
1818 params: EditIpForSpecialKeyParams,
1819 ) -> anyhow::Result<RestApiResponse<Value>> {
1820 self.trade_api_client.edit_ip_for_special_key(params).await
1821 }
1822
1823 /// Exit Special Key Mode (TRADE)
1824 ///
1825 /// Exit the Margin Special Key mode for Cross Margin Classic accounts.
1826 ///
1827 /// **All outstanding liabilities under the Cross Margin Classic account must be fully repaid before calling this endpoint.** Deleting the Margin Special Key alone does not constitute a valid exit.
1828 ///
1829 /// When a user creates a Margin Special API Key, the account enters "Special Key Mode". Upon a successful request, the following actions will be performed atomically:
1830 ///
1831 /// 1. All existing Margin Special API Keys under the Cross Margin Classic mode account will be deleted.
1832 /// 2. All pre-execution margin checks (including Open-order-loss calculation) will revert to standard mode.
1833 /// 3. A cooldown period (default: 24 hours) will be enforced, during which the account will not be permitted to create new Margin Special API Keys.
1834 ///
1835 /// For more information, please refer to [FAQ](https://www.binance.com/en/support/faq/detail/3208663e900d4d2e9fec4140e1832f4e).
1836 ///
1837 /// **Preconditions:**
1838 ///
1839 /// The following conditions must be met; otherwise the request will be rejected:
1840 ///
1841 /// - Account type must be **Cross Margin Classic**.
1842 /// - Account must currently be in **Special Key Mode**. If not, the request silently succeeds.
1843 /// - Account must **not be in liquidation**.
1844 /// - Account must **have no liability**.
1845 ///
1846 /// You need to enable "Permits Enable Spot & Margin Trading" option for the API Key which requests this endpoint.
1847 ///
1848 /// Weight(UID): 10
1849 ///
1850 /// Security Type: TRADE
1851 ///
1852 /// # Arguments
1853 ///
1854 /// - `params`: [`ExitSpecialKeyModeParams`]
1855 /// The parameters for this operation.
1856 ///
1857 /// # Returns
1858 ///
1859 /// [`RestApiResponse<serde_json::Value>`] on success.
1860 ///
1861 /// # Errors
1862 ///
1863 /// This function will return an [`anyhow::Error`] if:
1864 /// - the HTTP request fails
1865 /// - any parameter is invalid
1866 /// - the response cannot be parsed
1867 /// - or one of the following occurs:
1868 /// - `RequiredError`
1869 /// - `ConnectorClientError`
1870 /// - `UnauthorizedError`
1871 /// - `ForbiddenError`
1872 /// - `TooManyRequestsError`
1873 /// - `RateLimitBanError`
1874 /// - `ServerError`
1875 /// - `NotFoundError`
1876 /// - `NetworkError`
1877 /// - `BadRequestError`
1878 ///
1879 ///
1880 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#exit-special-key-mode).
1881 ///
1882 pub async fn exit_special_key_mode(
1883 &self,
1884 params: ExitSpecialKeyModeParams,
1885 ) -> anyhow::Result<RestApiResponse<serde_json::Value>> {
1886 self.trade_api_client.exit_special_key_mode(params).await
1887 }
1888
1889 /// Get Force Liquidation Record (`USER_DATA`)
1890 ///
1891 /// Get Force Liquidation Record
1892 ///
1893 /// Weight(IP): 1
1894 ///
1895 /// Security Type: `USER_DATA`
1896 ///
1897 /// Notes:
1898 /// - Response in descending order
1899 ///
1900 /// # Arguments
1901 ///
1902 /// - `params`: [`GetForceLiquidationRecordParams`]
1903 /// The parameters for this operation.
1904 ///
1905 /// # Returns
1906 ///
1907 /// [`RestApiResponse<models::GetForceLiquidationRecordResponse>`] on success.
1908 ///
1909 /// # Errors
1910 ///
1911 /// This function will return an [`anyhow::Error`] if:
1912 /// - the HTTP request fails
1913 /// - any parameter is invalid
1914 /// - the response cannot be parsed
1915 /// - or one of the following occurs:
1916 /// - `RequiredError`
1917 /// - `ConnectorClientError`
1918 /// - `UnauthorizedError`
1919 /// - `ForbiddenError`
1920 /// - `TooManyRequestsError`
1921 /// - `RateLimitBanError`
1922 /// - `ServerError`
1923 /// - `NotFoundError`
1924 /// - `NetworkError`
1925 /// - `BadRequestError`
1926 ///
1927 ///
1928 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#get-force-liquidation-record).
1929 ///
1930 pub async fn get_force_liquidation_record(
1931 &self,
1932 params: GetForceLiquidationRecordParams,
1933 ) -> anyhow::Result<RestApiResponse<models::GetForceLiquidationRecordResponse>> {
1934 self.trade_api_client
1935 .get_force_liquidation_record(params)
1936 .await
1937 }
1938
1939 /// Get Small Liability Exchange Coin List (`USER_DATA`)
1940 ///
1941 /// Query the coins which can be small liability exchange
1942 ///
1943 /// Weight(IP): 100
1944 ///
1945 /// Security Type: `USER_DATA`
1946 ///
1947 /// # Arguments
1948 ///
1949 /// - `params`: [`GetSmallLiabilityExchangeCoinListParams`]
1950 /// The parameters for this operation.
1951 ///
1952 /// # Returns
1953 ///
1954 /// [`RestApiResponse<Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>>`] on success.
1955 ///
1956 /// # Errors
1957 ///
1958 /// This function will return an [`anyhow::Error`] if:
1959 /// - the HTTP request fails
1960 /// - any parameter is invalid
1961 /// - the response cannot be parsed
1962 /// - or one of the following occurs:
1963 /// - `RequiredError`
1964 /// - `ConnectorClientError`
1965 /// - `UnauthorizedError`
1966 /// - `ForbiddenError`
1967 /// - `TooManyRequestsError`
1968 /// - `RateLimitBanError`
1969 /// - `ServerError`
1970 /// - `NotFoundError`
1971 /// - `NetworkError`
1972 /// - `BadRequestError`
1973 ///
1974 ///
1975 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#get-small-liability-exchange-coin-list).
1976 ///
1977 pub async fn get_small_liability_exchange_coin_list(
1978 &self,
1979 params: GetSmallLiabilityExchangeCoinListParams,
1980 ) -> anyhow::Result<RestApiResponse<Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>>>
1981 {
1982 self.trade_api_client
1983 .get_small_liability_exchange_coin_list(params)
1984 .await
1985 }
1986
1987 /// Get Small Liability Exchange History (`USER_DATA`)
1988 ///
1989 /// Get Small liability Exchange History
1990 ///
1991 /// Weight(UID): 100
1992 ///
1993 /// Security Type: `USER_DATA`
1994 ///
1995 /// # Arguments
1996 ///
1997 /// - `params`: [`GetSmallLiabilityExchangeHistoryParams`]
1998 /// The parameters for this operation.
1999 ///
2000 /// # Returns
2001 ///
2002 /// [`RestApiResponse<models::GetSmallLiabilityExchangeHistoryResponse>`] on success.
2003 ///
2004 /// # Errors
2005 ///
2006 /// This function will return an [`anyhow::Error`] if:
2007 /// - the HTTP request fails
2008 /// - any parameter is invalid
2009 /// - the response cannot be parsed
2010 /// - or one of the following occurs:
2011 /// - `RequiredError`
2012 /// - `ConnectorClientError`
2013 /// - `UnauthorizedError`
2014 /// - `ForbiddenError`
2015 /// - `TooManyRequestsError`
2016 /// - `RateLimitBanError`
2017 /// - `ServerError`
2018 /// - `NotFoundError`
2019 /// - `NetworkError`
2020 /// - `BadRequestError`
2021 ///
2022 ///
2023 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#get-small-liability-exchange-history).
2024 ///
2025 pub async fn get_small_liability_exchange_history(
2026 &self,
2027 params: GetSmallLiabilityExchangeHistoryParams,
2028 ) -> anyhow::Result<RestApiResponse<models::GetSmallLiabilityExchangeHistoryResponse>> {
2029 self.trade_api_client
2030 .get_small_liability_exchange_history(params)
2031 .await
2032 }
2033
2034 /// Liquidation Loan Repay (MARGIN)
2035 ///
2036 /// Repays the outstanding cross-margin liquidation loan from the user's spot wallet. A liquidation loan represents the account deficit incurred when account equity turns negative during liquidation (bankruptcy). The repayment amount must be greater than 0 and cannot exceed the remaining loan balance. If the Spot Account has insufficient USDC balance, the repayment will fail.
2037 ///
2038 /// Weight(UID): 100
2039 ///
2040 /// Security Type: MARGIN
2041 ///
2042 /// # Arguments
2043 ///
2044 /// - `params`: [`LiquidationLoanRepayParams`]
2045 /// The parameters for this operation.
2046 ///
2047 /// # Returns
2048 ///
2049 /// [`RestApiResponse<models::LiquidationLoanRepayResponse>`] on success.
2050 ///
2051 /// # Errors
2052 ///
2053 /// This function will return an [`anyhow::Error`] if:
2054 /// - the HTTP request fails
2055 /// - any parameter is invalid
2056 /// - the response cannot be parsed
2057 /// - or one of the following occurs:
2058 /// - `RequiredError`
2059 /// - `ConnectorClientError`
2060 /// - `UnauthorizedError`
2061 /// - `ForbiddenError`
2062 /// - `TooManyRequestsError`
2063 /// - `RateLimitBanError`
2064 /// - `ServerError`
2065 /// - `NotFoundError`
2066 /// - `NetworkError`
2067 /// - `BadRequestError`
2068 ///
2069 ///
2070 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#liquidation-loan-repay).
2071 ///
2072 pub async fn liquidation_loan_repay(
2073 &self,
2074 params: LiquidationLoanRepayParams,
2075 ) -> anyhow::Result<RestApiResponse<models::LiquidationLoanRepayResponse>> {
2076 self.trade_api_client.liquidation_loan_repay(params).await
2077 }
2078
2079 /// Margin Account Cancel all Open Orders on a Symbol (TRADE)
2080 ///
2081 /// Cancels all active orders on a symbol for margin account.<br></br>
2082 /// This includes OCO orders.
2083 ///
2084 /// Weight(IP): 1
2085 ///
2086 /// Security Type: TRADE
2087 ///
2088 /// # Arguments
2089 ///
2090 /// - `params`: [`MarginAccountCancelAllOpenOrdersOnASymbolParams`]
2091 /// The parameters for this operation.
2092 ///
2093 /// # Returns
2094 ///
2095 /// [`RestApiResponse<Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>>`] on success.
2096 ///
2097 /// # Errors
2098 ///
2099 /// This function will return an [`anyhow::Error`] if:
2100 /// - the HTTP request fails
2101 /// - any parameter is invalid
2102 /// - the response cannot be parsed
2103 /// - or one of the following occurs:
2104 /// - `RequiredError`
2105 /// - `ConnectorClientError`
2106 /// - `UnauthorizedError`
2107 /// - `ForbiddenError`
2108 /// - `TooManyRequestsError`
2109 /// - `RateLimitBanError`
2110 /// - `ServerError`
2111 /// - `NotFoundError`
2112 /// - `NetworkError`
2113 /// - `BadRequestError`
2114 ///
2115 ///
2116 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#margin-account-cancel-all-open-orders-on-asymbol).
2117 ///
2118 pub async fn margin_account_cancel_all_open_orders_on_a_symbol(
2119 &self,
2120 params: MarginAccountCancelAllOpenOrdersOnASymbolParams,
2121 ) -> anyhow::Result<
2122 RestApiResponse<Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>>,
2123 > {
2124 self.trade_api_client
2125 .margin_account_cancel_all_open_orders_on_a_symbol(params)
2126 .await
2127 }
2128
2129 /// Margin Account Cancel OCO (TRADE)
2130 ///
2131 /// Cancel an entire Order List for a margin account.
2132 ///
2133 /// Weight(UID): 1
2134 ///
2135 /// Security Type: TRADE
2136 ///
2137 /// Notes:
2138 /// - Canceling an individual leg will cancel the entire OCO
2139 ///
2140 /// # Arguments
2141 ///
2142 /// - `params`: [`MarginAccountCancelOcoParams`]
2143 /// The parameters for this operation.
2144 ///
2145 /// # Returns
2146 ///
2147 /// [`RestApiResponse<models::MarginAccountCancelOcoResponse>`] on success.
2148 ///
2149 /// # Errors
2150 ///
2151 /// This function will return an [`anyhow::Error`] if:
2152 /// - the HTTP request fails
2153 /// - any parameter is invalid
2154 /// - the response cannot be parsed
2155 /// - or one of the following occurs:
2156 /// - `RequiredError`
2157 /// - `ConnectorClientError`
2158 /// - `UnauthorizedError`
2159 /// - `ForbiddenError`
2160 /// - `TooManyRequestsError`
2161 /// - `RateLimitBanError`
2162 /// - `ServerError`
2163 /// - `NotFoundError`
2164 /// - `NetworkError`
2165 /// - `BadRequestError`
2166 ///
2167 ///
2168 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#margin-account-cancel-oco).
2169 ///
2170 pub async fn margin_account_cancel_oco(
2171 &self,
2172 params: MarginAccountCancelOcoParams,
2173 ) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOcoResponse>> {
2174 self.trade_api_client
2175 .margin_account_cancel_oco(params)
2176 .await
2177 }
2178
2179 /// Margin Account Cancel Order (TRADE)
2180 ///
2181 /// Cancel an active order for margin account.
2182 ///
2183 /// Weight(IP): 10
2184 ///
2185 /// Security Type: TRADE
2186 ///
2187 /// Notes:
2188 /// - Either orderId or origClientOrderId must be sent.
2189 ///
2190 /// # Arguments
2191 ///
2192 /// - `params`: [`MarginAccountCancelOrderParams`]
2193 /// The parameters for this operation.
2194 ///
2195 /// # Returns
2196 ///
2197 /// [`RestApiResponse<models::MarginAccountCancelOrderResponse>`] on success.
2198 ///
2199 /// # Errors
2200 ///
2201 /// This function will return an [`anyhow::Error`] if:
2202 /// - the HTTP request fails
2203 /// - any parameter is invalid
2204 /// - the response cannot be parsed
2205 /// - or one of the following occurs:
2206 /// - `RequiredError`
2207 /// - `ConnectorClientError`
2208 /// - `UnauthorizedError`
2209 /// - `ForbiddenError`
2210 /// - `TooManyRequestsError`
2211 /// - `RateLimitBanError`
2212 /// - `ServerError`
2213 /// - `NotFoundError`
2214 /// - `NetworkError`
2215 /// - `BadRequestError`
2216 ///
2217 ///
2218 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#margin-account-cancel-order).
2219 ///
2220 pub async fn margin_account_cancel_order(
2221 &self,
2222 params: MarginAccountCancelOrderParams,
2223 ) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOrderResponse>> {
2224 self.trade_api_client
2225 .margin_account_cancel_order(params)
2226 .await
2227 }
2228
2229 /// Margin Account New OCO (TRADE)
2230 ///
2231 /// Send in a new OCO for a margin account
2232 ///
2233 /// Weight: 6(UID) or 1500(UID) when sideEffectType is `MARGIN_BUY` or `AUTO_BORROW_REPAY`
2234 ///
2235 /// Security Type: TRADE
2236 ///
2237 /// Notes:
2238 /// - autoRepayAtCancel is suggested to set as “FALSE” to keep liability unrepaid under high frequent new order/cancel order execution
2239 ///
2240 /// # Arguments
2241 ///
2242 /// - `params`: [`MarginAccountNewOcoParams`]
2243 /// The parameters for this operation.
2244 ///
2245 /// # Returns
2246 ///
2247 /// [`RestApiResponse<models::MarginAccountNewOcoResponse>`] on success.
2248 ///
2249 /// # Errors
2250 ///
2251 /// This function will return an [`anyhow::Error`] if:
2252 /// - the HTTP request fails
2253 /// - any parameter is invalid
2254 /// - the response cannot be parsed
2255 /// - or one of the following occurs:
2256 /// - `RequiredError`
2257 /// - `ConnectorClientError`
2258 /// - `UnauthorizedError`
2259 /// - `ForbiddenError`
2260 /// - `TooManyRequestsError`
2261 /// - `RateLimitBanError`
2262 /// - `ServerError`
2263 /// - `NotFoundError`
2264 /// - `NetworkError`
2265 /// - `BadRequestError`
2266 ///
2267 ///
2268 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#margin-account-new-oco).
2269 ///
2270 pub async fn margin_account_new_oco(
2271 &self,
2272 params: MarginAccountNewOcoParams,
2273 ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOcoResponse>> {
2274 self.trade_api_client.margin_account_new_oco(params).await
2275 }
2276
2277 /// Margin Account New Order (TRADE)
2278 ///
2279 /// Post a new order for margin account.
2280 ///
2281 /// Weight: 6(UID) or 1500(UID) when sideEffectType is `MARGIN_BUY` or `AUTO_BORROW_REPAY`
2282 ///
2283 /// Security Type: TRADE
2284 ///
2285 /// Notes:
2286 /// - autoRepayAtCancel is suggested to set as “FALSE” to keep liability unrepaid under high frequent new order/cancel order execution
2287 ///
2288 /// # Arguments
2289 ///
2290 /// - `params`: [`MarginAccountNewOrderParams`]
2291 /// The parameters for this operation.
2292 ///
2293 /// # Returns
2294 ///
2295 /// [`RestApiResponse<models::MarginAccountNewOrderResponse>`] on success.
2296 ///
2297 /// # Errors
2298 ///
2299 /// This function will return an [`anyhow::Error`] if:
2300 /// - the HTTP request fails
2301 /// - any parameter is invalid
2302 /// - the response cannot be parsed
2303 /// - or one of the following occurs:
2304 /// - `RequiredError`
2305 /// - `ConnectorClientError`
2306 /// - `UnauthorizedError`
2307 /// - `ForbiddenError`
2308 /// - `TooManyRequestsError`
2309 /// - `RateLimitBanError`
2310 /// - `ServerError`
2311 /// - `NotFoundError`
2312 /// - `NetworkError`
2313 /// - `BadRequestError`
2314 ///
2315 ///
2316 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#margin-account-new-order).
2317 ///
2318 pub async fn margin_account_new_order(
2319 &self,
2320 params: MarginAccountNewOrderParams,
2321 ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOrderResponse>> {
2322 self.trade_api_client.margin_account_new_order(params).await
2323 }
2324
2325 /// Margin Account New OTO (TRADE)
2326 ///
2327 /// Post a new OTO order for margin account:
2328 ///
2329 /// - An OTO (One-Triggers-the-Other) is an order list comprised of 2
2330 /// orders.
2331 ///
2332 /// - The first order is called the **working order** and must be `LIMIT` or
2333 /// `LIMIT_MAKER`. Initially, only the working order goes on the order book.
2334 ///
2335 /// - The second order is called the **pending order**. It can be any order
2336 /// type except for `MARKET` orders using parameter `quoteOrderQty`. The
2337 /// pending order is only placed on the order book when the working order
2338 /// gets **fully filled**.
2339 ///
2340 /// - If either the working order or the pending order is cancelled
2341 /// individually, the other order in the order list will also be canceled or
2342 /// expired.
2343 ///
2344 /// - When the order list is placed, if the working order gets **immediately
2345 /// fully filled**, the placement response will show the working order as
2346 /// `FILLED` but the pending order will still appear as `PENDING_NEW`. You
2347 /// need to query the status of the pending order again to see its updated
2348 /// status.
2349 ///
2350 /// - OTOs add **2 orders** to the unfilled order count,
2351 /// `EXCHANGE_MAX_NUM_ORDERS` filter and `MAX_NUM_ORDERS` filter.
2352 ///
2353 /// Weight: 6(UID) or 1500(UID) when sideEffectType is `MARGIN_BUY` or `AUTO_BORROW_REPAY`
2354 ///
2355 /// Security Type: TRADE
2356 ///
2357 /// Notes:
2358 /// - autoRepayAtCancel is suggested to set as “FALSE” to keep liability unrepaid under high frequent new order/cancel order execution
2359 /// - Depending on the `pendingType` or `workingType`, some optional
2360 /// - parameters will become mandatory: | Type | Additional mandatory parameters | Additional information | | -------------------------------------------------------- | ------------------------------------------------------------ | ---------------------- | | `workingType` = `LIMIT` | `workingTimeInForce` | | | `pendingType` = `LIMIT` | `pendingPrice`, `pendingTimeInForce` | | | `pendingType` = `STOP_LOSS` or `TAKE_PROFIT` | `pendingStopPrice` and/or `pendingTrailingDelta` | | | `pendingType` = `STOP_LOSS_LIMIT` or `TAKE_PROFIT_LIMIT` | `pendingPrice`, `pendingStopPrice` and/or `pendingTrailingDelta`, `pendingTimeInForce` | | | `pendingTrailingDelta` is provided | `pendingPrice` | |
2361 ///
2362 /// # Arguments
2363 ///
2364 /// - `params`: [`MarginAccountNewOtoParams`]
2365 /// The parameters for this operation.
2366 ///
2367 /// # Returns
2368 ///
2369 /// [`RestApiResponse<models::MarginAccountNewOtoResponse>`] on success.
2370 ///
2371 /// # Errors
2372 ///
2373 /// This function will return an [`anyhow::Error`] if:
2374 /// - the HTTP request fails
2375 /// - any parameter is invalid
2376 /// - the response cannot be parsed
2377 /// - or one of the following occurs:
2378 /// - `RequiredError`
2379 /// - `ConnectorClientError`
2380 /// - `UnauthorizedError`
2381 /// - `ForbiddenError`
2382 /// - `TooManyRequestsError`
2383 /// - `RateLimitBanError`
2384 /// - `ServerError`
2385 /// - `NotFoundError`
2386 /// - `NetworkError`
2387 /// - `BadRequestError`
2388 ///
2389 ///
2390 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#margin-account-new-oto).
2391 ///
2392 pub async fn margin_account_new_oto(
2393 &self,
2394 params: MarginAccountNewOtoParams,
2395 ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtoResponse>> {
2396 self.trade_api_client.margin_account_new_oto(params).await
2397 }
2398
2399 /// Margin Account New OTOCO (TRADE)
2400 ///
2401 /// Post a new OTOCO order for margin account:
2402 ///
2403 ///
2404 /// - An OTOCO (One-Triggers-One-Cancels-the-Other) is an order list
2405 /// comprised of 3 orders.
2406 ///
2407 /// - The first order is called the **working order** and must be `LIMIT` or
2408 /// `LIMIT_MAKER`. Initially, only the working order goes on the order book.
2409 /// - The behavior of the working order is the same as the OTO.
2410 /// - OTOCO has 2 pending orders (pending above and pending below), forming
2411 /// an OCO pair. The pending orders are only placed on the order book when
2412 /// the working order gets **fully filled**.
2413 /// - The rules of the pending above and pending below follow the same rules as the [Order List OCO](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#margin-account-new-oco).
2414 /// - OTOCOs add **3 orders** against the unfilled order count,
2415 /// `EXCHANGE_MAX_NUM_ORDERS` filter, and `MAX_NUM_ORDERS` filter.
2416 ///
2417 /// Weight: 6(UID) or 1500(UID) when sideEffectType is `MARGIN_BUY` or `AUTO_BORROW_REPAY`
2418 ///
2419 /// Security Type: TRADE
2420 ///
2421 /// Notes:
2422 /// - autoRepayAtCancel is suggested to set as “FALSE” to keep liability unrepaid under high frequent new order/cancel order execution
2423 /// - Depending on the `pendingAboveType`/`pendingBelowType` or `workingType`, some optional parameters will become mandatory: | Type | Additional mandatory parameters | Additional information | | ------------------------------------ | ------------------------------------------------------------ | ---------------------- | | `workingType` = `LIMIT` | `workingTimeInForce` | | | `pendingAboveType`= `LIMIT_MAKER` | `pendingAbovePrice` | | | `pendingAboveType`= `STOP_LOSS` | `pendingAboveStopPrice` and/or `pendingAboveTrailingDelta` | | | `pendingAboveType`=`STOP_LOSS_LIMIT` | `pendingAbovePrice`, `pendingAboveStopPrice` and/or `pendingAboveTrailingDelta`, `pendingAboveTimeInForce` | | | `pendingBelowType`= `LIMIT_MAKER` | `pendingBelowPrice` | | | `pendingBelowType`= `STOP_LOSS` | `pendingBelowStopPrice` and/or `pendingBelowTrailingDelta` | | | `pendingBelowType`=`STOP_LOSS_LIMIT` | `pendingBelowPrice`, `pendingBelowStopPrice` and/or `pendingBelowTrailingDelta`, `pendingBelowTimeInForce` | | | `pendingAboveTrailingDelta` is provided | `pendingAbovePrice` | | | `pendingBelowTrailingDelta` is provided | `pendingBelowPrice` | |
2424 ///
2425 /// # Arguments
2426 ///
2427 /// - `params`: [`MarginAccountNewOtocoParams`]
2428 /// The parameters for this operation.
2429 ///
2430 /// # Returns
2431 ///
2432 /// [`RestApiResponse<models::MarginAccountNewOtocoResponse>`] on success.
2433 ///
2434 /// # Errors
2435 ///
2436 /// This function will return an [`anyhow::Error`] if:
2437 /// - the HTTP request fails
2438 /// - any parameter is invalid
2439 /// - the response cannot be parsed
2440 /// - or one of the following occurs:
2441 /// - `RequiredError`
2442 /// - `ConnectorClientError`
2443 /// - `UnauthorizedError`
2444 /// - `ForbiddenError`
2445 /// - `TooManyRequestsError`
2446 /// - `RateLimitBanError`
2447 /// - `ServerError`
2448 /// - `NotFoundError`
2449 /// - `NetworkError`
2450 /// - `BadRequestError`
2451 ///
2452 ///
2453 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#margin-account-new-otoco).
2454 ///
2455 pub async fn margin_account_new_otoco(
2456 &self,
2457 params: MarginAccountNewOtocoParams,
2458 ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtocoResponse>> {
2459 self.trade_api_client.margin_account_new_otoco(params).await
2460 }
2461
2462 /// Margin Manual Liquidation (TRADE)
2463 ///
2464 /// Margin Manual Liquidation
2465 ///
2466 /// Weight(UID): 3000
2467 ///
2468 /// Security Type: TRADE
2469 ///
2470 /// Notes:
2471 /// - This endpoint supports Cross Margin Classic Mode and Pro Mode.
2472 /// - Isolated Margin is only supported in restricted regions.
2473 ///
2474 /// # Arguments
2475 ///
2476 /// - `params`: [`MarginManualLiquidationParams`]
2477 /// The parameters for this operation.
2478 ///
2479 /// # Returns
2480 ///
2481 /// [`RestApiResponse<models::MarginManualLiquidationResponse>`] on success.
2482 ///
2483 /// # Errors
2484 ///
2485 /// This function will return an [`anyhow::Error`] if:
2486 /// - the HTTP request fails
2487 /// - any parameter is invalid
2488 /// - the response cannot be parsed
2489 /// - or one of the following occurs:
2490 /// - `RequiredError`
2491 /// - `ConnectorClientError`
2492 /// - `UnauthorizedError`
2493 /// - `ForbiddenError`
2494 /// - `TooManyRequestsError`
2495 /// - `RateLimitBanError`
2496 /// - `ServerError`
2497 /// - `NotFoundError`
2498 /// - `NetworkError`
2499 /// - `BadRequestError`
2500 ///
2501 ///
2502 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#margin-manual-liquidation).
2503 ///
2504 pub async fn margin_manual_liquidation(
2505 &self,
2506 params: MarginManualLiquidationParams,
2507 ) -> anyhow::Result<RestApiResponse<models::MarginManualLiquidationResponse>> {
2508 self.trade_api_client
2509 .margin_manual_liquidation(params)
2510 .await
2511 }
2512
2513 /// Query Current Margin Order Count Usage (TRADE)
2514 ///
2515 /// Displays the user's current margin order count usage for all intervals.
2516 ///
2517 /// Weight(IP): 20
2518 ///
2519 /// Security Type: TRADE
2520 ///
2521 /// # Arguments
2522 ///
2523 /// - `params`: [`QueryCurrentMarginOrderCountUsageParams`]
2524 /// The parameters for this operation.
2525 ///
2526 /// # Returns
2527 ///
2528 /// [`RestApiResponse<Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>>`] on success.
2529 ///
2530 /// # Errors
2531 ///
2532 /// This function will return an [`anyhow::Error`] if:
2533 /// - the HTTP request fails
2534 /// - any parameter is invalid
2535 /// - the response cannot be parsed
2536 /// - or one of the following occurs:
2537 /// - `RequiredError`
2538 /// - `ConnectorClientError`
2539 /// - `UnauthorizedError`
2540 /// - `ForbiddenError`
2541 /// - `TooManyRequestsError`
2542 /// - `RateLimitBanError`
2543 /// - `ServerError`
2544 /// - `NotFoundError`
2545 /// - `NetworkError`
2546 /// - `BadRequestError`
2547 ///
2548 ///
2549 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#query-current-margin-order-count-usage).
2550 ///
2551 pub async fn query_current_margin_order_count_usage(
2552 &self,
2553 params: QueryCurrentMarginOrderCountUsageParams,
2554 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>>>
2555 {
2556 self.trade_api_client
2557 .query_current_margin_order_count_usage(params)
2558 .await
2559 }
2560
2561 /// Query Liquidation Loan (`USER_DATA`)
2562 ///
2563 /// Query the current user's cross-margin liquidation loan information, including the original loan amount, repaid amount, and remaining amount. When a cross-margin account is liquidated and the account equity turns negative (bankruptcy), the system generates a liquidation loan record representing the deficit. This represents the shortfall amount denominated in USDC.
2564 ///
2565 /// Weight(UID): 100
2566 ///
2567 /// Security Type: `USER_DATA`
2568 ///
2569 /// # Arguments
2570 ///
2571 /// - `params`: [`QueryLiquidationLoanParams`]
2572 /// The parameters for this operation.
2573 ///
2574 /// # Returns
2575 ///
2576 /// [`RestApiResponse<models::QueryLiquidationLoanResponse>`] on success.
2577 ///
2578 /// # Errors
2579 ///
2580 /// This function will return an [`anyhow::Error`] if:
2581 /// - the HTTP request fails
2582 /// - any parameter is invalid
2583 /// - the response cannot be parsed
2584 /// - or one of the following occurs:
2585 /// - `RequiredError`
2586 /// - `ConnectorClientError`
2587 /// - `UnauthorizedError`
2588 /// - `ForbiddenError`
2589 /// - `TooManyRequestsError`
2590 /// - `RateLimitBanError`
2591 /// - `ServerError`
2592 /// - `NotFoundError`
2593 /// - `NetworkError`
2594 /// - `BadRequestError`
2595 ///
2596 ///
2597 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#query-liquidation-loan).
2598 ///
2599 pub async fn query_liquidation_loan(
2600 &self,
2601 params: QueryLiquidationLoanParams,
2602 ) -> anyhow::Result<RestApiResponse<models::QueryLiquidationLoanResponse>> {
2603 self.trade_api_client.query_liquidation_loan(params).await
2604 }
2605
2606 /// Query Liquidation Loan Repay History (`USER_DATA`)
2607 ///
2608 /// Query the repayment history of cross-margin liquidation loans (deficit caused by bankruptcy during liquidation). Supports time-range filtering and pagination.
2609 ///
2610 /// Weight(UID): 100
2611 ///
2612 /// Security Type: `USER_DATA`
2613 ///
2614 /// Notes:
2615 /// - The maximum query range is 90 days. If `startTime` is earlier than 90 days ago, it will be clamped to 90 days ago.
2616 /// - Only records with status `SUCCESS` or `PENDING` are returned. Failed repayment records are excluded.
2617 ///
2618 /// # Arguments
2619 ///
2620 /// - `params`: [`QueryLiquidationLoanRepayHistoryParams`]
2621 /// The parameters for this operation.
2622 ///
2623 /// # Returns
2624 ///
2625 /// [`RestApiResponse<models::QueryLiquidationLoanRepayHistoryResponse>`] on success.
2626 ///
2627 /// # Errors
2628 ///
2629 /// This function will return an [`anyhow::Error`] if:
2630 /// - the HTTP request fails
2631 /// - any parameter is invalid
2632 /// - the response cannot be parsed
2633 /// - or one of the following occurs:
2634 /// - `RequiredError`
2635 /// - `ConnectorClientError`
2636 /// - `UnauthorizedError`
2637 /// - `ForbiddenError`
2638 /// - `TooManyRequestsError`
2639 /// - `RateLimitBanError`
2640 /// - `ServerError`
2641 /// - `NotFoundError`
2642 /// - `NetworkError`
2643 /// - `BadRequestError`
2644 ///
2645 ///
2646 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#query-liquidation-loan-repay-history).
2647 ///
2648 pub async fn query_liquidation_loan_repay_history(
2649 &self,
2650 params: QueryLiquidationLoanRepayHistoryParams,
2651 ) -> anyhow::Result<RestApiResponse<models::QueryLiquidationLoanRepayHistoryResponse>> {
2652 self.trade_api_client
2653 .query_liquidation_loan_repay_history(params)
2654 .await
2655 }
2656
2657 /// Query Margin Account's all OCO (`USER_DATA`)
2658 ///
2659 /// Retrieves all OCO for a specific margin account based on provided optional parameters
2660 ///
2661 /// Weight(IP): 200
2662 ///
2663 /// Security Type: `USER_DATA`
2664 ///
2665 /// # Arguments
2666 ///
2667 /// - `params`: [`QueryMarginAccountsAllOcoParams`]
2668 /// The parameters for this operation.
2669 ///
2670 /// # Returns
2671 ///
2672 /// [`RestApiResponse<Vec<models::QueryMarginAccountsAllOcoResponseInner>>`] on success.
2673 ///
2674 /// # Errors
2675 ///
2676 /// This function will return an [`anyhow::Error`] if:
2677 /// - the HTTP request fails
2678 /// - any parameter is invalid
2679 /// - the response cannot be parsed
2680 /// - or one of the following occurs:
2681 /// - `RequiredError`
2682 /// - `ConnectorClientError`
2683 /// - `UnauthorizedError`
2684 /// - `ForbiddenError`
2685 /// - `TooManyRequestsError`
2686 /// - `RateLimitBanError`
2687 /// - `ServerError`
2688 /// - `NotFoundError`
2689 /// - `NetworkError`
2690 /// - `BadRequestError`
2691 ///
2692 ///
2693 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#query-margin-accounts-all-oco).
2694 ///
2695 pub async fn query_margin_accounts_all_oco(
2696 &self,
2697 params: QueryMarginAccountsAllOcoParams,
2698 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOcoResponseInner>>> {
2699 self.trade_api_client
2700 .query_margin_accounts_all_oco(params)
2701 .await
2702 }
2703
2704 /// Query Margin Account's All Orders (`USER_DATA`)
2705 ///
2706 /// Query Margin Account's All Orders
2707 ///
2708 /// Weight(IP): 200
2709 ///
2710 /// Security Type: `USER_DATA`
2711 ///
2712 /// Notes:
2713 /// - If orderId is set, it will get orders >= that orderId. Otherwise the
2714 /// orders within 24 hours are returned.
2715 ///
2716 /// - For some historical orders cummulativeQuoteQty will be < 0, meaning
2717 /// the data is not available at this time.
2718 ///
2719 /// - Less than 24 hours between startTime and endTime.
2720 ///
2721 /// # Arguments
2722 ///
2723 /// - `params`: [`QueryMarginAccountsAllOrdersParams`]
2724 /// The parameters for this operation.
2725 ///
2726 /// # Returns
2727 ///
2728 /// [`RestApiResponse<Vec<models::QueryMarginAccountsAllOrdersResponseInner>>`] on success.
2729 ///
2730 /// # Errors
2731 ///
2732 /// This function will return an [`anyhow::Error`] if:
2733 /// - the HTTP request fails
2734 /// - any parameter is invalid
2735 /// - the response cannot be parsed
2736 /// - or one of the following occurs:
2737 /// - `RequiredError`
2738 /// - `ConnectorClientError`
2739 /// - `UnauthorizedError`
2740 /// - `ForbiddenError`
2741 /// - `TooManyRequestsError`
2742 /// - `RateLimitBanError`
2743 /// - `ServerError`
2744 /// - `NotFoundError`
2745 /// - `NetworkError`
2746 /// - `BadRequestError`
2747 ///
2748 ///
2749 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#query-margin-accounts-all-orders).
2750 ///
2751 pub async fn query_margin_accounts_all_orders(
2752 &self,
2753 params: QueryMarginAccountsAllOrdersParams,
2754 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOrdersResponseInner>>>
2755 {
2756 self.trade_api_client
2757 .query_margin_accounts_all_orders(params)
2758 .await
2759 }
2760
2761 /// Query Margin Account's OCO (`USER_DATA`)
2762 ///
2763 /// Retrieves a specific OCO based on provided optional parameters
2764 ///
2765 /// Weight(IP): 10
2766 ///
2767 /// Security Type: `USER_DATA`
2768 ///
2769 /// # Arguments
2770 ///
2771 /// - `params`: [`QueryMarginAccountsOcoParams`]
2772 /// The parameters for this operation.
2773 ///
2774 /// # Returns
2775 ///
2776 /// [`RestApiResponse<models::QueryMarginAccountsOcoResponse>`] on success.
2777 ///
2778 /// # Errors
2779 ///
2780 /// This function will return an [`anyhow::Error`] if:
2781 /// - the HTTP request fails
2782 /// - any parameter is invalid
2783 /// - the response cannot be parsed
2784 /// - or one of the following occurs:
2785 /// - `RequiredError`
2786 /// - `ConnectorClientError`
2787 /// - `UnauthorizedError`
2788 /// - `ForbiddenError`
2789 /// - `TooManyRequestsError`
2790 /// - `RateLimitBanError`
2791 /// - `ServerError`
2792 /// - `NotFoundError`
2793 /// - `NetworkError`
2794 /// - `BadRequestError`
2795 ///
2796 ///
2797 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#query-margin-accounts-oco).
2798 ///
2799 pub async fn query_margin_accounts_oco(
2800 &self,
2801 params: QueryMarginAccountsOcoParams,
2802 ) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOcoResponse>> {
2803 self.trade_api_client
2804 .query_margin_accounts_oco(params)
2805 .await
2806 }
2807
2808 /// Query Margin Account's Open OCO (`USER_DATA`)
2809 ///
2810 /// Query Margin Account's Open OCO
2811 ///
2812 /// Weight(IP): 10
2813 ///
2814 /// Security Type: `USER_DATA`
2815 ///
2816 /// # Arguments
2817 ///
2818 /// - `params`: [`QueryMarginAccountsOpenOcoParams`]
2819 /// The parameters for this operation.
2820 ///
2821 /// # Returns
2822 ///
2823 /// [`RestApiResponse<Vec<models::QueryMarginAccountsOpenOcoResponseInner>>`] on success.
2824 ///
2825 /// # Errors
2826 ///
2827 /// This function will return an [`anyhow::Error`] if:
2828 /// - the HTTP request fails
2829 /// - any parameter is invalid
2830 /// - the response cannot be parsed
2831 /// - or one of the following occurs:
2832 /// - `RequiredError`
2833 /// - `ConnectorClientError`
2834 /// - `UnauthorizedError`
2835 /// - `ForbiddenError`
2836 /// - `TooManyRequestsError`
2837 /// - `RateLimitBanError`
2838 /// - `ServerError`
2839 /// - `NotFoundError`
2840 /// - `NetworkError`
2841 /// - `BadRequestError`
2842 ///
2843 ///
2844 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#query-margin-accounts-open-oco).
2845 ///
2846 pub async fn query_margin_accounts_open_oco(
2847 &self,
2848 params: QueryMarginAccountsOpenOcoParams,
2849 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOcoResponseInner>>> {
2850 self.trade_api_client
2851 .query_margin_accounts_open_oco(params)
2852 .await
2853 }
2854
2855 /// Query Margin Account's Open Orders (`USER_DATA`)
2856 ///
2857 /// Query Margin Account's Open Orders
2858 ///
2859 /// Weight(IP): 10
2860 ///
2861 /// Security Type: `USER_DATA`
2862 ///
2863 /// Notes:
2864 /// - If the symbol is not sent, orders for all symbols will be returned in
2865 /// an array.
2866 ///
2867 /// - When all symbols are returned, the number of requests counted against
2868 /// the rate limiter is equal to the number of symbols currently trading on
2869 /// the exchange.
2870 ///
2871 /// - If isIsolated ="TRUE", symbol must be sent.
2872 ///
2873 /// # Arguments
2874 ///
2875 /// - `params`: [`QueryMarginAccountsOpenOrdersParams`]
2876 /// The parameters for this operation.
2877 ///
2878 /// # Returns
2879 ///
2880 /// [`RestApiResponse<Vec<models::QueryMarginAccountsOpenOrdersResponseInner>>`] on success.
2881 ///
2882 /// # Errors
2883 ///
2884 /// This function will return an [`anyhow::Error`] if:
2885 /// - the HTTP request fails
2886 /// - any parameter is invalid
2887 /// - the response cannot be parsed
2888 /// - or one of the following occurs:
2889 /// - `RequiredError`
2890 /// - `ConnectorClientError`
2891 /// - `UnauthorizedError`
2892 /// - `ForbiddenError`
2893 /// - `TooManyRequestsError`
2894 /// - `RateLimitBanError`
2895 /// - `ServerError`
2896 /// - `NotFoundError`
2897 /// - `NetworkError`
2898 /// - `BadRequestError`
2899 ///
2900 ///
2901 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#query-margin-accounts-open-orders).
2902 ///
2903 pub async fn query_margin_accounts_open_orders(
2904 &self,
2905 params: QueryMarginAccountsOpenOrdersParams,
2906 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOrdersResponseInner>>>
2907 {
2908 self.trade_api_client
2909 .query_margin_accounts_open_orders(params)
2910 .await
2911 }
2912
2913 /// Query Margin Account's Order (`USER_DATA`)
2914 ///
2915 /// Query Margin Account's Order
2916 ///
2917 /// Weight(IP): 10
2918 ///
2919 /// Security Type: `USER_DATA`
2920 ///
2921 /// Notes:
2922 /// - Either orderId or origClientOrderId must be sent.
2923 ///
2924 /// - For some historical orders cummulativeQuoteQty will be < 0, meaning
2925 /// the data is not available at this time.
2926 ///
2927 /// # Arguments
2928 ///
2929 /// - `params`: [`QueryMarginAccountsOrderParams`]
2930 /// The parameters for this operation.
2931 ///
2932 /// # Returns
2933 ///
2934 /// [`RestApiResponse<models::QueryMarginAccountsOrderResponse>`] on success.
2935 ///
2936 /// # Errors
2937 ///
2938 /// This function will return an [`anyhow::Error`] if:
2939 /// - the HTTP request fails
2940 /// - any parameter is invalid
2941 /// - the response cannot be parsed
2942 /// - or one of the following occurs:
2943 /// - `RequiredError`
2944 /// - `ConnectorClientError`
2945 /// - `UnauthorizedError`
2946 /// - `ForbiddenError`
2947 /// - `TooManyRequestsError`
2948 /// - `RateLimitBanError`
2949 /// - `ServerError`
2950 /// - `NotFoundError`
2951 /// - `NetworkError`
2952 /// - `BadRequestError`
2953 ///
2954 ///
2955 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#query-margin-accounts-order).
2956 ///
2957 pub async fn query_margin_accounts_order(
2958 &self,
2959 params: QueryMarginAccountsOrderParams,
2960 ) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOrderResponse>> {
2961 self.trade_api_client
2962 .query_margin_accounts_order(params)
2963 .await
2964 }
2965
2966 /// Query Margin Account's Trade List (`USER_DATA`)
2967 ///
2968 /// Query Margin Account's Trade List
2969 ///
2970 /// Weight(IP): 10
2971 ///
2972 /// Security Type: `USER_DATA`
2973 ///
2974 /// Notes:
2975 /// - If fromId is set, it will get trades >= that fromId. Otherwise the
2976 /// trades within 24 hours are returned.
2977 ///
2978 /// - Less than 24 hours between startTime and endTime.
2979 ///
2980 /// # Arguments
2981 ///
2982 /// - `params`: [`QueryMarginAccountsTradeListParams`]
2983 /// The parameters for this operation.
2984 ///
2985 /// # Returns
2986 ///
2987 /// [`RestApiResponse<Vec<models::QueryMarginAccountsTradeListResponseInner>>`] on success.
2988 ///
2989 /// # Errors
2990 ///
2991 /// This function will return an [`anyhow::Error`] if:
2992 /// - the HTTP request fails
2993 /// - any parameter is invalid
2994 /// - the response cannot be parsed
2995 /// - or one of the following occurs:
2996 /// - `RequiredError`
2997 /// - `ConnectorClientError`
2998 /// - `UnauthorizedError`
2999 /// - `ForbiddenError`
3000 /// - `TooManyRequestsError`
3001 /// - `RateLimitBanError`
3002 /// - `ServerError`
3003 /// - `NotFoundError`
3004 /// - `NetworkError`
3005 /// - `BadRequestError`
3006 ///
3007 ///
3008 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#query-margin-accounts-trade-list).
3009 ///
3010 pub async fn query_margin_accounts_trade_list(
3011 &self,
3012 params: QueryMarginAccountsTradeListParams,
3013 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsTradeListResponseInner>>>
3014 {
3015 self.trade_api_client
3016 .query_margin_accounts_trade_list(params)
3017 .await
3018 }
3019
3020 /// Query Prevented Matches (`USER_DATA`)
3021 ///
3022 /// Displays the list of orders that were expired due to STP. (Self-Trade Prevention).
3023 ///
3024 /// Weight(IP): 10
3025 ///
3026 /// Security Type: `USER_DATA`
3027 ///
3028 /// Notes:
3029 /// - Supported parameter combinations:
3030 ///
3031 /// - `symbol` + `preventedMatchId`
3032 ///
3033 /// - `symbol` + `orderId`
3034 ///
3035 /// - `symbol` + `orderId` + `fromPreventedMatchId`
3036 ///
3037 /// - If `orderId` is provided, all prevented matches for that order will be
3038 /// returned.
3039 ///
3040 /// - If `preventedMatchId` is provided, the specific prevented match will
3041 /// be returned.
3042 ///
3043 /// - A single request returns a maximum of 500 records. If there are more
3044 /// than 500 records, use `symbol` + `orderId` + `fromPreventedMatchId`
3045 /// combination for pagination.
3046 ///
3047 /// # Arguments
3048 ///
3049 /// - `params`: [`QueryPreventedMatchesParams`]
3050 /// The parameters for this operation.
3051 ///
3052 /// # Returns
3053 ///
3054 /// [`RestApiResponse<Vec<models::QueryPreventedMatchesResponseInner>>`] on success.
3055 ///
3056 /// # Errors
3057 ///
3058 /// This function will return an [`anyhow::Error`] if:
3059 /// - the HTTP request fails
3060 /// - any parameter is invalid
3061 /// - the response cannot be parsed
3062 /// - or one of the following occurs:
3063 /// - `RequiredError`
3064 /// - `ConnectorClientError`
3065 /// - `UnauthorizedError`
3066 /// - `ForbiddenError`
3067 /// - `TooManyRequestsError`
3068 /// - `RateLimitBanError`
3069 /// - `ServerError`
3070 /// - `NotFoundError`
3071 /// - `NetworkError`
3072 /// - `BadRequestError`
3073 ///
3074 ///
3075 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#query-prevented-matches).
3076 ///
3077 pub async fn query_prevented_matches(
3078 &self,
3079 params: QueryPreventedMatchesParams,
3080 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryPreventedMatchesResponseInner>>> {
3081 self.trade_api_client.query_prevented_matches(params).await
3082 }
3083
3084 /// Query Special key(Low Latency Trading) (TRADE)
3085 ///
3086 /// Query Special Key Information.
3087 ///
3088 /// This only applies to Special Key for Low Latency Trading.
3089 ///
3090 /// Weight(UID): 1
3091 ///
3092 /// Security Type: TRADE
3093 ///
3094 /// # Arguments
3095 ///
3096 /// - `params`: [`QuerySpecialKeyParams`]
3097 /// The parameters for this operation.
3098 ///
3099 /// # Returns
3100 ///
3101 /// [`RestApiResponse<models::QuerySpecialKeyResponse>`] on success.
3102 ///
3103 /// # Errors
3104 ///
3105 /// This function will return an [`anyhow::Error`] if:
3106 /// - the HTTP request fails
3107 /// - any parameter is invalid
3108 /// - the response cannot be parsed
3109 /// - or one of the following occurs:
3110 /// - `RequiredError`
3111 /// - `ConnectorClientError`
3112 /// - `UnauthorizedError`
3113 /// - `ForbiddenError`
3114 /// - `TooManyRequestsError`
3115 /// - `RateLimitBanError`
3116 /// - `ServerError`
3117 /// - `NotFoundError`
3118 /// - `NetworkError`
3119 /// - `BadRequestError`
3120 ///
3121 ///
3122 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#query-special-key).
3123 ///
3124 pub async fn query_special_key(
3125 &self,
3126 params: QuerySpecialKeyParams,
3127 ) -> anyhow::Result<RestApiResponse<models::QuerySpecialKeyResponse>> {
3128 self.trade_api_client.query_special_key(params).await
3129 }
3130
3131 /// Query Special key List(Low Latency Trading) (TRADE)
3132 ///
3133 /// This only applies to Special Key for Low Latency Trading.
3134 ///
3135 /// Weight(UID): 1
3136 ///
3137 /// Security Type: TRADE
3138 ///
3139 /// # Arguments
3140 ///
3141 /// - `params`: [`QuerySpecialKeyListParams`]
3142 /// The parameters for this operation.
3143 ///
3144 /// # Returns
3145 ///
3146 /// [`RestApiResponse<Vec<models::QuerySpecialKeyListResponseInner>>`] on success.
3147 ///
3148 /// # Errors
3149 ///
3150 /// This function will return an [`anyhow::Error`] if:
3151 /// - the HTTP request fails
3152 /// - any parameter is invalid
3153 /// - the response cannot be parsed
3154 /// - or one of the following occurs:
3155 /// - `RequiredError`
3156 /// - `ConnectorClientError`
3157 /// - `UnauthorizedError`
3158 /// - `ForbiddenError`
3159 /// - `TooManyRequestsError`
3160 /// - `RateLimitBanError`
3161 /// - `ServerError`
3162 /// - `NotFoundError`
3163 /// - `NetworkError`
3164 /// - `BadRequestError`
3165 ///
3166 ///
3167 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#query-special-key-list).
3168 ///
3169 pub async fn query_special_key_list(
3170 &self,
3171 params: QuerySpecialKeyListParams,
3172 ) -> anyhow::Result<RestApiResponse<Vec<models::QuerySpecialKeyListResponseInner>>> {
3173 self.trade_api_client.query_special_key_list(params).await
3174 }
3175
3176 /// Small Liability Exchange (MARGIN)
3177 ///
3178 /// Small Liability Exchange
3179 ///
3180 /// Weight(UID): 3000
3181 ///
3182 /// Security Type: MARGIN
3183 ///
3184 /// Notes:
3185 /// - Only convert once within 6 hours
3186 /// - Only liability valuation less than 10 USDT are supported
3187 /// - The maximum number of coin is 10
3188 ///
3189 /// # Arguments
3190 ///
3191 /// - `params`: [`SmallLiabilityExchangeParams`]
3192 /// The parameters for this operation.
3193 ///
3194 /// # Returns
3195 ///
3196 /// [`RestApiResponse<Value>`] on success.
3197 ///
3198 /// # Errors
3199 ///
3200 /// This function will return an [`anyhow::Error`] if:
3201 /// - the HTTP request fails
3202 /// - any parameter is invalid
3203 /// - the response cannot be parsed
3204 /// - or one of the following occurs:
3205 /// - `RequiredError`
3206 /// - `ConnectorClientError`
3207 /// - `UnauthorizedError`
3208 /// - `ForbiddenError`
3209 /// - `TooManyRequestsError`
3210 /// - `RateLimitBanError`
3211 /// - `ServerError`
3212 /// - `NotFoundError`
3213 /// - `NetworkError`
3214 /// - `BadRequestError`
3215 ///
3216 ///
3217 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/trade#small-liability-exchange).
3218 ///
3219 pub async fn small_liability_exchange(
3220 &self,
3221 params: SmallLiabilityExchangeParams,
3222 ) -> anyhow::Result<RestApiResponse<Value>> {
3223 self.trade_api_client.small_liability_exchange(params).await
3224 }
3225
3226 /// Get Cross Margin Transfer History (`USER_DATA`)
3227 ///
3228 /// Get Cross Margin Transfer History
3229 ///
3230 /// Weight(IP): 1
3231 ///
3232 /// Security Type: `USER_DATA`
3233 ///
3234 /// Notes:
3235 /// - Response in descending order
3236 /// - The max interval between `startTime` and `endTime` is 30 days.
3237 /// - Returns data for last 7 days by default
3238 ///
3239 /// # Arguments
3240 ///
3241 /// - `params`: [`GetCrossMarginTransferHistoryParams`]
3242 /// The parameters for this operation.
3243 ///
3244 /// # Returns
3245 ///
3246 /// [`RestApiResponse<models::GetCrossMarginTransferHistoryResponse>`] on success.
3247 ///
3248 /// # Errors
3249 ///
3250 /// This function will return an [`anyhow::Error`] if:
3251 /// - the HTTP request fails
3252 /// - any parameter is invalid
3253 /// - the response cannot be parsed
3254 /// - or one of the following occurs:
3255 /// - `RequiredError`
3256 /// - `ConnectorClientError`
3257 /// - `UnauthorizedError`
3258 /// - `ForbiddenError`
3259 /// - `TooManyRequestsError`
3260 /// - `RateLimitBanError`
3261 /// - `ServerError`
3262 /// - `NotFoundError`
3263 /// - `NetworkError`
3264 /// - `BadRequestError`
3265 ///
3266 ///
3267 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/transfer#get-cross-margin-transfer-history).
3268 ///
3269 pub async fn get_cross_margin_transfer_history(
3270 &self,
3271 params: GetCrossMarginTransferHistoryParams,
3272 ) -> anyhow::Result<RestApiResponse<models::GetCrossMarginTransferHistoryResponse>> {
3273 self.transfer_api_client
3274 .get_cross_margin_transfer_history(params)
3275 .await
3276 }
3277
3278 /// Query Max Transfer-Out Amount (`USER_DATA`)
3279 ///
3280 /// Query Max Transfer-Out Amount
3281 ///
3282 /// Weight(IP): 50
3283 ///
3284 /// Security Type: `USER_DATA`
3285 ///
3286 /// Notes:
3287 /// - If isolatedSymbol is not sent, crossed margin data will be sent.
3288 ///
3289 /// # Arguments
3290 ///
3291 /// - `params`: [`QueryMaxTransferOutAmountParams`]
3292 /// The parameters for this operation.
3293 ///
3294 /// # Returns
3295 ///
3296 /// [`RestApiResponse<models::QueryMaxTransferOutAmountResponse>`] on success.
3297 ///
3298 /// # Errors
3299 ///
3300 /// This function will return an [`anyhow::Error`] if:
3301 /// - the HTTP request fails
3302 /// - any parameter is invalid
3303 /// - the response cannot be parsed
3304 /// - or one of the following occurs:
3305 /// - `RequiredError`
3306 /// - `ConnectorClientError`
3307 /// - `UnauthorizedError`
3308 /// - `ForbiddenError`
3309 /// - `TooManyRequestsError`
3310 /// - `RateLimitBanError`
3311 /// - `ServerError`
3312 /// - `NotFoundError`
3313 /// - `NetworkError`
3314 /// - `BadRequestError`
3315 ///
3316 ///
3317 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/transfer#query-max-transfer-out-amount).
3318 ///
3319 pub async fn query_max_transfer_out_amount(
3320 &self,
3321 params: QueryMaxTransferOutAmountParams,
3322 ) -> anyhow::Result<RestApiResponse<models::QueryMaxTransferOutAmountResponse>> {
3323 self.transfer_api_client
3324 .query_max_transfer_out_amount(params)
3325 .await
3326 }
3327
3328 /// Close User Data Stream (`USER_STREAM`)
3329 ///
3330 /// Close out a user data stream.
3331 ///
3332 /// Weight(UID): 3000
3333 ///
3334 /// Security Type: `USER_STREAM`
3335 ///
3336 /// # Arguments
3337 ///
3338 /// - `params`: [`CloseUserDataStreamParams`]
3339 /// The parameters for this operation.
3340 ///
3341 /// # Returns
3342 ///
3343 /// [`RestApiResponse<Value>`] on success.
3344 ///
3345 /// # Errors
3346 ///
3347 /// This function will return an [`anyhow::Error`] if:
3348 /// - the HTTP request fails
3349 /// - any parameter is invalid
3350 /// - the response cannot be parsed
3351 /// - or one of the following occurs:
3352 /// - `RequiredError`
3353 /// - `ConnectorClientError`
3354 /// - `UnauthorizedError`
3355 /// - `ForbiddenError`
3356 /// - `TooManyRequestsError`
3357 /// - `RateLimitBanError`
3358 /// - `ServerError`
3359 /// - `NotFoundError`
3360 /// - `NetworkError`
3361 /// - `BadRequestError`
3362 ///
3363 ///
3364 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/user-data-stream#close-user-data-stream).
3365 ///
3366 pub async fn close_user_data_stream(&self) -> anyhow::Result<RestApiResponse<Value>> {
3367 self.user_data_stream_api_client
3368 .close_user_data_stream()
3369 .await
3370 }
3371
3372 /// Keepalive User Data Stream (`USER_STREAM`)
3373 ///
3374 /// Keepalive a user data stream to prevent a time out.
3375 ///
3376 /// Weight(UID): 1
3377 ///
3378 /// Security Type: `USER_STREAM`
3379 ///
3380 /// # Arguments
3381 ///
3382 /// - `params`: [`KeepaliveUserDataStreamParams`]
3383 /// The parameters for this operation.
3384 ///
3385 /// # Returns
3386 ///
3387 /// [`RestApiResponse<Value>`] on success.
3388 ///
3389 /// # Errors
3390 ///
3391 /// This function will return an [`anyhow::Error`] if:
3392 /// - the HTTP request fails
3393 /// - any parameter is invalid
3394 /// - the response cannot be parsed
3395 /// - or one of the following occurs:
3396 /// - `RequiredError`
3397 /// - `ConnectorClientError`
3398 /// - `UnauthorizedError`
3399 /// - `ForbiddenError`
3400 /// - `TooManyRequestsError`
3401 /// - `RateLimitBanError`
3402 /// - `ServerError`
3403 /// - `NotFoundError`
3404 /// - `NetworkError`
3405 /// - `BadRequestError`
3406 ///
3407 ///
3408 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/user-data-stream#keepalive-user-data-stream).
3409 ///
3410 pub async fn keepalive_user_data_stream(
3411 &self,
3412 params: KeepaliveUserDataStreamParams,
3413 ) -> anyhow::Result<RestApiResponse<Value>> {
3414 self.user_data_stream_api_client
3415 .keepalive_user_data_stream(params)
3416 .await
3417 }
3418
3419 /// Start User Data Stream (`USER_STREAM`)
3420 ///
3421 /// Start a new user data stream.
3422 ///
3423 /// Weight(UID): 1
3424 ///
3425 /// Security Type: `USER_STREAM`
3426 ///
3427 /// # Arguments
3428 ///
3429 /// - `params`: [`StartUserDataStreamParams`]
3430 /// The parameters for this operation.
3431 ///
3432 /// # Returns
3433 ///
3434 /// [`RestApiResponse<models::StartUserDataStreamResponse>`] on success.
3435 ///
3436 /// # Errors
3437 ///
3438 /// This function will return an [`anyhow::Error`] if:
3439 /// - the HTTP request fails
3440 /// - any parameter is invalid
3441 /// - the response cannot be parsed
3442 /// - or one of the following occurs:
3443 /// - `RequiredError`
3444 /// - `ConnectorClientError`
3445 /// - `UnauthorizedError`
3446 /// - `ForbiddenError`
3447 /// - `TooManyRequestsError`
3448 /// - `RateLimitBanError`
3449 /// - `ServerError`
3450 /// - `NotFoundError`
3451 /// - `NetworkError`
3452 /// - `BadRequestError`
3453 ///
3454 ///
3455 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/core-trading-margin-trading/api/rest-api/user-data-stream#start-user-data-stream).
3456 ///
3457 pub async fn start_user_data_stream(
3458 &self,
3459 ) -> anyhow::Result<RestApiResponse<models::StartUserDataStreamResponse>> {
3460 self.user_data_stream_api_client
3461 .start_user_data_stream()
3462 .await
3463 }
3464}