"""
Binance Derivatives Trading Portfolio Margin REST API

OpenAPI Specification for the Binance Derivatives Trading Portfolio Margin REST API
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""

from typing import Optional, Union
from requests import Session
from binance_common.configuration import ConfigurationRestAPI
from binance_common.errors import RequiredError
from binance_common.models import ApiResponse
from binance_common.signature import Signers
from binance_common.utils import send_request

from ..models import CancelAllCmOpenConditionalOrdersResponse
from ..models import CancelAllCmOpenOrdersResponse
from ..models import CancelAllUmOpenConditionalOrdersResponse
from ..models import CancelAllUmOpenOrdersResponse
from ..models import CancelCmConditionalOrderResponse
from ..models import CancelCmOrderResponse
from ..models import CancelMarginAccountAllOpenOrdersOnASymbolResponse
from ..models import CancelMarginAccountOcoOrdersResponse
from ..models import CancelMarginAccountOrderResponse
from ..models import CancelUmConditionalOrderResponse
from ..models import CancelUmOrderResponse
from ..models import CmAccountTradeListResponse
from ..models import CmPositionAdlQuantileEstimationResponse
from ..models import GetUmFuturesBnbBurnStatusResponse
from ..models import MarginAccountBorrowResponse
from ..models import MarginAccountNewOcoResponse
from ..models import MarginAccountRepayResponse
from ..models import MarginAccountRepayDebtResponse
from ..models import MarginAccountTradeListResponse
from ..models import ModifyCmOrderResponse
from ..models import ModifyUmOrderResponse
from ..models import NewCmConditionalOrderResponse
from ..models import NewCmOrderResponse
from ..models import NewMarginOrderResponse
from ..models import NewUmConditionalOrderResponse
from ..models import NewUmOrderResponse
from ..models import QueryAllCmConditionalOrdersResponse
from ..models import QueryAllCmOrdersResponse
from ..models import QueryAllCurrentCmOpenConditionalOrdersResponse
from ..models import QueryAllCurrentCmOpenOrdersResponse
from ..models import QueryAllCurrentUmOpenConditionalOrdersResponse
from ..models import QueryAllCurrentUmOpenOrdersResponse
from ..models import QueryAllMarginAccountOrdersResponse
from ..models import QueryAllUmConditionalOrdersResponse
from ..models import QueryAllUmOrdersResponse
from ..models import QueryCmConditionalOrderHistoryResponse
from ..models import QueryCmModifyOrderHistoryResponse
from ..models import QueryCmOrderResponse
from ..models import QueryCurrentCmOpenConditionalOrderResponse
from ..models import QueryCurrentCmOpenOrderResponse
from ..models import QueryCurrentMarginOpenOrderResponse
from ..models import QueryCurrentUmOpenConditionalOrderResponse
from ..models import QueryCurrentUmOpenOrderResponse
from ..models import QueryMarginAccountOrderResponse
from ..models import QueryMarginAccountsAllOcoResponse
from ..models import QueryMarginAccountsOcoResponse
from ..models import QueryMarginAccountsOpenOcoResponse
from ..models import QueryUmConditionalOrderHistoryResponse
from ..models import QueryUmModifyOrderHistoryResponse
from ..models import QueryUmOrderResponse
from ..models import QueryUsersCmForceOrdersResponse
from ..models import QueryUsersMarginForceOrdersResponse
from ..models import QueryUsersUmForceOrdersResponse
from ..models import ToggleBnbBurnOnUmFuturesTradeResponse
from ..models import UmAccountTradeListResponse
from ..models import UmPositionAdlQuantileEstimationResponse


from ..models import MarginAccountNewOcoSideEnum
from ..models import MarginAccountNewOcoStopLimitTimeInForceEnum
from ..models import MarginAccountNewOcoNewOrderRespTypeEnum
from ..models import MarginAccountNewOcoSideEffectTypeEnum
from ..models import ModifyCmOrderSideEnum
from ..models import ModifyCmOrderPriceMatchEnum
from ..models import ModifyUmOrderSideEnum
from ..models import ModifyUmOrderPriceMatchEnum
from ..models import NewCmConditionalOrderSideEnum
from ..models import NewCmConditionalOrderStrategyTypeEnum
from ..models import NewCmConditionalOrderPositionSideEnum
from ..models import NewCmConditionalOrderTimeInForceEnum
from ..models import NewCmConditionalOrderWorkingTypeEnum
from ..models import NewCmOrderSideEnum
from ..models import NewCmOrderTypeEnum
from ..models import NewCmOrderPositionSideEnum
from ..models import NewCmOrderTimeInForceEnum
from ..models import NewCmOrderPriceMatchEnum
from ..models import NewCmOrderNewOrderRespTypeEnum
from ..models import NewMarginOrderSideEnum
from ..models import NewMarginOrderTypeEnum
from ..models import NewMarginOrderNewOrderRespTypeEnum
from ..models import NewMarginOrderSideEffectTypeEnum
from ..models import NewMarginOrderTimeInForceEnum
from ..models import NewMarginOrderSelfTradePreventionModeEnum
from ..models import NewUmConditionalOrderSideEnum
from ..models import NewUmConditionalOrderStrategyTypeEnum
from ..models import NewUmConditionalOrderPositionSideEnum
from ..models import NewUmConditionalOrderTimeInForceEnum
from ..models import NewUmConditionalOrderWorkingTypeEnum
from ..models import NewUmConditionalOrderPriceMatchEnum
from ..models import NewUmConditionalOrderSelfTradePreventionModeEnum
from ..models import NewUmOrderSideEnum
from ..models import NewUmOrderTypeEnum
from ..models import NewUmOrderPositionSideEnum
from ..models import NewUmOrderTimeInForceEnum
from ..models import NewUmOrderNewOrderRespTypeEnum
from ..models import NewUmOrderPriceMatchEnum
from ..models import NewUmOrderSelfTradePreventionModeEnum
from ..models import QueryUsersCmForceOrdersAutoCloseTypeEnum
from ..models import QueryUsersUmForceOrdersAutoCloseTypeEnum


class TradeApi:
    """API Client for TradeApi endpoints."""

    def __init__(
        self,
        configuration: ConfigurationRestAPI = None,
        session: Session = None,
        signer: Signers = None,
    ) -> None:
        self._configuration = configuration
        self._session = session
        self._signer = signer

    def cancel_all_cm_open_conditional_orders(
        self,
        symbol: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelAllCmOpenConditionalOrdersResponse]:
        """
                Cancel All CM Open Conditional Orders(TRADE)
                DELETE /papi/v1/cm/conditional/allOpenOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-CM-Open-Conditional-Orders

                Cancel All CM Open Conditional Orders

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CancelAllCmOpenConditionalOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if symbol is None:
            raise RequiredError(
                field="symbol", error_message="Missing required parameter 'symbol'"
            )

        body = {}
        payload = {"symbol": symbol, "recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="DELETE",
            path="/papi/v1/cm/conditional/allOpenOrders",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CancelAllCmOpenConditionalOrdersResponse,
            is_signed=True,
            signer=self._signer,
        )

    def cancel_all_cm_open_orders(
        self,
        symbol: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelAllCmOpenOrdersResponse]:
        """
                Cancel All CM Open Orders(TRADE)
                DELETE /papi/v1/cm/allOpenOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-CM-Open-Orders

                Cancel all active LIMIT orders on specific symbol

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CancelAllCmOpenOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if symbol is None:
            raise RequiredError(
                field="symbol", error_message="Missing required parameter 'symbol'"
            )

        body = {}
        payload = {"symbol": symbol, "recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="DELETE",
            path="/papi/v1/cm/allOpenOrders",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CancelAllCmOpenOrdersResponse,
            is_signed=True,
            signer=self._signer,
        )

    def cancel_all_um_open_conditional_orders(
        self,
        symbol: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelAllUmOpenConditionalOrdersResponse]:
        """
                Cancel All UM Open Conditional Orders (TRADE)
                DELETE /papi/v1/um/conditional/allOpenOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-UM-Open-Conditional-Orders

                Cancel All UM Open Conditional Orders

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CancelAllUmOpenConditionalOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if symbol is None:
            raise RequiredError(
                field="symbol", error_message="Missing required parameter 'symbol'"
            )

        body = {}
        payload = {"symbol": symbol, "recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="DELETE",
            path="/papi/v1/um/conditional/allOpenOrders",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CancelAllUmOpenConditionalOrdersResponse,
            is_signed=True,
            signer=self._signer,
        )

    def cancel_all_um_open_orders(
        self,
        symbol: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelAllUmOpenOrdersResponse]:
        """
                Cancel All UM Open Orders(TRADE)
                DELETE /papi/v1/um/allOpenOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-All-UM-Open-Orders

                Cancel all active LIMIT orders on specific symbol

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CancelAllUmOpenOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if symbol is None:
            raise RequiredError(
                field="symbol", error_message="Missing required parameter 'symbol'"
            )

        body = {}
        payload = {"symbol": symbol, "recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="DELETE",
            path="/papi/v1/um/allOpenOrders",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CancelAllUmOpenOrdersResponse,
            is_signed=True,
            signer=self._signer,
        )

    def cancel_cm_conditional_order(
        self,
        symbol: Union[str, None],
        strategy_id: Optional[int] = None,
        new_client_strategy_id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelCmConditionalOrderResponse]:
        """
                Cancel CM Conditional Order(TRADE)
                DELETE /papi/v1/cm/conditional/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-CM-Conditional-Order

                Cancel CM Conditional Order

        * Either `strategyId` or `newClientStrategyId` must be sent.

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    strategy_id (Optional[int] = None):
                    new_client_strategy_id (Optional[str] = None):
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CancelCmConditionalOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if symbol is None:
            raise RequiredError(
                field="symbol", error_message="Missing required parameter 'symbol'"
            )

        body = {}
        payload = {
            "symbol": symbol,
            "strategy_id": strategy_id,
            "new_client_strategy_id": new_client_strategy_id,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="DELETE",
            path="/papi/v1/cm/conditional/order",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CancelCmConditionalOrderResponse,
            is_signed=True,
            signer=self._signer,
        )

    def cancel_cm_order(
        self,
        symbol: Union[str, None],
        order_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelCmOrderResponse]:
        """
                Cancel CM Order(TRADE)
                DELETE /papi/v1/cm/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-CM-Order

                Cancel an active LIMIT order

        * Either `orderId` or `origClientOrderId` must be sent.

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    order_id (Optional[int] = None):
                    orig_client_order_id (Optional[str] = None):
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CancelCmOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if symbol is None:
            raise RequiredError(
                field="symbol", error_message="Missing required parameter 'symbol'"
            )

        body = {}
        payload = {
            "symbol": symbol,
            "order_id": order_id,
            "orig_client_order_id": orig_client_order_id,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="DELETE",
            path="/papi/v1/cm/order",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CancelCmOrderResponse,
            is_signed=True,
            signer=self._signer,
        )

    def cancel_margin_account_all_open_orders_on_a_symbol(
        self,
        symbol: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelMarginAccountAllOpenOrdersOnASymbolResponse]:
        """
                Cancel Margin Account All Open Orders on a Symbol(TRADE)
                DELETE /papi/v1/margin/allOpenOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-Margin-Account-All-Open-Orders-on-a-Symbol

                Cancel Margin Account All Open Orders on a Symbol

        Weight: 5

                Args:
                    symbol (Union[str, None]):
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CancelMarginAccountAllOpenOrdersOnASymbolResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if symbol is None:
            raise RequiredError(
                field="symbol", error_message="Missing required parameter 'symbol'"
            )

        body = {}
        payload = {"symbol": symbol, "recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="DELETE",
            path="/papi/v1/margin/allOpenOrders",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CancelMarginAccountAllOpenOrdersOnASymbolResponse,
            is_signed=True,
            signer=self._signer,
        )

    def cancel_margin_account_oco_orders(
        self,
        symbol: Union[str, None],
        order_list_id: Optional[int] = None,
        list_client_order_id: Optional[str] = None,
        new_client_order_id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelMarginAccountOcoOrdersResponse]:
        """
                Cancel Margin Account OCO Orders(TRADE)
                DELETE /papi/v1/margin/orderList
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-Margin-Account-OCO-Orders

                Cancel Margin Account OCO Orders

        * Additional notes: Canceling an individual leg will cancel the entire OCO

        Weight: 2

                Args:
                    symbol (Union[str, None]):
                    order_list_id (Optional[int] = None): Either `orderListId` or `listClientOrderId` must be provided
                    list_client_order_id (Optional[str] = None): Either `orderListId` or `listClientOrderId` must be provided
                    new_client_order_id (Optional[str] = None): Used to uniquely identify this cancel. Automatically generated by default
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CancelMarginAccountOcoOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if symbol is None:
            raise RequiredError(
                field="symbol", error_message="Missing required parameter 'symbol'"
            )

        body = {}
        payload = {
            "symbol": symbol,
            "order_list_id": order_list_id,
            "list_client_order_id": list_client_order_id,
            "new_client_order_id": new_client_order_id,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="DELETE",
            path="/papi/v1/margin/orderList",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CancelMarginAccountOcoOrdersResponse,
            is_signed=True,
            signer=self._signer,
        )

    def cancel_margin_account_order(
        self,
        symbol: Union[str, None],
        order_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        new_client_order_id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelMarginAccountOrderResponse]:
        """
                Cancel Margin Account Order(TRADE)
                DELETE /papi/v1/margin/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-Margin-Account-Order

                Cancel Margin Account Order

        * Either `orderId` or `origClientOrderId` must be sent.

        Weight: 2

                Args:
                    symbol (Union[str, None]):
                    order_id (Optional[int] = None):
                    orig_client_order_id (Optional[str] = None):
                    new_client_order_id (Optional[str] = None): Used to uniquely identify this cancel. Automatically generated by default
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CancelMarginAccountOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if symbol is None:
            raise RequiredError(
                field="symbol", error_message="Missing required parameter 'symbol'"
            )

        body = {}
        payload = {
            "symbol": symbol,
            "order_id": order_id,
            "orig_client_order_id": orig_client_order_id,
            "new_client_order_id": new_client_order_id,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="DELETE",
            path="/papi/v1/margin/order",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CancelMarginAccountOrderResponse,
            is_signed=True,
            signer=self._signer,
        )

    def cancel_um_conditional_order(
        self,
        symbol: Union[str, None],
        strategy_id: Optional[int] = None,
        new_client_strategy_id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelUmConditionalOrderResponse]:
        """
                Cancel UM Conditional Order(TRADE)
                DELETE /papi/v1/um/conditional/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-UM-Conditional-Order

                Cancel UM Conditional Order

        * Either `strategyId` or `newClientStrategyId` must be sent.

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    strategy_id (Optional[int] = None):
                    new_client_strategy_id (Optional[str] = None):
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CancelUmConditionalOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if symbol is None:
            raise RequiredError(
                field="symbol", error_message="Missing required parameter 'symbol'"
            )

        body = {}
        payload = {
            "symbol": symbol,
            "strategy_id": strategy_id,
            "new_client_strategy_id": new_client_strategy_id,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="DELETE",
            path="/papi/v1/um/conditional/order",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CancelUmConditionalOrderResponse,
            is_signed=True,
            signer=self._signer,
        )

    def cancel_um_order(
        self,
        symbol: Union[str, None],
        order_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelUmOrderResponse]:
        """
                Cancel UM Order(TRADE)
                DELETE /papi/v1/um/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Cancel-UM-Order

                Cancel an active UM LIMIT order

        * Either `orderId` or `origClientOrderId` must be sent.

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    order_id (Optional[int] = None):
                    orig_client_order_id (Optional[str] = None):
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CancelUmOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if symbol is None:
            raise RequiredError(
                field="symbol", error_message="Missing required parameter 'symbol'"
            )

        body = {}
        payload = {
            "symbol": symbol,
            "order_id": order_id,
            "orig_client_order_id": orig_client_order_id,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="DELETE",
            path="/papi/v1/um/order",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CancelUmOrderResponse,
            is_signed=True,
            signer=self._signer,
        )

    def cm_account_trade_list(
        self,
        symbol: Optional[str] = None,
        pair: Optional[str] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        from_id: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CmAccountTradeListResponse]:
        """
                CM Account Trade List(USER_DATA)
                GET /papi/v1/cm/userTrades
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/CM-Account-Trade-List

                Get trades for a specific account and CM 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 '24 hours' data will be returned.
        * The time between `startTime` and `endTime` cannot be longer than 24 hours.

        Weight: 20 with symbol, 40 with pair

                Args:
                    symbol (Optional[str] = None):
                    pair (Optional[str] = None):
                    start_time (Optional[int] = None): Timestamp in ms to get funding from INCLUSIVE.
                    end_time (Optional[int] = None): Timestamp in ms to get funding until INCLUSIVE.
                    from_id (Optional[int] = None): Trade id to fetch from. Default gets most recent trades.
                    limit (Optional[int] = None): Default 100; max 1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CmAccountTradeListResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "symbol": symbol,
            "pair": pair,
            "start_time": start_time,
            "end_time": end_time,
            "from_id": from_id,
            "limit": limit,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/papi/v1/cm/userTrades",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CmAccountTradeListResponse,
            is_signed=True,
            signer=self._signer,
        )

    def cm_position_adl_quantile_estimation(
        self,
        symbol: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CmPositionAdlQuantileEstimationResponse]:
        """
                CM Position ADL Quantile Estimation(USER_DATA)
                GET /papi/v1/cm/adlQuantile
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/CM-Position-ADL-Quantile-Estimation

                Query CM Position ADL Quantile Estimation
        * Values update every 30s.
        * Values 0, 1, 2, 3, 4 shows the queue position and possibility of ADL from low to high.
        * For positions of the symbol are in One-way Mode or isolated margined in Hedge Mode, "LONG", "SHORT", and "BOTH" will be returned to show the positions' adl quantiles of different position sides.
        * If the positions of the symbol are crossed margined in Hedge Mode:
        * "HEDGE" as a sign will be returned instead of "BOTH";
        * A same value caculated on unrealized pnls on long and short sides' positions will be shown for "LONG" and "SHORT" when there are positions in both of long and short sides.

        Weight: 5

                Args:
                    symbol (Optional[str] = None):
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CmPositionAdlQuantileEstimationResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {"symbol": symbol, "recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/papi/v1/cm/adlQuantile",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CmPositionAdlQuantileEstimationResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_um_futures_bnb_burn_status(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetUmFuturesBnbBurnStatusResponse]:
        """
                Get UM Futures BNB Burn Status (USER_DATA)
                GET /papi/v1/um/feeBurn
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Get-UM-Futures-BNB-Burn-Status

                Get user's BNB Fee Discount for UM Futures (Fee Discount On or Fee Discount Off )

        Weight: 30

                Args:
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetUmFuturesBnbBurnStatusResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {"recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/papi/v1/um/feeBurn",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetUmFuturesBnbBurnStatusResponse,
            is_signed=True,
            signer=self._signer,
        )

    def margin_account_borrow(
        self,
        asset: Union[str, None],
        amount: Union[float, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[MarginAccountBorrowResponse]:
        """
                Margin Account Borrow(MARGIN)
                POST /papi/v1/marginLoan
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Borrow

                Apply for a margin loan.

        Weight: 100

                Args:
                    asset (Union[str, None]):
                    amount (Union[float, None]):
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[MarginAccountBorrowResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if asset is None:
            raise RequiredError(
                field="asset", error_message="Missing required parameter 'asset'"
            )
        if amount is None:
            raise RequiredError(
                field="amount", error_message="Missing required parameter 'amount'"
            )

        body = {}
        payload = {"asset": asset, "amount": amount, "recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/papi/v1/marginLoan",
            payload=payload,
            body=body,
