binance_sdk/margin_trading/rest_api/mod.rs
1/*
2 * Binance Margin Trading REST API
3 *
4 * OpenAPI Specification for the Binance Margin Trading REST API
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 risk_data_stream_api_client: RiskDataStreamApiClient,
35 trade_api_client: TradeApiClient,
36 transfer_api_client: TransferApiClient,
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 risk_data_stream_api_client = RiskDataStreamApiClient::new(configuration.clone());
45 let trade_api_client = TradeApiClient::new(configuration.clone());
46 let transfer_api_client = TransferApiClient::new(configuration.clone());
47
48 Self {
49 configuration,
50 account_api_client,
51 borrow_repay_api_client,
52 market_data_api_client,
53 risk_data_stream_api_client,
54 trade_api_client,
55 transfer_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 /// * 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).
134 ///
135 /// Weight: 3000
136 ///
137 /// # Arguments
138 ///
139 /// - `params`: [`AdjustCrossMarginMaxLeverageParams`]
140 /// The parameters for this operation.
141 ///
142 /// # Returns
143 ///
144 /// [`RestApiResponse<models::AdjustCrossMarginMaxLeverageResponse>`] on success.
145 ///
146 /// # Errors
147 ///
148 /// This function will return an [`anyhow::Error`] if:
149 /// - the HTTP request fails
150 /// - any parameter is invalid
151 /// - the response cannot be parsed
152 /// - or one of the following occurs:
153 /// - `RequiredError`
154 /// - `ConnectorClientError`
155 /// - `UnauthorizedError`
156 /// - `ForbiddenError`
157 /// - `TooManyRequestsError`
158 /// - `RateLimitBanError`
159 /// - `ServerError`
160 /// - `NotFoundError`
161 /// - `NetworkError`
162 /// - `BadRequestError`
163 ///
164 ///
165 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/account/Adjust-cross-margin-max-leverage).
166 ///
167 pub async fn adjust_cross_margin_max_leverage(
168 &self,
169 params: AdjustCrossMarginMaxLeverageParams,
170 ) -> anyhow::Result<RestApiResponse<models::AdjustCrossMarginMaxLeverageResponse>> {
171 self.account_api_client
172 .adjust_cross_margin_max_leverage(params)
173 .await
174 }
175
176 /// Disable Isolated Margin Account (TRADE)
177 ///
178 /// Disable isolated margin account for a specific symbol. Each trading pair can only be deactivated once every 24
179 /// hours.
180 ///
181 /// Weight: 300(UID)
182 ///
183 /// # Arguments
184 ///
185 /// - `params`: [`DisableIsolatedMarginAccountParams`]
186 /// The parameters for this operation.
187 ///
188 /// # Returns
189 ///
190 /// [`RestApiResponse<models::DisableIsolatedMarginAccountResponse>`] on success.
191 ///
192 /// # Errors
193 ///
194 /// This function will return an [`anyhow::Error`] if:
195 /// - the HTTP request fails
196 /// - any parameter is invalid
197 /// - the response cannot be parsed
198 /// - or one of the following occurs:
199 /// - `RequiredError`
200 /// - `ConnectorClientError`
201 /// - `UnauthorizedError`
202 /// - `ForbiddenError`
203 /// - `TooManyRequestsError`
204 /// - `RateLimitBanError`
205 /// - `ServerError`
206 /// - `NotFoundError`
207 /// - `NetworkError`
208 /// - `BadRequestError`
209 ///
210 ///
211 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/account/Disable-Isolated-Margin-Account).
212 ///
213 pub async fn disable_isolated_margin_account(
214 &self,
215 params: DisableIsolatedMarginAccountParams,
216 ) -> anyhow::Result<RestApiResponse<models::DisableIsolatedMarginAccountResponse>> {
217 self.account_api_client
218 .disable_isolated_margin_account(params)
219 .await
220 }
221
222 /// Enable Isolated Margin Account (TRADE)
223 ///
224 /// Enable isolated margin account for a specific symbol(Only supports activation of previously disabled accounts).
225 ///
226 /// Weight: 300(UID)
227 ///
228 /// # Arguments
229 ///
230 /// - `params`: [`EnableIsolatedMarginAccountParams`]
231 /// The parameters for this operation.
232 ///
233 /// # Returns
234 ///
235 /// [`RestApiResponse<models::EnableIsolatedMarginAccountResponse>`] on success.
236 ///
237 /// # Errors
238 ///
239 /// This function will return an [`anyhow::Error`] if:
240 /// - the HTTP request fails
241 /// - any parameter is invalid
242 /// - the response cannot be parsed
243 /// - or one of the following occurs:
244 /// - `RequiredError`
245 /// - `ConnectorClientError`
246 /// - `UnauthorizedError`
247 /// - `ForbiddenError`
248 /// - `TooManyRequestsError`
249 /// - `RateLimitBanError`
250 /// - `ServerError`
251 /// - `NotFoundError`
252 /// - `NetworkError`
253 /// - `BadRequestError`
254 ///
255 ///
256 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/account/Enable-Isolated-Margin-Account).
257 ///
258 pub async fn enable_isolated_margin_account(
259 &self,
260 params: EnableIsolatedMarginAccountParams,
261 ) -> anyhow::Result<RestApiResponse<models::EnableIsolatedMarginAccountResponse>> {
262 self.account_api_client
263 .enable_isolated_margin_account(params)
264 .await
265 }
266
267 /// Get BNB Burn Status (`USER_DATA`)
268 ///
269 /// Get BNB Burn Status
270 ///
271 /// Weight: 1(IP)
272 ///
273 /// # Arguments
274 ///
275 /// - `params`: [`GetBnbBurnStatusParams`]
276 /// The parameters for this operation.
277 ///
278 /// # Returns
279 ///
280 /// [`RestApiResponse<models::GetBnbBurnStatusResponse>`] on success.
281 ///
282 /// # Errors
283 ///
284 /// This function will return an [`anyhow::Error`] if:
285 /// - the HTTP request fails
286 /// - any parameter is invalid
287 /// - the response cannot be parsed
288 /// - or one of the following occurs:
289 /// - `RequiredError`
290 /// - `ConnectorClientError`
291 /// - `UnauthorizedError`
292 /// - `ForbiddenError`
293 /// - `TooManyRequestsError`
294 /// - `RateLimitBanError`
295 /// - `ServerError`
296 /// - `NotFoundError`
297 /// - `NetworkError`
298 /// - `BadRequestError`
299 ///
300 ///
301 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/account/Get-BNB-Burn-Status).
302 ///
303 pub async fn get_bnb_burn_status(
304 &self,
305 params: GetBnbBurnStatusParams,
306 ) -> anyhow::Result<RestApiResponse<models::GetBnbBurnStatusResponse>> {
307 self.account_api_client.get_bnb_burn_status(params).await
308 }
309
310 /// Get Summary of Margin account (`USER_DATA`)
311 ///
312 /// Get personal margin level information
313 ///
314 /// Weight: 10(IP)
315 ///
316 /// # Arguments
317 ///
318 /// - `params`: [`GetSummaryOfMarginAccountParams`]
319 /// The parameters for this operation.
320 ///
321 /// # Returns
322 ///
323 /// [`RestApiResponse<models::GetSummaryOfMarginAccountResponse>`] on success.
324 ///
325 /// # Errors
326 ///
327 /// This function will return an [`anyhow::Error`] if:
328 /// - the HTTP request fails
329 /// - any parameter is invalid
330 /// - the response cannot be parsed
331 /// - or one of the following occurs:
332 /// - `RequiredError`
333 /// - `ConnectorClientError`
334 /// - `UnauthorizedError`
335 /// - `ForbiddenError`
336 /// - `TooManyRequestsError`
337 /// - `RateLimitBanError`
338 /// - `ServerError`
339 /// - `NotFoundError`
340 /// - `NetworkError`
341 /// - `BadRequestError`
342 ///
343 ///
344 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/account/Get-Summary-of-Margin-account).
345 ///
346 pub async fn get_summary_of_margin_account(
347 &self,
348 params: GetSummaryOfMarginAccountParams,
349 ) -> anyhow::Result<RestApiResponse<models::GetSummaryOfMarginAccountResponse>> {
350 self.account_api_client
351 .get_summary_of_margin_account(params)
352 .await
353 }
354
355 /// Query Cross Isolated Margin Capital Flow (`USER_DATA`)
356 ///
357 /// Query Cross Isolated Margin Capital Flow
358 ///
359 /// Weight: 100(IP)
360 ///
361 /// # Arguments
362 ///
363 /// - `params`: [`QueryCrossIsolatedMarginCapitalFlowParams`]
364 /// The parameters for this operation.
365 ///
366 /// # Returns
367 ///
368 /// [`RestApiResponse<Vec<models::QueryCrossIsolatedMarginCapitalFlowResponseInner>>`] on success.
369 ///
370 /// # Errors
371 ///
372 /// This function will return an [`anyhow::Error`] if:
373 /// - the HTTP request fails
374 /// - any parameter is invalid
375 /// - the response cannot be parsed
376 /// - or one of the following occurs:
377 /// - `RequiredError`
378 /// - `ConnectorClientError`
379 /// - `UnauthorizedError`
380 /// - `ForbiddenError`
381 /// - `TooManyRequestsError`
382 /// - `RateLimitBanError`
383 /// - `ServerError`
384 /// - `NotFoundError`
385 /// - `NetworkError`
386 /// - `BadRequestError`
387 ///
388 ///
389 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/account/Query-Cross-Isolated-Margin-Capital-Flow).
390 ///
391 pub async fn query_cross_isolated_margin_capital_flow(
392 &self,
393 params: QueryCrossIsolatedMarginCapitalFlowParams,
394 ) -> anyhow::Result<
395 RestApiResponse<Vec<models::QueryCrossIsolatedMarginCapitalFlowResponseInner>>,
396 > {
397 self.account_api_client
398 .query_cross_isolated_margin_capital_flow(params)
399 .await
400 }
401
402 /// Query Cross Margin Account Details (`USER_DATA`)
403 ///
404 /// Query Cross Margin Account Details
405 ///
406 /// Weight: 10(IP)
407 ///
408 /// # Arguments
409 ///
410 /// - `params`: [`QueryCrossMarginAccountDetailsParams`]
411 /// The parameters for this operation.
412 ///
413 /// # Returns
414 ///
415 /// [`RestApiResponse<models::QueryCrossMarginAccountDetailsResponse>`] on success.
416 ///
417 /// # Errors
418 ///
419 /// This function will return an [`anyhow::Error`] if:
420 /// - the HTTP request fails
421 /// - any parameter is invalid
422 /// - the response cannot be parsed
423 /// - or one of the following occurs:
424 /// - `RequiredError`
425 /// - `ConnectorClientError`
426 /// - `UnauthorizedError`
427 /// - `ForbiddenError`
428 /// - `TooManyRequestsError`
429 /// - `RateLimitBanError`
430 /// - `ServerError`
431 /// - `NotFoundError`
432 /// - `NetworkError`
433 /// - `BadRequestError`
434 ///
435 ///
436 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/account/Query-Cross-Margin-Account-Details).
437 ///
438 pub async fn query_cross_margin_account_details(
439 &self,
440 params: QueryCrossMarginAccountDetailsParams,
441 ) -> anyhow::Result<RestApiResponse<models::QueryCrossMarginAccountDetailsResponse>> {
442 self.account_api_client
443 .query_cross_margin_account_details(params)
444 .await
445 }
446
447 /// Query Cross Margin Fee Data (`USER_DATA`)
448 ///
449 /// Get cross margin fee data collection with any vip level or user's current specific data as <https://www.binance.com/en/margin-fee>
450 ///
451 /// Weight: 1 when coin is specified;(IP)
452 ///
453 /// # Arguments
454 ///
455 /// - `params`: [`QueryCrossMarginFeeDataParams`]
456 /// The parameters for this operation.
457 ///
458 /// # Returns
459 ///
460 /// [`RestApiResponse<Vec<models::QueryCrossMarginFeeDataResponseInner>>`] on success.
461 ///
462 /// # Errors
463 ///
464 /// This function will return an [`anyhow::Error`] if:
465 /// - the HTTP request fails
466 /// - any parameter is invalid
467 /// - the response cannot be parsed
468 /// - or one of the following occurs:
469 /// - `RequiredError`
470 /// - `ConnectorClientError`
471 /// - `UnauthorizedError`
472 /// - `ForbiddenError`
473 /// - `TooManyRequestsError`
474 /// - `RateLimitBanError`
475 /// - `ServerError`
476 /// - `NotFoundError`
477 /// - `NetworkError`
478 /// - `BadRequestError`
479 ///
480 ///
481 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/account/Query-Cross-Margin-Fee-Data).
482 ///
483 pub async fn query_cross_margin_fee_data(
484 &self,
485 params: QueryCrossMarginFeeDataParams,
486 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryCrossMarginFeeDataResponseInner>>> {
487 self.account_api_client
488 .query_cross_margin_fee_data(params)
489 .await
490 }
491
492 /// Query Enabled Isolated Margin Account Limit (`USER_DATA`)
493 ///
494 /// Query enabled isolated margin account limit.
495 ///
496 /// Weight: 1(IP)
497 ///
498 /// # Arguments
499 ///
500 /// - `params`: [`QueryEnabledIsolatedMarginAccountLimitParams`]
501 /// The parameters for this operation.
502 ///
503 /// # Returns
504 ///
505 /// [`RestApiResponse<models::QueryEnabledIsolatedMarginAccountLimitResponse>`] on success.
506 ///
507 /// # Errors
508 ///
509 /// This function will return an [`anyhow::Error`] if:
510 /// - the HTTP request fails
511 /// - any parameter is invalid
512 /// - the response cannot be parsed
513 /// - or one of the following occurs:
514 /// - `RequiredError`
515 /// - `ConnectorClientError`
516 /// - `UnauthorizedError`
517 /// - `ForbiddenError`
518 /// - `TooManyRequestsError`
519 /// - `RateLimitBanError`
520 /// - `ServerError`
521 /// - `NotFoundError`
522 /// - `NetworkError`
523 /// - `BadRequestError`
524 ///
525 ///
526 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/account/Query-Enabled-Isolated-Margin-Account-Limit).
527 ///
528 pub async fn query_enabled_isolated_margin_account_limit(
529 &self,
530 params: QueryEnabledIsolatedMarginAccountLimitParams,
531 ) -> anyhow::Result<RestApiResponse<models::QueryEnabledIsolatedMarginAccountLimitResponse>>
532 {
533 self.account_api_client
534 .query_enabled_isolated_margin_account_limit(params)
535 .await
536 }
537
538 /// Query Isolated Margin Account Info (`USER_DATA`)
539 ///
540 /// Query Isolated Margin Account Info
541 ///
542 /// * If "symbols" is not sent, all isolated assets will be returned.
543 /// * If "symbols" is sent, only the isolated assets of the sent symbols will be returned.
544 ///
545 /// Weight: 10(IP)
546 ///
547 /// # Arguments
548 ///
549 /// - `params`: [`QueryIsolatedMarginAccountInfoParams`]
550 /// The parameters for this operation.
551 ///
552 /// # Returns
553 ///
554 /// [`RestApiResponse<models::QueryIsolatedMarginAccountInfoResponse>`] on success.
555 ///
556 /// # Errors
557 ///
558 /// This function will return an [`anyhow::Error`] if:
559 /// - the HTTP request fails
560 /// - any parameter is invalid
561 /// - the response cannot be parsed
562 /// - or one of the following occurs:
563 /// - `RequiredError`
564 /// - `ConnectorClientError`
565 /// - `UnauthorizedError`
566 /// - `ForbiddenError`
567 /// - `TooManyRequestsError`
568 /// - `RateLimitBanError`
569 /// - `ServerError`
570 /// - `NotFoundError`
571 /// - `NetworkError`
572 /// - `BadRequestError`
573 ///
574 ///
575 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Account-Info).
576 ///
577 pub async fn query_isolated_margin_account_info(
578 &self,
579 params: QueryIsolatedMarginAccountInfoParams,
580 ) -> anyhow::Result<RestApiResponse<models::QueryIsolatedMarginAccountInfoResponse>> {
581 self.account_api_client
582 .query_isolated_margin_account_info(params)
583 .await
584 }
585
586 /// Query Isolated Margin Fee Data (`USER_DATA`)
587 ///
588 /// Get isolated margin fee data collection with any vip level or user's current specific data as <https://www.binance.com/en/margin-fee>
589 ///
590 /// Weight: 1 when a single is specified;(IP)
591 ///
592 /// # Arguments
593 ///
594 /// - `params`: [`QueryIsolatedMarginFeeDataParams`]
595 /// The parameters for this operation.
596 ///
597 /// # Returns
598 ///
599 /// [`RestApiResponse<Vec<models::QueryIsolatedMarginFeeDataResponseInner>>`] on success.
600 ///
601 /// # Errors
602 ///
603 /// This function will return an [`anyhow::Error`] if:
604 /// - the HTTP request fails
605 /// - any parameter is invalid
606 /// - the response cannot be parsed
607 /// - or one of the following occurs:
608 /// - `RequiredError`
609 /// - `ConnectorClientError`
610 /// - `UnauthorizedError`
611 /// - `ForbiddenError`
612 /// - `TooManyRequestsError`
613 /// - `RateLimitBanError`
614 /// - `ServerError`
615 /// - `NotFoundError`
616 /// - `NetworkError`
617 /// - `BadRequestError`
618 ///
619 ///
620 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Fee-Data).
621 ///
622 pub async fn query_isolated_margin_fee_data(
623 &self,
624 params: QueryIsolatedMarginFeeDataParams,
625 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryIsolatedMarginFeeDataResponseInner>>> {
626 self.account_api_client
627 .query_isolated_margin_fee_data(params)
628 .await
629 }
630
631 /// Get future hourly interest rate (`USER_DATA`)
632 ///
633 /// Get future hourly interest rate
634 ///
635 /// Weight: 100
636 ///
637 /// # Arguments
638 ///
639 /// - `params`: [`GetFutureHourlyInterestRateParams`]
640 /// The parameters for this operation.
641 ///
642 /// # Returns
643 ///
644 /// [`RestApiResponse<Vec<models::GetFutureHourlyInterestRateResponseInner>>`] on success.
645 ///
646 /// # Errors
647 ///
648 /// This function will return an [`anyhow::Error`] if:
649 /// - the HTTP request fails
650 /// - any parameter is invalid
651 /// - the response cannot be parsed
652 /// - or one of the following occurs:
653 /// - `RequiredError`
654 /// - `ConnectorClientError`
655 /// - `UnauthorizedError`
656 /// - `ForbiddenError`
657 /// - `TooManyRequestsError`
658 /// - `RateLimitBanError`
659 /// - `ServerError`
660 /// - `NotFoundError`
661 /// - `NetworkError`
662 /// - `BadRequestError`
663 ///
664 ///
665 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/borrow-and-repay/Get-a-future-hourly-interest-rate).
666 ///
667 pub async fn get_future_hourly_interest_rate(
668 &self,
669 params: GetFutureHourlyInterestRateParams,
670 ) -> anyhow::Result<RestApiResponse<Vec<models::GetFutureHourlyInterestRateResponseInner>>>
671 {
672 self.borrow_repay_api_client
673 .get_future_hourly_interest_rate(params)
674 .await
675 }
676
677 /// Get Interest History (`USER_DATA`)
678 ///
679 /// Get Interest History
680 ///
681 /// * Response in descending order
682 /// * If isolatedSymbol is not sent, crossed margin data will be returned
683 /// * The max interval between `startTime` and `endTime` is 30 days. It is a MUST to ensure data correctness.
684 /// * If `startTime`and `endTime` not sent, return records of the last 7 days by default.
685 /// * If `startTime` is sent and `endTime` is not sent, return records of [max(`startTime`, now-30d), now].
686 /// * If `startTime` is not sent and `endTime` is sent, return records of [`endTime`-7, `endTime`]
687 /// * `type` in response has 4 enums:
688 /// * `PERIODIC` interest charged per hour
689 /// * `ON_BORROW` first interest charged on borrow
690 /// * `PERIODIC_CONVERTED` interest charged per hour converted into BNB
691 /// * `ON_BORROW_CONVERTED` first interest charged on borrow converted into BNB
692 /// * `PORTFOLIO` interest charged daily on the portfolio margin negative balance
693 ///
694 /// Weight: 1(IP)
695 ///
696 /// # Arguments
697 ///
698 /// - `params`: [`GetInterestHistoryParams`]
699 /// The parameters for this operation.
700 ///
701 /// # Returns
702 ///
703 /// [`RestApiResponse<models::GetInterestHistoryResponse>`] on success.
704 ///
705 /// # Errors
706 ///
707 /// This function will return an [`anyhow::Error`] if:
708 /// - the HTTP request fails
709 /// - any parameter is invalid
710 /// - the response cannot be parsed
711 /// - or one of the following occurs:
712 /// - `RequiredError`
713 /// - `ConnectorClientError`
714 /// - `UnauthorizedError`
715 /// - `ForbiddenError`
716 /// - `TooManyRequestsError`
717 /// - `RateLimitBanError`
718 /// - `ServerError`
719 /// - `NotFoundError`
720 /// - `NetworkError`
721 /// - `BadRequestError`
722 ///
723 ///
724 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/borrow-and-repay/Get-Interest-History).
725 ///
726 pub async fn get_interest_history(
727 &self,
728 params: GetInterestHistoryParams,
729 ) -> anyhow::Result<RestApiResponse<models::GetInterestHistoryResponse>> {
730 self.borrow_repay_api_client
731 .get_interest_history(params)
732 .await
733 }
734
735 /// Margin account borrow/repay(MARGIN)
736 ///
737 /// Margin account borrow/repay(MARGIN)
738 ///
739 /// Weight: 1500
740 ///
741 /// # Arguments
742 ///
743 /// - `params`: [`MarginAccountBorrowRepayParams`]
744 /// The parameters for this operation.
745 ///
746 /// # Returns
747 ///
748 /// [`RestApiResponse<models::MarginAccountBorrowRepayResponse>`] on success.
749 ///
750 /// # Errors
751 ///
752 /// This function will return an [`anyhow::Error`] if:
753 /// - the HTTP request fails
754 /// - any parameter is invalid
755 /// - the response cannot be parsed
756 /// - or one of the following occurs:
757 /// - `RequiredError`
758 /// - `ConnectorClientError`
759 /// - `UnauthorizedError`
760 /// - `ForbiddenError`
761 /// - `TooManyRequestsError`
762 /// - `RateLimitBanError`
763 /// - `ServerError`
764 /// - `NotFoundError`
765 /// - `NetworkError`
766 /// - `BadRequestError`
767 ///
768 ///
769 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/borrow-and-repay/Margin-account-borrow-repay).
770 ///
771 pub async fn margin_account_borrow_repay(
772 &self,
773 params: MarginAccountBorrowRepayParams,
774 ) -> anyhow::Result<RestApiResponse<models::MarginAccountBorrowRepayResponse>> {
775 self.borrow_repay_api_client
776 .margin_account_borrow_repay(params)
777 .await
778 }
779
780 /// Query borrow/repay records in Margin `account(USER_DATA)`
781 ///
782 /// Query borrow/repay records in Margin account
783 ///
784 /// * `txId` or `startTime` must be sent. `txId` takes precedence.
785 /// * If an asset is sent, data within 30 days before `endTime`; If an asset is not sent, data within 7 days before `endTime`
786 /// * If neither `startTime` nor `endTime` is sent, the recent 7-day data will be returned.
787 /// * `startTime` set as `endTime` - 7days by default, `endTime` set as current time by default
788 ///
789 /// Weight: 10(IP)
790 ///
791 /// # Arguments
792 ///
793 /// - `params`: [`QueryBorrowRepayRecordsInMarginAccountParams`]
794 /// The parameters for this operation.
795 ///
796 /// # Returns
797 ///
798 /// [`RestApiResponse<models::QueryBorrowRepayRecordsInMarginAccountResponse>`] on success.
799 ///
800 /// # Errors
801 ///
802 /// This function will return an [`anyhow::Error`] if:
803 /// - the HTTP request fails
804 /// - any parameter is invalid
805 /// - the response cannot be parsed
806 /// - or one of the following occurs:
807 /// - `RequiredError`
808 /// - `ConnectorClientError`
809 /// - `UnauthorizedError`
810 /// - `ForbiddenError`
811 /// - `TooManyRequestsError`
812 /// - `RateLimitBanError`
813 /// - `ServerError`
814 /// - `NotFoundError`
815 /// - `NetworkError`
816 /// - `BadRequestError`
817 ///
818 ///
819 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Borrow-Repay).
820 ///
821 pub async fn query_borrow_repay_records_in_margin_account(
822 &self,
823 params: QueryBorrowRepayRecordsInMarginAccountParams,
824 ) -> anyhow::Result<RestApiResponse<models::QueryBorrowRepayRecordsInMarginAccountResponse>>
825 {
826 self.borrow_repay_api_client
827 .query_borrow_repay_records_in_margin_account(params)
828 .await
829 }
830
831 /// Query Margin Interest Rate History (`USER_DATA`)
832 ///
833 /// Query Margin Interest Rate History
834 ///
835 /// Weight: 1(IP)
836 ///
837 /// # Arguments
838 ///
839 /// - `params`: [`QueryMarginInterestRateHistoryParams`]
840 /// The parameters for this operation.
841 ///
842 /// # Returns
843 ///
844 /// [`RestApiResponse<Vec<models::QueryMarginInterestRateHistoryResponseInner>>`] on success.
845 ///
846 /// # Errors
847 ///
848 /// This function will return an [`anyhow::Error`] if:
849 /// - the HTTP request fails
850 /// - any parameter is invalid
851 /// - the response cannot be parsed
852 /// - or one of the following occurs:
853 /// - `RequiredError`
854 /// - `ConnectorClientError`
855 /// - `UnauthorizedError`
856 /// - `ForbiddenError`
857 /// - `TooManyRequestsError`
858 /// - `RateLimitBanError`
859 /// - `ServerError`
860 /// - `NotFoundError`
861 /// - `NetworkError`
862 /// - `BadRequestError`
863 ///
864 ///
865 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Margin-Interest-Rate-History).
866 ///
867 pub async fn query_margin_interest_rate_history(
868 &self,
869 params: QueryMarginInterestRateHistoryParams,
870 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginInterestRateHistoryResponseInner>>>
871 {
872 self.borrow_repay_api_client
873 .query_margin_interest_rate_history(params)
874 .await
875 }
876
877 /// Query Max Borrow (`USER_DATA`)
878 ///
879 /// Query Max Borrow
880 ///
881 /// * If isolatedSymbol is not sent, crossed margin data will be sent.
882 /// * `borrowLimit` is also available from [https://www.binance.com/en/margin-fee](https://www.binance.com/en/margin-fee)
883 ///
884 /// Weight: 50(IP)
885 ///
886 /// # Arguments
887 ///
888 /// - `params`: [`QueryMaxBorrowParams`]
889 /// The parameters for this operation.
890 ///
891 /// # Returns
892 ///
893 /// [`RestApiResponse<models::QueryMaxBorrowResponse>`] on success.
894 ///
895 /// # Errors
896 ///
897 /// This function will return an [`anyhow::Error`] if:
898 /// - the HTTP request fails
899 /// - any parameter is invalid
900 /// - the response cannot be parsed
901 /// - or one of the following occurs:
902 /// - `RequiredError`
903 /// - `ConnectorClientError`
904 /// - `UnauthorizedError`
905 /// - `ForbiddenError`
906 /// - `TooManyRequestsError`
907 /// - `RateLimitBanError`
908 /// - `ServerError`
909 /// - `NotFoundError`
910 /// - `NetworkError`
911 /// - `BadRequestError`
912 ///
913 ///
914 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Max-Borrow).
915 ///
916 pub async fn query_max_borrow(
917 &self,
918 params: QueryMaxBorrowParams,
919 ) -> anyhow::Result<RestApiResponse<models::QueryMaxBorrowResponse>> {
920 self.borrow_repay_api_client.query_max_borrow(params).await
921 }
922
923 /// Cross margin collateral ratio (`MARKET_DATA`)
924 ///
925 /// Cross margin collateral ratio
926 ///
927 /// Weight: 100(IP)
928 ///
929 /// # Arguments
930 ///
931 /// - `params`: [`CrossMarginCollateralRatioParams`]
932 /// The parameters for this operation.
933 ///
934 /// # Returns
935 ///
936 /// [`RestApiResponse<Vec<models::CrossMarginCollateralRatioResponseInner>>`] on success.
937 ///
938 /// # Errors
939 ///
940 /// This function will return an [`anyhow::Error`] if:
941 /// - the HTTP request fails
942 /// - any parameter is invalid
943 /// - the response cannot be parsed
944 /// - or one of the following occurs:
945 /// - `RequiredError`
946 /// - `ConnectorClientError`
947 /// - `UnauthorizedError`
948 /// - `ForbiddenError`
949 /// - `TooManyRequestsError`
950 /// - `RateLimitBanError`
951 /// - `ServerError`
952 /// - `NotFoundError`
953 /// - `NetworkError`
954 /// - `BadRequestError`
955 ///
956 ///
957 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/market-data/Cross-margin-collateral-ratio).
958 ///
959 pub async fn cross_margin_collateral_ratio(
960 &self,
961 ) -> anyhow::Result<RestApiResponse<Vec<models::CrossMarginCollateralRatioResponseInner>>> {
962 self.market_data_api_client
963 .cross_margin_collateral_ratio()
964 .await
965 }
966
967 /// Get All Cross Margin Pairs (`MARKET_DATA`)
968 ///
969 /// Get All Cross Margin Pairs
970 ///
971 /// Weight: 1(IP)
972 ///
973 /// # Arguments
974 ///
975 /// - `params`: [`GetAllCrossMarginPairsParams`]
976 /// The parameters for this operation.
977 ///
978 /// # Returns
979 ///
980 /// [`RestApiResponse<Vec<models::GetAllCrossMarginPairsResponseInner>>`] on success.
981 ///
982 /// # Errors
983 ///
984 /// This function will return an [`anyhow::Error`] if:
985 /// - the HTTP request fails
986 /// - any parameter is invalid
987 /// - the response cannot be parsed
988 /// - or one of the following occurs:
989 /// - `RequiredError`
990 /// - `ConnectorClientError`
991 /// - `UnauthorizedError`
992 /// - `ForbiddenError`
993 /// - `TooManyRequestsError`
994 /// - `RateLimitBanError`
995 /// - `ServerError`
996 /// - `NotFoundError`
997 /// - `NetworkError`
998 /// - `BadRequestError`
999 ///
1000 ///
1001 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/market-data/Get-All-Cross-Margin-Pairs).
1002 ///
1003 pub async fn get_all_cross_margin_pairs(
1004 &self,
1005 params: GetAllCrossMarginPairsParams,
1006 ) -> anyhow::Result<RestApiResponse<Vec<models::GetAllCrossMarginPairsResponseInner>>> {
1007 self.market_data_api_client
1008 .get_all_cross_margin_pairs(params)
1009 .await
1010 }
1011
1012 /// Get All Isolated Margin `Symbol(MARKET_DATA)`
1013 ///
1014 /// Get All Isolated Margin Symbol
1015 ///
1016 /// Weight: 10(IP)
1017 ///
1018 /// # Arguments
1019 ///
1020 /// - `params`: [`GetAllIsolatedMarginSymbolParams`]
1021 /// The parameters for this operation.
1022 ///
1023 /// # Returns
1024 ///
1025 /// [`RestApiResponse<Vec<models::GetAllIsolatedMarginSymbolResponseInner>>`] on success.
1026 ///
1027 /// # Errors
1028 ///
1029 /// This function will return an [`anyhow::Error`] if:
1030 /// - the HTTP request fails
1031 /// - any parameter is invalid
1032 /// - the response cannot be parsed
1033 /// - or one of the following occurs:
1034 /// - `RequiredError`
1035 /// - `ConnectorClientError`
1036 /// - `UnauthorizedError`
1037 /// - `ForbiddenError`
1038 /// - `TooManyRequestsError`
1039 /// - `RateLimitBanError`
1040 /// - `ServerError`
1041 /// - `NotFoundError`
1042 /// - `NetworkError`
1043 /// - `BadRequestError`
1044 ///
1045 ///
1046 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/market-data/Get-All-Isolated-Margin-Symbol).
1047 ///
1048 pub async fn get_all_isolated_margin_symbol(
1049 &self,
1050 params: GetAllIsolatedMarginSymbolParams,
1051 ) -> anyhow::Result<RestApiResponse<Vec<models::GetAllIsolatedMarginSymbolResponseInner>>> {
1052 self.market_data_api_client
1053 .get_all_isolated_margin_symbol(params)
1054 .await
1055 }
1056
1057 /// Get All Margin Assets (`MARKET_DATA`)
1058 ///
1059 /// Get All Margin Assets.
1060 ///
1061 /// Weight: 1(IP)
1062 ///
1063 /// # Arguments
1064 ///
1065 /// - `params`: [`GetAllMarginAssetsParams`]
1066 /// The parameters for this operation.
1067 ///
1068 /// # Returns
1069 ///
1070 /// [`RestApiResponse<Vec<models::GetAllMarginAssetsResponseInner>>`] on success.
1071 ///
1072 /// # Errors
1073 ///
1074 /// This function will return an [`anyhow::Error`] if:
1075 /// - the HTTP request fails
1076 /// - any parameter is invalid
1077 /// - the response cannot be parsed
1078 /// - or one of the following occurs:
1079 /// - `RequiredError`
1080 /// - `ConnectorClientError`
1081 /// - `UnauthorizedError`
1082 /// - `ForbiddenError`
1083 /// - `TooManyRequestsError`
1084 /// - `RateLimitBanError`
1085 /// - `ServerError`
1086 /// - `NotFoundError`
1087 /// - `NetworkError`
1088 /// - `BadRequestError`
1089 ///
1090 ///
1091 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/market-data/Get-All-Margin-Assets).
1092 ///
1093 pub async fn get_all_margin_assets(
1094 &self,
1095 params: GetAllMarginAssetsParams,
1096 ) -> anyhow::Result<RestApiResponse<Vec<models::GetAllMarginAssetsResponseInner>>> {
1097 self.market_data_api_client
1098 .get_all_margin_assets(params)
1099 .await
1100 }
1101
1102 /// Get Delist Schedule (`MARKET_DATA`)
1103 ///
1104 /// Get tokens or symbols delist schedule for cross margin and isolated margin
1105 ///
1106 /// Weight: 100
1107 ///
1108 /// # Arguments
1109 ///
1110 /// - `params`: [`GetDelistScheduleParams`]
1111 /// The parameters for this operation.
1112 ///
1113 /// # Returns
1114 ///
1115 /// [`RestApiResponse<Vec<models::GetDelistScheduleResponseInner>>`] on success.
1116 ///
1117 /// # Errors
1118 ///
1119 /// This function will return an [`anyhow::Error`] if:
1120 /// - the HTTP request fails
1121 /// - any parameter is invalid
1122 /// - the response cannot be parsed
1123 /// - or one of the following occurs:
1124 /// - `RequiredError`
1125 /// - `ConnectorClientError`
1126 /// - `UnauthorizedError`
1127 /// - `ForbiddenError`
1128 /// - `TooManyRequestsError`
1129 /// - `RateLimitBanError`
1130 /// - `ServerError`
1131 /// - `NotFoundError`
1132 /// - `NetworkError`
1133 /// - `BadRequestError`
1134 ///
1135 ///
1136 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/market-data/Get-Delist-Schedule).
1137 ///
1138 pub async fn get_delist_schedule(
1139 &self,
1140 params: GetDelistScheduleParams,
1141 ) -> anyhow::Result<RestApiResponse<Vec<models::GetDelistScheduleResponseInner>>> {
1142 self.market_data_api_client
1143 .get_delist_schedule(params)
1144 .await
1145 }
1146
1147 /// Get Limit Price `Pairs(MARKET_DATA)`
1148 ///
1149 /// Query trading pairs with restriction on limit price range.
1150 /// In margin trading, you can place orders with limit price. Limit price should be within (-15%, 15%) of current index price for a list of margin trading pairs. This rule only impacts limit sell orders with limit price that is lower than current index price and limit buy orders with limit price that is higher than current index price.
1151 ///
1152 /// - Buy order: Your order will be rejected with an error message notification if the limit price is 15% above the index price.
1153 /// - Sell order: Your order will be rejected with an error message notification if the limit price is 15% below the index price.
1154 /// Please review the limit price order placing strategy, backtest and calibrate the planned order size with the trading volume and order book depth to prevent trading loss.
1155 ///
1156 /// Weight: 1
1157 ///
1158 /// # Arguments
1159 ///
1160 /// - `params`: [`GetLimitPricePairsParams`]
1161 /// The parameters for this operation.
1162 ///
1163 /// # Returns
1164 ///
1165 /// [`RestApiResponse<models::GetLimitPricePairsResponse>`] on success.
1166 ///
1167 /// # Errors
1168 ///
1169 /// This function will return an [`anyhow::Error`] if:
1170 /// - the HTTP request fails
1171 /// - any parameter is invalid
1172 /// - the response cannot be parsed
1173 /// - or one of the following occurs:
1174 /// - `RequiredError`
1175 /// - `ConnectorClientError`
1176 /// - `UnauthorizedError`
1177 /// - `ForbiddenError`
1178 /// - `TooManyRequestsError`
1179 /// - `RateLimitBanError`
1180 /// - `ServerError`
1181 /// - `NotFoundError`
1182 /// - `NetworkError`
1183 /// - `BadRequestError`
1184 ///
1185 ///
1186 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/market-data/Get-Limit-Price-Pairs).
1187 ///
1188 pub async fn get_limit_price_pairs(
1189 &self,
1190 ) -> anyhow::Result<RestApiResponse<models::GetLimitPricePairsResponse>> {
1191 self.market_data_api_client.get_limit_price_pairs().await
1192 }
1193
1194 /// Get list Schedule (`MARKET_DATA`)
1195 ///
1196 /// Get the upcoming tokens or symbols listing schedule for Cross Margin and Isolated Margin.
1197 ///
1198 /// Weight: 100
1199 ///
1200 /// # Arguments
1201 ///
1202 /// - `params`: [`GetListScheduleParams`]
1203 /// The parameters for this operation.
1204 ///
1205 /// # Returns
1206 ///
1207 /// [`RestApiResponse<Vec<models::GetListScheduleResponseInner>>`] on success.
1208 ///
1209 /// # Errors
1210 ///
1211 /// This function will return an [`anyhow::Error`] if:
1212 /// - the HTTP request fails
1213 /// - any parameter is invalid
1214 /// - the response cannot be parsed
1215 /// - or one of the following occurs:
1216 /// - `RequiredError`
1217 /// - `ConnectorClientError`
1218 /// - `UnauthorizedError`
1219 /// - `ForbiddenError`
1220 /// - `TooManyRequestsError`
1221 /// - `RateLimitBanError`
1222 /// - `ServerError`
1223 /// - `NotFoundError`
1224 /// - `NetworkError`
1225 /// - `BadRequestError`
1226 ///
1227 ///
1228 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/market-data/Get-list-Schedule).
1229 ///
1230 pub async fn get_list_schedule(
1231 &self,
1232 params: GetListScheduleParams,
1233 ) -> anyhow::Result<RestApiResponse<Vec<models::GetListScheduleResponseInner>>> {
1234 self.market_data_api_client.get_list_schedule(params).await
1235 }
1236
1237 /// Get Margin Asset Risk-Based Liquidation Ratio (`MARKET_DATA`)
1238 ///
1239 /// Get Margin Asset Risk-Based Liquidation Ratio
1240 ///
1241 /// Weight: 1
1242 ///
1243 /// # Arguments
1244 ///
1245 /// - `params`: [`GetMarginAssetRiskBasedLiquidationRatioParams`]
1246 /// The parameters for this operation.
1247 ///
1248 /// # Returns
1249 ///
1250 /// [`RestApiResponse<Vec<models::GetMarginAssetRiskBasedLiquidationRatioResponseInner>>`] on success.
1251 ///
1252 /// # Errors
1253 ///
1254 /// This function will return an [`anyhow::Error`] if:
1255 /// - the HTTP request fails
1256 /// - any parameter is invalid
1257 /// - the response cannot be parsed
1258 /// - or one of the following occurs:
1259 /// - `RequiredError`
1260 /// - `ConnectorClientError`
1261 /// - `UnauthorizedError`
1262 /// - `ForbiddenError`
1263 /// - `TooManyRequestsError`
1264 /// - `RateLimitBanError`
1265 /// - `ServerError`
1266 /// - `NotFoundError`
1267 /// - `NetworkError`
1268 /// - `BadRequestError`
1269 ///
1270 ///
1271 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/market-data/Get-Margin-Asset-Risk-Based-Liquidation-Ratio).
1272 ///
1273 pub async fn get_margin_asset_risk_based_liquidation_ratio(
1274 &self,
1275 ) -> anyhow::Result<
1276 RestApiResponse<Vec<models::GetMarginAssetRiskBasedLiquidationRatioResponseInner>>,
1277 > {
1278 self.market_data_api_client
1279 .get_margin_asset_risk_based_liquidation_ratio()
1280 .await
1281 }
1282
1283 /// Get Margin Restricted Assets (`MARKET_DATA`)
1284 ///
1285 /// Get Margin Restricted Assets
1286 ///
1287 /// Weight: 1
1288 ///
1289 /// # Arguments
1290 ///
1291 /// - `params`: [`GetMarginRestrictedAssetsParams`]
1292 /// The parameters for this operation.
1293 ///
1294 /// # Returns
1295 ///
1296 /// [`RestApiResponse<models::GetMarginRestrictedAssetsResponse>`] on success.
1297 ///
1298 /// # Errors
1299 ///
1300 /// This function will return an [`anyhow::Error`] if:
1301 /// - the HTTP request fails
1302 /// - any parameter is invalid
1303 /// - the response cannot be parsed
1304 /// - or one of the following occurs:
1305 /// - `RequiredError`
1306 /// - `ConnectorClientError`
1307 /// - `UnauthorizedError`
1308 /// - `ForbiddenError`
1309 /// - `TooManyRequestsError`
1310 /// - `RateLimitBanError`
1311 /// - `ServerError`
1312 /// - `NotFoundError`
1313 /// - `NetworkError`
1314 /// - `BadRequestError`
1315 ///
1316 ///
1317 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/market-data/Get-Margin-Restricted-Assets).
1318 ///
1319 pub async fn get_margin_restricted_assets(
1320 &self,
1321 ) -> anyhow::Result<RestApiResponse<models::GetMarginRestrictedAssetsResponse>> {
1322 self.market_data_api_client
1323 .get_margin_restricted_assets()
1324 .await
1325 }
1326
1327 /// Query Isolated Margin Tier Data (`USER_DATA`)
1328 ///
1329 /// Get isolated margin tier data collection with any tier as <https://www.binance.com/en/margin-data>
1330 ///
1331 /// Weight: 1(IP)
1332 ///
1333 /// # Arguments
1334 ///
1335 /// - `params`: [`QueryIsolatedMarginTierDataParams`]
1336 /// The parameters for this operation.
1337 ///
1338 /// # Returns
1339 ///
1340 /// [`RestApiResponse<Vec<models::QueryIsolatedMarginTierDataResponseInner>>`] on success.
1341 ///
1342 /// # Errors
1343 ///
1344 /// This function will return an [`anyhow::Error`] if:
1345 /// - the HTTP request fails
1346 /// - any parameter is invalid
1347 /// - the response cannot be parsed
1348 /// - or one of the following occurs:
1349 /// - `RequiredError`
1350 /// - `ConnectorClientError`
1351 /// - `UnauthorizedError`
1352 /// - `ForbiddenError`
1353 /// - `TooManyRequestsError`
1354 /// - `RateLimitBanError`
1355 /// - `ServerError`
1356 /// - `NotFoundError`
1357 /// - `NetworkError`
1358 /// - `BadRequestError`
1359 ///
1360 ///
1361 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/market-data/Query-Isolated-Margin-Tier-Data).
1362 ///
1363 pub async fn query_isolated_margin_tier_data(
1364 &self,
1365 params: QueryIsolatedMarginTierDataParams,
1366 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryIsolatedMarginTierDataResponseInner>>>
1367 {
1368 self.market_data_api_client
1369 .query_isolated_margin_tier_data(params)
1370 .await
1371 }
1372
1373 /// Query Liability Coin Leverage Bracket in Cross Margin Pro `Mode(MARKET_DATA)`
1374 ///
1375 /// Liability Coin Leverage Bracket in Cross Margin Pro Mode
1376 ///
1377 /// Weight: 1
1378 ///
1379 /// # Arguments
1380 ///
1381 /// - `params`: [`QueryLiabilityCoinLeverageBracketInCrossMarginProModeParams`]
1382 /// The parameters for this operation.
1383 ///
1384 /// # Returns
1385 ///
1386 /// [`RestApiResponse<Vec<models::QueryLiabilityCoinLeverageBracketInCrossMarginProModeResponseInner>>`] on success.
1387 ///
1388 /// # Errors
1389 ///
1390 /// This function will return an [`anyhow::Error`] if:
1391 /// - the HTTP request fails
1392 /// - any parameter is invalid
1393 /// - the response cannot be parsed
1394 /// - or one of the following occurs:
1395 /// - `RequiredError`
1396 /// - `ConnectorClientError`
1397 /// - `UnauthorizedError`
1398 /// - `ForbiddenError`
1399 /// - `TooManyRequestsError`
1400 /// - `RateLimitBanError`
1401 /// - `ServerError`
1402 /// - `NotFoundError`
1403 /// - `NetworkError`
1404 /// - `BadRequestError`
1405 ///
1406 ///
1407 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/market-data/Query-Liability-Coin-Leverage-Bracket-in-Cross-Margin-Pro-Mode).
1408 ///
1409 pub async fn query_liability_coin_leverage_bracket_in_cross_margin_pro_mode(
1410 &self,
1411 ) -> anyhow::Result<
1412 RestApiResponse<
1413 Vec<models::QueryLiabilityCoinLeverageBracketInCrossMarginProModeResponseInner>,
1414 >,
1415 > {
1416 self.market_data_api_client
1417 .query_liability_coin_leverage_bracket_in_cross_margin_pro_mode()
1418 .await
1419 }
1420
1421 /// Query Margin Available `Inventory(USER_DATA)`
1422 ///
1423 /// Margin available Inventory query
1424 ///
1425 /// Weight: 50
1426 ///
1427 /// # Arguments
1428 ///
1429 /// - `params`: [`QueryMarginAvailableInventoryParams`]
1430 /// The parameters for this operation.
1431 ///
1432 /// # Returns
1433 ///
1434 /// [`RestApiResponse<models::QueryMarginAvailableInventoryResponse>`] on success.
1435 ///
1436 /// # Errors
1437 ///
1438 /// This function will return an [`anyhow::Error`] if:
1439 /// - the HTTP request fails
1440 /// - any parameter is invalid
1441 /// - the response cannot be parsed
1442 /// - or one of the following occurs:
1443 /// - `RequiredError`
1444 /// - `ConnectorClientError`
1445 /// - `UnauthorizedError`
1446 /// - `ForbiddenError`
1447 /// - `TooManyRequestsError`
1448 /// - `RateLimitBanError`
1449 /// - `ServerError`
1450 /// - `NotFoundError`
1451 /// - `NetworkError`
1452 /// - `BadRequestError`
1453 ///
1454 ///
1455 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/market-data/Query-margin-avaliable-inventory).
1456 ///
1457 pub async fn query_margin_available_inventory(
1458 &self,
1459 params: QueryMarginAvailableInventoryParams,
1460 ) -> anyhow::Result<RestApiResponse<models::QueryMarginAvailableInventoryResponse>> {
1461 self.market_data_api_client
1462 .query_margin_available_inventory(params)
1463 .await
1464 }
1465
1466 /// Query Margin `PriceIndex` (`MARKET_DATA`)
1467 ///
1468 /// Query Margin `PriceIndex`
1469 ///
1470 /// Weight: 10(IP)
1471 ///
1472 /// # Arguments
1473 ///
1474 /// - `params`: [`QueryMarginPriceindexParams`]
1475 /// The parameters for this operation.
1476 ///
1477 /// # Returns
1478 ///
1479 /// [`RestApiResponse<models::QueryMarginPriceindexResponse>`] on success.
1480 ///
1481 /// # Errors
1482 ///
1483 /// This function will return an [`anyhow::Error`] if:
1484 /// - the HTTP request fails
1485 /// - any parameter is invalid
1486 /// - the response cannot be parsed
1487 /// - or one of the following occurs:
1488 /// - `RequiredError`
1489 /// - `ConnectorClientError`
1490 /// - `UnauthorizedError`
1491 /// - `ForbiddenError`
1492 /// - `TooManyRequestsError`
1493 /// - `RateLimitBanError`
1494 /// - `ServerError`
1495 /// - `NotFoundError`
1496 /// - `NetworkError`
1497 /// - `BadRequestError`
1498 ///
1499 ///
1500 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/market-data/Query-Margin-PriceIndex).
1501 ///
1502 pub async fn query_margin_priceindex(
1503 &self,
1504 params: QueryMarginPriceindexParams,
1505 ) -> anyhow::Result<RestApiResponse<models::QueryMarginPriceindexResponse>> {
1506 self.market_data_api_client
1507 .query_margin_priceindex(params)
1508 .await
1509 }
1510
1511 /// Close User Data Stream (`USER_STREAM`)
1512 ///
1513 /// Close out a user data stream.
1514 ///
1515 /// Weight: 3000
1516 ///
1517 /// # Arguments
1518 ///
1519 /// - `params`: [`CloseUserDataStreamParams`]
1520 /// The parameters for this operation.
1521 ///
1522 /// # Returns
1523 ///
1524 /// [`RestApiResponse<Value>`] on success.
1525 ///
1526 /// # Errors
1527 ///
1528 /// This function will return an [`anyhow::Error`] if:
1529 /// - the HTTP request fails
1530 /// - any parameter is invalid
1531 /// - the response cannot be parsed
1532 /// - or one of the following occurs:
1533 /// - `RequiredError`
1534 /// - `ConnectorClientError`
1535 /// - `UnauthorizedError`
1536 /// - `ForbiddenError`
1537 /// - `TooManyRequestsError`
1538 /// - `RateLimitBanError`
1539 /// - `ServerError`
1540 /// - `NotFoundError`
1541 /// - `NetworkError`
1542 /// - `BadRequestError`
1543 ///
1544 ///
1545 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/risk-data-stream/Close-User-Data-Stream).
1546 ///
1547 pub async fn close_user_data_stream(&self) -> anyhow::Result<RestApiResponse<Value>> {
1548 self.risk_data_stream_api_client
1549 .close_user_data_stream()
1550 .await
1551 }
1552
1553 /// Keepalive User Data Stream (`USER_STREAM`)
1554 ///
1555 /// Keepalive a user data stream to prevent a time out.
1556 ///
1557 /// Weight: 1
1558 ///
1559 /// # Arguments
1560 ///
1561 /// - `params`: [`KeepaliveUserDataStreamParams`]
1562 /// The parameters for this operation.
1563 ///
1564 /// # Returns
1565 ///
1566 /// [`RestApiResponse<Value>`] on success.
1567 ///
1568 /// # Errors
1569 ///
1570 /// This function will return an [`anyhow::Error`] if:
1571 /// - the HTTP request fails
1572 /// - any parameter is invalid
1573 /// - the response cannot be parsed
1574 /// - or one of the following occurs:
1575 /// - `RequiredError`
1576 /// - `ConnectorClientError`
1577 /// - `UnauthorizedError`
1578 /// - `ForbiddenError`
1579 /// - `TooManyRequestsError`
1580 /// - `RateLimitBanError`
1581 /// - `ServerError`
1582 /// - `NotFoundError`
1583 /// - `NetworkError`
1584 /// - `BadRequestError`
1585 ///
1586 ///
1587 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/risk-data-stream/Keepalive-User-Data-Stream).
1588 ///
1589 pub async fn keepalive_user_data_stream(
1590 &self,
1591 params: KeepaliveUserDataStreamParams,
1592 ) -> anyhow::Result<RestApiResponse<Value>> {
1593 self.risk_data_stream_api_client
1594 .keepalive_user_data_stream(params)
1595 .await
1596 }
1597
1598 /// Start User Data Stream (`USER_STREAM`)
1599 ///
1600 /// Start a new user data stream.
1601 ///
1602 /// Weight: 1
1603 ///
1604 /// # Arguments
1605 ///
1606 /// - `params`: [`StartUserDataStreamParams`]
1607 /// The parameters for this operation.
1608 ///
1609 /// # Returns
1610 ///
1611 /// [`RestApiResponse<models::StartUserDataStreamResponse>`] on success.
1612 ///
1613 /// # Errors
1614 ///
1615 /// This function will return an [`anyhow::Error`] if:
1616 /// - the HTTP request fails
1617 /// - any parameter is invalid
1618 /// - the response cannot be parsed
1619 /// - or one of the following occurs:
1620 /// - `RequiredError`
1621 /// - `ConnectorClientError`
1622 /// - `UnauthorizedError`
1623 /// - `ForbiddenError`
1624 /// - `TooManyRequestsError`
1625 /// - `RateLimitBanError`
1626 /// - `ServerError`
1627 /// - `NotFoundError`
1628 /// - `NetworkError`
1629 /// - `BadRequestError`
1630 ///
1631 ///
1632 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/risk-data-stream/Start-User-Data-Stream).
1633 ///
1634 pub async fn start_user_data_stream(
1635 &self,
1636 ) -> anyhow::Result<RestApiResponse<models::StartUserDataStreamResponse>> {
1637 self.risk_data_stream_api_client
1638 .start_user_data_stream()
1639 .await
1640 }
1641
1642 /// Create Special Key(Low-Latency Trading)(TRADE)
1643 ///
1644 /// - 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.
1645 /// - If you are VIP level 6 or below, please contact your VIP manager for eligibility criterias.
1646 ///
1647 /// **Supported Products:**
1648 ///
1649 /// - Cross Margin
1650 /// - Isolated Margin
1651 /// - Portfolio Margin Pro
1652 ///
1653 /// **Unsupported Products:**
1654 ///
1655 /// - Portfolio Margin
1656 ///
1657 /// We support several types of API keys:
1658 ///
1659 /// * Ed25519 (recommended)
1660 /// * HMAC
1661 /// * RSA
1662 ///
1663 /// 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) .
1664 ///
1665 /// Weight: 1(UID)
1666 ///
1667 /// # Arguments
1668 ///
1669 /// - `params`: [`CreateSpecialKeyParams`]
1670 /// The parameters for this operation.
1671 ///
1672 /// # Returns
1673 ///
1674 /// [`RestApiResponse<models::CreateSpecialKeyResponse>`] on success.
1675 ///
1676 /// # Errors
1677 ///
1678 /// This function will return an [`anyhow::Error`] if:
1679 /// - the HTTP request fails
1680 /// - any parameter is invalid
1681 /// - the response cannot be parsed
1682 /// - or one of the following occurs:
1683 /// - `RequiredError`
1684 /// - `ConnectorClientError`
1685 /// - `UnauthorizedError`
1686 /// - `ForbiddenError`
1687 /// - `TooManyRequestsError`
1688 /// - `RateLimitBanError`
1689 /// - `ServerError`
1690 /// - `NotFoundError`
1691 /// - `NetworkError`
1692 /// - `BadRequestError`
1693 ///
1694 ///
1695 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Create-Special-Key-of-Low-Latency-Trading).
1696 ///
1697 pub async fn create_special_key(
1698 &self,
1699 params: CreateSpecialKeyParams,
1700 ) -> anyhow::Result<RestApiResponse<models::CreateSpecialKeyResponse>> {
1701 self.trade_api_client.create_special_key(params).await
1702 }
1703
1704 /// Delete Special Key(Low-Latency Trading)(TRADE)
1705 ///
1706 /// This only applies to Special Key for Low Latency Trading.
1707 ///
1708 /// If apiKey is given, apiName will be ignored. If apiName is given with no apiKey, all apikeys with given apiName will be deleted.
1709 ///
1710 /// You need to enable Permits “Enable Spot & Margin Trading” option for the API Key which requests this endpoint.
1711 ///
1712 /// Weight: 1(UID)
1713 ///
1714 /// # Arguments
1715 ///
1716 /// - `params`: [`DeleteSpecialKeyParams`]
1717 /// The parameters for this operation.
1718 ///
1719 /// # Returns
1720 ///
1721 /// [`RestApiResponse<Value>`] on success.
1722 ///
1723 /// # Errors
1724 ///
1725 /// This function will return an [`anyhow::Error`] if:
1726 /// - the HTTP request fails
1727 /// - any parameter is invalid
1728 /// - the response cannot be parsed
1729 /// - or one of the following occurs:
1730 /// - `RequiredError`
1731 /// - `ConnectorClientError`
1732 /// - `UnauthorizedError`
1733 /// - `ForbiddenError`
1734 /// - `TooManyRequestsError`
1735 /// - `RateLimitBanError`
1736 /// - `ServerError`
1737 /// - `NotFoundError`
1738 /// - `NetworkError`
1739 /// - `BadRequestError`
1740 ///
1741 ///
1742 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Delete-Special-Key-of-Low-Latency-Trading).
1743 ///
1744 pub async fn delete_special_key(
1745 &self,
1746 params: DeleteSpecialKeyParams,
1747 ) -> anyhow::Result<RestApiResponse<Value>> {
1748 self.trade_api_client.delete_special_key(params).await
1749 }
1750
1751 /// Edit ip for Special Key(Low-Latency Trading)(TRADE)
1752 ///
1753 /// Edit ip restriction. This only applies to Special Key for Low Latency Trading.
1754 ///
1755 /// You need to enable Permits “Enable Spot & Margin Trading” option for the API Key which requests this endpoint.
1756 ///
1757 /// Weight: 1(UID)
1758 ///
1759 /// # Arguments
1760 ///
1761 /// - `params`: [`EditIpForSpecialKeyParams`]
1762 /// The parameters for this operation.
1763 ///
1764 /// # Returns
1765 ///
1766 /// [`RestApiResponse<Value>`] on success.
1767 ///
1768 /// # Errors
1769 ///
1770 /// This function will return an [`anyhow::Error`] if:
1771 /// - the HTTP request fails
1772 /// - any parameter is invalid
1773 /// - the response cannot be parsed
1774 /// - or one of the following occurs:
1775 /// - `RequiredError`
1776 /// - `ConnectorClientError`
1777 /// - `UnauthorizedError`
1778 /// - `ForbiddenError`
1779 /// - `TooManyRequestsError`
1780 /// - `RateLimitBanError`
1781 /// - `ServerError`
1782 /// - `NotFoundError`
1783 /// - `NetworkError`
1784 /// - `BadRequestError`
1785 ///
1786 ///
1787 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Edit-ip-for-Special-Key-of-Low-Latency-Trading).
1788 ///
1789 pub async fn edit_ip_for_special_key(
1790 &self,
1791 params: EditIpForSpecialKeyParams,
1792 ) -> anyhow::Result<RestApiResponse<Value>> {
1793 self.trade_api_client.edit_ip_for_special_key(params).await
1794 }
1795
1796 /// Get Force Liquidation Record (`USER_DATA`)
1797 ///
1798 /// Get Force Liquidation Record
1799 ///
1800 /// * Response in descending order
1801 ///
1802 /// Weight: 1(IP)
1803 ///
1804 /// # Arguments
1805 ///
1806 /// - `params`: [`GetForceLiquidationRecordParams`]
1807 /// The parameters for this operation.
1808 ///
1809 /// # Returns
1810 ///
1811 /// [`RestApiResponse<models::GetForceLiquidationRecordResponse>`] on success.
1812 ///
1813 /// # Errors
1814 ///
1815 /// This function will return an [`anyhow::Error`] if:
1816 /// - the HTTP request fails
1817 /// - any parameter is invalid
1818 /// - the response cannot be parsed
1819 /// - or one of the following occurs:
1820 /// - `RequiredError`
1821 /// - `ConnectorClientError`
1822 /// - `UnauthorizedError`
1823 /// - `ForbiddenError`
1824 /// - `TooManyRequestsError`
1825 /// - `RateLimitBanError`
1826 /// - `ServerError`
1827 /// - `NotFoundError`
1828 /// - `NetworkError`
1829 /// - `BadRequestError`
1830 ///
1831 ///
1832 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Get-Force-Liquidation-Record).
1833 ///
1834 pub async fn get_force_liquidation_record(
1835 &self,
1836 params: GetForceLiquidationRecordParams,
1837 ) -> anyhow::Result<RestApiResponse<models::GetForceLiquidationRecordResponse>> {
1838 self.trade_api_client
1839 .get_force_liquidation_record(params)
1840 .await
1841 }
1842
1843 /// Get Small Liability Exchange Coin List (`USER_DATA`)
1844 ///
1845 /// Query the coins which can be small liability exchange
1846 ///
1847 /// Weight: 100
1848 ///
1849 /// # Arguments
1850 ///
1851 /// - `params`: [`GetSmallLiabilityExchangeCoinListParams`]
1852 /// The parameters for this operation.
1853 ///
1854 /// # Returns
1855 ///
1856 /// [`RestApiResponse<Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>>`] on success.
1857 ///
1858 /// # Errors
1859 ///
1860 /// This function will return an [`anyhow::Error`] if:
1861 /// - the HTTP request fails
1862 /// - any parameter is invalid
1863 /// - the response cannot be parsed
1864 /// - or one of the following occurs:
1865 /// - `RequiredError`
1866 /// - `ConnectorClientError`
1867 /// - `UnauthorizedError`
1868 /// - `ForbiddenError`
1869 /// - `TooManyRequestsError`
1870 /// - `RateLimitBanError`
1871 /// - `ServerError`
1872 /// - `NotFoundError`
1873 /// - `NetworkError`
1874 /// - `BadRequestError`
1875 ///
1876 ///
1877 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Get-Small-Liability-Exchange-Coin-List).
1878 ///
1879 pub async fn get_small_liability_exchange_coin_list(
1880 &self,
1881 params: GetSmallLiabilityExchangeCoinListParams,
1882 ) -> anyhow::Result<RestApiResponse<Vec<models::GetSmallLiabilityExchangeCoinListResponseInner>>>
1883 {
1884 self.trade_api_client
1885 .get_small_liability_exchange_coin_list(params)
1886 .await
1887 }
1888
1889 /// Get Small Liability Exchange History (`USER_DATA`)
1890 ///
1891 /// Get Small liability Exchange History
1892 ///
1893 /// Weight: 100(UID)
1894 ///
1895 /// # Arguments
1896 ///
1897 /// - `params`: [`GetSmallLiabilityExchangeHistoryParams`]
1898 /// The parameters for this operation.
1899 ///
1900 /// # Returns
1901 ///
1902 /// [`RestApiResponse<models::GetSmallLiabilityExchangeHistoryResponse>`] on success.
1903 ///
1904 /// # Errors
1905 ///
1906 /// This function will return an [`anyhow::Error`] if:
1907 /// - the HTTP request fails
1908 /// - any parameter is invalid
1909 /// - the response cannot be parsed
1910 /// - or one of the following occurs:
1911 /// - `RequiredError`
1912 /// - `ConnectorClientError`
1913 /// - `UnauthorizedError`
1914 /// - `ForbiddenError`
1915 /// - `TooManyRequestsError`
1916 /// - `RateLimitBanError`
1917 /// - `ServerError`
1918 /// - `NotFoundError`
1919 /// - `NetworkError`
1920 /// - `BadRequestError`
1921 ///
1922 ///
1923 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Get-Small-Liability-Exchange-History).
1924 ///
1925 pub async fn get_small_liability_exchange_history(
1926 &self,
1927 params: GetSmallLiabilityExchangeHistoryParams,
1928 ) -> anyhow::Result<RestApiResponse<models::GetSmallLiabilityExchangeHistoryResponse>> {
1929 self.trade_api_client
1930 .get_small_liability_exchange_history(params)
1931 .await
1932 }
1933
1934 /// Margin Account Cancel all Open Orders on a Symbol (TRADE)
1935 ///
1936 /// Cancels all active orders on a symbol for margin account.<br></br>
1937 /// This includes OCO orders.
1938 ///
1939 /// Weight: 1
1940 ///
1941 /// # Arguments
1942 ///
1943 /// - `params`: [`MarginAccountCancelAllOpenOrdersOnASymbolParams`]
1944 /// The parameters for this operation.
1945 ///
1946 /// # Returns
1947 ///
1948 /// [`RestApiResponse<Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>>`] on success.
1949 ///
1950 /// # Errors
1951 ///
1952 /// This function will return an [`anyhow::Error`] if:
1953 /// - the HTTP request fails
1954 /// - any parameter is invalid
1955 /// - the response cannot be parsed
1956 /// - or one of the following occurs:
1957 /// - `RequiredError`
1958 /// - `ConnectorClientError`
1959 /// - `UnauthorizedError`
1960 /// - `ForbiddenError`
1961 /// - `TooManyRequestsError`
1962 /// - `RateLimitBanError`
1963 /// - `ServerError`
1964 /// - `NotFoundError`
1965 /// - `NetworkError`
1966 /// - `BadRequestError`
1967 ///
1968 ///
1969 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Margin-Account-Cancel-All-Open-Orders).
1970 ///
1971 pub async fn margin_account_cancel_all_open_orders_on_a_symbol(
1972 &self,
1973 params: MarginAccountCancelAllOpenOrdersOnASymbolParams,
1974 ) -> anyhow::Result<
1975 RestApiResponse<Vec<models::MarginAccountCancelAllOpenOrdersOnASymbolResponseInner>>,
1976 > {
1977 self.trade_api_client
1978 .margin_account_cancel_all_open_orders_on_a_symbol(params)
1979 .await
1980 }
1981
1982 /// Margin Account Cancel OCO (TRADE)
1983 ///
1984 /// Cancel an entire Order List for a margin account.
1985 ///
1986 /// * Canceling an individual leg will cancel the entire OCO
1987 ///
1988 /// Weight: 1(UID)
1989 ///
1990 /// # Arguments
1991 ///
1992 /// - `params`: [`MarginAccountCancelOcoParams`]
1993 /// The parameters for this operation.
1994 ///
1995 /// # Returns
1996 ///
1997 /// [`RestApiResponse<models::MarginAccountCancelOcoResponse>`] on success.
1998 ///
1999 /// # Errors
2000 ///
2001 /// This function will return an [`anyhow::Error`] if:
2002 /// - the HTTP request fails
2003 /// - any parameter is invalid
2004 /// - the response cannot be parsed
2005 /// - or one of the following occurs:
2006 /// - `RequiredError`
2007 /// - `ConnectorClientError`
2008 /// - `UnauthorizedError`
2009 /// - `ForbiddenError`
2010 /// - `TooManyRequestsError`
2011 /// - `RateLimitBanError`
2012 /// - `ServerError`
2013 /// - `NotFoundError`
2014 /// - `NetworkError`
2015 /// - `BadRequestError`
2016 ///
2017 ///
2018 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Margin-Account-Cancel-OCO).
2019 ///
2020 pub async fn margin_account_cancel_oco(
2021 &self,
2022 params: MarginAccountCancelOcoParams,
2023 ) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOcoResponse>> {
2024 self.trade_api_client
2025 .margin_account_cancel_oco(params)
2026 .await
2027 }
2028
2029 /// Margin Account Cancel Order (TRADE)
2030 ///
2031 /// Cancel an active order for margin account.
2032 ///
2033 /// * Either orderId or origClientOrderId must be sent.
2034 ///
2035 /// Weight: 10(IP)
2036 ///
2037 /// # Arguments
2038 ///
2039 /// - `params`: [`MarginAccountCancelOrderParams`]
2040 /// The parameters for this operation.
2041 ///
2042 /// # Returns
2043 ///
2044 /// [`RestApiResponse<models::MarginAccountCancelOrderResponse>`] on success.
2045 ///
2046 /// # Errors
2047 ///
2048 /// This function will return an [`anyhow::Error`] if:
2049 /// - the HTTP request fails
2050 /// - any parameter is invalid
2051 /// - the response cannot be parsed
2052 /// - or one of the following occurs:
2053 /// - `RequiredError`
2054 /// - `ConnectorClientError`
2055 /// - `UnauthorizedError`
2056 /// - `ForbiddenError`
2057 /// - `TooManyRequestsError`
2058 /// - `RateLimitBanError`
2059 /// - `ServerError`
2060 /// - `NotFoundError`
2061 /// - `NetworkError`
2062 /// - `BadRequestError`
2063 ///
2064 ///
2065 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Margin-Account-Cancel-Order).
2066 ///
2067 pub async fn margin_account_cancel_order(
2068 &self,
2069 params: MarginAccountCancelOrderParams,
2070 ) -> anyhow::Result<RestApiResponse<models::MarginAccountCancelOrderResponse>> {
2071 self.trade_api_client
2072 .margin_account_cancel_order(params)
2073 .await
2074 }
2075
2076 /// Margin Account New OCO (TRADE)
2077 ///
2078 /// Send in a new OCO for a margin account
2079 ///
2080 /// * autoRepayAtCancel is suggested to set as “FALSE” to keep liability unrepaid under high frequent new order/cancel order execution
2081 ///
2082 /// Weight: 6(UID)
2083 ///
2084 /// # Arguments
2085 ///
2086 /// - `params`: [`MarginAccountNewOcoParams`]
2087 /// The parameters for this operation.
2088 ///
2089 /// # Returns
2090 ///
2091 /// [`RestApiResponse<models::MarginAccountNewOcoResponse>`] on success.
2092 ///
2093 /// # Errors
2094 ///
2095 /// This function will return an [`anyhow::Error`] if:
2096 /// - the HTTP request fails
2097 /// - any parameter is invalid
2098 /// - the response cannot be parsed
2099 /// - or one of the following occurs:
2100 /// - `RequiredError`
2101 /// - `ConnectorClientError`
2102 /// - `UnauthorizedError`
2103 /// - `ForbiddenError`
2104 /// - `TooManyRequestsError`
2105 /// - `RateLimitBanError`
2106 /// - `ServerError`
2107 /// - `NotFoundError`
2108 /// - `NetworkError`
2109 /// - `BadRequestError`
2110 ///
2111 ///
2112 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Margin-Account-New-OCO).
2113 ///
2114 pub async fn margin_account_new_oco(
2115 &self,
2116 params: MarginAccountNewOcoParams,
2117 ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOcoResponse>> {
2118 self.trade_api_client.margin_account_new_oco(params).await
2119 }
2120
2121 /// Margin Account New Order (TRADE)
2122 ///
2123 /// Post a new order for margin account.
2124 ///
2125 /// * autoRepayAtCancel is suggested to set as “FALSE” to keep liability unrepaid under high frequent new order/cancel order execution
2126 ///
2127 /// Weight: 6(UID)
2128 ///
2129 /// # Arguments
2130 ///
2131 /// - `params`: [`MarginAccountNewOrderParams`]
2132 /// The parameters for this operation.
2133 ///
2134 /// # Returns
2135 ///
2136 /// [`RestApiResponse<models::MarginAccountNewOrderResponse>`] on success.
2137 ///
2138 /// # Errors
2139 ///
2140 /// This function will return an [`anyhow::Error`] if:
2141 /// - the HTTP request fails
2142 /// - any parameter is invalid
2143 /// - the response cannot be parsed
2144 /// - or one of the following occurs:
2145 /// - `RequiredError`
2146 /// - `ConnectorClientError`
2147 /// - `UnauthorizedError`
2148 /// - `ForbiddenError`
2149 /// - `TooManyRequestsError`
2150 /// - `RateLimitBanError`
2151 /// - `ServerError`
2152 /// - `NotFoundError`
2153 /// - `NetworkError`
2154 /// - `BadRequestError`
2155 ///
2156 ///
2157 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Margin-Account-New-Order).
2158 ///
2159 pub async fn margin_account_new_order(
2160 &self,
2161 params: MarginAccountNewOrderParams,
2162 ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOrderResponse>> {
2163 self.trade_api_client.margin_account_new_order(params).await
2164 }
2165
2166 /// Margin Account New OTO (TRADE)
2167 ///
2168 /// Post a new OTO order for margin account:
2169 ///
2170 /// - An OTO (One-Triggers-the-Other) is an order list comprised of 2 orders.
2171 /// - The first order is called the **working order** and must be `LIMIT` or `LIMIT_MAKER`. Initially, only the working order goes on the order book.
2172 /// - The second order is called the **pending order**. It can be any order type except for `MARKET` orders using parameter `quoteOrderQty`. The pending order is only placed on the order book when the working order gets **fully filled**.
2173 /// - If either the working order or the pending order is cancelled individually, the other order in the order list will also be canceled or expired.
2174 /// - When the order list is placed, if the working order gets **immediately fully filled**, the placement response will show the working order as `FILLED` but the pending order will still appear as `PENDING_NEW`. You need to query the status of the pending order again to see its updated status.
2175 /// - OTOs add **2 orders** to the unfilled order count, `EXCHANGE_MAX_NUM_ORDERS` filter and `MAX_NUM_ORDERS` filter.
2176 ///
2177 /// * autoRepayAtCancel is suggested to set as “FALSE” to keep liability unrepaid under high frequent new order/cancel order execution
2178 /// * Depending on the `pendingType` or `workingType`, some optional parameters will become mandatory:
2179 ///
2180 /// Weight: 6(UID)
2181 ///
2182 /// # Arguments
2183 ///
2184 /// - `params`: [`MarginAccountNewOtoParams`]
2185 /// The parameters for this operation.
2186 ///
2187 /// # Returns
2188 ///
2189 /// [`RestApiResponse<models::MarginAccountNewOtoResponse>`] on success.
2190 ///
2191 /// # Errors
2192 ///
2193 /// This function will return an [`anyhow::Error`] if:
2194 /// - the HTTP request fails
2195 /// - any parameter is invalid
2196 /// - the response cannot be parsed
2197 /// - or one of the following occurs:
2198 /// - `RequiredError`
2199 /// - `ConnectorClientError`
2200 /// - `UnauthorizedError`
2201 /// - `ForbiddenError`
2202 /// - `TooManyRequestsError`
2203 /// - `RateLimitBanError`
2204 /// - `ServerError`
2205 /// - `NotFoundError`
2206 /// - `NetworkError`
2207 /// - `BadRequestError`
2208 ///
2209 ///
2210 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Margin-Account-New-OTO).
2211 ///
2212 pub async fn margin_account_new_oto(
2213 &self,
2214 params: MarginAccountNewOtoParams,
2215 ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtoResponse>> {
2216 self.trade_api_client.margin_account_new_oto(params).await
2217 }
2218
2219 /// Margin Account New OTOCO (TRADE)
2220 ///
2221 /// Post a new OTOCO order for margin account:
2222 ///
2223 /// - An OTOCO (One-Triggers-One-Cancels-the-Other) is an order list comprised of 3 orders.
2224 /// - The first order is called the **working order** and must be `LIMIT` or `LIMIT_MAKER`. Initially, only the working order goes on the order book.
2225 /// - The behavior of the working order is the same as the OTO.
2226 /// - OTOCO has 2 pending orders (pending above and pending below), forming an OCO pair. The pending orders are only placed on the order book when the working order gets **fully filled**.
2227 /// - The rules of the pending above and pending below follow the same rules as the [Order List OCO](https://developers.binance.com/docs/margin_trading/trade/Margin-Account-New-OCO).
2228 /// - OTOCOs add **3 orders** against the unfilled order count, `EXCHANGE_MAX_NUM_ORDERS` filter, and `MAX_NUM_ORDERS` filter.
2229 ///
2230 /// * autoRepayAtCancel is suggested to set as “FALSE” to keep liability unrepaid under high frequent new order/cancel order execution
2231 /// * Depending on the `pendingAboveType`/`pendingBelowType` or `workingType`, some optional parameters will become mandatory:
2232 ///
2233 /// Weight: 6(UID)
2234 ///
2235 /// # Arguments
2236 ///
2237 /// - `params`: [`MarginAccountNewOtocoParams`]
2238 /// The parameters for this operation.
2239 ///
2240 /// # Returns
2241 ///
2242 /// [`RestApiResponse<models::MarginAccountNewOtocoResponse>`] on success.
2243 ///
2244 /// # Errors
2245 ///
2246 /// This function will return an [`anyhow::Error`] if:
2247 /// - the HTTP request fails
2248 /// - any parameter is invalid
2249 /// - the response cannot be parsed
2250 /// - or one of the following occurs:
2251 /// - `RequiredError`
2252 /// - `ConnectorClientError`
2253 /// - `UnauthorizedError`
2254 /// - `ForbiddenError`
2255 /// - `TooManyRequestsError`
2256 /// - `RateLimitBanError`
2257 /// - `ServerError`
2258 /// - `NotFoundError`
2259 /// - `NetworkError`
2260 /// - `BadRequestError`
2261 ///
2262 ///
2263 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Margin-Account-New-OTOCO).
2264 ///
2265 pub async fn margin_account_new_otoco(
2266 &self,
2267 params: MarginAccountNewOtocoParams,
2268 ) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOtocoResponse>> {
2269 self.trade_api_client.margin_account_new_otoco(params).await
2270 }
2271
2272 /// Margin Manual Liquidation(MARGIN)
2273 ///
2274 /// Margin Manual Liquidation
2275 ///
2276 /// * This endpoint can support Cross Margin Classic Mode and Pro Mode.
2277 /// * And only support Isolated Margin for restricted region.
2278 ///
2279 /// Weight: 3000
2280 ///
2281 /// # Arguments
2282 ///
2283 /// - `params`: [`MarginManualLiquidationParams`]
2284 /// The parameters for this operation.
2285 ///
2286 /// # Returns
2287 ///
2288 /// [`RestApiResponse<models::MarginManualLiquidationResponse>`] on success.
2289 ///
2290 /// # Errors
2291 ///
2292 /// This function will return an [`anyhow::Error`] if:
2293 /// - the HTTP request fails
2294 /// - any parameter is invalid
2295 /// - the response cannot be parsed
2296 /// - or one of the following occurs:
2297 /// - `RequiredError`
2298 /// - `ConnectorClientError`
2299 /// - `UnauthorizedError`
2300 /// - `ForbiddenError`
2301 /// - `TooManyRequestsError`
2302 /// - `RateLimitBanError`
2303 /// - `ServerError`
2304 /// - `NotFoundError`
2305 /// - `NetworkError`
2306 /// - `BadRequestError`
2307 ///
2308 ///
2309 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Margin-Manual-Liquidation).
2310 ///
2311 pub async fn margin_manual_liquidation(
2312 &self,
2313 params: MarginManualLiquidationParams,
2314 ) -> anyhow::Result<RestApiResponse<models::MarginManualLiquidationResponse>> {
2315 self.trade_api_client
2316 .margin_manual_liquidation(params)
2317 .await
2318 }
2319
2320 /// Query Current Margin Order Count Usage (TRADE)
2321 ///
2322 /// Displays the user's current margin order count usage for all intervals.
2323 ///
2324 /// Weight: 20(IP)
2325 ///
2326 /// # Arguments
2327 ///
2328 /// - `params`: [`QueryCurrentMarginOrderCountUsageParams`]
2329 /// The parameters for this operation.
2330 ///
2331 /// # Returns
2332 ///
2333 /// [`RestApiResponse<Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>>`] on success.
2334 ///
2335 /// # Errors
2336 ///
2337 /// This function will return an [`anyhow::Error`] if:
2338 /// - the HTTP request fails
2339 /// - any parameter is invalid
2340 /// - the response cannot be parsed
2341 /// - or one of the following occurs:
2342 /// - `RequiredError`
2343 /// - `ConnectorClientError`
2344 /// - `UnauthorizedError`
2345 /// - `ForbiddenError`
2346 /// - `TooManyRequestsError`
2347 /// - `RateLimitBanError`
2348 /// - `ServerError`
2349 /// - `NotFoundError`
2350 /// - `NetworkError`
2351 /// - `BadRequestError`
2352 ///
2353 ///
2354 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Query-Current-Margin-Order-Count-Usage).
2355 ///
2356 pub async fn query_current_margin_order_count_usage(
2357 &self,
2358 params: QueryCurrentMarginOrderCountUsageParams,
2359 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryCurrentMarginOrderCountUsageResponseInner>>>
2360 {
2361 self.trade_api_client
2362 .query_current_margin_order_count_usage(params)
2363 .await
2364 }
2365
2366 /// Query Margin Account's all OCO (`USER_DATA`)
2367 ///
2368 /// Retrieves all OCO for a specific margin account based on provided optional parameters
2369 ///
2370 /// Weight: 200(IP)
2371 ///
2372 /// # Arguments
2373 ///
2374 /// - `params`: [`QueryMarginAccountsAllOcoParams`]
2375 /// The parameters for this operation.
2376 ///
2377 /// # Returns
2378 ///
2379 /// [`RestApiResponse<Vec<models::QueryMarginAccountsAllOcoResponseInner>>`] on success.
2380 ///
2381 /// # Errors
2382 ///
2383 /// This function will return an [`anyhow::Error`] if:
2384 /// - the HTTP request fails
2385 /// - any parameter is invalid
2386 /// - the response cannot be parsed
2387 /// - or one of the following occurs:
2388 /// - `RequiredError`
2389 /// - `ConnectorClientError`
2390 /// - `UnauthorizedError`
2391 /// - `ForbiddenError`
2392 /// - `TooManyRequestsError`
2393 /// - `RateLimitBanError`
2394 /// - `ServerError`
2395 /// - `NotFoundError`
2396 /// - `NetworkError`
2397 /// - `BadRequestError`
2398 ///
2399 ///
2400 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-all-OCO).
2401 ///
2402 pub async fn query_margin_accounts_all_oco(
2403 &self,
2404 params: QueryMarginAccountsAllOcoParams,
2405 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOcoResponseInner>>> {
2406 self.trade_api_client
2407 .query_margin_accounts_all_oco(params)
2408 .await
2409 }
2410
2411 /// Query Margin Account's All Orders (`USER_DATA`)
2412 ///
2413 /// Query Margin Account's All Orders
2414 ///
2415 /// * If orderId is set, it will get orders >= that orderId. Otherwise the orders within 24 hours are returned.
2416 /// * For some historical orders cummulativeQuoteQty will be < 0, meaning the data is not available at this time.
2417 /// * Less than 24 hours between startTime and endTime.
2418 ///
2419 /// Weight: 200(IP)
2420 ///
2421 /// # Arguments
2422 ///
2423 /// - `params`: [`QueryMarginAccountsAllOrdersParams`]
2424 /// The parameters for this operation.
2425 ///
2426 /// # Returns
2427 ///
2428 /// [`RestApiResponse<Vec<models::QueryMarginAccountsAllOrdersResponseInner>>`] on success.
2429 ///
2430 /// # Errors
2431 ///
2432 /// This function will return an [`anyhow::Error`] if:
2433 /// - the HTTP request fails
2434 /// - any parameter is invalid
2435 /// - the response cannot be parsed
2436 /// - or one of the following occurs:
2437 /// - `RequiredError`
2438 /// - `ConnectorClientError`
2439 /// - `UnauthorizedError`
2440 /// - `ForbiddenError`
2441 /// - `TooManyRequestsError`
2442 /// - `RateLimitBanError`
2443 /// - `ServerError`
2444 /// - `NotFoundError`
2445 /// - `NetworkError`
2446 /// - `BadRequestError`
2447 ///
2448 ///
2449 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-Orders).
2450 ///
2451 pub async fn query_margin_accounts_all_orders(
2452 &self,
2453 params: QueryMarginAccountsAllOrdersParams,
2454 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOrdersResponseInner>>>
2455 {
2456 self.trade_api_client
2457 .query_margin_accounts_all_orders(params)
2458 .await
2459 }
2460
2461 /// Query Margin Account's OCO (`USER_DATA`)
2462 ///
2463 /// Retrieves a specific OCO based on provided optional parameters
2464 ///
2465 /// Weight: 10(IP)
2466 ///
2467 /// # Arguments
2468 ///
2469 /// - `params`: [`QueryMarginAccountsOcoParams`]
2470 /// The parameters for this operation.
2471 ///
2472 /// # Returns
2473 ///
2474 /// [`RestApiResponse<models::QueryMarginAccountsOcoResponse>`] on success.
2475 ///
2476 /// # Errors
2477 ///
2478 /// This function will return an [`anyhow::Error`] if:
2479 /// - the HTTP request fails
2480 /// - any parameter is invalid
2481 /// - the response cannot be parsed
2482 /// - or one of the following occurs:
2483 /// - `RequiredError`
2484 /// - `ConnectorClientError`
2485 /// - `UnauthorizedError`
2486 /// - `ForbiddenError`
2487 /// - `TooManyRequestsError`
2488 /// - `RateLimitBanError`
2489 /// - `ServerError`
2490 /// - `NotFoundError`
2491 /// - `NetworkError`
2492 /// - `BadRequestError`
2493 ///
2494 ///
2495 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-OCO).
2496 ///
2497 pub async fn query_margin_accounts_oco(
2498 &self,
2499 params: QueryMarginAccountsOcoParams,
2500 ) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOcoResponse>> {
2501 self.trade_api_client
2502 .query_margin_accounts_oco(params)
2503 .await
2504 }
2505
2506 /// Query Margin Account's Open OCO (`USER_DATA`)
2507 ///
2508 /// Query Margin Account's Open OCO
2509 ///
2510 /// Weight: 10(IP)
2511 ///
2512 /// # Arguments
2513 ///
2514 /// - `params`: [`QueryMarginAccountsOpenOcoParams`]
2515 /// The parameters for this operation.
2516 ///
2517 /// # Returns
2518 ///
2519 /// [`RestApiResponse<Vec<models::QueryMarginAccountsOpenOcoResponseInner>>`] on success.
2520 ///
2521 /// # Errors
2522 ///
2523 /// This function will return an [`anyhow::Error`] if:
2524 /// - the HTTP request fails
2525 /// - any parameter is invalid
2526 /// - the response cannot be parsed
2527 /// - or one of the following occurs:
2528 /// - `RequiredError`
2529 /// - `ConnectorClientError`
2530 /// - `UnauthorizedError`
2531 /// - `ForbiddenError`
2532 /// - `TooManyRequestsError`
2533 /// - `RateLimitBanError`
2534 /// - `ServerError`
2535 /// - `NotFoundError`
2536 /// - `NetworkError`
2537 /// - `BadRequestError`
2538 ///
2539 ///
2540 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Open-OCO).
2541 ///
2542 pub async fn query_margin_accounts_open_oco(
2543 &self,
2544 params: QueryMarginAccountsOpenOcoParams,
2545 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOcoResponseInner>>> {
2546 self.trade_api_client
2547 .query_margin_accounts_open_oco(params)
2548 .await
2549 }
2550
2551 /// Query Margin Account's Open Orders (`USER_DATA`)
2552 ///
2553 /// Query Margin Account's Open Orders
2554 ///
2555 /// * If the symbol is not sent, orders for all symbols will be returned in an array.
2556 /// * When all symbols are returned, the number of requests counted against the rate limiter is equal to the number of symbols currently trading on the exchange.
2557 /// * If isIsolated ="TRUE", symbol must be sent.
2558 ///
2559 /// Weight: 10(IP)
2560 ///
2561 /// # Arguments
2562 ///
2563 /// - `params`: [`QueryMarginAccountsOpenOrdersParams`]
2564 /// The parameters for this operation.
2565 ///
2566 /// # Returns
2567 ///
2568 /// [`RestApiResponse<Vec<models::QueryMarginAccountsOpenOrdersResponseInner>>`] on success.
2569 ///
2570 /// # Errors
2571 ///
2572 /// This function will return an [`anyhow::Error`] if:
2573 /// - the HTTP request fails
2574 /// - any parameter is invalid
2575 /// - the response cannot be parsed
2576 /// - or one of the following occurs:
2577 /// - `RequiredError`
2578 /// - `ConnectorClientError`
2579 /// - `UnauthorizedError`
2580 /// - `ForbiddenError`
2581 /// - `TooManyRequestsError`
2582 /// - `RateLimitBanError`
2583 /// - `ServerError`
2584 /// - `NotFoundError`
2585 /// - `NetworkError`
2586 /// - `BadRequestError`
2587 ///
2588 ///
2589 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Open-Orders).
2590 ///
2591 pub async fn query_margin_accounts_open_orders(
2592 &self,
2593 params: QueryMarginAccountsOpenOrdersParams,
2594 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOrdersResponseInner>>>
2595 {
2596 self.trade_api_client
2597 .query_margin_accounts_open_orders(params)
2598 .await
2599 }
2600
2601 /// Query Margin Account's Order (`USER_DATA`)
2602 ///
2603 /// Query Margin Account's Order
2604 ///
2605 /// * Either orderId or origClientOrderId must be sent.
2606 /// * For some historical orders cummulativeQuoteQty will be < 0, meaning the data is not available at this time.
2607 ///
2608 /// Weight: 10(IP)
2609 ///
2610 /// # Arguments
2611 ///
2612 /// - `params`: [`QueryMarginAccountsOrderParams`]
2613 /// The parameters for this operation.
2614 ///
2615 /// # Returns
2616 ///
2617 /// [`RestApiResponse<models::QueryMarginAccountsOrderResponse>`] on success.
2618 ///
2619 /// # Errors
2620 ///
2621 /// This function will return an [`anyhow::Error`] if:
2622 /// - the HTTP request fails
2623 /// - any parameter is invalid
2624 /// - the response cannot be parsed
2625 /// - or one of the following occurs:
2626 /// - `RequiredError`
2627 /// - `ConnectorClientError`
2628 /// - `UnauthorizedError`
2629 /// - `ForbiddenError`
2630 /// - `TooManyRequestsError`
2631 /// - `RateLimitBanError`
2632 /// - `ServerError`
2633 /// - `NotFoundError`
2634 /// - `NetworkError`
2635 /// - `BadRequestError`
2636 ///
2637 ///
2638 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Order).
2639 ///
2640 pub async fn query_margin_accounts_order(
2641 &self,
2642 params: QueryMarginAccountsOrderParams,
2643 ) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOrderResponse>> {
2644 self.trade_api_client
2645 .query_margin_accounts_order(params)
2646 .await
2647 }
2648
2649 /// Query Margin Account's Trade List (`USER_DATA`)
2650 ///
2651 /// Query Margin Account's Trade List
2652 ///
2653 /// * If fromId is set, it will get trades >= that fromId. Otherwise the trades within 24 hours are returned.
2654 /// * Less than 24 hours between startTime and endTime.
2655 ///
2656 /// Weight: 10(IP)
2657 ///
2658 /// # Arguments
2659 ///
2660 /// - `params`: [`QueryMarginAccountsTradeListParams`]
2661 /// The parameters for this operation.
2662 ///
2663 /// # Returns
2664 ///
2665 /// [`RestApiResponse<Vec<models::QueryMarginAccountsTradeListResponseInner>>`] on success.
2666 ///
2667 /// # Errors
2668 ///
2669 /// This function will return an [`anyhow::Error`] if:
2670 /// - the HTTP request fails
2671 /// - any parameter is invalid
2672 /// - the response cannot be parsed
2673 /// - or one of the following occurs:
2674 /// - `RequiredError`
2675 /// - `ConnectorClientError`
2676 /// - `UnauthorizedError`
2677 /// - `ForbiddenError`
2678 /// - `TooManyRequestsError`
2679 /// - `RateLimitBanError`
2680 /// - `ServerError`
2681 /// - `NotFoundError`
2682 /// - `NetworkError`
2683 /// - `BadRequestError`
2684 ///
2685 ///
2686 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Trade-List).
2687 ///
2688 pub async fn query_margin_accounts_trade_list(
2689 &self,
2690 params: QueryMarginAccountsTradeListParams,
2691 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsTradeListResponseInner>>>
2692 {
2693 self.trade_api_client
2694 .query_margin_accounts_trade_list(params)
2695 .await
2696 }
2697
2698 /// Query Prevented `Matches(USER_DATA)`
2699 ///
2700 ///
2701 /// Weight: 10(IP)
2702 ///
2703 /// # Arguments
2704 ///
2705 /// - `params`: [`QueryPreventedMatchesParams`]
2706 /// The parameters for this operation.
2707 ///
2708 /// # Returns
2709 ///
2710 /// [`RestApiResponse<Vec<models::QueryPreventedMatchesResponseInner>>`] on success.
2711 ///
2712 /// # Errors
2713 ///
2714 /// This function will return an [`anyhow::Error`] if:
2715 /// - the HTTP request fails
2716 /// - any parameter is invalid
2717 /// - the response cannot be parsed
2718 /// - or one of the following occurs:
2719 /// - `RequiredError`
2720 /// - `ConnectorClientError`
2721 /// - `UnauthorizedError`
2722 /// - `ForbiddenError`
2723 /// - `TooManyRequestsError`
2724 /// - `RateLimitBanError`
2725 /// - `ServerError`
2726 /// - `NotFoundError`
2727 /// - `NetworkError`
2728 /// - `BadRequestError`
2729 ///
2730 ///
2731 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Prevented-Matches).
2732 ///
2733 pub async fn query_prevented_matches(
2734 &self,
2735 params: QueryPreventedMatchesParams,
2736 ) -> anyhow::Result<RestApiResponse<Vec<models::QueryPreventedMatchesResponseInner>>> {
2737 self.trade_api_client.query_prevented_matches(params).await
2738 }
2739
2740 /// Query Special key(Low Latency Trading)(TRADE)
2741 ///
2742 /// Query Special Key Information.
2743 ///
2744 /// This only applies to Special Key for Low Latency Trading.
2745 ///
2746 /// Weight: 1(UID)
2747 ///
2748 /// # Arguments
2749 ///
2750 /// - `params`: [`QuerySpecialKeyParams`]
2751 /// The parameters for this operation.
2752 ///
2753 /// # Returns
2754 ///
2755 /// [`RestApiResponse<models::QuerySpecialKeyResponse>`] on success.
2756 ///
2757 /// # Errors
2758 ///
2759 /// This function will return an [`anyhow::Error`] if:
2760 /// - the HTTP request fails
2761 /// - any parameter is invalid
2762 /// - the response cannot be parsed
2763 /// - or one of the following occurs:
2764 /// - `RequiredError`
2765 /// - `ConnectorClientError`
2766 /// - `UnauthorizedError`
2767 /// - `ForbiddenError`
2768 /// - `TooManyRequestsError`
2769 /// - `RateLimitBanError`
2770 /// - `ServerError`
2771 /// - `NotFoundError`
2772 /// - `NetworkError`
2773 /// - `BadRequestError`
2774 ///
2775 ///
2776 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Query-Special-Key-of-Low-Latency-Trading).
2777 ///
2778 pub async fn query_special_key(
2779 &self,
2780 params: QuerySpecialKeyParams,
2781 ) -> anyhow::Result<RestApiResponse<models::QuerySpecialKeyResponse>> {
2782 self.trade_api_client.query_special_key(params).await
2783 }
2784
2785 /// Query Special key List(Low Latency Trading)(TRADE)
2786 ///
2787 /// This only applies to Special Key for Low Latency Trading.
2788 ///
2789 /// Weight: 1(UID)
2790 ///
2791 /// # Arguments
2792 ///
2793 /// - `params`: [`QuerySpecialKeyListParams`]
2794 /// The parameters for this operation.
2795 ///
2796 /// # Returns
2797 ///
2798 /// [`RestApiResponse<Vec<models::QuerySpecialKeyListResponseInner>>`] on success.
2799 ///
2800 /// # Errors
2801 ///
2802 /// This function will return an [`anyhow::Error`] if:
2803 /// - the HTTP request fails
2804 /// - any parameter is invalid
2805 /// - the response cannot be parsed
2806 /// - or one of the following occurs:
2807 /// - `RequiredError`
2808 /// - `ConnectorClientError`
2809 /// - `UnauthorizedError`
2810 /// - `ForbiddenError`
2811 /// - `TooManyRequestsError`
2812 /// - `RateLimitBanError`
2813 /// - `ServerError`
2814 /// - `NotFoundError`
2815 /// - `NetworkError`
2816 /// - `BadRequestError`
2817 ///
2818 ///
2819 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Query-Special-Key-List-of-Low-Latency-Trading).
2820 ///
2821 pub async fn query_special_key_list(
2822 &self,
2823 params: QuerySpecialKeyListParams,
2824 ) -> anyhow::Result<RestApiResponse<Vec<models::QuerySpecialKeyListResponseInner>>> {
2825 self.trade_api_client.query_special_key_list(params).await
2826 }
2827
2828 /// Small Liability Exchange (MARGIN)
2829 ///
2830 /// Small Liability Exchange
2831 ///
2832 /// * Only convert once within 6 hours
2833 /// * Only liability valuation less than 10 USDT are supported
2834 /// * The maximum number of coin is 10
2835 ///
2836 /// Weight: 3000(UID)
2837 ///
2838 /// # Arguments
2839 ///
2840 /// - `params`: [`SmallLiabilityExchangeParams`]
2841 /// The parameters for this operation.
2842 ///
2843 /// # Returns
2844 ///
2845 /// [`RestApiResponse<Value>`] on success.
2846 ///
2847 /// # Errors
2848 ///
2849 /// This function will return an [`anyhow::Error`] if:
2850 /// - the HTTP request fails
2851 /// - any parameter is invalid
2852 /// - the response cannot be parsed
2853 /// - or one of the following occurs:
2854 /// - `RequiredError`
2855 /// - `ConnectorClientError`
2856 /// - `UnauthorizedError`
2857 /// - `ForbiddenError`
2858 /// - `TooManyRequestsError`
2859 /// - `RateLimitBanError`
2860 /// - `ServerError`
2861 /// - `NotFoundError`
2862 /// - `NetworkError`
2863 /// - `BadRequestError`
2864 ///
2865 ///
2866 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/trade/Small-Liability-Exchange).
2867 ///
2868 pub async fn small_liability_exchange(
2869 &self,
2870 params: SmallLiabilityExchangeParams,
2871 ) -> anyhow::Result<RestApiResponse<Value>> {
2872 self.trade_api_client.small_liability_exchange(params).await
2873 }
2874
2875 /// Get Cross Margin Transfer History (`USER_DATA`)
2876 ///
2877 /// Get Cross Margin Transfer History
2878 ///
2879 /// * Response in descending order
2880 /// * The max interval between `startTime` and `endTime` is 30 days.
2881 /// * Returns data for last 7 days by default
2882 ///
2883 /// Weight: 1(IP)
2884 ///
2885 /// # Arguments
2886 ///
2887 /// - `params`: [`GetCrossMarginTransferHistoryParams`]
2888 /// The parameters for this operation.
2889 ///
2890 /// # Returns
2891 ///
2892 /// [`RestApiResponse<models::GetCrossMarginTransferHistoryResponse>`] on success.
2893 ///
2894 /// # Errors
2895 ///
2896 /// This function will return an [`anyhow::Error`] if:
2897 /// - the HTTP request fails
2898 /// - any parameter is invalid
2899 /// - the response cannot be parsed
2900 /// - or one of the following occurs:
2901 /// - `RequiredError`
2902 /// - `ConnectorClientError`
2903 /// - `UnauthorizedError`
2904 /// - `ForbiddenError`
2905 /// - `TooManyRequestsError`
2906 /// - `RateLimitBanError`
2907 /// - `ServerError`
2908 /// - `NotFoundError`
2909 /// - `NetworkError`
2910 /// - `BadRequestError`
2911 ///
2912 ///
2913 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/transfer/Get-Cross-Margin-Transfer-History).
2914 ///
2915 pub async fn get_cross_margin_transfer_history(
2916 &self,
2917 params: GetCrossMarginTransferHistoryParams,
2918 ) -> anyhow::Result<RestApiResponse<models::GetCrossMarginTransferHistoryResponse>> {
2919 self.transfer_api_client
2920 .get_cross_margin_transfer_history(params)
2921 .await
2922 }
2923
2924 /// Query Max Transfer-Out Amount (`USER_DATA`)
2925 ///
2926 /// Query Max Transfer-Out Amount
2927 ///
2928 /// * If isolatedSymbol is not sent, crossed margin data will be sent.
2929 ///
2930 /// Weight: 50(IP)
2931 ///
2932 /// # Arguments
2933 ///
2934 /// - `params`: [`QueryMaxTransferOutAmountParams`]
2935 /// The parameters for this operation.
2936 ///
2937 /// # Returns
2938 ///
2939 /// [`RestApiResponse<models::QueryMaxTransferOutAmountResponse>`] on success.
2940 ///
2941 /// # Errors
2942 ///
2943 /// This function will return an [`anyhow::Error`] if:
2944 /// - the HTTP request fails
2945 /// - any parameter is invalid
2946 /// - the response cannot be parsed
2947 /// - or one of the following occurs:
2948 /// - `RequiredError`
2949 /// - `ConnectorClientError`
2950 /// - `UnauthorizedError`
2951 /// - `ForbiddenError`
2952 /// - `TooManyRequestsError`
2953 /// - `RateLimitBanError`
2954 /// - `ServerError`
2955 /// - `NotFoundError`
2956 /// - `NetworkError`
2957 /// - `BadRequestError`
2958 ///
2959 ///
2960 /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/margin_trading/transfer/Query-Max-Transfer-Out-Amount).
2961 ///
2962 pub async fn query_max_transfer_out_amount(
2963 &self,
2964 params: QueryMaxTransferOutAmountParams,
2965 ) -> anyhow::Result<RestApiResponse<models::QueryMaxTransferOutAmountResponse>> {
2966 self.transfer_api_client
2967 .query_max_transfer_out_amount(params)
2968 .await
2969 }
2970}