/*
* Portfolio Margin REST API
*
* Access account information, manage margin positions, and trade with Binance Portfolio Margin.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#![allow(unused_imports)]
use http::Method;
use serde::de::DeserializeOwned;
use serde_json::Value;
use std::collections::BTreeMap;
use crate::common::{config::ConfigurationRestApi, models::RestApiResponse, utils::send_request};
mod apis;
mod models;
pub use apis::*;
pub use models::*;
#[derive(Debug, Clone)]
pub struct RestApi {
configuration: ConfigurationRestApi,
account_api_client: AccountApiClient,
market_data_api_client: MarketDataApiClient,
trade_api_client: TradeApiClient,
user_data_streams_api_client: UserDataStreamsApiClient,
}
impl RestApi {
pub fn new(configuration: ConfigurationRestApi) -> Self {
let account_api_client = AccountApiClient::new(configuration.clone());
let market_data_api_client = MarketDataApiClient::new(configuration.clone());
let trade_api_client = TradeApiClient::new(configuration.clone());
let user_data_streams_api_client = UserDataStreamsApiClient::new(configuration.clone());
Self {
configuration,
account_api_client,
market_data_api_client,
trade_api_client,
user_data_streams_api_client,
}
}
/// Send an unsigned request to the API
///
/// # Arguments
///
/// * `endpoint` - The API endpoint to send the request to
/// * `method` - The HTTP method to use for the request
/// * `query_params` - A map of query parameters to send with the request
/// * `body_params` - A map of body parameters to send with the request
///
/// # Returns
///
/// A `RestApiResponse` containing the deserialized response data on success, or an error if the request fails
///
/// # Errors
///
/// Returns an `anyhow::Error` if the HTTP request fails or if parsing the response fails
pub async fn send_request<R: DeserializeOwned + Send + 'static>(
&self,
endpoint: &str,
method: Method,
query_params: BTreeMap<String, Value>,
body_params: BTreeMap<String, Value>,
) -> anyhow::Result<RestApiResponse<R>> {
send_request::<R>(
&self.configuration,
endpoint,
method,
query_params,
body_params,
None,
false,
)
.await
}
/// Send a signed request to the API
///
/// # Arguments
///
/// * `endpoint` - The API endpoint to send the request to
/// * `method` - The HTTP method to use for the request
/// * `query_params` - A map of query parameters to send with the request
/// * `body_params` - A map of body parameters to send with the request
///
/// # Returns
///
/// A `RestApiResponse` containing the deserialized response data on success, or an error if the request fails
///
/// # Errors
///
/// Returns an `anyhow::Error` if the HTTP request fails or if parsing the response fails
pub async fn send_signed_request<R: DeserializeOwned + Send + 'static>(
&self,
endpoint: &str,
method: Method,
query_params: BTreeMap<String, Value>,
body_params: BTreeMap<String, Value>,
) -> anyhow::Result<RestApiResponse<R>> {
send_request::<R>(
&self.configuration,
endpoint,
method,
query_params,
body_params,
None,
true,
)
.await
}
/// Account Balance (`USER_DATA`)
///
/// Query account balance
///
/// Weight(IP): 20
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`AccountBalanceParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::AccountBalanceResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#account-balance).
///
pub async fn account_balance(
&self,
params: AccountBalanceParams,
) -> anyhow::Result<RestApiResponse<models::AccountBalanceResponse>> {
self.account_api_client.account_balance(params).await
}
/// Account Information (`USER_DATA`)
///
/// Query account information
///
/// Weight(IP): 20
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`AccountInformationParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::AccountInformationResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#account-information).
///
pub async fn account_information(
&self,
params: AccountInformationParams,
) -> anyhow::Result<RestApiResponse<models::AccountInformationResponse>> {
self.account_api_client.account_information(params).await
}
/// BNB transfer (TRADE)
///
/// Transfer BNB in and out of UM
///
/// Weight(IP): 750
///
/// Security Type: TRADE
///
/// Notes:
/// - The endpoint can only be called 10 times per 10 minutes in a rolling manner
///
/// # Arguments
///
/// - `params`: [`BnbTransferParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::BnbTransferResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#bnb-transfer).
///
pub async fn bnb_transfer(
&self,
params: BnbTransferParams,
) -> anyhow::Result<RestApiResponse<models::BnbTransferResponse>> {
self.account_api_client.bnb_transfer(params).await
}
/// Change Auto-repay-futures Status (TRADE)
///
/// Change Auto-repay-futures Status
///
/// Weight(IP): 750
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`ChangeAutoRepayFuturesStatusParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ChangeAutoRepayFuturesStatusResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#change-auto-repay-futures-status).
///
pub async fn change_auto_repay_futures_status(
&self,
params: ChangeAutoRepayFuturesStatusParams,
) -> anyhow::Result<RestApiResponse<models::ChangeAutoRepayFuturesStatusResponse>> {
self.account_api_client
.change_auto_repay_futures_status(params)
.await
}
/// Change CM Initial Leverage (TRADE)
///
/// Change user's initial leverage of specific symbol in CM.
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`ChangeCmInitialLeverageParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ChangeCmInitialLeverageResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#change-cm-initial-leverage).
///
pub async fn change_cm_initial_leverage(
&self,
params: ChangeCmInitialLeverageParams,
) -> anyhow::Result<RestApiResponse<models::ChangeCmInitialLeverageResponse>> {
self.account_api_client
.change_cm_initial_leverage(params)
.await
}
/// Change CM Position Mode (TRADE)
///
/// Change user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol in CM
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`ChangeCmPositionModeParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ChangeCmPositionModeResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#change-cm-position-mode).
///
pub async fn change_cm_position_mode(
&self,
params: ChangeCmPositionModeParams,
) -> anyhow::Result<RestApiResponse<models::ChangeCmPositionModeResponse>> {
self.account_api_client
.change_cm_position_mode(params)
.await
}
/// Change UM Initial Leverage (TRADE)
///
/// Change user's initial leverage of specific symbol in UM.
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`ChangeUmInitialLeverageParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ChangeUmInitialLeverageResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#change-um-initial-leverage).
///
pub async fn change_um_initial_leverage(
&self,
params: ChangeUmInitialLeverageParams,
) -> anyhow::Result<RestApiResponse<models::ChangeUmInitialLeverageResponse>> {
self.account_api_client
.change_um_initial_leverage(params)
.await
}
/// Change UM Position Mode (TRADE)
///
/// Change user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol in UM
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`ChangeUmPositionModeParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ChangeUmPositionModeResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#change-um-position-mode).
///
pub async fn change_um_position_mode(
&self,
params: ChangeUmPositionModeParams,
) -> anyhow::Result<RestApiResponse<models::ChangeUmPositionModeResponse>> {
self.account_api_client
.change_um_position_mode(params)
.await
}
/// CM Notional and Leverage Brackets (`USER_DATA`)
///
/// Query CM notional and leverage brackets
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`CmNotionalAndLeverageBracketsParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::CmNotionalAndLeverageBracketsResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#cm-notional-and-leverage-brackets).
///
pub async fn cm_notional_and_leverage_brackets(
&self,
params: CmNotionalAndLeverageBracketsParams,
) -> anyhow::Result<RestApiResponse<Vec<models::CmNotionalAndLeverageBracketsResponseInner>>>
{
self.account_api_client
.cm_notional_and_leverage_brackets(params)
.await
}
/// Fund Auto-collection (TRADE)
///
/// Fund collection for Portfolio Margin
///
/// Weight(IP): 750
///
/// Security Type: TRADE
///
/// Notes:
/// - BNB assets will not be auto-collected.
/// - Rolling window endpoint can be called at most 500 times per hour.
///
/// # Arguments
///
/// - `params`: [`FundAutoCollectionParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::FundAutoCollectionResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#fund-auto-collection).
///
pub async fn fund_auto_collection(
&self,
params: FundAutoCollectionParams,
) -> anyhow::Result<RestApiResponse<models::FundAutoCollectionResponse>> {
self.account_api_client.fund_auto_collection(params).await
}
/// Fund Collection by Asset (TRADE)
///
/// Transfers specific asset from Futures Account to Margin account
///
/// Weight(IP): 30
///
/// Security Type: TRADE
///
/// Notes:
/// - The BNB transfer is not be supported
///
/// # Arguments
///
/// - `params`: [`FundCollectionByAssetParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::FundCollectionByAssetResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#fund-collection-by-asset).
///
pub async fn fund_collection_by_asset(
&self,
params: FundCollectionByAssetParams,
) -> anyhow::Result<RestApiResponse<models::FundCollectionByAssetResponse>> {
self.account_api_client
.fund_collection_by_asset(params)
.await
}
/// Get Auto-repay-futures Status (`USER_DATA`)
///
/// Query Auto-repay-futures Status
///
/// Weight(IP): 30
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`GetAutoRepayFuturesStatusParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetAutoRepayFuturesStatusResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-auto-repay-futures-status).
///
pub async fn get_auto_repay_futures_status(
&self,
params: GetAutoRepayFuturesStatusParams,
) -> anyhow::Result<RestApiResponse<models::GetAutoRepayFuturesStatusResponse>> {
self.account_api_client
.get_auto_repay_futures_status(params)
.await
}
/// Get CM Account Detail (`USER_DATA`)
///
/// Get current CM account asset and position information.
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`GetCmAccountDetailParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetCmAccountDetailResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-cm-account-detail).
///
pub async fn get_cm_account_detail(
&self,
params: GetCmAccountDetailParams,
) -> anyhow::Result<RestApiResponse<models::GetCmAccountDetailResponse>> {
self.account_api_client.get_cm_account_detail(params).await
}
/// Get CM Current Position Mode (`USER_DATA`)
///
/// Get user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol in CM
///
/// Weight(IP): 30
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`GetCmCurrentPositionModeParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetCmCurrentPositionModeResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-cm-current-position-mode).
///
pub async fn get_cm_current_position_mode(
&self,
params: GetCmCurrentPositionModeParams,
) -> anyhow::Result<RestApiResponse<models::GetCmCurrentPositionModeResponse>> {
self.account_api_client
.get_cm_current_position_mode(params)
.await
}
/// Get CM Income History (`USER_DATA`)
///
/// Get CM Income History.
///
/// Weight(IP): 30
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - If `incomeType` is not sent, all kinds of flow will be returned
/// - "trandId" is unique in the same "incomeType" for a user
/// - The interval between `startTime` and `endTime` can not exceed 200 days:
/// - If `startTime` and `endTime` are not sent, the last 200 days will be returned
///
/// # Arguments
///
/// - `params`: [`GetCmIncomeHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::GetCmIncomeHistoryResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-cm-income-history).
///
pub async fn get_cm_income_history(
&self,
params: GetCmIncomeHistoryParams,
) -> anyhow::Result<RestApiResponse<Vec<models::GetCmIncomeHistoryResponseInner>>> {
self.account_api_client.get_cm_income_history(params).await
}
/// Get Download Id For UM Futures Order History (`USER_DATA`)
///
/// Get download id for UM futures order history
///
/// Weight(IP): 1500
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Request Limitation is 10 times per month, shared by front end download page and rest api
/// - The time between `startTime` and `endTime` can not be longer than 1 year
///
/// # Arguments
///
/// - `params`: [`GetDownloadIdForUmFuturesOrderHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetDownloadIdForUmFuturesOrderHistoryResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-download-id-for-um-futures-order-history).
///
pub async fn get_download_id_for_um_futures_order_history(
&self,
params: GetDownloadIdForUmFuturesOrderHistoryParams,
) -> anyhow::Result<RestApiResponse<models::GetDownloadIdForUmFuturesOrderHistoryResponse>>
{
self.account_api_client
.get_download_id_for_um_futures_order_history(params)
.await
}
/// Get Download Id For UM Futures Trade History (`USER_DATA`)
///
/// Get download id for UM futures trade history
///
/// Weight(IP): 1500
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Request Limitation is 5 times per month, shared by front end download page and rest api
/// - The time between `startTime` and `endTime` can not be longer than 1 year
///
/// # Arguments
///
/// - `params`: [`GetDownloadIdForUmFuturesTradeHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetDownloadIdForUmFuturesTradeHistoryResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-download-id-for-um-futures-trade-history).
///
pub async fn get_download_id_for_um_futures_trade_history(
&self,
params: GetDownloadIdForUmFuturesTradeHistoryParams,
) -> anyhow::Result<RestApiResponse<models::GetDownloadIdForUmFuturesTradeHistoryResponse>>
{
self.account_api_client
.get_download_id_for_um_futures_trade_history(params)
.await
}
/// Get Download Id For UM Futures Transaction History (`USER_DATA`)
///
/// Get download id for UM futures transaction history
///
/// Weight(IP): 1500
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Request Limitation is 5 times per month, shared by front end download page and rest api
/// - The time between `startTime` and `endTime` can not be longer than 1 year
///
/// # Arguments
///
/// - `params`: [`GetDownloadIdForUmFuturesTransactionHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetDownloadIdForUmFuturesTransactionHistoryResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-download-id-for-um-futures-transaction-history).
///
pub async fn get_download_id_for_um_futures_transaction_history(
&self,
params: GetDownloadIdForUmFuturesTransactionHistoryParams,
) -> anyhow::Result<RestApiResponse<models::GetDownloadIdForUmFuturesTransactionHistoryResponse>>
{
self.account_api_client
.get_download_id_for_um_futures_transaction_history(params)
.await
}
/// Get Margin Borrow/Loan Interest History (`USER_DATA`)
///
/// Get Margin Borrow/Loan Interest History
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Response in descending order
/// - The max interval between startTime and endTime is 30 days. It is a MUST to ensure data correctness.
/// - If `startTime` and `endTime` not sent, return records of the last 7 days by default
/// - If `startTime` is sent and `endTime` is not sent, the records from `startTime` to the present will be returned; if `startTime` is more than 30 days ago, the records of the past 30 days will be returned.
/// - If `startTime` is not sent and `endTime` is sent, the records of the 7 days before `endTime` is returned.
/// - Type in response has 5 enums:
/// - `PERIODIC` interest charged per hour
/// - `ON_BORROW` first interest charged on borrow
/// - `PERIODIC_CONVERTED` interest charged per hour converted into BNB
/// - `ON_BORROW_CONVERTED` first interest charged on borrow converted into BNB
/// - `PORTFOLIO` Portfolio Margin negative balance daily interest
///
/// # Arguments
///
/// - `params`: [`GetMarginBorrowLoanInterestHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetMarginBorrowLoanInterestHistoryResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-margin-borrow-loan-interest-history).
///
pub async fn get_margin_borrow_loan_interest_history(
&self,
params: GetMarginBorrowLoanInterestHistoryParams,
) -> anyhow::Result<RestApiResponse<models::GetMarginBorrowLoanInterestHistoryResponse>> {
self.account_api_client
.get_margin_borrow_loan_interest_history(params)
.await
}
/// Get UM Account Detail (`USER_DATA`)
///
/// Get current UM account asset and position information.
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`GetUmAccountDetailParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetUmAccountDetailResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-um-account-detail).
///
pub async fn get_um_account_detail(
&self,
params: GetUmAccountDetailParams,
) -> anyhow::Result<RestApiResponse<models::GetUmAccountDetailResponse>> {
self.account_api_client.get_um_account_detail(params).await
}
/// Get UM Account Detail V2 (`USER_DATA`)
///
/// Get current UM account asset and position information.
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`GetUmAccountDetailV2Params`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetUmAccountDetailV2Response>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-um-account-detail-v2).
///
pub async fn get_um_account_detail_v2(
&self,
params: GetUmAccountDetailV2Params,
) -> anyhow::Result<RestApiResponse<models::GetUmAccountDetailV2Response>> {
self.account_api_client
.get_um_account_detail_v2(params)
.await
}
/// Get UM Current Position Mode (`USER_DATA`)
///
/// Get user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol in UM
///
/// Weight(IP): 30
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`GetUmCurrentPositionModeParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetUmCurrentPositionModeResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-um-current-position-mode).
///
pub async fn get_um_current_position_mode(
&self,
params: GetUmCurrentPositionModeParams,
) -> anyhow::Result<RestApiResponse<models::GetUmCurrentPositionModeResponse>> {
self.account_api_client
.get_um_current_position_mode(params)
.await
}
/// Get UM Futures Order Download Link by Id (`USER_DATA`)
///
/// Get UM futures order download link by Id
///
/// Weight(IP): 10
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Download link expiration: 7 days
///
/// # Arguments
///
/// - `params`: [`GetUmFuturesOrderDownloadLinkByIdParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetUmFuturesOrderDownloadLinkByIdResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-um-futures-order-download-link-by-id).
///
pub async fn get_um_futures_order_download_link_by_id(
&self,
params: GetUmFuturesOrderDownloadLinkByIdParams,
) -> anyhow::Result<RestApiResponse<models::GetUmFuturesOrderDownloadLinkByIdResponse>> {
self.account_api_client
.get_um_futures_order_download_link_by_id(params)
.await
}
/// Get UM Futures Trade Download Link by Id (`USER_DATA`)
///
/// Get UM futures trade download link by Id
///
/// Weight(IP): 10
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Download link expiration: 7 days
///
/// # Arguments
///
/// - `params`: [`GetUmFuturesTradeDownloadLinkByIdParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetUmFuturesTradeDownloadLinkByIdResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-um-futures-trade-download-link-by-id).
///
pub async fn get_um_futures_trade_download_link_by_id(
&self,
params: GetUmFuturesTradeDownloadLinkByIdParams,
) -> anyhow::Result<RestApiResponse<models::GetUmFuturesTradeDownloadLinkByIdResponse>> {
self.account_api_client
.get_um_futures_trade_download_link_by_id(params)
.await
}
/// Get UM Futures Transaction Download Link by Id (`USER_DATA`)
///
/// Get UM futures Transaction download link by Id
///
/// Weight(IP): 10
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Download link expiration: 7 days
///
/// # Arguments
///
/// - `params`: [`GetUmFuturesTransactionDownloadLinkByIdParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetUmFuturesTransactionDownloadLinkByIdResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-um-futures-transaction-download-link-by-id).
///
pub async fn get_um_futures_transaction_download_link_by_id(
&self,
params: GetUmFuturesTransactionDownloadLinkByIdParams,
) -> anyhow::Result<RestApiResponse<models::GetUmFuturesTransactionDownloadLinkByIdResponse>>
{
self.account_api_client
.get_um_futures_transaction_download_link_by_id(params)
.await
}
/// Get UM Income History (`USER_DATA`)
///
/// Get UM Income History.
///
/// Weight(IP): 30
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - If neither `startTime` nor `endTime` is sent, the recent 7-day data will be returned.
/// - If `incomeType` is not sent, all kinds of flow will be returned
/// - "trandId" is unique in the same incomeType for a user
/// - Income history only contains data for the last three months
///
/// # Arguments
///
/// - `params`: [`GetUmIncomeHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::GetUmIncomeHistoryResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-um-income-history).
///
pub async fn get_um_income_history(
&self,
params: GetUmIncomeHistoryParams,
) -> anyhow::Result<RestApiResponse<Vec<models::GetUmIncomeHistoryResponseInner>>> {
self.account_api_client.get_um_income_history(params).await
}
/// Get User Commission Rate for CM (`USER_DATA`)
///
/// Get User Commission Rate for CM
///
/// Weight(IP): 20
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`GetUserCommissionRateForCmParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetUserCommissionRateForCmResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-user-commission-rate-for-cm).
///
pub async fn get_user_commission_rate_for_cm(
&self,
params: GetUserCommissionRateForCmParams,
) -> anyhow::Result<RestApiResponse<models::GetUserCommissionRateForCmResponse>> {
self.account_api_client
.get_user_commission_rate_for_cm(params)
.await
}
/// Get User Commission Rate for UM (`USER_DATA`)
///
/// Get User Commission Rate for UM
///
/// Weight(IP): 20
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`GetUserCommissionRateForUmParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetUserCommissionRateForUmResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#get-user-commission-rate-for-um).
///
pub async fn get_user_commission_rate_for_um(
&self,
params: GetUserCommissionRateForUmParams,
) -> anyhow::Result<RestApiResponse<models::GetUserCommissionRateForUmResponse>> {
self.account_api_client
.get_user_commission_rate_for_um(params)
.await
}
/// Margin Max Borrow (`USER_DATA`)
///
/// Query margin max borrow
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`MarginMaxBorrowParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::MarginMaxBorrowResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#margin-max-borrow).
///
pub async fn margin_max_borrow(
&self,
params: MarginMaxBorrowParams,
) -> anyhow::Result<RestApiResponse<models::MarginMaxBorrowResponse>> {
self.account_api_client.margin_max_borrow(params).await
}
/// Portfolio Margin UM Trading Quantitative Rules Indicators (`USER_DATA`)
///
/// Portfolio Margin UM Trading Quantitative Rules Indicators
///
/// Weight: - 1 for a single `symbol`
/// - 10 when `symbol` is omitted
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`PortfolioMarginUmTradingQuantitativeRulesIndicatorsParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::PortfolioMarginUmTradingQuantitativeRulesIndicatorsResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#portfolio-margin-um-trading-quantitative-rules-indicators).
///
pub async fn portfolio_margin_um_trading_quantitative_rules_indicators(
&self,
params: PortfolioMarginUmTradingQuantitativeRulesIndicatorsParams,
) -> anyhow::Result<
RestApiResponse<models::PortfolioMarginUmTradingQuantitativeRulesIndicatorsResponse>,
> {
self.account_api_client
.portfolio_margin_um_trading_quantitative_rules_indicators(params)
.await
}
/// Query CM Position Information (`USER_DATA`)
///
/// Get current CM position information.
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - If neither `marginAsset` nor `pair` is sent, positions of all symbols with `TRADING` status will be returned.
/// - for One-way Mode user, the response will only show the "BOTH" positions
/// - for Hedge Mode user, the response will show "LONG", and "SHORT" positions. **Note**
/// - Please use with user data stream `ACCOUNT_UPDATE` to meet your timeliness and accuracy needs.
///
/// # Arguments
///
/// - `params`: [`QueryCmPositionInformationParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryCmPositionInformationResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#query-cm-position-information).
///
pub async fn query_cm_position_information(
&self,
params: QueryCmPositionInformationParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryCmPositionInformationResponseInner>>> {
self.account_api_client
.query_cm_position_information(params)
.await
}
/// Query Margin Loan Record (`USER_DATA`)
///
/// Query margin loan record
///
/// Weight(IP): 10
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - txId or startTime must be sent. txId takes precedence.
/// - Response in descending order
/// - The max interval between `startTime` and `endTime` is 30 days.
/// - If `startTime` and `endTime` not sent, return records of the last 7 days by default
/// - Set `archived` to `true` to query data from 6 months ago
///
/// # Arguments
///
/// - `params`: [`QueryMarginLoanRecordParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryMarginLoanRecordResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#query-margin-loan-record).
///
pub async fn query_margin_loan_record(
&self,
params: QueryMarginLoanRecordParams,
) -> anyhow::Result<RestApiResponse<models::QueryMarginLoanRecordResponse>> {
self.account_api_client
.query_margin_loan_record(params)
.await
}
/// Query Margin Max Withdraw (`USER_DATA`)
///
/// Query Margin Max Withdraw
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`QueryMarginMaxWithdrawParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryMarginMaxWithdrawResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#query-margin-max-withdraw).
///
pub async fn query_margin_max_withdraw(
&self,
params: QueryMarginMaxWithdrawParams,
) -> anyhow::Result<RestApiResponse<models::QueryMarginMaxWithdrawResponse>> {
self.account_api_client
.query_margin_max_withdraw(params)
.await
}
/// Query Margin repay Record (`USER_DATA`)
///
/// Query margin repay record.
///
/// Weight(IP): 10
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - txId or startTime must be sent. txId takes precedence.
/// - Response in descending order
/// - The max interval between `startTime` and `endTime` is 30 days.
/// - If `startTime` and `endTime` not sent, return records of the last 7 days by default
/// - Set `archived` to `true` to query data from 6 months ago
///
/// # Arguments
///
/// - `params`: [`QueryMarginRepayRecordParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryMarginRepayRecordResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#query-margin-repay-record).
///
pub async fn query_margin_repay_record(
&self,
params: QueryMarginRepayRecordParams,
) -> anyhow::Result<RestApiResponse<models::QueryMarginRepayRecordResponse>> {
self.account_api_client
.query_margin_repay_record(params)
.await
}
/// Query Portfolio Margin Negative Balance Interest History (`USER_DATA`)
///
/// Query interest history of negative balance for portfolio margin.
///
/// Weight(IP): 50
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Results are returned in descending order.
/// - The query range cannot exceed 30 days to ensure data correctness.
/// - If both `startTime` and `endTime` are omitted, the most recent 7 days are returned by default.
/// - If `startTime` is provided but `endTime` is omitted, records from `startTime` to now are returned; if that exceeds 30 days, only the most recent 30 days are returned.
/// - If `endTime` is provided but `startTime` is omitted, records from the 7 days before `endTime` are returned.
///
/// # Arguments
///
/// - `params`: [`QueryPortfolioMarginNegativeBalanceInterestHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryPortfolioMarginNegativeBalanceInterestHistoryResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#query-portfolio-margin-negative-balance-interest-history).
///
pub async fn query_portfolio_margin_negative_balance_interest_history(
&self,
params: QueryPortfolioMarginNegativeBalanceInterestHistoryParams,
) -> anyhow::Result<
RestApiResponse<
Vec<models::QueryPortfolioMarginNegativeBalanceInterestHistoryResponseInner>,
>,
> {
self.account_api_client
.query_portfolio_margin_negative_balance_interest_history(params)
.await
}
/// Query UM Position Information (`USER_DATA`)
///
/// Get current UM position information.
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Please use with account push event `ACCOUNT_UPDATE` for timeliness and accuracy.
/// - In One-way Mode, only positions with side `BOTH` are shown.
/// - In Hedge Mode, positions with sides `BOTH`, `LONG`, and `SHORT` are shown.
///
/// # Arguments
///
/// - `params`: [`QueryUmPositionInformationParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryUmPositionInformationResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#query-um-position-information).
///
pub async fn query_um_position_information(
&self,
params: QueryUmPositionInformationParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryUmPositionInformationResponseInner>>> {
self.account_api_client
.query_um_position_information(params)
.await
}
/// Query User Negative Balance Auto Exchange Record (`USER_DATA`)
///
/// Query user negative balance auto exchange record
///
/// Weight(IP): 100
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Response in descending order
/// - The max interval between `startTime` and `endTime` is 3 months.
///
/// # Arguments
///
/// - `params`: [`QueryUserNegativeBalanceAutoExchangeRecordParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryUserNegativeBalanceAutoExchangeRecordResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#query-user-negative-balance-auto-exchange-record).
///
pub async fn query_user_negative_balance_auto_exchange_record(
&self,
params: QueryUserNegativeBalanceAutoExchangeRecordParams,
) -> anyhow::Result<RestApiResponse<models::QueryUserNegativeBalanceAutoExchangeRecordResponse>>
{
self.account_api_client
.query_user_negative_balance_auto_exchange_record(params)
.await
}
/// Query User Rate Limit (`USER_DATA`)
///
/// Query User Rate Limit
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`QueryUserRateLimitParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryUserRateLimitResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#query-user-rate-limit).
///
pub async fn query_user_rate_limit(
&self,
params: QueryUserRateLimitParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryUserRateLimitResponseInner>>> {
self.account_api_client.query_user_rate_limit(params).await
}
/// Repay futures Negative Balance (`USER_DATA`)
///
/// Repay futures Negative Balance
///
/// Weight(IP): 750
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`RepayFuturesNegativeBalanceParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::RepayFuturesNegativeBalanceResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#repay-futures-negative-balance).
///
pub async fn repay_futures_negative_balance(
&self,
params: RepayFuturesNegativeBalanceParams,
) -> anyhow::Result<RestApiResponse<models::RepayFuturesNegativeBalanceResponse>> {
self.account_api_client
.repay_futures_negative_balance(params)
.await
}
/// UM Futures Account Configuration (`USER_DATA`)
///
/// Query UM Futures account configuration
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`UmFuturesAccountConfigurationParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::UmFuturesAccountConfigurationResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#um-futures-account-configuration).
///
pub async fn um_futures_account_configuration(
&self,
params: UmFuturesAccountConfigurationParams,
) -> anyhow::Result<RestApiResponse<models::UmFuturesAccountConfigurationResponse>> {
self.account_api_client
.um_futures_account_configuration(params)
.await
}
/// UM Futures Symbol Configuration (`USER_DATA`)
///
/// Get current UM account symbol configuration.
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`UmFuturesSymbolConfigurationParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::UmFuturesSymbolConfigurationResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#um-futures-symbol-configuration).
///
pub async fn um_futures_symbol_configuration(
&self,
params: UmFuturesSymbolConfigurationParams,
) -> anyhow::Result<RestApiResponse<Vec<models::UmFuturesSymbolConfigurationResponseInner>>>
{
self.account_api_client
.um_futures_symbol_configuration(params)
.await
}
/// UM Notional and Leverage Brackets (`USER_DATA`)
///
/// Query UM notional and leverage brackets
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`UmNotionalAndLeverageBracketsParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::UmNotionalAndLeverageBracketsResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/account#um-notional-and-leverage-brackets).
///
pub async fn um_notional_and_leverage_brackets(
&self,
params: UmNotionalAndLeverageBracketsParams,
) -> anyhow::Result<RestApiResponse<Vec<models::UmNotionalAndLeverageBracketsResponseInner>>>
{
self.account_api_client
.um_notional_and_leverage_brackets(params)
.await
}
/// Test Connectivity
///
/// Test connectivity to the Rest API.
///
/// Weight(IP): 1
///
/// # Arguments
///
/// - `params`: [`TestConnectivityParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Value>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/market-data#test-connectivity).
///
pub async fn test_connectivity(&self) -> anyhow::Result<RestApiResponse<Value>> {
self.market_data_api_client.test_connectivity().await
}
/// Cancel All CM Open Conditional Orders (TRADE)
///
/// Cancel All CM Open Conditional Orders
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`CancelAllCmOpenConditionalOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CancelAllCmOpenConditionalOrdersResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cancel-all-cm-open-conditional-orders).
///
pub async fn cancel_all_cm_open_conditional_orders(
&self,
params: CancelAllCmOpenConditionalOrdersParams,
) -> anyhow::Result<RestApiResponse<models::CancelAllCmOpenConditionalOrdersResponse>> {
self.trade_api_client
.cancel_all_cm_open_conditional_orders(params)
.await
}
/// Cancel All CM Open Orders (TRADE)
///
/// Cancel all active LIMIT orders on specific symbol
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`CancelAllCmOpenOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CancelAllCmOpenOrdersResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cancel-all-cm-open-orders).
///
pub async fn cancel_all_cm_open_orders(
&self,
params: CancelAllCmOpenOrdersParams,
) -> anyhow::Result<RestApiResponse<models::CancelAllCmOpenOrdersResponse>> {
self.trade_api_client
.cancel_all_cm_open_orders(params)
.await
}
/// Cancel All UM Algo Open Orders (TRADE)
///
/// Cancel All UM Algo Open Orders
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`CancelAllUmAlgoOpenOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CancelAllUmAlgoOpenOrdersResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cancel-all-um-algo-open-orders).
///
pub async fn cancel_all_um_algo_open_orders(
&self,
params: CancelAllUmAlgoOpenOrdersParams,
) -> anyhow::Result<RestApiResponse<models::CancelAllUmAlgoOpenOrdersResponse>> {
self.trade_api_client
.cancel_all_um_algo_open_orders(params)
.await
}
/// Cancel All UM Open Conditional Orders - Deprecated (TRADE)
///
/// Cancel All UM Open Conditional Orders
///
/// > **Deprecated:** This endpoint has returned HTTP 404 since 2026-04-28 and is no longer available. Use `DELETE /papi/v1/um/algo/allOpenOrders` instead. Field changes: `strategyId` -> `algoId`, `newClientStrategyId` -> `clientAlgoId`, `strategyStatus` -> `algoStatus`, `stopPrice` -> `triggerPrice`, `activationPrice` -> `activatePrice` (TRAILING_STOP_MARKET orders). `algoType` is a new fixed-value field (`CONDITIONAL`), not a rename of `strategyType` -- the order type now lives in `type` (request) / `orderType` (response).
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`CancelAllUmOpenConditionalOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CancelAllUmOpenConditionalOrdersResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cancel-all-um-open-conditional-orders).
///
/// # Deprecation
///
/// **Deprecated:** This method may be removed in a future version.
#[deprecated]
pub async fn cancel_all_um_open_conditional_orders(
&self,
params: CancelAllUmOpenConditionalOrdersParams,
) -> anyhow::Result<RestApiResponse<models::CancelAllUmOpenConditionalOrdersResponse>> {
self.trade_api_client
.cancel_all_um_open_conditional_orders(params)
.await
}
/// Cancel All UM Open Orders (TRADE)
///
/// Cancel all active LIMIT orders on specific symbol
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`CancelAllUmOpenOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CancelAllUmOpenOrdersResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cancel-all-um-open-orders).
///
pub async fn cancel_all_um_open_orders(
&self,
params: CancelAllUmOpenOrdersParams,
) -> anyhow::Result<RestApiResponse<models::CancelAllUmOpenOrdersResponse>> {
self.trade_api_client
.cancel_all_um_open_orders(params)
.await
}
/// Cancel CM Conditional Order (TRADE)
///
/// Cancel CM Conditional Order
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Either `strategyId` or `newClientStrategyId` must be sent.
///
/// # Arguments
///
/// - `params`: [`CancelCmConditionalOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CancelCmConditionalOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cancel-cm-conditional-order).
///
pub async fn cancel_cm_conditional_order(
&self,
params: CancelCmConditionalOrderParams,
) -> anyhow::Result<RestApiResponse<models::CancelCmConditionalOrderResponse>> {
self.trade_api_client
.cancel_cm_conditional_order(params)
.await
}
/// Cancel CM Order (TRADE)
///
/// Cancel an active LIMIT order
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Either `orderId` or `origClientOrderId` must be sent.
///
/// # Arguments
///
/// - `params`: [`CancelCmOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CancelCmOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cancel-cm-order).
///
pub async fn cancel_cm_order(
&self,
params: CancelCmOrderParams,
) -> anyhow::Result<RestApiResponse<models::CancelCmOrderResponse>> {
self.trade_api_client.cancel_cm_order(params).await
}
/// Cancel Margin Account All Open Orders on a Symbol (TRADE)
///
/// Cancel Margin Account All Open Orders on a Symbol
///
/// Weight(IP): 5
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`CancelMarginAccountAllOpenOrdersOnASymbolParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::CancelMarginAccountAllOpenOrdersOnASymbolResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cancel-margin-account-all-open-orders-on-asymbol).
///
pub async fn cancel_margin_account_all_open_orders_on_a_symbol(
&self,
params: CancelMarginAccountAllOpenOrdersOnASymbolParams,
) -> anyhow::Result<
RestApiResponse<Vec<models::CancelMarginAccountAllOpenOrdersOnASymbolResponseInner>>,
> {
self.trade_api_client
.cancel_margin_account_all_open_orders_on_a_symbol(params)
.await
}
/// Cancel Margin Account OCO Orders (TRADE)
///
/// Cancel Margin Account OCO Orders
///
/// Weight(IP): 2
///
/// Security Type: TRADE
///
/// Notes:
/// - Additional notes: Canceling an individual leg will cancel the entire OCO
///
/// # Arguments
///
/// - `params`: [`CancelMarginAccountOcoOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CancelMarginAccountOcoOrdersResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cancel-margin-account-oco-orders).
///
pub async fn cancel_margin_account_oco_orders(
&self,
params: CancelMarginAccountOcoOrdersParams,
) -> anyhow::Result<RestApiResponse<models::CancelMarginAccountOcoOrdersResponse>> {
self.trade_api_client
.cancel_margin_account_oco_orders(params)
.await
}
/// Cancel Margin Account Order (TRADE)
///
/// Cancel Margin Account Order
///
/// Weight(IP): 2
///
/// Security Type: TRADE
///
/// Notes:
/// - Either `orderId` or `origClientOrderId` must be sent.
///
/// # Arguments
///
/// - `params`: [`CancelMarginAccountOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CancelMarginAccountOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cancel-margin-account-order).
///
pub async fn cancel_margin_account_order(
&self,
params: CancelMarginAccountOrderParams,
) -> anyhow::Result<RestApiResponse<models::CancelMarginAccountOrderResponse>> {
self.trade_api_client
.cancel_margin_account_order(params)
.await
}
/// Cancel UM Algo Order (TRADE)
///
/// Cancel an active UM algo order
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Either `algoId` or `clientAlgoId` must be sent.
///
/// # Arguments
///
/// - `params`: [`CancelUmAlgoOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CancelUmAlgoOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cancel-um-algo-order).
///
pub async fn cancel_um_algo_order(
&self,
params: CancelUmAlgoOrderParams,
) -> anyhow::Result<RestApiResponse<models::CancelUmAlgoOrderResponse>> {
self.trade_api_client.cancel_um_algo_order(params).await
}
/// Cancel UM Conditional Order - Deprecated (TRADE)
///
/// Cancel UM Conditional Order
///
/// > **Deprecated:** This endpoint has returned HTTP 404 since 2026-04-28 and is no longer available. Use `DELETE /papi/v1/um/algo/order` instead. Field changes: `strategyId` -> `algoId`, `newClientStrategyId` -> `clientAlgoId`, `strategyStatus` -> `algoStatus`, `stopPrice` -> `triggerPrice`, `activationPrice` -> `activatePrice` (TRAILING_STOP_MARKET orders). `algoType` is a new fixed-value field (`CONDITIONAL`), not a rename of `strategyType` -- the order type now lives in `type` (request) / `orderType` (response).
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Either `strategyId` or `newClientStrategyId` must be sent.
///
/// # Arguments
///
/// - `params`: [`CancelUmConditionalOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CancelUmConditionalOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cancel-um-conditional-order).
///
/// # Deprecation
///
/// **Deprecated:** This method may be removed in a future version.
#[deprecated]
pub async fn cancel_um_conditional_order(
&self,
params: CancelUmConditionalOrderParams,
) -> anyhow::Result<RestApiResponse<models::CancelUmConditionalOrderResponse>> {
self.trade_api_client
.cancel_um_conditional_order(params)
.await
}
/// Cancel UM Order (TRADE)
///
/// Cancel an active UM LIMIT order
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Either `orderId` or `origClientOrderId` must be sent.
///
/// # Arguments
///
/// - `params`: [`CancelUmOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::CancelUmOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cancel-um-order).
///
pub async fn cancel_um_order(
&self,
params: CancelUmOrderParams,
) -> anyhow::Result<RestApiResponse<models::CancelUmOrderResponse>> {
self.trade_api_client.cancel_um_order(params).await
}
/// CM Account Trade List (`USER_DATA`)
///
/// Get trades for a specific account and CM symbol.
///
/// Weight: - 20 with `symbol`
/// - 40 with `pair`
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Either `symbol` or `pair` must be sent
/// - `symbol` and `pair` cannot be sent together
/// - `pair` and `fromId` cannot be sent together
/// - `OrderId` can only be sent together with symbol
/// - If a `pair` is sent, tickers for all symbols of the `pair` will be returned
/// - The parameter `fromId` cannot be sent with `startTime` or `endTime`
/// - If `startTime` and `endTime` are both not sent, then the last '24 hours' data will be returned.
/// - The time between `startTime` and `endTime` cannot be longer than 24 hours.
///
/// # Arguments
///
/// - `params`: [`CmAccountTradeListParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::CmAccountTradeListResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cm-account-trade-list).
///
pub async fn cm_account_trade_list(
&self,
params: CmAccountTradeListParams,
) -> anyhow::Result<RestApiResponse<Vec<models::CmAccountTradeListResponseInner>>> {
self.trade_api_client.cm_account_trade_list(params).await
}
/// CM Position ADL Quantile Estimation (`USER_DATA`)
///
/// Query CM Position ADL Quantile Estimation
/// * Values update every 30s.
/// * Values 0, 1, 2, 3, 4 shows the queue position and possibility of ADL from low to high.
/// * For positions of the symbol are in One-way Mode or isolated margined in Hedge Mode, "LONG", "SHORT", and "BOTH" will be returned to show the positions' adl quantiles of different position sides.
/// * If the positions of the symbol are crossed margined in Hedge Mode:
/// * "HEDGE" as a sign will be returned instead of "BOTH";
/// * A same value caculated on unrealized pnls on long and short sides' positions will be shown for "LONG" and "SHORT" when there are positions in both of long and short sides.
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`CmPositionAdlQuantileEstimationParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::CmPositionAdlQuantileEstimationResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#cm-position-adl-quantile-estimation).
///
pub async fn cm_position_adl_quantile_estimation(
&self,
params: CmPositionAdlQuantileEstimationParams,
) -> anyhow::Result<RestApiResponse<Vec<models::CmPositionAdlQuantileEstimationResponseInner>>>
{
self.trade_api_client
.cm_position_adl_quantile_estimation(params)
.await
}
/// Futures `TradFi` Perps Contract (`USER_DATA`)
///
/// Sign TradFi-Perps agreement contract
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`FuturesTradfiPerpsContractParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::FuturesTradfiPerpsContractResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#futures-tradfi-perps-contract).
///
pub async fn futures_tradfi_perps_contract(
&self,
params: FuturesTradfiPerpsContractParams,
) -> anyhow::Result<RestApiResponse<models::FuturesTradfiPerpsContractResponse>> {
self.trade_api_client
.futures_tradfi_perps_contract(params)
.await
}
/// Get UM Futures BNB Burn Status (`USER_DATA`)
///
/// Get user's BNB Fee Discount for UM Futures (Fee Discount On or Fee Discount Off )
///
/// Weight(IP): 30
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`GetUmFuturesBnbBurnStatusParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::GetUmFuturesBnbBurnStatusResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#get-um-futures-bnb-burn-status).
///
pub async fn get_um_futures_bnb_burn_status(
&self,
params: GetUmFuturesBnbBurnStatusParams,
) -> anyhow::Result<RestApiResponse<models::GetUmFuturesBnbBurnStatusResponse>> {
self.trade_api_client
.get_um_futures_bnb_burn_status(params)
.await
}
/// Margin Account Borrow (MARGIN)
///
/// Apply for a margin loan.
///
/// Weight(IP): 100
///
/// Security Type: MARGIN
///
/// # Arguments
///
/// - `params`: [`MarginAccountBorrowParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::MarginAccountBorrowResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#margin-account-borrow).
///
pub async fn margin_account_borrow(
&self,
params: MarginAccountBorrowParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountBorrowResponse>> {
self.trade_api_client.margin_account_borrow(params).await
}
/// Margin Account New OCO (TRADE)
///
/// Send in a new OCO for a margin account
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Other Info:
/// - Price Restrictions:
/// - `SELL`: Limit Price > Last Price > Stop Price
/// - `BUY`: Limit Price * Quantity Restrictions:
/// - Both legs must have the same quantity
/// - `ICEBERG` quantities however do not have to be the same.
/// - Order Rate Limit
/// - `OCO` counts as 2 orders against the order rate limit.
///
/// # Arguments
///
/// - `params`: [`MarginAccountNewOcoParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::MarginAccountNewOcoResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#margin-account-new-oco).
///
pub async fn margin_account_new_oco(
&self,
params: MarginAccountNewOcoParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountNewOcoResponse>> {
self.trade_api_client.margin_account_new_oco(params).await
}
/// Margin Account Repay (MARGIN)
///
/// Repay for a margin loan.
///
/// Weight(IP): 100
///
/// Security Type: MARGIN
///
/// # Arguments
///
/// - `params`: [`MarginAccountRepayParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::MarginAccountRepayResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#margin-account-repay).
///
pub async fn margin_account_repay(
&self,
params: MarginAccountRepayParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountRepayResponse>> {
self.trade_api_client.margin_account_repay(params).await
}
/// Margin Account Repay Debt (TRADE)
///
/// Repay debt for a margin loan.
///
/// Weight(IP): 3000
///
/// Security Type: TRADE
///
/// Notes:
/// - The repay asset amount cannot exceed 50000 USD equivalent value for a single request.
/// - If `amount` is not sent, all the asset loan will be repaid if having enough specific repay assets.
/// - If `amount` is sent, only the certain amount of the asset loan will be repaid if having enough specific repay assets.
/// - The system will use the same asset to repay the loan first (if have) no matter whether put the asset in `specifyRepayAssets`
///
/// # Arguments
///
/// - `params`: [`MarginAccountRepayDebtParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::MarginAccountRepayDebtResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#margin-account-repay-debt).
///
pub async fn margin_account_repay_debt(
&self,
params: MarginAccountRepayDebtParams,
) -> anyhow::Result<RestApiResponse<models::MarginAccountRepayDebtResponse>> {
self.trade_api_client
.margin_account_repay_debt(params)
.await
}
/// Margin Account Trade List (`USER_DATA`)
///
/// Margin Account Trade List
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - **Note:** * If `fromId` is set, returns orders with id >= `fromId`; otherwise returns recent order history.
/// - The interval between `startTime` and `endTime` must be less than 24 hours.
///
/// # Arguments
///
/// - `params`: [`MarginAccountTradeListParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::MarginAccountTradeListResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#margin-account-trade-list).
///
pub async fn margin_account_trade_list(
&self,
params: MarginAccountTradeListParams,
) -> anyhow::Result<RestApiResponse<Vec<models::MarginAccountTradeListResponseInner>>> {
self.trade_api_client
.margin_account_trade_list(params)
.await
}
/// Modify CM Order (TRADE)
///
/// Order modify function, currently only LIMIT order modification is supported, modified orders will be reordered in the match queue
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Either `orderId` or `origClientOrderId` must be sent, and the `orderId` will prevail if both are sent.
/// - Both `quantity` and `price` must be sent
/// - When the new `quantity` or `price` doesn't satisfy `PRICE_FILTER` / `PERCENT_FILTER` / `LOT_SIZE`, amendment will be rejected and the order will stay as it is.
/// - However the order will be cancelled by the amendment in the following situations:
/// - when the order is in partially filled status and the new `quantity` <= `executedQty`
/// - When the order is `GTX` and the new price will cause it to be executed immediately
///
/// # Arguments
///
/// - `params`: [`ModifyCmOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ModifyCmOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#modify-cm-order).
///
pub async fn modify_cm_order(
&self,
params: ModifyCmOrderParams,
) -> anyhow::Result<RestApiResponse<models::ModifyCmOrderResponse>> {
self.trade_api_client.modify_cm_order(params).await
}
/// Modify UM Order (TRADE)
///
/// Order modify function, currently only LIMIT order modification is supported, modified orders will be reordered in the match queue
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Either orderId or origClientOrderId must be sent, and the orderId will prevail if both are sent.
/// - Both quantity and price must be sent
/// - When the new quantity or price doesn't satisfy `PRICE_FILTER` / `PERCENT_FILTER` / `LOT_SIZE`, amendment will be rejected and the order will stay as it is.
/// - However the order will be cancelled by the amendment in the following situations:
/// - when the order is in partially filled status and the new quantity <= executedQty
/// - When the order is GTX and the new price will cause it to be executed immediately
/// - The amendment keeps the order's original selfTradePreventionMode.
///
/// # Arguments
///
/// - `params`: [`ModifyUmOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ModifyUmOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#modify-um-order).
///
pub async fn modify_um_order(
&self,
params: ModifyUmOrderParams,
) -> anyhow::Result<RestApiResponse<models::ModifyUmOrderResponse>> {
self.trade_api_client.modify_um_order(params).await
}
/// New CM Conditional Order (TRADE)
///
/// New CM Conditional Order
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Additional mandatory parameters based on type:
/// - Order with type `STOP/TAKE_PROFIT`, parameter `timeInForce` can be sent ( default `GTC`).
/// - Condition orders will be triggered when:
/// - `STOP`, `STOP_MARKET`:
/// - BUY: "`MARK_PRICE`" >= `stopPrice`
/// - SELL: "`MARK_PRICE`" = `stopPrice`
/// - `TRAILING_STOP_MARKET`:
/// - BUY: the lowest mark price after order placed ``= the lowest mark price
/// - (1 + `callbackRate`)
/// - SELL: the highest mark price after order placed >= `activationPrice`, and the latest mark price = `stopPrice`
/// - SELL: latest price ("`MARK_PRICE`" or "`CONTRACT_PRICE`") = `stopPrice`
///
/// # Arguments
///
/// - `params`: [`NewCmConditionalOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::NewCmConditionalOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#new-cm-conditional-order).
///
pub async fn new_cm_conditional_order(
&self,
params: NewCmConditionalOrderParams,
) -> anyhow::Result<RestApiResponse<models::NewCmConditionalOrderResponse>> {
self.trade_api_client.new_cm_conditional_order(params).await
}
/// New CM Order (TRADE)
///
/// Place new CM order
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Additional mandatory parameters based on `type`:
/// - If `newOrderRespType` is sent as `RESULT` :
/// - `MARKET` order: the final FILLED result of the order will be return directly.
/// - `LIMIT` order with special `timeInForce`: the final status result of the order(FILLED or EXPIRED) will be returned directly.
///
/// # Arguments
///
/// - `params`: [`NewCmOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::NewCmOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#new-cm-order).
///
pub async fn new_cm_order(
&self,
params: NewCmOrderParams,
) -> anyhow::Result<RestApiResponse<models::NewCmOrderResponse>> {
self.trade_api_client.new_cm_order(params).await
}
/// New Margin Order (TRADE)
///
/// New Margin Order
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// # Arguments
///
/// - `params`: [`NewMarginOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::NewMarginOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#new-margin-order).
///
pub async fn new_margin_order(
&self,
params: NewMarginOrderParams,
) -> anyhow::Result<RestApiResponse<models::NewMarginOrderResponse>> {
self.trade_api_client.new_margin_order(params).await
}
/// New UM Algo Order (TRADE)
///
/// Place new UM conditional order
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Algo order with type `STOP`, parameter `timeInForce` can be sent (default `GTC`).
/// - Algo order with type `TAKE_PROFIT`, parameter `timeInForce` can be sent (default `GTC`).
/// - Condition orders will be triggered when price reaches the `triggerPrice`.
/// - `STOP`, `STOP_MARKET`: BUY: latest price >= `triggerPrice`; SELL: latest price <= `triggerPrice`.
/// - `TAKE_PROFIT`, `TAKE_PROFIT_MARKET`: BUY: latest price <= `triggerPrice`; SELL: latest price >= `triggerPrice`.
/// - `TRAILING_STOP_MARKET`: BUY: lowest price after order placed <= `activatePrice`, and latest price >= lowest price * (1 + `callbackRate`); SELL: highest price after order placed >= `activatePrice`, and latest price <= highest price * (1 - `callbackRate`).
/// - `STOP_MARKET`, `TAKE_PROFIT_MARKET` with `closePosition`=`true`: follow the same rules for conditional orders; if triggered, close all current long position (if `SELL`) or current short position (if `BUY`); cannot be used with `quantity` parameter; cannot be used with `reduceOnly` parameter; in Hedge Mode, cannot be used with `BUY` orders in `LONG` position side, and cannot be used with `SELL` orders in `SHORT` position side.
/// - `selfTradePreventionMode` is only effective when `timeInForce` set to `IOC` or `GTC` or `GTD`.
///
/// # Arguments
///
/// - `params`: [`NewUmAlgoOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::NewUmAlgoOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#new-um-algo-order).
///
pub async fn new_um_algo_order(
&self,
params: NewUmAlgoOrderParams,
) -> anyhow::Result<RestApiResponse<models::NewUmAlgoOrderResponse>> {
self.trade_api_client.new_um_algo_order(params).await
}
/// New UM Conditional Order - Deprecated (TRADE)
///
/// Place new UM conditional order
///
/// > **Deprecated:** This endpoint has returned HTTP 404 since 2026-04-28 and is no longer available. Use `POST /papi/v1/um/algo/order` instead. Field changes: `strategyId` -> `algoId`, `newClientStrategyId` -> `clientAlgoId`, `strategyStatus` -> `algoStatus`, `stopPrice` -> `triggerPrice`, `activationPrice` -> `activatePrice` (TRAILING_STOP_MARKET orders). `algoType` is a new fixed-value field (`CONDITIONAL`), not a rename of `strategyType` -- the order type now lives in `type` (request) / `orderType` (response).
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Additional mandatory parameters based on type:
/// - Order with type `STOP/TAKE_PROFIT`, parameter `timeInForce` can be sent ( default `GTC`).
/// - Condition orders will be triggered when:
/// - `STOP`, `STOP_MARKET`:
/// - BUY: "`MARK_PRICE`" >= `stopPrice`
/// - SELL: "`MARK_PRICE`" = `stopPrice`
/// - `TRAILING_STOP_MARKET`:
/// - BUY: the lowest mark price after order placed ``= the lowest mark price
/// - (1 + `callbackRate`)
/// - SELL: the highest mark price after order placed >= `activationPrice`, and the latest mark price = `stopPrice`
/// - SELL: latest price ("`MARK_PRICE`" or "`CONTRACT_PRICE`") = `stopPrice`
/// - `selfTradePreventionMode` is only effective when `timeInForce` set to `IOC` or `GTC` or `GTD`.
/// - In extreme market conditions, timeInForce `GTD` order auto cancel time might be delayed comparing to `goodTillDate`
///
/// # Arguments
///
/// - `params`: [`NewUmConditionalOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::NewUmConditionalOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#new-um-conditional-order).
///
/// # Deprecation
///
/// **Deprecated:** This method may be removed in a future version.
#[deprecated]
pub async fn new_um_conditional_order(
&self,
params: NewUmConditionalOrderParams,
) -> anyhow::Result<RestApiResponse<models::NewUmConditionalOrderResponse>> {
self.trade_api_client.new_um_conditional_order(params).await
}
/// New UM Order (TRADE)
///
/// Place new UM order
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Additional mandatory parameters based on type:
/// - If `newOrderRespType` is sent as `RESULT` :
/// - `MARKET` order: the final FILLED result of the order will be return directly.
/// - `LIMIT` order with special `timeInForce`: the final status result of the order(FILLED or EXPIRED) will be returned directly.
/// - `selfTradePreventionMode` is only effective when `timeInForce` set to `IOC` or `GTC` or `GTD`.
/// - In extreme market conditions, timeInForce `GTD` order auto cancel time might be delayed comparing to `goodTillDate`
///
/// # Arguments
///
/// - `params`: [`NewUmOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::NewUmOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#new-um-order).
///
pub async fn new_um_order(
&self,
params: NewUmOrderParams,
) -> anyhow::Result<RestApiResponse<models::NewUmOrderResponse>> {
self.trade_api_client.new_um_order(params).await
}
/// Query All CM Conditional Orders (`USER_DATA`)
///
/// Query All CM Conditional Orders
///
/// Weight: - 1 for a single `symbol`
/// - 40 when `symbol` is omitted
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - These orders will not be found:
/// - order strategyStatus is `CANCELED` or `EXPIRED`, **AND**
/// - order has NO filled trade, **AND**
/// - created time + 7 days * The query time period must be less than 7 days( default as the recent 7 days).
///
/// # Arguments
///
/// - `params`: [`QueryAllCmConditionalOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryAllCmConditionalOrdersResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-all-cm-conditional-orders).
///
pub async fn query_all_cm_conditional_orders(
&self,
params: QueryAllCmConditionalOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryAllCmConditionalOrdersResponseInner>>>
{
self.trade_api_client
.query_all_cm_conditional_orders(params)
.await
}
/// Query All CM Orders (`USER_DATA`)
///
/// Get all account CM orders; active, canceled, or filled.
///
/// Weight: - 20 with `symbol`
/// - 40 with `pair`
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Either `symbol` or `pair` must be sent.
/// - If `orderId` is set, it will get orders >= that orderId. Otherwise most recent orders are returned.
/// - These orders will not be found:
/// - order status is `CANCELED` or `EXPIRED`, **AND**
/// - order has NO filled trade, **AND**
/// - created time + 3 days < current time
///
/// # Arguments
///
/// - `params`: [`QueryAllCmOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryAllCmOrdersResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-all-cm-orders).
///
pub async fn query_all_cm_orders(
&self,
params: QueryAllCmOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryAllCmOrdersResponseInner>>> {
self.trade_api_client.query_all_cm_orders(params).await
}
/// Query All Current CM Open Conditional Orders (`USER_DATA`)
///
/// Get all open conditional orders on a symbol. **Careful** when accessing this with no symbol.
///
/// Weight: - 1 for a single `symbol`
/// - 40 when `symbol` is omitted
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - If the symbol is not sent, orders for all symbols will be returned in an array.
///
/// # Arguments
///
/// - `params`: [`QueryAllCurrentCmOpenConditionalOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryAllCurrentCmOpenConditionalOrdersResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-all-current-cm-open-conditional-orders).
///
pub async fn query_all_current_cm_open_conditional_orders(
&self,
params: QueryAllCurrentCmOpenConditionalOrdersParams,
) -> anyhow::Result<
RestApiResponse<Vec<models::QueryAllCurrentCmOpenConditionalOrdersResponseInner>>,
> {
self.trade_api_client
.query_all_current_cm_open_conditional_orders(params)
.await
}
/// Query All Current CM Open Orders (`USER_DATA`)
///
/// Get all open orders on a symbol.
///
/// * If the symbol is not sent, orders for all symbols will be returned in an array.
///
/// Weight: - 1 for a single `symbol`
/// - 40 when `symbol` is omitted
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`QueryAllCurrentCmOpenOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryAllCmOrdersResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-all-current-cm-open-orders).
///
pub async fn query_all_current_cm_open_orders(
&self,
params: QueryAllCurrentCmOpenOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryAllCmOrdersResponseInner>>> {
self.trade_api_client
.query_all_current_cm_open_orders(params)
.await
}
/// Query All Current UM Open Algo Orders (`USER_DATA`)
///
/// Get all UM open algo orders on a symbol. If the symbol is not sent, orders for all symbols will be returned.
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Weight: 1 for a single symbol; 40 when the symbol parameter is omitted.
///
/// # Arguments
///
/// - `params`: [`QueryAllCurrentUmOpenAlgoOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryAllCurrentUmOpenAlgoOrdersResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-all-current-um-open-algo-orders).
///
pub async fn query_all_current_um_open_algo_orders(
&self,
params: QueryAllCurrentUmOpenAlgoOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryAllCurrentUmOpenAlgoOrdersResponseInner>>>
{
self.trade_api_client
.query_all_current_um_open_algo_orders(params)
.await
}
/// Query All Current UM Open Conditional Orders - Deprecated (`USER_DATA`)
///
/// Get all open conditional orders on a symbol.
///
/// > **Deprecated:** This endpoint has returned HTTP 404 since 2026-04-28 and is no longer available. Use `GET /papi/v1/um/algo/openAlgoOrders` instead. Field changes: `strategyId` -> `algoId`, `newClientStrategyId` -> `clientAlgoId`, `strategyStatus` -> `algoStatus`, `stopPrice` -> `triggerPrice`, `activationPrice` -> `activatePrice` (TRAILING_STOP_MARKET orders). `algoType` is a new fixed-value field (`CONDITIONAL`), not a rename of `strategyType` -- the order type now lives in `type` (request) / `orderType` (response).
///
/// Weight: - 1 for a single `symbol`
/// - 40 when `symbol` is omitted
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - If `symbol` is not provided, conditional open orders for all symbols are returned.
///
/// # Arguments
///
/// - `params`: [`QueryAllCurrentUmOpenConditionalOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryAllCurrentUmOpenConditionalOrdersResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-all-current-um-open-conditional-orders).
///
/// # Deprecation
///
/// **Deprecated:** This method may be removed in a future version.
#[deprecated]
pub async fn query_all_current_um_open_conditional_orders(
&self,
params: QueryAllCurrentUmOpenConditionalOrdersParams,
) -> anyhow::Result<
RestApiResponse<Vec<models::QueryAllCurrentUmOpenConditionalOrdersResponseInner>>,
> {
self.trade_api_client
.query_all_current_um_open_conditional_orders(params)
.await
}
/// Query All Current UM Open Orders (`USER_DATA`)
///
/// Get all open orders on a symbol.
///
/// Weight: - 1 for a single `symbol`
/// - 40 when `symbol` is omitted
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - If the symbol is not sent, orders for all symbols will be returned in an array.
///
/// # Arguments
///
/// - `params`: [`QueryAllCurrentUmOpenOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryAllCurrentUmOpenOrdersResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-all-current-um-open-orders).
///
pub async fn query_all_current_um_open_orders(
&self,
params: QueryAllCurrentUmOpenOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryAllCurrentUmOpenOrdersResponseInner>>>
{
self.trade_api_client
.query_all_current_um_open_orders(params)
.await
}
/// Query All Margin Account Orders (`USER_DATA`)
///
/// Query All Margin Account Orders
///
/// Weight(IP): 100
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - If `orderId` is set, returns orders with id >= `orderId`; otherwise returns recent order history.
/// - For some historical orders, `cummulativeQuoteQty < 0` means the data is unavailable at this time.
///
/// # Arguments
///
/// - `params`: [`QueryAllMarginAccountOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryAllMarginAccountOrdersResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-all-margin-account-orders).
///
pub async fn query_all_margin_account_orders(
&self,
params: QueryAllMarginAccountOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryAllMarginAccountOrdersResponseInner>>>
{
self.trade_api_client
.query_all_margin_account_orders(params)
.await
}
/// Query All UM Conditional Orders - Deprecated (`USER_DATA`)
///
/// Query All UM Conditional Orders
///
/// > **Deprecated:** This endpoint has returned HTTP 404 since 2026-04-28 and is no longer available. Use `GET /papi/v1/um/algo/allAlgoOrders` instead. Field changes: `strategyId` -> `algoId`, `newClientStrategyId` -> `clientAlgoId`, `strategyStatus` -> `algoStatus`, `stopPrice` -> `triggerPrice`, `activationPrice` -> `activatePrice` (TRAILING_STOP_MARKET orders). `algoType` is a new fixed-value field (`CONDITIONAL`), not a rename of `strategyType` -- the order type now lives in `type` (request) / `orderType` (response).
///
/// Weight: - 1 for a single `symbol`
/// - 40 when `symbol` is omitted
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - These orders will not be found:
/// - order strategyStatus is `CANCELED` or `EXPIRED`, **AND**
/// - order has NO filled trade, **AND**
/// - created time + 7 days * The query time period must be less than 7 days( default as the recent 7 days).
///
/// # Arguments
///
/// - `params`: [`QueryAllUmConditionalOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryAllUmConditionalOrdersResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-all-um-conditional-orders).
///
/// # Deprecation
///
/// **Deprecated:** This method may be removed in a future version.
#[deprecated]
pub async fn query_all_um_conditional_orders(
&self,
params: QueryAllUmConditionalOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryAllUmConditionalOrdersResponseInner>>>
{
self.trade_api_client
.query_all_um_conditional_orders(params)
.await
}
/// Query All UM Orders (`USER_DATA`)
///
/// Get all account UM orders; active, canceled, or filled.
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - If `orderId` is set, it will get orders >= that orderId. Otherwise most recent orders are returned.
/// - The query time period must be less then 7 days( default as the recent 7 days).
///
/// # Arguments
///
/// - `params`: [`QueryAllUmOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryAllCurrentUmOpenOrdersResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-all-um-orders).
///
pub async fn query_all_um_orders(
&self,
params: QueryAllUmOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryAllCurrentUmOpenOrdersResponseInner>>>
{
self.trade_api_client.query_all_um_orders(params).await
}
/// Query CM Conditional Order History (`USER_DATA`)
///
/// Query CM Conditional Order History
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Either `strategyId` or `newClientStrategyId` must be sent.
/// - `NEW` orders will not be found.
/// - These orders will not be found:
/// - order status is `CANCELED` or `EXPIRED`, **AND**
/// - order has NO filled trade, **AND**
/// - created time + 7 days < current time
///
/// # Arguments
///
/// - `params`: [`QueryCmConditionalOrderHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryCmConditionalOrderHistoryResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-cm-conditional-order-history).
///
pub async fn query_cm_conditional_order_history(
&self,
params: QueryCmConditionalOrderHistoryParams,
) -> anyhow::Result<RestApiResponse<models::QueryCmConditionalOrderHistoryResponse>> {
self.trade_api_client
.query_cm_conditional_order_history(params)
.await
}
/// Query CM Modify Order History (TRADE)
///
/// Get order modification history
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Either `orderId` or `origClientOrderId` must be sent, and the `orderId` will prevail if both are sent.
///
/// # Arguments
///
/// - `params`: [`QueryCmModifyOrderHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryCmModifyOrderHistoryResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-cm-modify-order-history).
///
pub async fn query_cm_modify_order_history(
&self,
params: QueryCmModifyOrderHistoryParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryCmModifyOrderHistoryResponseInner>>> {
self.trade_api_client
.query_cm_modify_order_history(params)
.await
}
/// Query CM Order (`USER_DATA`)
///
/// Check an CM order's status.
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Either `orderId` or `origClientOrderId` must be sent.
/// - These orders will not be found:
/// - order status is `CANCELED` or `EXPIRED`, **AND**
/// - order has NO filled trade, **AND**
/// - created time + 3 days < current time
///
/// # Arguments
///
/// - `params`: [`QueryCmOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryCmOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-cm-order).
///
pub async fn query_cm_order(
&self,
params: QueryCmOrderParams,
) -> anyhow::Result<RestApiResponse<models::QueryCmOrderResponse>> {
self.trade_api_client.query_cm_order(params).await
}
/// Query Current CM Open Conditional Order (`USER_DATA`)
///
/// Query Current CM Open Conditional Order
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Either `strategyId` or `newClientStrategyId` must be sent.
/// - If the queried order has been triggered, cancelled or expired, the error message "Order does not exist" will be returned.
///
/// # Arguments
///
/// - `params`: [`QueryCurrentCmOpenConditionalOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryCurrentCmOpenConditionalOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-current-cm-open-conditional-order).
///
pub async fn query_current_cm_open_conditional_order(
&self,
params: QueryCurrentCmOpenConditionalOrderParams,
) -> anyhow::Result<RestApiResponse<models::QueryCurrentCmOpenConditionalOrderResponse>> {
self.trade_api_client
.query_current_cm_open_conditional_order(params)
.await
}
/// Query Current CM Open Order (`USER_DATA`)
///
/// Query current CM open order
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Either `orderId` or `origClientOrderId` must be sent.
/// - If the queried order has been filled or cancelled, the error message "Order does not exist" will be returned.
///
/// # Arguments
///
/// - `params`: [`QueryCurrentCmOpenOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryAllCmOrdersResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-current-cm-open-order).
///
pub async fn query_current_cm_open_order(
&self,
params: QueryCurrentCmOpenOrderParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryAllCmOrdersResponseInner>>> {
self.trade_api_client
.query_current_cm_open_order(params)
.await
}
/// Query Current Margin Open Order (`USER_DATA`)
///
/// Query Current Margin Open Order
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - If `symbol` is not sent, order records for all symbols are returned.
/// - When returning all symbols, the request count charged to the rate limiter equals the number of symbols currently trading on the exchange.
///
/// # Arguments
///
/// - `params`: [`QueryCurrentMarginOpenOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryCurrentMarginOpenOrderResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-current-margin-open-order).
///
pub async fn query_current_margin_open_order(
&self,
params: QueryCurrentMarginOpenOrderParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryCurrentMarginOpenOrderResponseInner>>>
{
self.trade_api_client
.query_current_margin_open_order(params)
.await
}
/// Query Current UM Open Algo Order (`USER_DATA`)
///
/// Check an UM algo order's status. Orders will not be found if: status is CANCELED/EXPIRED with no fills and created 3+ days ago; or created 90+ days ago.
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Either `algoId` or `clientAlgoId` must be sent. `algoId` is self-increment for each specific `symbol`.
///
/// # Arguments
///
/// - `params`: [`QueryCurrentUmOpenAlgoOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryCurrentUmOpenAlgoOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-current-um-open-algo-order).
///
pub async fn query_current_um_open_algo_order(
&self,
params: QueryCurrentUmOpenAlgoOrderParams,
) -> anyhow::Result<RestApiResponse<models::QueryCurrentUmOpenAlgoOrderResponse>> {
self.trade_api_client
.query_current_um_open_algo_order(params)
.await
}
/// Query Current UM Open Conditional Order - Deprecated (`USER_DATA`)
///
/// Query Current UM Open Conditional Order
///
/// > **Deprecated:** This endpoint has returned HTTP 404 since 2026-04-28 and is no longer available. Use `GET /papi/v1/um/algo/algoOrder` instead. Field changes: `strategyId` -> `algoId`, `newClientStrategyId` -> `clientAlgoId`, `strategyStatus` -> `algoStatus`, `stopPrice` -> `triggerPrice`, `activationPrice` -> `activatePrice` (TRAILING_STOP_MARKET orders). `algoType` is a new fixed-value field (`CONDITIONAL`), not a rename of `strategyType` -- the order type now lives in `type` (request) / `orderType` (response).
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Either `strategyId` or `newClientStrategyId` must be sent.
/// - If the queried order has been `CANCELED`, `TRIGGERED` or `EXPIRED`, the error message "Order does not exist" will be returned.
///
/// # Arguments
///
/// - `params`: [`QueryCurrentUmOpenConditionalOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryCurrentUmOpenConditionalOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-current-um-open-conditional-order).
///
/// # Deprecation
///
/// **Deprecated:** This method may be removed in a future version.
#[deprecated]
pub async fn query_current_um_open_conditional_order(
&self,
params: QueryCurrentUmOpenConditionalOrderParams,
) -> anyhow::Result<RestApiResponse<models::QueryCurrentUmOpenConditionalOrderResponse>> {
self.trade_api_client
.query_current_um_open_conditional_order(params)
.await
}
/// Query Current UM Open Order (`USER_DATA`)
///
/// Query current UM open order
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Either `orderId` or `origClientOrderId` must be sent.
/// - If the queried order has been filled or cancelled, the error message "Order does not exist" will be returned.
///
/// # Arguments
///
/// - `params`: [`QueryCurrentUmOpenOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryCurrentUmOpenOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-current-um-open-order).
///
pub async fn query_current_um_open_order(
&self,
params: QueryCurrentUmOpenOrderParams,
) -> anyhow::Result<RestApiResponse<models::QueryCurrentUmOpenOrderResponse>> {
self.trade_api_client
.query_current_um_open_order(params)
.await
}
/// Query Margin Account Order (`USER_DATA`)
///
/// Query Margin Account Order
///
/// Weight(IP): 10
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Either `orderId` or `origClientOrderId` must be sent.
/// - For some historical orders, `cummulativeQuoteQty < 0` means the data is unavailable at this time.
///
/// # Arguments
///
/// - `params`: [`QueryMarginAccountOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryMarginAccountOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-margin-account-order).
///
pub async fn query_margin_account_order(
&self,
params: QueryMarginAccountOrderParams,
) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountOrderResponse>> {
self.trade_api_client
.query_margin_account_order(params)
.await
}
/// Query Margin Account's all OCO (`USER_DATA`)
///
/// Query all OCO for a specific margin account based on provided optional parameters
///
/// Weight(IP): 100
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`QueryMarginAccountsAllOcoParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryMarginAccountsAllOcoResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-margin-accounts-all-oco).
///
pub async fn query_margin_accounts_all_oco(
&self,
params: QueryMarginAccountsAllOcoParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsAllOcoResponseInner>>> {
self.trade_api_client
.query_margin_accounts_all_oco(params)
.await
}
/// Query Margin Account's OCO (`USER_DATA`)
///
/// Retrieves a specific OCO based on provided optional parameters
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`QueryMarginAccountsOcoParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryMarginAccountsOcoResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-margin-accounts-oco).
///
pub async fn query_margin_accounts_oco(
&self,
params: QueryMarginAccountsOcoParams,
) -> anyhow::Result<RestApiResponse<models::QueryMarginAccountsOcoResponse>> {
self.trade_api_client
.query_margin_accounts_oco(params)
.await
}
/// Query Margin Account's Open OCO (`USER_DATA`)
///
/// Query Margin Account's Open OCO
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`QueryMarginAccountsOpenOcoParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryMarginAccountsOpenOcoResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-margin-accounts-open-oco).
///
pub async fn query_margin_accounts_open_oco(
&self,
params: QueryMarginAccountsOpenOcoParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryMarginAccountsOpenOcoResponseInner>>> {
self.trade_api_client
.query_margin_accounts_open_oco(params)
.await
}
/// Query UM Algo Order History (`USER_DATA`)
///
/// Get all algo orders: ACTIVE, CANCELED, TRIGGERED or FINISHED.
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - If `algoId` is set, it will get orders >= that `algoId`. Otherwise most recent orders are returned.
/// - The query time period must be less than 7 days (default as the recent 7 days).
///
/// # Arguments
///
/// - `params`: [`QueryUmAlgoOrderHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryUmAlgoOrderHistoryResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-um-algo-order-history).
///
pub async fn query_um_algo_order_history(
&self,
params: QueryUmAlgoOrderHistoryParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryUmAlgoOrderHistoryResponseInner>>> {
self.trade_api_client
.query_um_algo_order_history(params)
.await
}
/// Query UM Conditional Order History - Deprecated (`USER_DATA`)
///
/// Query UM Conditional Order History
///
/// > **Deprecated:** This endpoint has returned HTTP 404 since 2026-04-28 and is no longer available. Use `GET /papi/v1/um/algo/allAlgoOrders` instead. Field changes: `strategyId` -> `algoId`, `newClientStrategyId` -> `clientAlgoId`, `strategyStatus` -> `algoStatus`, `stopPrice` -> `triggerPrice`, `activationPrice` -> `activatePrice` (TRAILING_STOP_MARKET orders). `algoType` is a new fixed-value field (`CONDITIONAL`), not a rename of `strategyType` -- the order type now lives in `type` (request) / `orderType` (response).
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - Either `strategyId` or `newClientStrategyId` must be sent.
/// - `NEW` orders will not be found.
/// - These orders will not be found:
/// - order status is `CANCELED` or `EXPIRED`, **AND**
/// - order has NO filled trade, **AND**
/// - created time + 7 days < current time
///
/// # Arguments
///
/// - `params`: [`QueryUmConditionalOrderHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryUmConditionalOrderHistoryResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-um-conditional-order-history).
///
/// # Deprecation
///
/// **Deprecated:** This method may be removed in a future version.
#[deprecated]
pub async fn query_um_conditional_order_history(
&self,
params: QueryUmConditionalOrderHistoryParams,
) -> anyhow::Result<RestApiResponse<models::QueryUmConditionalOrderHistoryResponse>> {
self.trade_api_client
.query_um_conditional_order_history(params)
.await
}
/// Query UM Modify Order History (TRADE)
///
/// Get order modification history
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - Either `orderId` or `origClientOrderId` must be sent, and the `orderId` will prevail if both are sent.
///
/// # Arguments
///
/// - `params`: [`QueryUmModifyOrderHistoryParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryUmModifyOrderHistoryResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-um-modify-order-history).
///
pub async fn query_um_modify_order_history(
&self,
params: QueryUmModifyOrderHistoryParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryUmModifyOrderHistoryResponseInner>>> {
self.trade_api_client
.query_um_modify_order_history(params)
.await
}
/// Query UM Order (`USER_DATA`)
///
/// Check an UM order's status.
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - These orders will not be found:
/// - Either `orderId` or `origClientOrderId` must be sent.
/// - order status is `CANCELED` or `EXPIRED`, **AND**
/// - order has NO filled trade, **AND**
/// - created time + 3 days < current time
///
/// # Arguments
///
/// - `params`: [`QueryUmOrderParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryUmOrderResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-um-order).
///
pub async fn query_um_order(
&self,
params: QueryUmOrderParams,
) -> anyhow::Result<RestApiResponse<models::QueryUmOrderResponse>> {
self.trade_api_client.query_um_order(params).await
}
/// Query User's CM Force Orders (`USER_DATA`)
///
/// Query User's CM Force Orders
///
/// Weight: - 20 with `symbol`
/// - 50 without `symbol`
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - If "autoCloseType" is not sent, orders with both of the types will be returned
/// - If "startTime" is not sent, data within 7 days before "endTime" can be queried
///
/// # Arguments
///
/// - `params`: [`QueryUsersCmForceOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryUsersCmForceOrdersResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-users-cm-force-orders).
///
pub async fn query_users_cm_force_orders(
&self,
params: QueryUsersCmForceOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryUsersCmForceOrdersResponseInner>>> {
self.trade_api_client
.query_users_cm_force_orders(params)
.await
}
/// Query User's Margin Force Orders (`USER_DATA`)
///
/// Query user's margin force orders
///
/// Weight(IP): 1
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`QueryUsersMarginForceOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::QueryUsersMarginForceOrdersResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-users-margin-force-orders).
///
pub async fn query_users_margin_force_orders(
&self,
params: QueryUsersMarginForceOrdersParams,
) -> anyhow::Result<RestApiResponse<models::QueryUsersMarginForceOrdersResponse>> {
self.trade_api_client
.query_users_margin_force_orders(params)
.await
}
/// Query User's UM Force Orders (`USER_DATA`)
///
/// Query User's UM Force Orders
///
/// Weight: - 20 with `symbol`
/// - 50 without `symbol`
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - If `autoCloseType` is not sent, orders with both of the types will be returned
/// - If `startTime` is not sent, data within 7 days before `endTime` can be queried
///
/// # Arguments
///
/// - `params`: [`QueryUsersUmForceOrdersParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::QueryUsersUmForceOrdersResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#query-users-um-force-orders).
///
pub async fn query_users_um_force_orders(
&self,
params: QueryUsersUmForceOrdersParams,
) -> anyhow::Result<RestApiResponse<Vec<models::QueryUsersUmForceOrdersResponseInner>>> {
self.trade_api_client
.query_users_um_force_orders(params)
.await
}
/// Toggle BNB Burn On UM Futures Trade (TRADE)
///
/// Change user's BNB Fee Discount for UM Futures (Fee Discount On or Fee Discount Off ) on ***EVERY symbol***
///
/// Weight(IP): 1
///
/// Security Type: TRADE
///
/// Notes:
/// - The BNB would not be collected from UM-PM account to the Portfolio Margin account.
///
/// # Arguments
///
/// - `params`: [`ToggleBnbBurnOnUmFuturesTradeParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::ToggleBnbBurnOnUmFuturesTradeResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#toggle-bnb-burn-on-um-futures-trade).
///
pub async fn toggle_bnb_burn_on_um_futures_trade(
&self,
params: ToggleBnbBurnOnUmFuturesTradeParams,
) -> anyhow::Result<RestApiResponse<models::ToggleBnbBurnOnUmFuturesTradeResponse>> {
self.trade_api_client
.toggle_bnb_burn_on_um_futures_trade(params)
.await
}
/// UM Account Trade List (`USER_DATA`)
///
/// Get trades for a specific account and UM symbol.
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// Notes:
/// - If `startTime` and `endTime` are both not sent, then the last '7 days' data will be returned.
/// - The time between `startTime` and `endTime` cannot be longer than 7 days.
/// - The parameter `fromId` cannot be sent with `startTime` or `endTime`.
///
/// # Arguments
///
/// - `params`: [`UmAccountTradeListParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::UmAccountTradeListResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#um-account-trade-list).
///
pub async fn um_account_trade_list(
&self,
params: UmAccountTradeListParams,
) -> anyhow::Result<RestApiResponse<Vec<models::UmAccountTradeListResponseInner>>> {
self.trade_api_client.um_account_trade_list(params).await
}
/// UM Position ADL Quantile Estimation (`USER_DATA`)
///
/// Query UM Position ADL Quantile Estimation
///
/// * Values update every 30s.
/// * Values 0, 1, 2, 3, 4 shows the queue position and possibility of ADL from low to high.
/// * For positions of the symbol are in One-way Mode or isolated margined in Hedge Mode, "LONG", "SHORT", and "BOTH" will be returned to show the positions' adl quantiles of different position sides.
/// * If the positions of the symbol are crossed margined in Hedge Mode:
/// * "HEDGE" as a sign will be returned instead of "BOTH";
/// * A same value caculated on unrealized pnls on long and short sides' positions will be shown for "LONG" and "SHORT" when there are positions in both of long and short sides.
///
/// Weight(IP): 5
///
/// Security Type: `USER_DATA`
///
/// # Arguments
///
/// - `params`: [`UmPositionAdlQuantileEstimationParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Vec<models::UmPositionAdlQuantileEstimationResponseInner>>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/trade#um-position-adl-quantile-estimation).
///
pub async fn um_position_adl_quantile_estimation(
&self,
params: UmPositionAdlQuantileEstimationParams,
) -> anyhow::Result<RestApiResponse<Vec<models::UmPositionAdlQuantileEstimationResponseInner>>>
{
self.trade_api_client
.um_position_adl_quantile_estimation(params)
.await
}
/// Close User Data Stream (`USER_STREAM`)
///
/// Close out a user data stream.
///
/// Weight(IP): 1
///
/// Security Type: `USER_STREAM`
///
/// # Arguments
///
/// - `params`: [`CloseUserDataStreamParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Value>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/user-data-streams#close-user-data-stream).
///
pub async fn close_user_data_stream(&self) -> anyhow::Result<RestApiResponse<Value>> {
self.user_data_streams_api_client
.close_user_data_stream()
.await
}
/// Keepalive User Data Stream (`USER_STREAM`)
///
/// Keepalive a user data stream to prevent a time out. User data streams
/// will close after 60 minutes. It's recommended to send a ping about every
/// 60 minutes.
///
/// Weight(IP): 1
///
/// Security Type: `USER_STREAM`
///
/// # Arguments
///
/// - `params`: [`KeepaliveUserDataStreamParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<Value>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/user-data-streams#keepalive-user-data-stream).
///
pub async fn keepalive_user_data_stream(&self) -> anyhow::Result<RestApiResponse<Value>> {
self.user_data_streams_api_client
.keepalive_user_data_stream()
.await
}
/// Start User Data Stream (`USER_STREAM`)
///
/// Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent. If the account has an active `listenKey`, that `listenKey` will be returned and its validity will be extended for 60 minutes.
///
/// Weight(IP): 1
///
/// Security Type: `USER_STREAM`
///
/// # Arguments
///
/// - `params`: [`StartUserDataStreamParams`]
/// The parameters for this operation.
///
/// # Returns
///
/// [`RestApiResponse<models::StartUserDataStreamResponse>`] on success.
///
/// # Errors
///
/// This function will return an [`anyhow::Error`] if:
/// - the HTTP request fails
/// - any parameter is invalid
/// - the response cannot be parsed
/// - or one of the following occurs:
/// - `RequiredError`
/// - `ConnectorClientError`
/// - `UnauthorizedError`
/// - `ForbiddenError`
/// - `TooManyRequestsError`
/// - `RateLimitBanError`
/// - `ServerError`
/// - `NotFoundError`
/// - `NetworkError`
/// - `BadRequestError`
///
///
/// For full API details, see the [Binance API Documentation](https://developers.binance.com/en/docs/catalog/advanced-trading-derivatives-trading-portfolio-margin/api/rest-api/user-data-streams#start-user-data-stream).
///
pub async fn start_user_data_stream(
&self,
) -> anyhow::Result<RestApiResponse<models::StartUserDataStreamResponse>> {
self.user_data_streams_api_client
.start_user_data_stream()
.await
}
}