/*
 * Binance Derivatives Trading COIN Futures REST API
 *
 * OpenAPI Specification for the Binance Derivatives Trading COIN Futures REST API
 *
 * 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,
    portfolio_margin_endpoints_api_client: PortfolioMarginEndpointsApiClient,
    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 portfolio_margin_endpoints_api_client =
            PortfolioMarginEndpointsApiClient::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,
            portfolio_margin_endpoints_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 Information (`USER_DATA`)
    ///
    /// Get current account information.
    ///
    /// * for One-way Mode user, the "positions" will only show the "BOTH" positions
    /// * for Hedge Mode user, the "positions" will show "BOTH", "LONG", and "SHORT" positions.
    ///
    /// Weight: 5
    ///
    /// # 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/docs/derivatives/coin-margined-futures/account/rest-api/Account-Information).
    ///
    pub async fn account_information(
        &self,
        params: AccountInformationParams,
    ) -> anyhow::Result<RestApiResponse<models::AccountInformationResponse>> {
        self.account_api_client.account_information(params).await
    }

    /// Futures Account Balance (`USER_DATA`)
    ///
    /// Check futures account balance
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`FuturesAccountBalanceParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::FuturesAccountBalanceResponseInner>>`] 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/docs/derivatives/coin-margined-futures/account/rest-api/Futures-Account-Balance).
    ///
    pub async fn futures_account_balance(
        &self,
        params: FuturesAccountBalanceParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::FuturesAccountBalanceResponseInner>>> {
        self.account_api_client
            .futures_account_balance(params)
            .await
    }

    /// Get Current Position `Mode(USER_DATA)`
    ///
    /// Get user's position mode (Hedge Mode or One-way Mode ) on ***EVERY symbol***
    ///
    /// Weight: 30
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetCurrentPositionModeParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetCurrentPositionModeResponse>`] 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/docs/derivatives/coin-margined-futures/account/rest-api/Get-Current-Position-Mode).
    ///
    pub async fn get_current_position_mode(
        &self,
        params: GetCurrentPositionModeParams,
    ) -> anyhow::Result<RestApiResponse<models::GetCurrentPositionModeResponse>> {
        self.account_api_client
            .get_current_position_mode(params)
            .await
    }

    /// Get Download Id For Futures Order History (`USER_DATA`)
    ///
    /// Get Download Id For Futures Order History
    ///
    /// * 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
    ///
    /// Weight: 5
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetDownloadIdForFuturesOrderHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetDownloadIdForFuturesOrderHistoryResponse>`] 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/docs/derivatives/coin-margined-futures/account/rest-api/Get-Download-Id-For-Futures-Order-History).
    ///
    pub async fn get_download_id_for_futures_order_history(
        &self,
        params: GetDownloadIdForFuturesOrderHistoryParams,
    ) -> anyhow::Result<RestApiResponse<models::GetDownloadIdForFuturesOrderHistoryResponse>> {
        self.account_api_client
            .get_download_id_for_futures_order_history(params)
            .await
    }

    /// Get Download Id For Futures Trade History (`USER_DATA`)
    ///
    /// Get download id for futures trade history
    ///
    /// * 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
    ///
    /// Weight: 5
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetDownloadIdForFuturesTradeHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetDownloadIdForFuturesTradeHistoryResponse>`] 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/docs/derivatives/coin-margined-futures/account/rest-api/Get-Download-Id-For-Futures-Trade-History).
    ///
    pub async fn get_download_id_for_futures_trade_history(
        &self,
        params: GetDownloadIdForFuturesTradeHistoryParams,
    ) -> anyhow::Result<RestApiResponse<models::GetDownloadIdForFuturesTradeHistoryResponse>> {
        self.account_api_client
            .get_download_id_for_futures_trade_history(params)
            .await
    }

    /// Get Download Id For Futures Transaction `History(USER_DATA)`
    ///
    /// Get download id for futures transaction history
    ///
    /// * 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
    ///
    /// Weight: 5
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetDownloadIdForFuturesTransactionHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetDownloadIdForFuturesTransactionHistoryResponse>`] 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/docs/derivatives/coin-margined-futures/account/rest-api/Get-Download-Id-For-Futures-Transaction-History).
    ///
    pub async fn get_download_id_for_futures_transaction_history(
        &self,
        params: GetDownloadIdForFuturesTransactionHistoryParams,
    ) -> anyhow::Result<RestApiResponse<models::GetDownloadIdForFuturesTransactionHistoryResponse>>
    {
        self.account_api_client
            .get_download_id_for_futures_transaction_history(params)
            .await
    }

    /// Get Futures Order History Download Link by Id (`USER_DATA`)
    ///
    /// Get futures order history download link by Id
    ///
    /// * Download link expiration: 24h
    ///
    /// Weight: 5
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetFuturesOrderHistoryDownloadLinkByIdParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetFuturesOrderHistoryDownloadLinkByIdResponse>`] 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/docs/derivatives/coin-margined-futures/account/rest-api/Get-Futures-Order-History-Download-Link-by-Id).
    ///
    pub async fn get_futures_order_history_download_link_by_id(
        &self,
        params: GetFuturesOrderHistoryDownloadLinkByIdParams,
    ) -> anyhow::Result<RestApiResponse<models::GetFuturesOrderHistoryDownloadLinkByIdResponse>>
    {
        self.account_api_client
            .get_futures_order_history_download_link_by_id(params)
            .await
    }

    /// Get Futures Trade Download Link by `Id(USER_DATA)`
    ///
    /// Get futures trade download link by Id
    ///
    /// * Download link expiration: 24h
    ///
    /// Weight: 5
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetFuturesTradeDownloadLinkByIdParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetFuturesTradeDownloadLinkByIdResponse>`] 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/docs/derivatives/coin-margined-futures/account/rest-api/Get-Futures-Trade-Download-Link-by-Id).
    ///
    pub async fn get_futures_trade_download_link_by_id(
        &self,
        params: GetFuturesTradeDownloadLinkByIdParams,
    ) -> anyhow::Result<RestApiResponse<models::GetFuturesTradeDownloadLinkByIdResponse>> {
        self.account_api_client
            .get_futures_trade_download_link_by_id(params)
            .await
    }

    /// Get Futures Transaction History Download Link by Id (`USER_DATA`)
    ///
    /// Get futures transaction history download link by Id
    ///
    /// * Download link expiration: 24h
    ///
    /// Weight: 5
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetFuturesTransactionHistoryDownloadLinkByIdParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetFuturesTransactionHistoryDownloadLinkByIdResponse>`] 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/docs/derivatives/coin-margined-futures/account/rest-api/Get-Futures-Transaction-History-Download-Link-by-Id).
    ///
    pub async fn get_futures_transaction_history_download_link_by_id(
        &self,
        params: GetFuturesTransactionHistoryDownloadLinkByIdParams,
    ) -> anyhow::Result<RestApiResponse<models::GetFuturesTransactionHistoryDownloadLinkByIdResponse>>
    {
        self.account_api_client
            .get_futures_transaction_history_download_link_by_id(params)
            .await
    }

    /// Get Income `History(USER_DATA)`
    ///
    /// Get income history
    ///
    /// * If `incomeType ` is not sent, all kinds of flow will be returned
    /// * "trandId" is unique in the same "incomeType" for a user
    /// * The time between `startTime` and `endTime` can not be longer than 1 year
    ///
    /// Weight: 20
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetIncomeHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::GetIncomeHistoryResponseInner>>`] 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/docs/derivatives/coin-margined-futures/account/rest-api/Get-Income-History).
    ///
    pub async fn get_income_history(
        &self,
        params: GetIncomeHistoryParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::GetIncomeHistoryResponseInner>>> {
        self.account_api_client.get_income_history(params).await
    }

    /// Notional Bracket for `Pair(USER_DATA)`
    ///
    /// **Not recommended to continue using this v1 endpoint**
    ///
    /// Get the pair's default notional bracket list, may return ambiguous values when there have been multiple different `symbol` brackets under the `pair`, suggest using the following `GET /dapi/v2/leverageBracket` query instead to get the specific `symbol` notional bracket list.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`NotionalBracketForPairParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::NotionalBracketForPairResponseInner>>`] 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/docs/derivatives/coin-margined-futures/account/rest-api/Notional-Bracket-for-Pair).
    ///
    pub async fn notional_bracket_for_pair(
        &self,
        params: NotionalBracketForPairParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::NotionalBracketForPairResponseInner>>> {
        self.account_api_client
            .notional_bracket_for_pair(params)
            .await
    }

    /// Notional Bracket for `Symbol(USER_DATA)`
    ///
    /// Get the symbol's notional bracket list.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`NotionalBracketForSymbolParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::NotionalBracketForSymbolResponseInner>>`] 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/docs/derivatives/coin-margined-futures/account/rest-api/Notional-Bracket-for-Symbol).
    ///
    pub async fn notional_bracket_for_symbol(
        &self,
        params: NotionalBracketForSymbolParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::NotionalBracketForSymbolResponseInner>>> {
        self.account_api_client
            .notional_bracket_for_symbol(params)
            .await
    }

    /// User Commission Rate (`USER_DATA`)
    ///
    /// Query user commission rate
    ///
    /// Weight: 20
    ///
    /// # Arguments
    ///
    /// - `params`: [`UserCommissionRateParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::UserCommissionRateResponse>`] 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/docs/derivatives/coin-margined-futures/account/rest-api/User-Commission-Rate).
    ///
    pub async fn user_commission_rate(
        &self,
        params: UserCommissionRateParams,
    ) -> anyhow::Result<RestApiResponse<models::UserCommissionRateResponse>> {
        self.account_api_client.user_commission_rate(params).await
    }

    /// Basis
    ///
    /// Query basis
    ///
    /// * If startTime and endTime are not sent, the most recent data is returned.
    /// * Only the data of the latest 30 days is available.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`BasisParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::BasisResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Basis).
    ///
    pub async fn basis(
        &self,
        params: BasisParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::BasisResponseInner>>> {
        self.market_data_api_client.basis(params).await
    }

    /// Check Server time
    ///
    /// Test connectivity to the Rest API and get the current server time.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`CheckServerTimeParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::CheckServerTimeResponse>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Check-Server-time).
    ///
    pub async fn check_server_time(
        &self,
    ) -> anyhow::Result<RestApiResponse<models::CheckServerTimeResponse>> {
        self.market_data_api_client.check_server_time().await
    }

    /// Compressed/Aggregate Trades List
    ///
    /// Get compressed, aggregate trades. Market trades that fill in 100ms with the same price and the same taking side will have the quantity aggregated.
    ///
    /// * support querying futures trade histories that are not older than one year
    /// * If both `startTime` and `endTime` are sent, time between `startTime` and `endTime` must be less than 1 hour.
    /// * If `fromId`, `startTime`, and `endTime` are not sent, the most recent aggregate trades will be returned.
    /// * Only market trades will be aggregated and returned, which means the insurance fund trades and ADL trades won't be aggregated.
    /// * Sending both `startTime`/`endTime` and `fromId` might cause response timeout, please send either `fromId` or `startTime`/`endTime`
    ///
    /// Weight: 20
    ///
    /// # Arguments
    ///
    /// - `params`: [`CompressedAggregateTradesListParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::CompressedAggregateTradesListResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Compressed-Aggregate-Trades-List).
    ///
    pub async fn compressed_aggregate_trades_list(
        &self,
        params: CompressedAggregateTradesListParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::CompressedAggregateTradesListResponseInner>>>
    {
        self.market_data_api_client
            .compressed_aggregate_trades_list(params)
            .await
    }

    /// Continuous Contract Kline/Candlestick Data
    ///
    /// Kline/candlestick bars for a specific contract type.
    /// Klines are uniquely identified by their open time.
    ///
    /// * Contract type:
    /// * PERPETUAL
    /// * `CURRENT_QUARTER`
    /// * `NEXT_QUARTER`
    ///
    ///
    /// 1000 | 10
    /// * The difference between `startTime` and `endTime` can only be up to 200 days
    /// * Between `startTime` and `endTime`, the most recent `limit` data from `endTime` will be returned:
    /// * If `startTime` and `endTime` are not sent, current timestamp will be set as `endTime`, and the most recent data will be returned.
    /// * If `startTime` is sent only, the timestamp of 200 days after `startTime` will be set as `endTime`(up to the current time)
    /// * If `endTime` is sent only, the timestamp of 200 days before `endTime` will be set as `startTime`
    ///
    /// Weight: based on parameter LIMIT
    /// LIMIT | weight
    /// ---|---
    /// [1,100) | 1
    /// [100, 500) | 2
    /// [500, 1000] | 5
    /// > 1000 | 10
    ///
    /// # Arguments
    ///
    /// - `params`: [`ContinuousContractKlineCandlestickDataParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<Vec<models::ContinuousContractKlineCandlestickDataResponseItemInner>>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Continuous-Contract-Kline-Candlestick-Data).
    ///
    pub async fn continuous_contract_kline_candlestick_data(
        &self,
        params: ContinuousContractKlineCandlestickDataParams,
    ) -> anyhow::Result<
        RestApiResponse<Vec<Vec<models::ContinuousContractKlineCandlestickDataResponseItemInner>>>,
    > {
        self.market_data_api_client
            .continuous_contract_kline_candlestick_data(params)
            .await
    }

    /// Exchange Information
    ///
    /// Current exchange trading rules and symbol information
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`ExchangeInformationParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::ExchangeInformationResponse>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Exchange-Information).
    ///
    pub async fn exchange_information(
        &self,
    ) -> anyhow::Result<RestApiResponse<models::ExchangeInformationResponse>> {
        self.market_data_api_client.exchange_information().await
    }

    /// Get Funding Rate History of Perpetual Futures
    ///
    /// Get Funding Rate History of Perpetual Futures
    ///
    /// * empty array will be returned for delivery symbols.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetFundingRateHistoryOfPerpetualFuturesParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::GetFundingRateHistoryOfPerpetualFuturesResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Get-Funding-Rate-History-of-Perpetual-Futures).
    ///
    pub async fn get_funding_rate_history_of_perpetual_futures(
        &self,
        params: GetFundingRateHistoryOfPerpetualFuturesParams,
    ) -> anyhow::Result<
        RestApiResponse<Vec<models::GetFundingRateHistoryOfPerpetualFuturesResponseInner>>,
    > {
        self.market_data_api_client
            .get_funding_rate_history_of_perpetual_futures(params)
            .await
    }

    /// Get Funding Rate Info
    ///
    /// Query funding rate info for symbols that had `FundingRateCap`/ `FundingRateFloor` / fundingIntervalHours adjustment
    ///
    /// Weight: 0
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetFundingRateInfoParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::GetFundingRateInfoResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Get-Funding-Info).
    ///
    pub async fn get_funding_rate_info(
        &self,
    ) -> anyhow::Result<RestApiResponse<Vec<models::GetFundingRateInfoResponseInner>>> {
        self.market_data_api_client.get_funding_rate_info().await
    }

    /// Index Price and Mark Price
    ///
    /// Query index price and mark price
    ///
    /// Weight: 10
    ///
    /// # Arguments
    ///
    /// - `params`: [`IndexPriceAndMarkPriceParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::IndexPriceAndMarkPriceResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Index-Price-and-Mark-Price).
    ///
    pub async fn index_price_and_mark_price(
        &self,
        params: IndexPriceAndMarkPriceParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::IndexPriceAndMarkPriceResponseInner>>> {
        self.market_data_api_client
            .index_price_and_mark_price(params)
            .await
    }

    /// Index Price Kline/Candlestick Data
    ///
    /// Kline/candlestick bars for the index price of a pair. Klines are uniquely identified by their open time.
    ///
    ///
    /// 1000 | 10
    /// * The difference between `startTime` and `endTime` can only be up to 200 days
    /// * Between `startTime` and `endTime`, the most recent `limit` data from `endTime` will be returned:
    /// * If `startTime` and `endTime` are not sent, current timestamp will be set as `endTime`, and the most recent data will be returned.
    /// * If `startTime` is sent only, the timestamp of 200 days after `startTime` will be set as `endTime`(up to the current time)
    /// * If `endTime` is sent only, the timestamp of 200 days before `endTime` will be set as `startTime`
    ///
    /// Weight: based on parameter LIMIT
    /// LIMIT | weight
    /// ---|---
    /// [1,100) | 1
    /// [100, 500) | 2
    /// [500, 1000] | 5
    /// > 1000 | 10
    ///
    /// # Arguments
    ///
    /// - `params`: [`IndexPriceKlineCandlestickDataParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<Vec<models::IndexPriceKlineCandlestickDataResponseItemInner>>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Index-Price-Kline-Candlestick-Data).
    ///
    pub async fn index_price_kline_candlestick_data(
        &self,
        params: IndexPriceKlineCandlestickDataParams,
    ) -> anyhow::Result<
        RestApiResponse<Vec<Vec<models::IndexPriceKlineCandlestickDataResponseItemInner>>>,
    > {
        self.market_data_api_client
            .index_price_kline_candlestick_data(params)
            .await
    }

    /// Kline/Candlestick Data
    ///
    /// Kline/candlestick bars for a symbol.
    /// Klines are uniquely identified by their open time.
    ///
    /// 1000 | 10
    /// * The difference between `startTime` and `endTime` can only be up to 200 days
    /// * Between `startTime` and `endTime`, the most recent `limit` data from `endTime` will be returned:
    /// * If `startTime` and `endTime` are not sent, current timestamp will be set as `endTime`, and the most recent data will be returned.
    /// * If `startTime` is sent only, the timestamp of 200 days after `startTime` will be set as `endTime`(up to the current time)
    /// * If `endTime` is sent only, the timestamp of 200 days before `endTime` will be set as `startTime`
    ///
    /// Weight: based on parameter LIMIT
    /// LIMIT | weight
    /// ---|---
    /// [1,100) | 1
    /// [100, 500) | 2
    /// [500, 1000] | 5
    /// > 1000 | 10
    ///
    /// # Arguments
    ///
    /// - `params`: [`KlineCandlestickDataParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<Vec<models::ContinuousContractKlineCandlestickDataResponseItemInner>>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Kline-Candlestick-Data).
    ///
    pub async fn kline_candlestick_data(
        &self,
        params: KlineCandlestickDataParams,
    ) -> anyhow::Result<
        RestApiResponse<Vec<Vec<models::ContinuousContractKlineCandlestickDataResponseItemInner>>>,
    > {
        self.market_data_api_client
            .kline_candlestick_data(params)
            .await
    }

    /// Long/Short Ratio
    ///
    /// Query symbol Long/Short Ratio
    ///
    /// * If startTime and endTime are not sent, the most recent data is returned.
    /// * Only the data of the latest 30 days is available.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`LongShortRatioParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::LongShortRatioResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Long-Short-Ratio).
    ///
    pub async fn long_short_ratio(
        &self,
        params: LongShortRatioParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::LongShortRatioResponseInner>>> {
        self.market_data_api_client.long_short_ratio(params).await
    }

    /// Mark Price Kline/Candlestick Data
    ///
    /// Kline/candlestick bars for the mark price of a symbol.
    /// Klines are uniquely identified by their open time.
    ///
    ///
    /// 1000 | 10
    /// * The difference between `startTime` and `endTime` can only be up to 200 days
    /// * Between `startTime` and `endTime`, the most recent `limit` data from `endTime` will be returned:
    /// * If `startTime` and `endTime` are not sent, current timestamp will be set as `endTime`, and the most recent data will be returned.
    /// * If `startTime` is sent only, the timestamp of 200 days after `startTime` will be set as `endTime`(up to the current time)
    /// * If `endTime` is sent only, the timestamp of 200 days before `endTime` will be set as `startTime`
    ///
    /// Weight: based on parameter LIMIT
    /// LIMIT | weight
    /// ---|---
    /// [1,100) | 1
    /// [100, 500) | 2
    /// [500, 1000] | 5
    /// > 1000 | 10
    ///
    /// # Arguments
    ///
    /// - `params`: [`MarkPriceKlineCandlestickDataParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<Vec<models::MarkPriceKlineCandlestickDataResponseItemInner>>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Mark-Price-Kline-Candlestick-Data).
    ///
    pub async fn mark_price_kline_candlestick_data(
        &self,
        params: MarkPriceKlineCandlestickDataParams,
    ) -> anyhow::Result<
        RestApiResponse<Vec<Vec<models::MarkPriceKlineCandlestickDataResponseItemInner>>>,
    > {
        self.market_data_api_client
            .mark_price_kline_candlestick_data(params)
            .await
    }

    /// Old Trades `Lookup(MARKET_DATA)`
    ///
    /// Get older market historical trades.
    ///
    /// * Market trades means trades filled in the order book. Only market trades will be returned, which means the insurance fund trades and ADL trades won't be returned.
    ///
    /// Weight: 20
    ///
    /// # Arguments
    ///
    /// - `params`: [`OldTradesLookupParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::OldTradesLookupResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Old-Trades-Lookup).
    ///
    pub async fn old_trades_lookup(
        &self,
        params: OldTradesLookupParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::OldTradesLookupResponseInner>>> {
        self.market_data_api_client.old_trades_lookup(params).await
    }

    /// Open Interest
    ///
    /// Get present open interest of a specific symbol.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`OpenInterestParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::OpenInterestResponse>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Open-Interest).
    ///
    pub async fn open_interest(
        &self,
        params: OpenInterestParams,
    ) -> anyhow::Result<RestApiResponse<models::OpenInterestResponse>> {
        self.market_data_api_client.open_interest(params).await
    }

    /// Open Interest Statistics
    ///
    /// Query open interest stats
    ///
    ///
    /// * If startTime and endTime are not sent, the most recent data is returned.
    /// * Only the data of the latest 30 days is available.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`OpenInterestStatisticsParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::OpenInterestStatisticsResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Open-Interest-Statistics).
    ///
    pub async fn open_interest_statistics(
        &self,
        params: OpenInterestStatisticsParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::OpenInterestStatisticsResponseInner>>> {
        self.market_data_api_client
            .open_interest_statistics(params)
            .await
    }

    /// Order Book
    ///
    /// Query orderbook on specific symbol
    ///
    /// Weight: Adjusted based on the limit:
    /// Limit | Weight
    /// ------------ | ------------
    /// 5, 10, 20, 50 | 2
    /// 100 | 5
    /// 500 | 10
    /// 1000 | 20
    ///
    /// # Arguments
    ///
    /// - `params`: [`OrderBookParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::OrderBookResponse>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Order-Book).
    ///
    pub async fn order_book(
        &self,
        params: OrderBookParams,
    ) -> anyhow::Result<RestApiResponse<models::OrderBookResponse>> {
        self.market_data_api_client.order_book(params).await
    }

    /// Premium index Kline Data
    ///
    /// Premium index kline bars of a symbol. Klines are uniquely identified by their open time.
    ///
    ///
    /// * If startTime and endTime are not sent, the most recent klines are returned.
    ///
    /// Weight: based on parameter LIMIT
    /// | LIMIT       | weight |
    /// | ----------- | ------ |
    /// | [1,100)     | 1      |
    /// | [100, 500)  | 2      |
    /// | [500, 1000] | 5      |
    /// | > 1000      | 10     |
    ///
    /// # Arguments
    ///
    /// - `params`: [`PremiumIndexKlineDataParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<Vec<models::PremiumIndexKlineDataResponseItemInner>>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Premium-index-Kline-Data).
    ///
    pub async fn premium_index_kline_data(
        &self,
        params: PremiumIndexKlineDataParams,
    ) -> anyhow::Result<RestApiResponse<Vec<Vec<models::PremiumIndexKlineDataResponseItemInner>>>>
    {
        self.market_data_api_client
            .premium_index_kline_data(params)
            .await
    }

    /// Query Index Price Constituents
    ///
    /// Query index price constituents
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`QueryIndexPriceConstituentsParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::QueryIndexPriceConstituentsResponse>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Index-Constituents).
    ///
    pub async fn query_index_price_constituents(
        &self,
        params: QueryIndexPriceConstituentsParams,
    ) -> anyhow::Result<RestApiResponse<models::QueryIndexPriceConstituentsResponse>> {
        self.market_data_api_client
            .query_index_price_constituents(params)
            .await
    }

    /// Recent Trades List
    ///
    /// Get recent market trades
    ///
    /// * Market trades means trades filled in the order book. Only market trades will be returned, which means the insurance fund trades and ADL trades won't be returned.
    ///
    /// Weight: 5
    ///
    /// # Arguments
    ///
    /// - `params`: [`RecentTradesListParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::RecentTradesListResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Recent-Trades-List).
    ///
    pub async fn recent_trades_list(
        &self,
        params: RecentTradesListParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::RecentTradesListResponseInner>>> {
        self.market_data_api_client.recent_trades_list(params).await
    }

    /// Symbol Order Book Ticker
    ///
    /// Best price/qty on the order book for a symbol or symbols.
    ///
    /// * Symbol and pair cannot be sent together
    /// * If a pair is sent,tickers for all symbols of the pair will be returned
    /// * If either a pair or symbol is sent, tickers for all symbols of all pairs will be returned
    ///
    /// Weight: 2 for a single symbol, 5 when the symbol parameter is omitted
    ///
    /// # Arguments
    ///
    /// - `params`: [`SymbolOrderBookTickerParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::SymbolOrderBookTickerResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Symbol-Order-Book-Ticker).
    ///
    pub async fn symbol_order_book_ticker(
        &self,
        params: SymbolOrderBookTickerParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::SymbolOrderBookTickerResponseInner>>> {
        self.market_data_api_client
            .symbol_order_book_ticker(params)
            .await
    }

    /// Symbol Price Ticker
    ///
    /// Latest price for a symbol or symbols.
    ///
    /// * Symbol and pair cannot be sent together
    /// * If a pair is sent,tickers for all symbols of the pair will be returned
    /// * If either a pair or symbol is sent, tickers for all symbols of all pairs will be returned
    ///
    /// Weight: 1 for a single symbol, 2 when the symbol parameter is omitted
    ///
    /// # Arguments
    ///
    /// - `params`: [`SymbolPriceTickerParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::SymbolPriceTickerResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Symbol-Price-Ticker).
    ///
    pub async fn symbol_price_ticker(
        &self,
        params: SymbolPriceTickerParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::SymbolPriceTickerResponseInner>>> {
        self.market_data_api_client
            .symbol_price_ticker(params)
            .await
    }

    /// Taker Buy/Sell Volume
    ///
    /// Taker Buy Volume: the total volume of buy orders filled by takers within the period.
    /// Taker Sell Volume: the total volume of sell orders filled by takers within the period.
    ///
    /// * If startTime and endTime are not sent, the most recent data is returned.
    /// * Only the data of the latest 30 days is available.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`TakerBuySellVolumeParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::TakerBuySellVolumeResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Taker-Buy-Sell-Volume).
    ///
    pub async fn taker_buy_sell_volume(
        &self,
        params: TakerBuySellVolumeParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::TakerBuySellVolumeResponseInner>>> {
        self.market_data_api_client
            .taker_buy_sell_volume(params)
            .await
    }

    /// Test Connectivity
    ///
    /// Test connectivity to the Rest API.
    ///
    /// Weight: 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Test-Connectivity).
    ///
    pub async fn test_connectivity(&self) -> anyhow::Result<RestApiResponse<Value>> {
        self.market_data_api_client.test_connectivity().await
    }

    /// 24hr Ticker Price Change Statistics
    ///
    /// 24 hour rolling window price change statistics.
    ///
    /// * Symbol and pair cannot be sent together
    /// * If a pair is sent,tickers for all symbols of the pair will be returned
    /// * If either a pair or symbol is sent, tickers for all symbols of all pairs will be returned
    ///
    /// Weight: 1 for a single symbol, 40 when the symbol parameter is omitted
    /// Careful when accessing this with no symbol.
    ///
    /// # Arguments
    ///
    /// - `params`: [`Ticker24hrPriceChangeStatisticsParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::Ticker24hrPriceChangeStatisticsResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/24hr-Ticker-Price-Change-Statistics).
    ///
    pub async fn ticker24hr_price_change_statistics(
        &self,
        params: Ticker24hrPriceChangeStatisticsParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::Ticker24hrPriceChangeStatisticsResponseInner>>>
    {
        self.market_data_api_client
            .ticker24hr_price_change_statistics(params)
            .await
    }

    /// Top Trader Long/Short Ratio (Accounts)
    ///
    /// The proportion of net long and net short accounts to total accounts of the top 20% users with the highest margin balance. Each account is counted once only.
    /// Long Account % = Accounts of top traders with net long positions / Total accounts of top traders with open positions
    /// Short Account % = Accounts of top traders with net short positions / Total accounts of top traders with open positions
    /// Long/Short Ratio (Accounts) = Long Account % / Short Account %
    ///
    /// * If startTime and endTime are not sent, the most recent data is returned.
    /// * Only the data of the latest 30 days is available.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`TopTraderLongShortRatioAccountsParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::TopTraderLongShortRatioAccountsResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Top-Long-Short-Account-Ratio).
    ///
    pub async fn top_trader_long_short_ratio_accounts(
        &self,
        params: TopTraderLongShortRatioAccountsParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::TopTraderLongShortRatioAccountsResponseInner>>>
    {
        self.market_data_api_client
            .top_trader_long_short_ratio_accounts(params)
            .await
    }

    /// Top Trader Long/Short Ratio (Positions)
    ///
    /// The proportion of net long and net short positions to total open positions of the top 20% users with the highest margin balance.
    /// Long Position % = Long positions of top traders / Total open positions of top traders
    /// Short Position % = Short positions of top traders / Total open positions of top traders
    /// Long/Short Ratio (Positions) = Long Position % / Short Position %
    ///
    /// * If startTime and endTime are not sent, the most recent data is returned.
    /// * Only the data of the latest 30 days is available.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`TopTraderLongShortRatioPositionsParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::TopTraderLongShortRatioPositionsResponseInner>>`] 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/docs/derivatives/coin-margined-futures/market-data/rest-api/Top-Trader-Long-Short-Ratio).
    ///
    pub async fn top_trader_long_short_ratio_positions(
        &self,
        params: TopTraderLongShortRatioPositionsParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::TopTraderLongShortRatioPositionsResponseInner>>>
    {
        self.market_data_api_client
            .top_trader_long_short_ratio_positions(params)
            .await
    }

    /// Classic Portfolio Margin Account Information (`USER_DATA`)
    ///
    /// Get Classic Portfolio Margin current account information.
    ///
    /// * maxWithdrawAmount is for asset transfer out to the spot wallet.
    ///
    /// Weight: 5
    ///
    /// # Arguments
    ///
    /// - `params`: [`ClassicPortfolioMarginAccountInformationParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::ClassicPortfolioMarginAccountInformationResponse>`] 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/docs/derivatives/coin-margined-futures/portfolio-margin-endpoints/Classic-Portfolio-Margin-Account-Information).
    ///
    pub async fn classic_portfolio_margin_account_information(
        &self,
        params: ClassicPortfolioMarginAccountInformationParams,
    ) -> anyhow::Result<RestApiResponse<models::ClassicPortfolioMarginAccountInformationResponse>>
    {
        self.portfolio_margin_endpoints_api_client
            .classic_portfolio_margin_account_information(params)
            .await
    }

    /// Account Trade List (`USER_DATA`)
    ///
    /// Get trades for a specific account and symbol.
    ///
    ///
    /// * 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 7 days' data will be returned.
    /// * The time between startTime and endTime cannot be longer than 7 days.
    ///
    /// Weight: 20 with symbol，40 with pair
    ///
    /// # Arguments
    ///
    /// - `params`: [`AccountTradeListParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::AccountTradeListResponseInner>>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Account-Trade-List).
    ///
    pub async fn account_trade_list(
        &self,
        params: AccountTradeListParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::AccountTradeListResponseInner>>> {
        self.trade_api_client.account_trade_list(params).await
    }

    /// All Orders (`USER_DATA`)
    ///
    /// Get all account orders; active, canceled, or filled.
    ///
    /// * 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
    /// * order create time + 90 days < current time
    ///
    ///
    /// * Either `symbol` or `pair` must be sent.
    /// * `pair` can't be sent with `orderId`
    /// * If `orderId` is set, it will get orders >= that `orderId`. Otherwise most recent orders are returned.
    /// * 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).
    ///
    /// Weight: 20 with symbol, 40 with pair
    ///
    /// # Arguments
    ///
    /// - `params`: [`AllOrdersParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::AllOrdersResponseInner>>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/All-Orders).
    ///
    pub async fn all_orders(
        &self,
        params: AllOrdersParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::AllOrdersResponseInner>>> {
        self.trade_api_client.all_orders(params).await
    }

    /// Auto-Cancel All Open Orders (TRADE)
    ///
    /// Cancel all open orders of the specified symbol at the end of the specified countdown. This rest endpoint means to ensure your open orders are canceled in case of an outage. The endpoint should be called repeatedly as heartbeats so that the existing countdown time can be canceled and repalced by a new one. The system will check all countdowns **approximately every 10 milliseconds**, so please note that sufficient redundancy should be considered when using this function. We do not recommend setting the countdown time to be too precise or too small.
    ///
    /// * Example usage:
    /// Call this endpoint at 30s intervals with an countdownTime of 120000 (120s).
    /// If this endpoint is not called within 120 seconds, all your orders of the specified symbol will be automatically canceled.
    /// If this endpoint is called with an countdownTime of 0, the countdown timer will be stopped.
    ///
    /// Weight: 10
    ///
    /// # Arguments
    ///
    /// - `params`: [`AutoCancelAllOpenOrdersParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::AutoCancelAllOpenOrdersResponse>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Auto-Cancel-All-Open-Orders).
    ///
    pub async fn auto_cancel_all_open_orders(
        &self,
        params: AutoCancelAllOpenOrdersParams,
    ) -> anyhow::Result<RestApiResponse<models::AutoCancelAllOpenOrdersResponse>> {
        self.trade_api_client
            .auto_cancel_all_open_orders(params)
            .await
    }

    /// Cancel All Open Orders(TRADE)
    ///
    /// Cancel All Open Orders
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`CancelAllOpenOrdersParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::CancelAllOpenOrdersResponse>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Cancel-All-Open-Orders).
    ///
    pub async fn cancel_all_open_orders(
        &self,
        params: CancelAllOpenOrdersParams,
    ) -> anyhow::Result<RestApiResponse<models::CancelAllOpenOrdersResponse>> {
        self.trade_api_client.cancel_all_open_orders(params).await
    }

    /// Cancel Multiple Orders(TRADE)
    ///
    /// Cancel Multiple Orders
    ///
    /// * Either `orderIdList` or `origClientOrderIdList ` must be sent.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`CancelMultipleOrdersParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::CancelMultipleOrdersResponseInner>>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Cancel-Multiple-Orders).
    ///
    pub async fn cancel_multiple_orders(
        &self,
        params: CancelMultipleOrdersParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::CancelMultipleOrdersResponseInner>>> {
        self.trade_api_client.cancel_multiple_orders(params).await
    }

    /// Cancel Order (TRADE)
    ///
    /// Cancel an active order.
    ///
    ///
    /// * Either `orderId` or `origClientOrderId` must be sent.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`CancelOrderParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::CancelOrderResponse>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Cancel-Order).
    ///
    pub async fn cancel_order(
        &self,
        params: CancelOrderParams,
    ) -> anyhow::Result<RestApiResponse<models::CancelOrderResponse>> {
        self.trade_api_client.cancel_order(params).await
    }

    /// Change Initial Leverage (TRADE)
    ///
    /// Change user's initial leverage in the specific symbol market.
    /// For Hedge Mode, LONG and SHORT positions of one symbol use the same initial leverage and share a total notional value.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`ChangeInitialLeverageParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::ChangeInitialLeverageResponse>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Change-Initial-Leverage).
    ///
    pub async fn change_initial_leverage(
        &self,
        params: ChangeInitialLeverageParams,
    ) -> anyhow::Result<RestApiResponse<models::ChangeInitialLeverageResponse>> {
        self.trade_api_client.change_initial_leverage(params).await
    }

    /// Change Margin Type (TRADE)
    ///
    /// Change user's margin type in the specific symbol market.For Hedge Mode, LONG and SHORT positions of one symbol use the same margin type.
    /// With ISOLATED margin type, margins of the LONG and SHORT positions are isolated from each other.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`ChangeMarginTypeParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::ChangeMarginTypeResponse>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Change-Margin-Type).
    ///
    pub async fn change_margin_type(
        &self,
        params: ChangeMarginTypeParams,
    ) -> anyhow::Result<RestApiResponse<models::ChangeMarginTypeResponse>> {
        self.trade_api_client.change_margin_type(params).await
    }

    /// Change Position Mode(TRADE)
    ///
    /// Change user's position mode (Hedge Mode or One-way Mode ) on ***EVERY symbol***
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`ChangePositionModeParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::ChangePositionModeResponse>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Change-Position-Mode).
    ///
    pub async fn change_position_mode(
        &self,
        params: ChangePositionModeParams,
    ) -> anyhow::Result<RestApiResponse<models::ChangePositionModeResponse>> {
        self.trade_api_client.change_position_mode(params).await
    }

    /// Current All Open Orders (`USER_DATA`)
    ///
    /// Get all open orders on a symbol. **Careful** when accessing this with no symbol.
    ///
    /// Weight: 1 for a single symbol, 40 for mutltiple symbols
    ///
    /// # Arguments
    ///
    /// - `params`: [`CurrentAllOpenOrdersParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::AllOrdersResponseInner>>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Current-All-Open-Orders).
    ///
    pub async fn current_all_open_orders(
        &self,
        params: CurrentAllOpenOrdersParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::AllOrdersResponseInner>>> {
        self.trade_api_client.current_all_open_orders(params).await
    }

    /// Get Order Modify History (`USER_DATA`)
    ///
    /// Get order modification history
    ///
    ///
    /// * Either `orderId` or `origClientOrderId` must be sent, and the `orderId` will prevail if both are sent.
    /// * Order modify history longer than 3 month is not avaliable
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetOrderModifyHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::GetOrderModifyHistoryResponseInner>>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Get-Order-Modify-History).
    ///
    pub async fn get_order_modify_history(
        &self,
        params: GetOrderModifyHistoryParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::GetOrderModifyHistoryResponseInner>>> {
        self.trade_api_client.get_order_modify_history(params).await
    }

    /// Get Position Margin Change History(TRADE)
    ///
    /// Get position margin change history
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetPositionMarginChangeHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::GetPositionMarginChangeHistoryResponseInner>>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Get-Position-Margin-Change-History).
    ///
    pub async fn get_position_margin_change_history(
        &self,
        params: GetPositionMarginChangeHistoryParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::GetPositionMarginChangeHistoryResponseInner>>>
    {
        self.trade_api_client
            .get_position_margin_change_history(params)
            .await
    }

    /// Modify Isolated Position Margin(TRADE)
    ///
    /// Modify Isolated Position Margin
    ///
    /// * Only for isolated symbol
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`ModifyIsolatedPositionMarginParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::ModifyIsolatedPositionMarginResponse>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Isolated-Position-Margin).
    ///
    pub async fn modify_isolated_position_margin(
        &self,
        params: ModifyIsolatedPositionMarginParams,
    ) -> anyhow::Result<RestApiResponse<models::ModifyIsolatedPositionMarginResponse>> {
        self.trade_api_client
            .modify_isolated_position_margin(params)
            .await
    }

    /// Modify Multiple Orders(TRADE)
    ///
    /// Modify Multiple Orders
    ///
    /// * Parameter rules are same with `Modify Order`
    /// * Batch modify orders are processed concurrently, and the order of matching is not guaranteed.
    /// * The order of returned contents for batch modify orders is the same as the order of the order list.
    /// * One order can only be modfied for less than 10000 times
    ///
    /// Weight: 5
    ///
    /// # Arguments
    ///
    /// - `params`: [`ModifyMultipleOrdersParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::ModifyMultipleOrdersResponseInner>>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Multiple-Orders).
    ///
    pub async fn modify_multiple_orders(
        &self,
        params: ModifyMultipleOrdersParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::ModifyMultipleOrdersResponseInner>>> {
        self.trade_api_client.modify_multiple_orders(params).await
    }

    /// Modify Order (TRADE)
    ///
    /// Order modify function, currently only LIMIT order modification is supported, modified orders will be reordered in the match queue
    ///
    /// * Either `orderId` or `origClientOrderId` must be sent, and the `orderId` will prevail if both are sent.
    /// * Either `quantity` or `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
    /// * One order can only be modfied for less than 10000 times
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`ModifyOrderParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::ModifyOrderResponse>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Order).
    ///
    pub async fn modify_order(
        &self,
        params: ModifyOrderParams,
    ) -> anyhow::Result<RestApiResponse<models::ModifyOrderResponse>> {
        self.trade_api_client.modify_order(params).await
    }

    /// New Order (TRADE)
    ///
    /// Send in a new order.
    ///
    ///
    /// * Order with type `STOP`,  parameter `timeInForce` can be sent ( default `GTC`).
    /// * Order with type `TAKE_PROFIT`,  parameter `timeInForce` can be sent ( default `GTC`).
    /// * Condition orders will be triggered when:
    ///
    /// * If parameter`priceProtect`is sent as true:
    /// * when price reaches the `stopPrice` ，the difference rate between "`MARK_PRICE`" and "`CONTRACT_PRICE`" cannot be larger than the "triggerProtect" of the symbol
    /// * "triggerProtect" of a symbol can be got from `GET /dapi/v1/exchangeInfo`
    ///
    /// * `STOP`, `STOP_MARKET`:
    /// * BUY: latest price ("`MARK_PRICE`" or "`CONTRACT_PRICE`") >= `stopPrice`
    /// * SELL: latest price ("`MARK_PRICE`" or "`CONTRACT_PRICE`") <= `stopPrice`
    /// * `TAKE_PROFIT`, `TAKE_PROFIT_MARKET`:
    /// * BUY: latest price ("`MARK_PRICE`" or "`CONTRACT_PRICE`") <= `stopPrice`
    /// * SELL: latest price ("`MARK_PRICE`" or "`CONTRACT_PRICE`") >= `stopPrice`
    /// * `TRAILING_STOP_MARKET`:
    /// * BUY: the lowest price after order placed `<= `activationPrice`, and the latest price >`= the lowest price * (1 + `callbackRate`)
    /// * SELL: the highest price after order placed >= `activationPrice`, and the latest price <= the highest price * (1 - `callbackRate`)
    ///
    /// * For `TRAILING_STOP_MARKET`, if you got such error code.
    /// ``{"code": -2021, "msg": "Order would immediately trigger."}``
    /// means that the parameters you send do not meet the following requirements:
    /// * BUY: `activationPrice` should be smaller than latest price.
    /// * SELL: `activationPrice` should be larger than latest price.
    ///
    /// * 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.
    ///
    /// * `STOP_MARKET`, `TAKE_PROFIT_MARKET` with `closePosition`=`true`:
    /// * Follow the same rules for condition 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`.
    ///
    /// Weight: 1 on 1min order rate limit(X-MBX-ORDER-COUNT-1M)\
    /// 0 on IP rate limit(x-mbx-used-weight-1m)
    ///
    /// # Arguments
    ///
    /// - `params`: [`NewOrderParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::NewOrderResponse>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/New-Order).
    ///
    pub async fn new_order(
        &self,
        params: NewOrderParams,
    ) -> anyhow::Result<RestApiResponse<models::NewOrderResponse>> {
        self.trade_api_client.new_order(params).await
    }

    /// Place Multiple Orders(TRADE)
    ///
    /// Place multiple orders
    ///
    /// * Parameter rules are same with `New Order`
    /// * Batch orders are processed concurrently, and the order of matching is not guaranteed.
    /// * The order of returned contents for batch orders is the same as the order of the order list.
    ///
    /// Weight: 5
    ///
    /// # Arguments
    ///
    /// - `params`: [`PlaceMultipleOrdersParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::PlaceMultipleOrdersResponseInner>>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Place-Multiple-Orders).
    ///
    pub async fn place_multiple_orders(
        &self,
        params: PlaceMultipleOrdersParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::PlaceMultipleOrdersResponseInner>>> {
        self.trade_api_client.place_multiple_orders(params).await
    }

    /// Position ADL Quantile `Estimation(USER_DATA)`
    ///
    /// Query 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: 5
    ///
    /// # Arguments
    ///
    /// - `params`: [`PositionAdlQuantileEstimationParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::PositionAdlQuantileEstimationResponseInner>>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Position-ADL-Quantile-Estimation).
    ///
    pub async fn position_adl_quantile_estimation(
        &self,
        params: PositionAdlQuantileEstimationParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::PositionAdlQuantileEstimationResponseInner>>>
    {
        self.trade_api_client
            .position_adl_quantile_estimation(params)
            .await
    }

    /// Position `Information(USER_DATA)`
    ///
    /// Get current account information.
    ///
    /// * 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 "BOTH", "LONG", and "SHORT" positions.
    /// Please use with user data stream `ACCOUNT_UPDATE` to meet your timeliness and accuracy needs.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`PositionInformationParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::PositionInformationResponseInner>>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Position-Information).
    ///
    pub async fn position_information(
        &self,
        params: PositionInformationParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::PositionInformationResponseInner>>> {
        self.trade_api_client.position_information(params).await
    }

    /// Query Current Open `Order(USER_DATA)`
    ///
    /// Query Current Open Order
    ///
    /// * 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.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`QueryCurrentOpenOrderParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::QueryCurrentOpenOrderResponse>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Query-Current-Open-Order).
    ///
    pub async fn query_current_open_order(
        &self,
        params: QueryCurrentOpenOrderParams,
    ) -> anyhow::Result<RestApiResponse<models::QueryCurrentOpenOrderResponse>> {
        self.trade_api_client.query_current_open_order(params).await
    }

    /// Query Order (`USER_DATA`)
    ///
    /// Check an order's status.
    ///
    /// * 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
    /// * order create time + 90 days < current time
    ///
    ///
    /// * Either `orderId` or `origClientOrderId` must be sent.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`QueryOrderParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::QueryOrderResponse>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Query-Order).
    ///
    pub async fn query_order(
        &self,
        params: QueryOrderParams,
    ) -> anyhow::Result<RestApiResponse<models::QueryOrderResponse>> {
        self.trade_api_client.query_order(params).await
    }

    /// User's Force `Orders(USER_DATA)`
    ///
    /// User's Force Orders
    ///
    /// * If "autoCloseType" is not sent, orders with both of the types will be returned
    /// * If "startTime" is not sent, data within 200 days before "endTime" can be queried
    ///
    /// Weight: 20 with symbol, 50 without symbol
    ///
    /// # Arguments
    ///
    /// - `params`: [`UsersForceOrdersParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::UsersForceOrdersResponseInner>>`] 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/docs/derivatives/coin-margined-futures/trade/rest-api/Users-Force-Orders).
    ///
    pub async fn users_force_orders(
        &self,
        params: UsersForceOrdersParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::UsersForceOrdersResponseInner>>> {
        self.trade_api_client.users_force_orders(params).await
    }

    /// Close User Data `Stream(USER_STREAM)`
    ///
    /// Close out a user data stream.
    ///
    /// Weight: 1
    ///
    /// # 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/docs/derivatives/coin-margined-futures/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.
    ///
    /// Weight: 1
    ///
    /// # Arguments
    ///
    /// - `params`: [`KeepaliveUserDataStreamParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::KeepaliveUserDataStreamResponse>`] 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/docs/derivatives/coin-margined-futures/user-data-streams/Keepalive-User-Data-Stream).
    ///
    pub async fn keepalive_user_data_stream(
        &self,
    ) -> anyhow::Result<RestApiResponse<models::KeepaliveUserDataStreamResponse>> {
        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: 1
    ///
    /// # 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/docs/derivatives/coin-margined-futures/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
    }
}
