"""
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,
            time_unit=self._configuration.time_unit,
            response_model=MarginAccountBorrowResponse,
            is_signed=True,
            signer=self._signer,
        )

    def margin_account_new_oco(
        self,
        symbol: Union[str, None],
        side: Union[MarginAccountNewOcoSideEnum, None],
        quantity: Union[float, None],
        price: Union[float, None],
        stop_price: Union[float, None],
        list_client_order_id: Optional[str] = None,
        limit_client_order_id: Optional[str] = None,
        limit_iceberg_qty: Optional[float] = None,
        stop_client_order_id: Optional[str] = None,
        stop_limit_price: Optional[float] = None,
        stop_iceberg_qty: Optional[float] = None,
        stop_limit_time_in_force: Optional[
            MarginAccountNewOcoStopLimitTimeInForceEnum
        ] = None,
        new_order_resp_type: Optional[MarginAccountNewOcoNewOrderRespTypeEnum] = None,
        side_effect_type: Optional[MarginAccountNewOcoSideEffectTypeEnum] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[MarginAccountNewOcoResponse]:
        """
                Margin Account New OCO(TRADE)
                POST /papi/v1/margin/order/oco
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-New-OCO

                Send in a new OCO for a margin account

        * Price Restrictions:
        * `SELL`: Limit Price > Last Price > Stop Price
        * `BUY`: Limit Price < Last Price < Stop Price
        * Quantity Restrictions:
        * Both legs must have the same quantity
        * `ICEBERG` quantities however do not have to be the same.
        * Order Rate Limit
        * `OCO` counts as 2 orders against the order rate limit.

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    side (Union[MarginAccountNewOcoSideEnum, None]):
                    quantity (Union[float, None]): Order quantity
                    price (Union[float, None]):
                    stop_price (Union[float, None]):
                    list_client_order_id (Optional[str] = None): Either `orderListId` or `listClientOrderId` must be provided
                    limit_client_order_id (Optional[str] = None): A unique Id for the limit order
                    limit_iceberg_qty (Optional[float] = None):
                    stop_client_order_id (Optional[str] = None): A unique Id for the stop loss/stop loss limit leg
                    stop_limit_price (Optional[float] = None): If provided, stopLimitTimeInForce is required.
                    stop_iceberg_qty (Optional[float] = None):
                    stop_limit_time_in_force (Optional[MarginAccountNewOcoStopLimitTimeInForceEnum] = None): Valid values are `GTC/FOK/IOC`
                    new_order_resp_type (Optional[MarginAccountNewOcoNewOrderRespTypeEnum] = None): "ACK", "RESULT", default "ACK"
                    side_effect_type (Optional[MarginAccountNewOcoSideEffectTypeEnum] = None): NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; default NO_SIDE_EFFECT.
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[MarginAccountNewOcoResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        body = {}
        payload = {
            "symbol": symbol,
            "side": side,
            "quantity": quantity,
            "price": price,
            "stop_price": stop_price,
            "list_client_order_id": list_client_order_id,
            "limit_client_order_id": limit_client_order_id,
            "limit_iceberg_qty": limit_iceberg_qty,
            "stop_client_order_id": stop_client_order_id,
            "stop_limit_price": stop_limit_price,
            "stop_iceberg_qty": stop_iceberg_qty,
            "stop_limit_time_in_force": stop_limit_time_in_force,
            "new_order_resp_type": new_order_resp_type,
            "side_effect_type": side_effect_type,
            "recv_window": recv_window,
        }

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

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

                Repay for a margin loan.

        Weight: 100

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

                Returns:
                    ApiResponse[MarginAccountRepayResponse]

                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/repayLoan",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=MarginAccountRepayResponse,
            is_signed=True,
            signer=self._signer,
        )

    def margin_account_repay_debt(
        self,
        asset: Union[str, None],
        amount: Optional[str] = None,
        specify_repay_assets: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[MarginAccountRepayDebtResponse]:
        """
                Margin Account Repay Debt(TRADE)
                POST /papi/v1/margin/repay-debt
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Repay-Debt

                Repay debt for a margin loan.

        * The repay asset amount cannot exceed 50000 USD equivalent value for a single request.
        * If `amount` is not sent, all the asset loan will be repaid if having enough specific repay assets.
        * If `amount` is sent, only the certain amount of the asset loan will be repaid if having enough specific repay assets.
        * The system will use the same asset to repay the loan first (if have) no matter whether put the asset in `specifyRepayAssets`

        Weight: 3000

                Args:
                    asset (Union[str, None]):
                    amount (Optional[str] = None):
                    specify_repay_assets (Optional[str] = None): Specific asset list to repay debt; Can be added in batch, separated by commas
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[MarginAccountRepayDebtResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/papi/v1/margin/repay-debt",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=MarginAccountRepayDebtResponse,
            is_signed=True,
            signer=self._signer,
        )

    def margin_account_trade_list(
        self,
        symbol: Union[str, None],
        order_id: Optional[int] = 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[MarginAccountTradeListResponse]:
        """
                Margin Account Trade List (USER_DATA)
                GET /papi/v1/margin/myTrades
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Trade-List

                Margin Account Trade List

        Weight: 5

                Args:
                    symbol (Union[str, None]):
                    order_id (Optional[int] = 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[MarginAccountTradeListResponse]

                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,
            "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/margin/myTrades",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=MarginAccountTradeListResponse,
            is_signed=True,
            signer=self._signer,
        )

    def modify_cm_order(
        self,
        symbol: Union[str, None],
        side: Union[ModifyCmOrderSideEnum, None],
        quantity: Union[float, None],
        price: Union[float, None],
        order_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        price_match: Optional[ModifyCmOrderPriceMatchEnum] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ModifyCmOrderResponse]:
        """
                Modify CM Order(TRADE)
                PUT /papi/v1/cm/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Modify-CM-Order

                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.
        * Both `quantity` and `price` must be sent
        * When the new `quantity` or `price` doesn't satisfy PRICE_FILTER / PERCENT_FILTER / LOT_SIZE, amendment will be rejected and the order will stay as it is.
        * However the order will be cancelled by the amendment in the following situations:
        * when the order is in partially filled status and the new `quantity` <= `executedQty`
        * When the order is `GTX` and the new price will cause it to be executed immediately

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    side (Union[ModifyCmOrderSideEnum, None]):
                    quantity (Union[float, None]): Order quantity
                    price (Union[float, None]):
                    order_id (Optional[int] = None):
                    orig_client_order_id (Optional[str] = None):
                    price_match (Optional[ModifyCmOrderPriceMatchEnum] = None): only avaliable for `LIMIT`/`STOP`/`TAKE_PROFIT` order; can be set to `OPPONENT`/ `OPPONENT_5`/ `OPPONENT_10`/ `OPPONENT_20`: /`QUEUE`/ `QUEUE_5`/ `QUEUE_10`/ `QUEUE_20`; Can't be passed together with `price`
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[ModifyCmOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        body = {}
        payload = {
            "symbol": symbol,
            "side": side,
            "quantity": quantity,
            "price": price,
            "order_id": order_id,
            "orig_client_order_id": orig_client_order_id,
            "price_match": price_match,
            "recv_window": recv_window,
        }

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

    def modify_um_order(
        self,
        symbol: Union[str, None],
        side: Union[ModifyUmOrderSideEnum, None],
        quantity: Union[float, None],
        price: Union[float, None],
        order_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        price_match: Optional[ModifyUmOrderPriceMatchEnum] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ModifyUmOrderResponse]:
        """
                Modify UM Order(TRADE)
                PUT /papi/v1/um/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Modify-UM-Order

                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.
        * Both quantity and price must be sent
        * When the new quantity or price doesn't satisfy PRICE_FILTER / PERCENT_FILTER / LOT_SIZE, amendment will be rejected and the order will stay as it is.
        * However the order will be cancelled by the amendment in the following situations:
        * when the order is in partially filled status and the new quantity <= executedQty
        * When the order is GTX and the new price will cause it to be executed immediately

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    side (Union[ModifyUmOrderSideEnum, None]):
                    quantity (Union[float, None]): Order quantity
                    price (Union[float, None]):
                    order_id (Optional[int] = None):
                    orig_client_order_id (Optional[str] = None):
                    price_match (Optional[ModifyUmOrderPriceMatchEnum] = None): only avaliable for `LIMIT`/`STOP`/`TAKE_PROFIT` order; can be set to `OPPONENT`/ `OPPONENT_5`/ `OPPONENT_10`/ `OPPONENT_20`: /`QUEUE`/ `QUEUE_5`/ `QUEUE_10`/ `QUEUE_20`; Can't be passed together with `price`
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[ModifyUmOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        body = {}
        payload = {
            "symbol": symbol,
            "side": side,
            "quantity": quantity,
            "price": price,
            "order_id": order_id,
            "orig_client_order_id": orig_client_order_id,
            "price_match": price_match,
            "recv_window": recv_window,
        }

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

    def new_cm_conditional_order(
        self,
        symbol: Union[str, None],
        side: Union[NewCmConditionalOrderSideEnum, None],
        strategy_type: Union[NewCmConditionalOrderStrategyTypeEnum, None],
        position_side: Optional[NewCmConditionalOrderPositionSideEnum] = None,
        time_in_force: Optional[NewCmConditionalOrderTimeInForceEnum] = None,
        quantity: Optional[float] = None,
        reduce_only: Optional[str] = None,
        price: Optional[float] = None,
        working_type: Optional[NewCmConditionalOrderWorkingTypeEnum] = None,
        price_protect: Optional[str] = None,
        new_client_strategy_id: Optional[str] = None,
        stop_price: Optional[float] = None,
        activation_price: Optional[float] = None,
        callback_rate: Optional[float] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[NewCmConditionalOrderResponse]:
        """
                New CM Conditional Order(TRADE)
                POST /papi/v1/cm/conditional/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-CM-Conditional-Order

                New CM Conditional Order

        * Order with type `STOP/TAKE_PROFIT`, parameter `timeInForce` can be sent ( default `GTC`).
        * Condition orders will be triggered when:
        * `STOP`, `STOP_MARKET`:
        * BUY: "MARK_PRICE"  >= `stopPrice`
        * SELL: "MARK_PRICE" <= `stopPrice`
        * `TAKE_PROFIT`, `TAKE_PROFIT_MARKET`:
        * BUY: "MARK_PRICE" <= `stopPrice`
        * SELL: "MARK_PRICE" >= `stopPrice`
        * `TRAILING_STOP_MARKET`:
        * BUY: the lowest mark price after order placed `<= `activationPrice`, and the latest mark price >`= the lowest mark price * (1 + `callbackRate`)
        * SELL: the highest mark price after order placed >= `activationPrice`, and the latest mark price <= the highest mark 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 mark price.
        * SELL: `activationPrice` should be larger than latest mark price.
        * 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 /fapi/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`

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    side (Union[NewCmConditionalOrderSideEnum, None]):
                    strategy_type (Union[NewCmConditionalOrderStrategyTypeEnum, None]): "STOP", "STOP_MARKET", "TAKE_PROFIT", "TAKE_PROFIT_MARKET", and "TRAILING_STOP_MARKET"
                    position_side (Optional[NewCmConditionalOrderPositionSideEnum] = None): Default `BOTH` for One-way Mode ; `LONG` or `SHORT` for Hedge Mode. It must be sent in Hedge Mode.
                    time_in_force (Optional[NewCmConditionalOrderTimeInForceEnum] = None):
                    quantity (Optional[float] = None):
                    reduce_only (Optional[str] = None): "true" or "false". default "false". Cannot be sent in Hedge Mode .
                    price (Optional[float] = None):
                    working_type (Optional[NewCmConditionalOrderWorkingTypeEnum] = None): stopPrice triggered by: "MARK_PRICE", "CONTRACT_PRICE". Default "CONTRACT_PRICE"
                    price_protect (Optional[str] = None): "TRUE" or "FALSE", default "FALSE". Used with `STOP/STOP_MARKET` or `TAKE_PROFIT/TAKE_PROFIT_MARKET` orders
                    new_client_strategy_id (Optional[str] = None):
                    stop_price (Optional[float] = None): Used with `STOP/STOP_MARKET` or `TAKE_PROFIT/TAKE_PROFIT_MARKET` orders.
                    activation_price (Optional[float] = None): Used with `TRAILING_STOP_MARKET` orders, default as the mark price
                    callback_rate (Optional[float] = None): Used with `TRAILING_STOP_MARKET` orders, min 0.1, max 5 where 1 for 1%
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[NewCmConditionalOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        body = {}
        payload = {
            "symbol": symbol,
            "side": side,
            "strategy_type": strategy_type,
            "position_side": position_side,
            "time_in_force": time_in_force,
            "quantity": quantity,
            "reduce_only": reduce_only,
            "price": price,
            "working_type": working_type,
            "price_protect": price_protect,
            "new_client_strategy_id": new_client_strategy_id,
            "stop_price": stop_price,
            "activation_price": activation_price,
            "callback_rate": callback_rate,
            "recv_window": recv_window,
        }

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

    def new_cm_order(
        self,
        symbol: Union[str, None],
        side: Union[NewCmOrderSideEnum, None],
        type: Union[NewCmOrderTypeEnum, None],
        position_side: Optional[NewCmOrderPositionSideEnum] = None,
        time_in_force: Optional[NewCmOrderTimeInForceEnum] = None,
        quantity: Optional[float] = None,
        reduce_only: Optional[str] = None,
        price: Optional[float] = None,
        price_match: Optional[NewCmOrderPriceMatchEnum] = None,
        new_client_order_id: Optional[str] = None,
        new_order_resp_type: Optional[NewCmOrderNewOrderRespTypeEnum] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[NewCmOrderResponse]:
        """
                New CM Order(TRADE)
                POST /papi/v1/cm/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-CM-Order

                Place new CM order

        * 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.

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    side (Union[NewCmOrderSideEnum, None]):
                    type (Union[NewCmOrderTypeEnum, None]): `LIMIT`, `MARKET`
                    position_side (Optional[NewCmOrderPositionSideEnum] = None): Default `BOTH` for One-way Mode ; `LONG` or `SHORT` for Hedge Mode. It must be sent in Hedge Mode.
                    time_in_force (Optional[NewCmOrderTimeInForceEnum] = None):
                    quantity (Optional[float] = None):
                    reduce_only (Optional[str] = None): "true" or "false". default "false". Cannot be sent in Hedge Mode .
                    price (Optional[float] = None):
                    price_match (Optional[NewCmOrderPriceMatchEnum] = None): only avaliable for `LIMIT`/`STOP`/`TAKE_PROFIT` order; can be set to `OPPONENT`/ `OPPONENT_5`/ `OPPONENT_10`/ `OPPONENT_20`: /`QUEUE`/ `QUEUE_5`/ `QUEUE_10`/ `QUEUE_20`; Can't be passed together with `price`
                    new_client_order_id (Optional[str] = None): Used to uniquely identify this cancel. Automatically generated by default
                    new_order_resp_type (Optional[NewCmOrderNewOrderRespTypeEnum] = None): "ACK", "RESULT", default "ACK"
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[NewCmOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        body = {}
        payload = {
            "symbol": symbol,
            "side": side,
            "type": type,
            "position_side": position_side,
            "time_in_force": time_in_force,
            "quantity": quantity,
            "reduce_only": reduce_only,
            "price": price,
            "price_match": price_match,
            "new_client_order_id": new_client_order_id,
            "new_order_resp_type": new_order_resp_type,
            "recv_window": recv_window,
        }

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

    def new_margin_order(
        self,
        symbol: Union[str, None],
        side: Union[NewMarginOrderSideEnum, None],
        type: Union[NewMarginOrderTypeEnum, None],
        quantity: Optional[float] = None,
        quote_order_qty: Optional[float] = None,
        price: Optional[float] = None,
        stop_price: Optional[float] = None,
        new_client_order_id: Optional[str] = None,
        new_order_resp_type: Optional[NewMarginOrderNewOrderRespTypeEnum] = None,
        iceberg_qty: Optional[float] = None,
        side_effect_type: Optional[NewMarginOrderSideEffectTypeEnum] = None,
        time_in_force: Optional[NewMarginOrderTimeInForceEnum] = None,
        self_trade_prevention_mode: Optional[
            NewMarginOrderSelfTradePreventionModeEnum
        ] = None,
        auto_repay_at_cancel: Optional[bool] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[NewMarginOrderResponse]:
        """
                New Margin Order(TRADE)
                POST /papi/v1/margin/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-Margin-Order

                New Margin Order

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    side (Union[NewMarginOrderSideEnum, None]):
                    type (Union[NewMarginOrderTypeEnum, None]): `LIMIT`, `MARKET`
                    quantity (Optional[float] = None):
                    quote_order_qty (Optional[float] = None):
                    price (Optional[float] = None):
                    stop_price (Optional[float] = None): Used with `STOP/STOP_MARKET` or `TAKE_PROFIT/TAKE_PROFIT_MARKET` orders.
                    new_client_order_id (Optional[str] = None): Used to uniquely identify this cancel. Automatically generated by default
                    new_order_resp_type (Optional[NewMarginOrderNewOrderRespTypeEnum] = None): "ACK", "RESULT", default "ACK"
                    iceberg_qty (Optional[float] = None): Used with `LIMIT`, `STOP_LOSS_LIMIT`, and `TAKE_PROFIT_LIMIT` to create an iceberg order
                    side_effect_type (Optional[NewMarginOrderSideEffectTypeEnum] = None): NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; default NO_SIDE_EFFECT.
                    time_in_force (Optional[NewMarginOrderTimeInForceEnum] = None):
                    self_trade_prevention_mode (Optional[NewMarginOrderSelfTradePreventionModeEnum] = None): `NONE`:No STP / `EXPIRE_TAKER`:expire taker order when STP triggers/ `EXPIRE_MAKER`:expire taker order when STP triggers/ `EXPIRE_BOTH`:expire both orders when STP triggers
                    auto_repay_at_cancel (Optional[bool] = None): 只有在自动借款单或者自动借还单生效，true表示的是撤单后需要把订单产生的借款归还，默认为true
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[NewMarginOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        body = {}
        payload = {
            "symbol": symbol,
            "side": side,
            "type": type,
            "quantity": quantity,
            "quote_order_qty": quote_order_qty,
            "price": price,
            "stop_price": stop_price,
            "new_client_order_id": new_client_order_id,
            "new_order_resp_type": new_order_resp_type,
            "iceberg_qty": iceberg_qty,
            "side_effect_type": side_effect_type,
            "time_in_force": time_in_force,
            "self_trade_prevention_mode": self_trade_prevention_mode,
            "auto_repay_at_cancel": auto_repay_at_cancel,
            "recv_window": recv_window,
        }

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

    def new_um_conditional_order(
        self,
        symbol: Union[str, None],
        side: Union[NewUmConditionalOrderSideEnum, None],
        strategy_type: Union[NewUmConditionalOrderStrategyTypeEnum, None],
        position_side: Optional[NewUmConditionalOrderPositionSideEnum] = None,
        time_in_force: Optional[NewUmConditionalOrderTimeInForceEnum] = None,
        quantity: Optional[float] = None,
        reduce_only: Optional[str] = None,
        price: Optional[float] = None,
        working_type: Optional[NewUmConditionalOrderWorkingTypeEnum] = None,
        price_protect: Optional[str] = None,
        new_client_strategy_id: Optional[str] = None,
        stop_price: Optional[float] = None,
        activation_price: Optional[float] = None,
        callback_rate: Optional[float] = None,
        price_match: Optional[NewUmConditionalOrderPriceMatchEnum] = None,
        self_trade_prevention_mode: Optional[
            NewUmConditionalOrderSelfTradePreventionModeEnum
        ] = None,
        good_till_date: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[NewUmConditionalOrderResponse]:
        """
                New UM Conditional Order (TRADE)
                POST /papi/v1/um/conditional/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-UM-Conditional-Order

                Place new UM conditional order

        * Order with type `STOP/TAKE_PROFIT`, parameter `timeInForce` can be sent ( default `GTC`).
        * Condition orders will be triggered when:
        * `STOP`, `STOP_MARKET`:
        * BUY: "MARK_PRICE"  >= `stopPrice`
        * SELL: "MARK_PRICE" <= `stopPrice`
        * `TAKE_PROFIT`, `TAKE_PROFIT_MARKET`:
        * BUY: "MARK_PRICE" <= `stopPrice`
        * SELL: "MARK_PRICE" >= `stopPrice`
        * `TRAILING_STOP_MARKET`:
        * BUY: the lowest mark price after order placed `<= `activationPrice`, and the latest mark price >`= the lowest mark price * (1 + `callbackRate`)
        * SELL: the highest mark price after order placed >= `activationPrice`, and the latest mark price <= the highest mark 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 mark price.
        * SELL: `activationPrice` should be larger than latest mark price.
        * 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 /fapi/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`
        * `selfTradePreventionMode` is only effective when `timeInForce` set to `IOC` or `GTC` or `GTD`.
        * In extreme market conditions, timeInForce `GTD` order auto cancel time might be delayed comparing to `goodTillDate`

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    side (Union[NewUmConditionalOrderSideEnum, None]):
                    strategy_type (Union[NewUmConditionalOrderStrategyTypeEnum, None]): "STOP", "STOP_MARKET", "TAKE_PROFIT", "TAKE_PROFIT_MARKET", and "TRAILING_STOP_MARKET"
                    position_side (Optional[NewUmConditionalOrderPositionSideEnum] = None): Default `BOTH` for One-way Mode ; `LONG` or `SHORT` for Hedge Mode. It must be sent in Hedge Mode.
                    time_in_force (Optional[NewUmConditionalOrderTimeInForceEnum] = None):
                    quantity (Optional[float] = None):
                    reduce_only (Optional[str] = None): "true" or "false". default "false". Cannot be sent in Hedge Mode .
                    price (Optional[float] = None):
                    working_type (Optional[NewUmConditionalOrderWorkingTypeEnum] = None): stopPrice triggered by: "MARK_PRICE", "CONTRACT_PRICE". Default "CONTRACT_PRICE"
                    price_protect (Optional[str] = None): "TRUE" or "FALSE", default "FALSE". Used with `STOP/STOP_MARKET` or `TAKE_PROFIT/TAKE_PROFIT_MARKET` orders
                    new_client_strategy_id (Optional[str] = None):
                    stop_price (Optional[float] = None): Used with `STOP/STOP_MARKET` or `TAKE_PROFIT/TAKE_PROFIT_MARKET` orders.
                    activation_price (Optional[float] = None): Used with `TRAILING_STOP_MARKET` orders, default as the mark price
                    callback_rate (Optional[float] = None): Used with `TRAILING_STOP_MARKET` orders, min 0.1, max 5 where 1 for 1%
                    price_match (Optional[NewUmConditionalOrderPriceMatchEnum] = None): only avaliable for `LIMIT`/`STOP`/`TAKE_PROFIT` order; can be set to `OPPONENT`/ `OPPONENT_5`/ `OPPONENT_10`/ `OPPONENT_20`: /`QUEUE`/ `QUEUE_5`/ `QUEUE_10`/ `QUEUE_20`; Can't be passed together with `price`
                    self_trade_prevention_mode (Optional[NewUmConditionalOrderSelfTradePreventionModeEnum] = None): `NONE`:No STP / `EXPIRE_TAKER`:expire taker order when STP triggers/ `EXPIRE_MAKER`:expire taker order when STP triggers/ `EXPIRE_BOTH`:expire both orders when STP triggers
                    good_till_date (Optional[int] = None): order cancel time for timeInForce `GTD`, mandatory when `timeInforce` set to `GTD`; order the timestamp only retains second-level precision, ms part will be ignored; The goodTillDate timestamp must be greater than the current time plus 600 seconds and smaller than 253402300799000Mode. It must be sent in Hedge Mode.
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[NewUmConditionalOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        body = {}
        payload = {
            "symbol": symbol,
            "side": side,
            "strategy_type": strategy_type,
            "position_side": position_side,
            "time_in_force": time_in_force,
            "quantity": quantity,
            "reduce_only": reduce_only,
            "price": price,
            "working_type": working_type,
            "price_protect": price_protect,
            "new_client_strategy_id": new_client_strategy_id,
            "stop_price": stop_price,
            "activation_price": activation_price,
            "callback_rate": callback_rate,
            "price_match": price_match,
            "self_trade_prevention_mode": self_trade_prevention_mode,
            "good_till_date": good_till_date,
            "recv_window": recv_window,
        }

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

    def new_um_order(
        self,
        symbol: Union[str, None],
        side: Union[NewUmOrderSideEnum, None],
        type: Union[NewUmOrderTypeEnum, None],
        position_side: Optional[NewUmOrderPositionSideEnum] = None,
        time_in_force: Optional[NewUmOrderTimeInForceEnum] = None,
        quantity: Optional[float] = None,
        reduce_only: Optional[str] = None,
        price: Optional[float] = None,
        new_client_order_id: Optional[str] = None,
        new_order_resp_type: Optional[NewUmOrderNewOrderRespTypeEnum] = None,
        price_match: Optional[NewUmOrderPriceMatchEnum] = None,
        self_trade_prevention_mode: Optional[
            NewUmOrderSelfTradePreventionModeEnum
        ] = None,
        good_till_date: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[NewUmOrderResponse]:
        """
                New UM Order (TRADE)
                POST /papi/v1/um/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-UM-Order

                Place new UM order

        * If `newOrderRespType` is sent as `RESULT` :
        * `MARKET` order: the final FILLED result of the order will be return directly.
        * `LIMIT` order with special `timeInForce`: the final status result of the order(FILLED or EXPIRED) will be returned directly.
        * `selfTradePreventionMode` is only effective when `timeInForce` set to `IOC` or `GTC` or `GTD`.
        * In extreme market conditions, timeInForce `GTD` order auto cancel time might be delayed comparing to `goodTillDate`

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    side (Union[NewUmOrderSideEnum, None]):
                    type (Union[NewUmOrderTypeEnum, None]): `LIMIT`, `MARKET`
                    position_side (Optional[NewUmOrderPositionSideEnum] = None): Default `BOTH` for One-way Mode ; `LONG` or `SHORT` for Hedge Mode. It must be sent in Hedge Mode.
                    time_in_force (Optional[NewUmOrderTimeInForceEnum] = None):
                    quantity (Optional[float] = None):
                    reduce_only (Optional[str] = None): "true" or "false". default "false". Cannot be sent in Hedge Mode .
                    price (Optional[float] = None):
                    new_client_order_id (Optional[str] = None): Used to uniquely identify this cancel. Automatically generated by default
                    new_order_resp_type (Optional[NewUmOrderNewOrderRespTypeEnum] = None): "ACK", "RESULT", default "ACK"
                    price_match (Optional[NewUmOrderPriceMatchEnum] = None): only avaliable for `LIMIT`/`STOP`/`TAKE_PROFIT` order; can be set to `OPPONENT`/ `OPPONENT_5`/ `OPPONENT_10`/ `OPPONENT_20`: /`QUEUE`/ `QUEUE_5`/ `QUEUE_10`/ `QUEUE_20`; Can't be passed together with `price`
                    self_trade_prevention_mode (Optional[NewUmOrderSelfTradePreventionModeEnum] = None): `NONE`:No STP / `EXPIRE_TAKER`:expire taker order when STP triggers/ `EXPIRE_MAKER`:expire taker order when STP triggers/ `EXPIRE_BOTH`:expire both orders when STP triggers
                    good_till_date (Optional[int] = None): order cancel time for timeInForce `GTD`, mandatory when `timeInforce` set to `GTD`; order the timestamp only retains second-level precision, ms part will be ignored; The goodTillDate timestamp must be greater than the current time plus 600 seconds and smaller than 253402300799000Mode. It must be sent in Hedge Mode.
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[NewUmOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        body = {}
        payload = {
            "symbol": symbol,
            "side": side,
            "type": type,
            "position_side": position_side,
            "time_in_force": time_in_force,
            "quantity": quantity,
            "reduce_only": reduce_only,
            "price": price,
            "new_client_order_id": new_client_order_id,
            "new_order_resp_type": new_order_resp_type,
            "price_match": price_match,
            "self_trade_prevention_mode": self_trade_prevention_mode,
            "good_till_date": good_till_date,
            "recv_window": recv_window,
        }

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

    def query_all_cm_conditional_orders(
        self,
        symbol: Optional[str] = None,
        strategy_id: Optional[int] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryAllCmConditionalOrdersResponse]:
        """
                Query All CM Conditional Orders(USER_DATA)
                GET /papi/v1/cm/conditional/allOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Conditional-Orders

                Query All CM Conditional Orders

        * These orders will not be found:
        * order strategyStatus is `CANCELED` or `EXPIRED`, **AND**
        * order has NO filled trade, **AND**
        * created time + 7 days < current time
        * The query time period must be less than 7 days( default as the recent 7 days).

        Weight: 1 for a single symbol; 40 when the symbol parameter is omitted

                Args:
                    symbol (Optional[str] = None):
                    strategy_id (Optional[int] = 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.
                    limit (Optional[int] = None): Default 100; max 1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryAllCmConditionalOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

    def query_all_cm_orders(
        self,
        symbol: Union[str, None],
        pair: Optional[str] = None,
        order_id: Optional[int] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryAllCmOrdersResponse]:
        """
                Query All CM Orders (USER_DATA)
                GET /papi/v1/cm/allOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-CM-Orders

                Get all account CM orders; active, canceled, or filled.

        * Either `symbol` or `pair` must be sent.
        * If `orderId` is set, it will get orders >= that orderId. Otherwise most recent orders are returned.
        * These orders will not be found:
        * order status is `CANCELED` or `EXPIRED`, **AND**
        * order has NO filled trade, **AND**
        * created time + 3 days < current time

        Weight: 20 with symbol, 40 with pair

                Args:
                    symbol (Union[str, None]):
                    pair (Optional[str] = None):
                    order_id (Optional[int] = 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.
                    limit (Optional[int] = None): Default 100; max 1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryAllCmOrdersResponse]

                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,
            "pair": pair,
            "order_id": order_id,
            "start_time": start_time,
            "end_time": end_time,
            "limit": limit,
            "recv_window": recv_window,
        }

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

    def query_all_current_cm_open_conditional_orders(
        self,
        symbol: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryAllCurrentCmOpenConditionalOrdersResponse]:
        """
                Query All Current CM Open Conditional Orders (USER_DATA)
                GET /papi/v1/cm/conditional/openOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-CM-Open-Conditional-Orders

                Get all open conditional orders on a symbol. **Careful** when accessing this with no symbol.

        * If the symbol is not sent, orders for all symbols will be returned in an array.

        Weight: 1 for a single symbol; 40 when the symbol parameter is omitted

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

                Returns:
                    ApiResponse[QueryAllCurrentCmOpenConditionalOrdersResponse]

                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/conditional/openOrders",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryAllCurrentCmOpenConditionalOrdersResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_all_current_cm_open_orders(
        self,
        symbol: Optional[str] = None,
        pair: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryAllCurrentCmOpenOrdersResponse]:
        """
                Query All Current CM Open Orders(USER_DATA)
                GET /papi/v1/cm/openOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-CM-Open-Orders

                Get all open orders on a symbol.

        * If the symbol is not sent, orders for all symbols will be returned in an array.

        Weight: 1 for a single symbol; 40 when the symbol parameter is omitted
        Careful when accessing this with no symbol.

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

                Returns:
                    ApiResponse[QueryAllCurrentCmOpenOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

    def query_all_current_um_open_conditional_orders(
        self,
        symbol: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryAllCurrentUmOpenConditionalOrdersResponse]:
        """
                Query All Current UM Open Conditional Orders(USER_DATA)
                GET /papi/v1/um/conditional/openOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-UM-Open-Conditional-Orders

                Get all open conditional orders on a symbol.

        * If the symbol is not sent, orders for all symbols will be returned in an array.

        Weight: 1 for a single symbol; 40 when the symbol parameter is omitted
        Careful when accessing this with no symbol.

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

                Returns:
                    ApiResponse[QueryAllCurrentUmOpenConditionalOrdersResponse]

                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/um/conditional/openOrders",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryAllCurrentUmOpenConditionalOrdersResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_all_current_um_open_orders(
        self,
        symbol: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryAllCurrentUmOpenOrdersResponse]:
        """
                Query All Current UM Open Orders(USER_DATA)
                GET /papi/v1/um/openOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Current-UM-Open-Orders

                Get all open orders on a symbol.


        * If the symbol is not sent, orders for all symbols will be returned in an array.

        Weight: 1 for a single symbol; 40 when the symbol parameter is omitted

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

                Returns:
                    ApiResponse[QueryAllCurrentUmOpenOrdersResponse]

                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/um/openOrders",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryAllCurrentUmOpenOrdersResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_all_margin_account_orders(
        self,
        symbol: Union[str, None],
        order_id: Optional[int] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryAllMarginAccountOrdersResponse]:
        """
                Query All Margin Account Orders (USER_DATA)
                GET /papi/v1/margin/allOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-Margin-Account-Orders

                Query All Margin Account Orders

        Weight: 100

                Args:
                    symbol (Union[str, None]):
                    order_id (Optional[int] = 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.
                    limit (Optional[int] = None): Default 100; max 1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryAllMarginAccountOrdersResponse]

                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,
            "start_time": start_time,
            "end_time": end_time,
            "limit": limit,
            "recv_window": recv_window,
        }

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

    def query_all_um_conditional_orders(
        self,
        symbol: Optional[str] = None,
        strategy_id: Optional[int] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryAllUmConditionalOrdersResponse]:
        """
                Query All UM Conditional Orders(USER_DATA)
                GET /papi/v1/um/conditional/allOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Conditional-Orders

                Query All UM Conditional Orders

        * These orders will not be found:
        * order strategyStatus is `CANCELED` or `EXPIRED`, **AND**
        * order has NO filled trade, **AND**
        * created time + 7 days < current time
        * The query time period must be less than 7 days( default as the recent 7 days).

        Weight: 1 for a single symbol; 40 when the symbol parameter is omitted

                Args:
                    symbol (Optional[str] = None):
                    strategy_id (Optional[int] = 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.
                    limit (Optional[int] = None): Default 100; max 1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryAllUmConditionalOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

    def query_all_um_orders(
        self,
        symbol: Union[str, None],
        order_id: Optional[int] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryAllUmOrdersResponse]:
        """
                Query All UM Orders(USER_DATA)
                GET /papi/v1/um/allOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-All-UM-Orders

                Get all account UM 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

        * 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: 5

                Args:
                    symbol (Union[str, None]):
                    order_id (Optional[int] = 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.
                    limit (Optional[int] = None): Default 100; max 1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryAllUmOrdersResponse]

                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,
            "start_time": start_time,
            "end_time": end_time,
            "limit": limit,
            "recv_window": recv_window,
        }

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

    def query_cm_conditional_order_history(
        self,
        symbol: Union[str, None],
        strategy_id: Optional[int] = None,
        new_client_strategy_id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryCmConditionalOrderHistoryResponse]:
        """
                Query CM Conditional Order History(USER_DATA)
                GET /papi/v1/cm/conditional/orderHistory
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-CM-Conditional-Order-History

                Query CM Conditional Order History


        * Either `strategyId` or `newClientStrategyId` must be sent.
        * `NEW` orders will not be found.
        * These orders will not be found:
        * order status is `CANCELED` or `EXPIRED`, **AND**
        * order has NO filled trade, **AND**
        * created time + 7 days < current time

        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[QueryCmConditionalOrderHistoryResponse]

                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="GET",
            path="/papi/v1/cm/conditional/orderHistory",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryCmConditionalOrderHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_cm_modify_order_history(
        self,
        symbol: Union[str, None],
        order_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryCmModifyOrderHistoryResponse]:
        """
                Query CM Modify Order History(TRADE)
                GET /papi/v1/cm/orderAmendment
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-CM-Modify-Order-History

                Get order modification history

        * Either `orderId` or `origClientOrderId` must be sent, and the `orderId` will prevail if both are sent.

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    order_id (Optional[int] = None):
                    orig_client_order_id (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.
                    limit (Optional[int] = None): Default 100; max 1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryCmModifyOrderHistoryResponse]

                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,
            "start_time": start_time,
            "end_time": end_time,
            "limit": limit,
            "recv_window": recv_window,
        }

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

    def query_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[QueryCmOrderResponse]:
        """
                Query CM Order(USER_DATA)
                GET /papi/v1/cm/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-CM-Order

                Check an CM order's status.

        * Either `orderId` or `origClientOrderId` must be sent.
        * These orders will not be found:
        * order status is `CANCELED` or `EXPIRED`, **AND**
        * order has NO filled trade, **AND**
        * created time + 3 days < current time

        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[QueryCmOrderResponse]

                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="GET",
            path="/papi/v1/cm/order",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryCmOrderResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_current_cm_open_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[QueryCurrentCmOpenConditionalOrderResponse]:
        """
                Query Current CM Open Conditional Order(USER_DATA)
                GET /papi/v1/cm/conditional/openOrder
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-CM-Open-Conditional-Order

                Query Current CM Open Conditional Order

        * Either `strategyId` or `newClientStrategyId` must be sent.
        * If the queried order has been triggered, cancelled or expired, the error message "Order does not exist" will be returned.

        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[QueryCurrentCmOpenConditionalOrderResponse]

                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="GET",
            path="/papi/v1/cm/conditional/openOrder",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryCurrentCmOpenConditionalOrderResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_current_cm_open_order(
        self,
        symbol: Union[str, None],
        order_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryCurrentCmOpenOrderResponse]:
        """
                Query Current CM Open Order (USER_DATA)
                GET /papi/v1/cm/openOrder
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-CM-Open-Order

                Query current CM 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

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

                Returns:
                    ApiResponse[QueryCurrentCmOpenOrderResponse]

                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="GET",
            path="/papi/v1/cm/openOrder",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryCurrentCmOpenOrderResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_current_margin_open_order(
        self,
        symbol: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryCurrentMarginOpenOrderResponse]:
        """
                Query Current Margin Open Order (USER_DATA)
                GET /papi/v1/margin/openOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-Margin-Open-Order

                Query Current Margin Open Order

        Weight: 5

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

                Returns:
                    ApiResponse[QueryCurrentMarginOpenOrderResponse]

                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="GET",
            path="/papi/v1/margin/openOrders",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryCurrentMarginOpenOrderResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_current_um_open_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[QueryCurrentUmOpenConditionalOrderResponse]:
        """
                Query Current UM Open Conditional Order(USER_DATA)
                GET /papi/v1/um/conditional/openOrder
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-UM-Open-Conditional-Order

                Query Current UM Open Conditional Order

        * Either `strategyId` or `newClientStrategyId` must be sent.
        * If the queried order has been `CANCELED`, `TRIGGERED`或`EXPIRED`, the error message "Order does not exist" will be returned.

        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[QueryCurrentUmOpenConditionalOrderResponse]

                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="GET",
            path="/papi/v1/um/conditional/openOrder",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryCurrentUmOpenConditionalOrderResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_current_um_open_order(
        self,
        symbol: Union[str, None],
        order_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryCurrentUmOpenOrderResponse]:
        """
                Query Current UM Open Order(USER_DATA)
                GET /papi/v1/um/openOrder
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Current-UM-Open-Order

                Query current UM 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

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

                Returns:
                    ApiResponse[QueryCurrentUmOpenOrderResponse]

                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="GET",
            path="/papi/v1/um/openOrder",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryCurrentUmOpenOrderResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_margin_account_order(
        self,
        symbol: Union[str, None],
        order_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryMarginAccountOrderResponse]:
        """
                Query Margin Account Order (USER_DATA)
                GET /papi/v1/margin/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Margin-Account-Order

                Query Margin Account Order

        Weight: 10

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

                Returns:
                    ApiResponse[QueryMarginAccountOrderResponse]

                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="GET",
            path="/papi/v1/margin/order",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryMarginAccountOrderResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_margin_accounts_all_oco(
        self,
        from_id: Optional[int] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryMarginAccountsAllOcoResponse]:
        """
                Query Margin Account's all OCO (USER_DATA)
                GET /papi/v1/margin/allOrderList
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Margin-Account-all-OCO

                Query all OCO for a specific margin account based on provided optional parameters

        Weight: 100

                Args:
                    from_id (Optional[int] = None): Trade id to fetch from. Default gets most recent trades.
                    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.
                    limit (Optional[int] = None): Default 100; max 1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryMarginAccountsAllOcoResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

    def query_margin_accounts_oco(
        self,
        order_list_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryMarginAccountsOcoResponse]:
        """
                Query Margin Account's OCO (USER_DATA)
                GET /papi/v1/margin/orderList
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Margin-Account-OCO

                Retrieves a specific OCO based on provided optional parameters

        Weight: 5

                Args:
                    order_list_id (Optional[int] = None): Either `orderListId` or `listClientOrderId` must be provided
                    orig_client_order_id (Optional[str] = None):
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryMarginAccountsOcoResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "order_list_id": order_list_id,
            "orig_client_order_id": orig_client_order_id,
            "recv_window": recv_window,
        }

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

    def query_margin_accounts_open_oco(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryMarginAccountsOpenOcoResponse]:
        """
                Query Margin Account's Open OCO (USER_DATA)
                GET /papi/v1/margin/openOrderList
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Margin-Account-Open-OCO

                Query Margin Account's Open OCO

        Weight: 5

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

                Returns:
                    ApiResponse[QueryMarginAccountsOpenOcoResponse]

                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/margin/openOrderList",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryMarginAccountsOpenOcoResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_um_conditional_order_history(
        self,
        symbol: Union[str, None],
        strategy_id: Optional[int] = None,
        new_client_strategy_id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryUmConditionalOrderHistoryResponse]:
        """
                Query UM Conditional Order History(USER_DATA)
                GET /papi/v1/um/conditional/orderHistory
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-UM-Conditional-Order-History

                Query UM Conditional Order History

        * Either `strategyId` or `newClientStrategyId` must be sent.
        * `NEW` orders will not be found.
        * These orders will not be found:
        * order status is `CANCELED` or `EXPIRED`, **AND**
        * order has NO filled trade, **AND**
        * created time + 7 days < current time

        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[QueryUmConditionalOrderHistoryResponse]

                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="GET",
            path="/papi/v1/um/conditional/orderHistory",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryUmConditionalOrderHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_um_modify_order_history(
        self,
        symbol: Union[str, None],
        order_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryUmModifyOrderHistoryResponse]:
        """
                Query UM Modify Order History(TRADE)
                GET /papi/v1/um/orderAmendment
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-UM-Modify-Order-History

                Get order modification history

        * Either `orderId` or `origClientOrderId` must be sent, and the `orderId` will prevail if both are sent.

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    order_id (Optional[int] = None):
                    orig_client_order_id (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.
                    limit (Optional[int] = None): Default 100; max 1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryUmModifyOrderHistoryResponse]

                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,
            "start_time": start_time,
            "end_time": end_time,
            "limit": limit,
            "recv_window": recv_window,
        }

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

    def query_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[QueryUmOrderResponse]:
        """
                Query UM Order (USER_DATA)
                GET /papi/v1/um/order
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-UM-Order

                Check an UM order's status.

        * These orders will not be found:
        * Either `orderId` or `origClientOrderId` must be sent.
        * order status is `CANCELED` or `EXPIRED`, **AND**
        * order has NO filled trade, **AND**
        * created time + 3 days < current time

        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[QueryUmOrderResponse]

                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="GET",
            path="/papi/v1/um/order",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryUmOrderResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_users_cm_force_orders(
        self,
        symbol: Optional[str] = None,
        auto_close_type: Optional[QueryUsersCmForceOrdersAutoCloseTypeEnum] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryUsersCmForceOrdersResponse]:
        """
                Query User's CM Force Orders(USER_DATA)
                GET /papi/v1/cm/forceOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Users-CM-Force-Orders

                Query User's CM Force Orders

        * If "autoCloseType" is not sent, orders with both of the types will be returned
        * If "startTime" is not sent, data within 7 days before "endTime" can be queried

        Weight: 20 with symbol, 50 without symbol

                Args:
                    symbol (Optional[str] = None):
                    auto_close_type (Optional[QueryUsersCmForceOrdersAutoCloseTypeEnum] = None): `LIQUIDATION` for liquidation orders, `ADL` for ADL orders.
                    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.
                    limit (Optional[int] = None): Default 100; max 1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryUsersCmForceOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

    def query_users_margin_force_orders(
        self,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        current: Optional[int] = None,
        size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryUsersMarginForceOrdersResponse]:
        """
                Query User's Margin Force Orders(USER_DATA)
                GET /papi/v1/margin/forceOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Users-Margin-Force-Orders

                Query user's margin force orders

        Weight: 1

                Args:
                    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.
                    current (Optional[int] = None): Currently querying page. Start from 1. Default:1
                    size (Optional[int] = None): Default:10 Max:100
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryUsersMarginForceOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "start_time": start_time,
            "end_time": end_time,
            "current": current,
            "size": size,
            "recv_window": recv_window,
        }

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

    def query_users_um_force_orders(
        self,
        symbol: Optional[str] = None,
        auto_close_type: Optional[QueryUsersUmForceOrdersAutoCloseTypeEnum] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryUsersUmForceOrdersResponse]:
        """
                Query User's UM Force Orders (USER_DATA)
                GET /papi/v1/um/forceOrders
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-Users-UM-Force-Orders

                Query User's UM Force Orders

        * If `autoCloseType` is not sent, orders with both of the types will be returned
        * If `startTime` is not sent, data within 7 days before `endTime` can be queried

        Weight: 20 with symbol, 50 without symbol

                Args:
                    symbol (Optional[str] = None):
                    auto_close_type (Optional[QueryUsersUmForceOrdersAutoCloseTypeEnum] = None): `LIQUIDATION` for liquidation orders, `ADL` for ADL orders.
                    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.
                    limit (Optional[int] = None): Default 100; max 1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryUsersUmForceOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

    def toggle_bnb_burn_on_um_futures_trade(
        self,
        fee_burn: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ToggleBnbBurnOnUmFuturesTradeResponse]:
        """
                Toggle BNB Burn On UM Futures Trade (TRADE)
                POST /papi/v1/um/feeBurn
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Toggle-BNB-Burn-On-UM-Futures-Trade

                Change user's BNB Fee Discount for UM Futures (Fee Discount On or Fee Discount Off ) on ***EVERY symbol***


        * The BNB would not be collected from UM-PM account to the Portfolio Margin account.

        Weight: 1

                Args:
                    fee_burn (Union[str, None]): "true": Fee Discount On; "false": Fee Discount Off
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[ToggleBnbBurnOnUmFuturesTradeResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

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

    def um_account_trade_list(
        self,
        symbol: Union[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[UmAccountTradeListResponse]:
        """
                UM Account Trade List(USER_DATA)
                GET /papi/v1/um/userTrades
                https://developers.binance.com/docs/derivatives/portfolio-margin/trade/UM-Account-Trade-List

                Get trades for a specific account and UM symbol.


        * If `startTime` and `endTime` are both not sent, then the last '7 days' data will be returned.
        * The time between `startTime` and `endTime` cannot be longer than 7 days.
        * The parameter `fromId` cannot be sent with `startTime` or `endTime`.

        Weight: 5

                Args:
                    symbol (Union[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[UmAccountTradeListResponse]

                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,
            "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/um/userTrades",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=UmAccountTradeListResponse,
            is_signed=True,
            signer=self._signer,
        )

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

                Query UM Position ADL Quantile Estimation

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

        Weight: 5

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

                Returns:
                    ApiResponse[UmPositionAdlQuantileEstimationResponse]

                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/um/adlQuantile",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=UmPositionAdlQuantileEstimationResponse,
            is_signed=True,
            signer=self._signer,
        )
