"""
Binance Derivatives Trading COIN Futures REST API

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

Do not edit the class manually.
"""

from typing import List, 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 AccountTradeListResponse
from ..models import AllOrdersResponse

from ..models import CancelAllOpenOrdersResponse
from ..models import CancelMultipleOrdersResponse
from ..models import CancelOrderResponse
from ..models import ChangeInitialLeverageResponse
from ..models import ChangeMarginTypeResponse
from ..models import ChangePositionModeResponse
from ..models import CurrentAllOpenOrdersResponse
from ..models import GetOrderModifyHistoryResponse
from ..models import GetPositionMarginChangeHistoryResponse
from ..models import ModifyIsolatedPositionMarginResponse
from ..models import ModifyMultipleOrdersResponse
from ..models import ModifyOrderResponse
from ..models import NewOrderResponse
from ..models import PositionAdlQuantileEstimationResponse
from ..models import PositionInformationResponse
from ..models import QueryCurrentOpenOrderResponse
from ..models import QueryOrderResponse
from ..models import UsersForceOrdersResponse


from ..models import ChangeMarginTypeMarginTypeEnum
from ..models import ModifyIsolatedPositionMarginTypeEnum
from ..models import ModifyIsolatedPositionMarginPositionSideEnum
from ..models import ModifyOrderSideEnum
from ..models import ModifyOrderPriceMatchEnum
from ..models import NewOrderSideEnum
from ..models import NewOrderTypeEnum
from ..models import NewOrderPositionSideEnum
from ..models import NewOrderTimeInForceEnum
from ..models import NewOrderWorkingTypeEnum
from ..models import NewOrderNewOrderRespTypeEnum
from ..models import NewOrderPriceMatchEnum
from ..models import NewOrderSelfTradePreventionModeEnum
from ..models import UsersForceOrdersAutoCloseTypeEnum


from ..models import ModifyMultipleOrdersBatchOrdersParameterInner


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 account_trade_list(
        self,
        symbol: Optional[str] = None,
        pair: Optional[str] = None,
        order_id: 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[AccountTradeListResponse]:
        """
                Account Trade List (USER_DATA)
                GET /dapi/v1/userTrades
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Account-Trade-List

                Get trades for a specific account and symbol.


        * Either symbol or pair must be sent
        * Symbol and pair cannot be sent together
        * Pair and fromId cannot be sent together
        * OrderId can only be sent together with symbol
        * If a pair is sent,tickers for all symbols of the pair will be returned
        * The parameter `fromId` cannot be sent with `startTime` or `endTime`
        * If startTime and endTime are both not sent, then the last 7 days' data will be returned.
        * The time between startTime and endTime cannot be longer than 7 days.

        Weight: 20 with symbol，40 with pair

                Args:
                    symbol (Optional[str] = None):
                    pair (Optional[str] = None):
                    order_id (Optional[str] = None):
                    start_time (Optional[int] = None):
                    end_time (Optional[int] = None):
                    from_id (Optional[int] = None): ID to get aggregate trades from INCLUSIVE.
                    limit (Optional[int] = None): Default 100; max 1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[AccountTradeListResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "symbol": symbol,
            "pair": pair,
            "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="/dapi/v1/userTrades",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=AccountTradeListResponse,
            is_signed=True,
            signer=self._signer,
        )

    def all_orders(
        self,
        symbol: Optional[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[AllOrdersResponse]:
        """
                All Orders (USER_DATA)
                GET /dapi/v1/allOrders
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/All-Orders

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

        * These orders will not be found:
        * order status is CANCELED or EXPIRED AND order has NO filled trade AND created time + 3 days < current time
        * order create time + 90 days < current time


        * Either `symbol` or `pair` must be sent.
        * `pair` can't be sent with `orderId`
        * If `orderId` is set, it will get orders >= that `orderId`. Otherwise most recent orders are returned.
        * If orderId is set, it will get orders >= that orderId. Otherwise most recent orders are returned.
        * The query time period must be less then 7 days( default as the recent 7 days).

        Weight: 20 with symbol, 40 with pair

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

                Returns:
                    ApiResponse[AllOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

    def auto_cancel_all_open_orders(
        self,
        symbol: Union[str, None],
        countdown_time: Union[int, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[None]:
        """
                Auto-Cancel All Open Orders (TRADE)
                POST /dapi/v1/countdownCancelAll
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Auto-Cancel-All-Open-Orders

                Cancel all open orders of the specified symbol at the end of the specified countdown. This rest endpoint means to ensure your open orders are canceled in case of an outage. The endpoint should be called repeatedly as heartbeats so that the existing countdown time can be canceled and repalced by a new one. The system will check all countdowns **approximately every 10 milliseconds**, so please note that sufficient redundancy should be considered when using this function. We do not recommend setting the countdown time to be too precise or too small.

        * Example usage:
        Call this endpoint at 30s intervals with an countdownTime of 120000 (120s).
        If this endpoint is not called within 120 seconds, all your orders of the specified symbol will be automatically canceled.
        If this endpoint is called with an countdownTime of 0, the countdown timer will be stopped.

        Weight: 10

                Args:
                    symbol (Union[str, None]):
                    countdown_time (Union[int, None]): countdown time, 1000 for 1 second. 0 to cancel the timer
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[None]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/dapi/v1/countdownCancelAll",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            is_signed=True,
            signer=self._signer,
        )

    def cancel_all_open_orders(
        self,
        symbol: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelAllOpenOrdersResponse]:
        """
                Cancel All Open Orders(TRADE)
                DELETE /dapi/v1/allOpenOrders
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Cancel-All-Open-Orders

                Cancel All Open Orders

        Weight: 1

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

                Returns:
                    ApiResponse[CancelAllOpenOrdersResponse]

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

    def cancel_multiple_orders(
        self,
        symbol: Union[str, None],
        order_id_list: Optional[List[int]] = None,
        orig_client_order_id_list: Optional[List[str]] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelMultipleOrdersResponse]:
        """
                Cancel Multiple Orders(TRADE)
                DELETE /dapi/v1/batchOrders
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Cancel-Multiple-Orders

                Cancel Multiple Orders

        * Either `orderIdList` or `origClientOrderIdList ` must be sent.

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    order_id_list (Optional[List[int]] = None): max length 10 <br /> e.g. [1234567,2345678]
                    orig_client_order_id_list (Optional[List[str]] = None): max length 10<br /> e.g. ["my_id_1","my_id_2"], encode the double quotes. No space after comma.
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[CancelMultipleOrdersResponse]

                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_list": order_id_list,
            "orig_client_order_id_list": orig_client_order_id_list,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="DELETE",
            path="/dapi/v1/batchOrders",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=CancelMultipleOrdersResponse,
            is_signed=True,
            signer=self._signer,
        )

    def cancel_order(
        self,
        symbol: Union[str, None],
        order_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CancelOrderResponse]:
        """
                Cancel Order (TRADE)
                DELETE /dapi/v1/order
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Cancel-Order

                Cancel an active 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[CancelOrderResponse]

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

    def change_initial_leverage(
        self,
        symbol: Union[str, None],
        leverage: Union[int, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ChangeInitialLeverageResponse]:
        """
                Change Initial Leverage (TRADE)
                POST /dapi/v1/leverage
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Change-Initial-Leverage

                Change user's initial leverage in the specific symbol market.
        For Hedge Mode, LONG and SHORT positions of one symbol use the same initial leverage and share a total notional value.

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    leverage (Union[int, None]): target initial leverage: int from 1 to 125
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[ChangeInitialLeverageResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/dapi/v1/leverage",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=ChangeInitialLeverageResponse,
            is_signed=True,
            signer=self._signer,
        )

    def change_margin_type(
        self,
        symbol: Union[str, None],
        margin_type: Union[ChangeMarginTypeMarginTypeEnum, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ChangeMarginTypeResponse]:
        """
                Change Margin Type (TRADE)
                POST /dapi/v1/marginType
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Change-Margin-Type

                Change user's margin type in the specific symbol market.For Hedge Mode, LONG and SHORT positions of one symbol use the same margin type.
        With ISOLATED margin type, margins of the LONG and SHORT positions are isolated from each other.

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    margin_type (Union[ChangeMarginTypeMarginTypeEnum, None]): ISOLATED, CROSSED
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[ChangeMarginTypeResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/dapi/v1/marginType",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=ChangeMarginTypeResponse,
            is_signed=True,
            signer=self._signer,
        )

    def change_position_mode(
        self,
        dual_side_position: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ChangePositionModeResponse]:
        """
                Change Position Mode(TRADE)
                POST /dapi/v1/positionSide/dual
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Change-Position-Mode

                Change user's position mode (Hedge Mode or One-way Mode ) on ***EVERY symbol***

        Weight: 1

                Args:
                    dual_side_position (Union[str, None]): "true": Hedge Mode; "false": One-way Mode
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[ChangePositionModeResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/dapi/v1/positionSide/dual",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=ChangePositionModeResponse,
            is_signed=True,
            signer=self._signer,
        )

    def current_all_open_orders(
        self,
        symbol: Optional[str] = None,
        pair: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CurrentAllOpenOrdersResponse]:
        """
                Current All Open Orders (USER_DATA)
                GET /dapi/v1/openOrders
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Current-All-Open-Orders

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

        Weight: 1 for a single symbol, 40 for mutltiple symbols

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

                Returns:
                    ApiResponse[CurrentAllOpenOrdersResponse]

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

    def get_order_modify_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[GetOrderModifyHistoryResponse]:
        """
                Get Order Modify History (USER_DATA)
                GET /dapi/v1/orderAmendment
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Get-Order-Modify-History

                Get order modification history


        * Either `orderId` or `origClientOrderId` must be sent, and the `orderId` will prevail if both are sent.
        * Order modify history longer than 3 month is not avaliable

        Weight: 1

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

                Returns:
                    ApiResponse[GetOrderModifyHistoryResponse]

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

    def get_position_margin_change_history(
        self,
        symbol: Union[str, None],
        type: Optional[int] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetPositionMarginChangeHistoryResponse]:
        """
                Get Position Margin Change History(TRADE)
                GET /dapi/v1/positionMargin/history
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Get-Position-Margin-Change-History

                Get position margin change history

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    type (Optional[int] = None): 1: Add position margin,2: Reduce position margin
                    start_time (Optional[int] = None):
                    end_time (Optional[int] = None):
                    limit (Optional[int] = None): Default 100; max 1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetPositionMarginChangeHistoryResponse]

                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,
            "type": 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="/dapi/v1/positionMargin/history",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetPositionMarginChangeHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def modify_isolated_position_margin(
        self,
        symbol: Union[str, None],
        amount: Union[float, None],
        type: Union[ModifyIsolatedPositionMarginTypeEnum, None],
        position_side: Optional[ModifyIsolatedPositionMarginPositionSideEnum] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ModifyIsolatedPositionMarginResponse]:
        """
                Modify Isolated Position Margin(TRADE)
                POST /dapi/v1/positionMargin
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Isolated-Position-Margin

                Modify Isolated Position Margin

        * Only for isolated symbol

        Weight: 1

                Args:
                    symbol (Union[str, None]):
                    amount (Union[float, None]):
                    type (Union[ModifyIsolatedPositionMarginTypeEnum, None]):
                    position_side (Optional[ModifyIsolatedPositionMarginPositionSideEnum] = None): Default `BOTH` for One-way Mode ; `LONG` or `SHORT` for Hedge Mode. It must be sent with Hedge Mode.
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[ModifyIsolatedPositionMarginResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        body = {}
        payload = {
            "symbol": symbol,
            "amount": amount,
            "type": type,
            "position_side": position_side,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/dapi/v1/positionMargin",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=ModifyIsolatedPositionMarginResponse,
            is_signed=True,
            signer=self._signer,
        )

    def modify_multiple_orders(
        self,
        batch_orders: Union[List[ModifyMultipleOrdersBatchOrdersParameterInner], None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ModifyMultipleOrdersResponse]:
        """
                Modify Multiple Orders(TRADE)
                PUT /dapi/v1/batchOrders
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-Multiple-Orders

                Modify Multiple Orders

        * Parameter rules are same with `Modify Order`
        * Batch modify orders are processed concurrently, and the order of matching is not guaranteed.
        * The order of returned contents for batch modify orders is the same as the order of the order list.
        * One order can only be modfied for less than 10000 times

        Weight: 5

                Args:
                    batch_orders (Union[List[ModifyMultipleOrdersBatchOrdersParameterInner], None]): order list. Max 5 orders
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[ModifyMultipleOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

        return send_request(
            self._session,
            self._configuration,
            method="PUT",
            path="/dapi/v1/batchOrders",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=ModifyMultipleOrdersResponse,
            is_signed=True,
            signer=self._signer,
        )

    def modify_order(
        self,
        symbol: Union[str, None],
        side: Union[ModifyOrderSideEnum, None],
        order_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        quantity: Optional[float] = None,
        price: Optional[float] = None,
        price_match: Optional[ModifyOrderPriceMatchEnum] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ModifyOrderResponse]:
        """
                Modify Order (TRADE)
                PUT /dapi/v1/order
                https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Modify-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.
        * Either `quantity` or `price` must be sent.
        * When the new `quantity` or `price` doesn't satisfy PRICE_FILTER / PERCENT_FILTER / LOT_SIZE, amendment will be rejected and the order will stay as it is.
