"""
Binance Spot WebSocket API

OpenAPI Specifications for the Binance Spot WebSocket API

API documents:
  - [Github web-socket-api documentation file](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-api.md)
  - [General API information for web-socket-api on website](https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/general-api-information)

The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""

from binance_common.errors import RequiredError
from binance_common.models import WebsocketApiResponse
from binance_common.signature import Signers
from binance_common.websocket import WebSocketAPIBase

from ..models import OpenOrdersCancelAllResponse
from ..models import OrderAmendKeepPriorityResponse
from ..models import OrderCancelResponse
from ..models import OrderCancelReplaceResponse
from ..models import OrderListCancelResponse
from ..models import OrderListPlaceResponse
from ..models import OrderListPlaceOcoResponse
from ..models import OrderListPlaceOpoResponse
from ..models import OrderListPlaceOpocoResponse
from ..models import OrderListPlaceOtoResponse
from ..models import OrderListPlaceOtocoResponse
from ..models import OrderPlaceResponse
from ..models import OrderTestResponse
from ..models import SorOrderPlaceResponse
from ..models import SorOrderTestResponse


from ..models import OrderCancelCancelRestrictionsEnum
from ..models import OrderCancelReplaceCancelReplaceModeEnum
from ..models import OrderCancelReplaceSideEnum
from ..models import OrderCancelReplaceTypeEnum
from ..models import OrderCancelReplaceTimeInForceEnum
from ..models import OrderCancelReplaceNewOrderRespTypeEnum
from ..models import OrderCancelReplaceSelfTradePreventionModeEnum
from ..models import OrderCancelReplaceCancelRestrictionsEnum
from ..models import OrderCancelReplaceOrderRateLimitExceededModeEnum
from ..models import OrderCancelReplacePegPriceTypeEnum
from ..models import OrderCancelReplacePegOffsetTypeEnum
from ..models import OrderListPlaceSideEnum
from ..models import OrderListPlaceStopLimitTimeInForceEnum
from ..models import OrderListPlaceNewOrderRespTypeEnum
from ..models import OrderListPlaceSelfTradePreventionModeEnum
from ..models import OrderListPlaceOcoSideEnum
from ..models import OrderListPlaceOcoAboveTypeEnum
from ..models import OrderListPlaceOcoBelowTypeEnum
from ..models import OrderListPlaceOcoAboveTimeInForceEnum
from ..models import OrderListPlaceOcoAbovePegPriceTypeEnum
from ..models import OrderListPlaceOcoAbovePegOffsetTypeEnum
from ..models import OrderListPlaceOcoBelowTimeInForceEnum
from ..models import OrderListPlaceOcoBelowPegPriceTypeEnum
from ..models import OrderListPlaceOcoBelowPegOffsetTypeEnum
from ..models import OrderListPlaceOcoNewOrderRespTypeEnum
from ..models import OrderListPlaceOcoSelfTradePreventionModeEnum
from ..models import OrderListPlaceOpoWorkingTypeEnum
from ..models import OrderListPlaceOpoWorkingSideEnum
from ..models import OrderListPlaceOpoPendingTypeEnum
from ..models import OrderListPlaceOpoPendingSideEnum
from ..models import OrderListPlaceOpoNewOrderRespTypeEnum
from ..models import OrderListPlaceOpoSelfTradePreventionModeEnum
from ..models import OrderListPlaceOpoWorkingTimeInForceEnum
from ..models import OrderListPlaceOpoWorkingPegPriceTypeEnum
from ..models import OrderListPlaceOpoWorkingPegOffsetTypeEnum
from ..models import OrderListPlaceOpoPendingTimeInForceEnum
from ..models import OrderListPlaceOpoPendingPegPriceTypeEnum
from ..models import OrderListPlaceOpoPendingPegOffsetTypeEnum
from ..models import OrderListPlaceOpocoWorkingTypeEnum
from ..models import OrderListPlaceOpocoWorkingSideEnum
from ..models import OrderListPlaceOpocoPendingSideEnum
from ..models import OrderListPlaceOpocoPendingAboveTypeEnum
from ..models import OrderListPlaceOpocoNewOrderRespTypeEnum
from ..models import OrderListPlaceOpocoSelfTradePreventionModeEnum
from ..models import OrderListPlaceOpocoWorkingTimeInForceEnum
from ..models import OrderListPlaceOpocoWorkingPegPriceTypeEnum
from ..models import OrderListPlaceOpocoWorkingPegOffsetTypeEnum
from ..models import OrderListPlaceOpocoPendingAboveTimeInForceEnum
from ..models import OrderListPlaceOpocoPendingAbovePegPriceTypeEnum
from ..models import OrderListPlaceOpocoPendingAbovePegOffsetTypeEnum
from ..models import OrderListPlaceOpocoPendingBelowTypeEnum
from ..models import OrderListPlaceOpocoPendingBelowTimeInForceEnum
from ..models import OrderListPlaceOpocoPendingBelowPegPriceTypeEnum
from ..models import OrderListPlaceOpocoPendingBelowPegOffsetTypeEnum
from ..models import OrderListPlaceOtoWorkingTypeEnum
from ..models import OrderListPlaceOtoWorkingSideEnum
from ..models import OrderListPlaceOtoPendingTypeEnum
from ..models import OrderListPlaceOtoPendingSideEnum
from ..models import OrderListPlaceOtoNewOrderRespTypeEnum
from ..models import OrderListPlaceOtoSelfTradePreventionModeEnum
from ..models import OrderListPlaceOtoWorkingTimeInForceEnum
from ..models import OrderListPlaceOtoWorkingPegPriceTypeEnum
from ..models import OrderListPlaceOtoWorkingPegOffsetTypeEnum
from ..models import OrderListPlaceOtoPendingTimeInForceEnum
from ..models import OrderListPlaceOtoPendingPegOffsetTypeEnum
from ..models import OrderListPlaceOtoPendingPegPriceTypeEnum
from ..models import OrderListPlaceOtocoWorkingTypeEnum
from ..models import OrderListPlaceOtocoWorkingSideEnum
from ..models import OrderListPlaceOtocoPendingSideEnum
from ..models import OrderListPlaceOtocoPendingAboveTypeEnum
from ..models import OrderListPlaceOtocoNewOrderRespTypeEnum
from ..models import OrderListPlaceOtocoSelfTradePreventionModeEnum
from ..models import OrderListPlaceOtocoWorkingTimeInForceEnum
from ..models import OrderListPlaceOtocoWorkingPegPriceTypeEnum
from ..models import OrderListPlaceOtocoWorkingPegOffsetTypeEnum
from ..models import OrderListPlaceOtocoPendingAboveTimeInForceEnum
from ..models import OrderListPlaceOtocoPendingAbovePegPriceTypeEnum
from ..models import OrderListPlaceOtocoPendingAbovePegOffsetTypeEnum
from ..models import OrderListPlaceOtocoPendingBelowTypeEnum
from ..models import OrderListPlaceOtocoPendingBelowTimeInForceEnum
from ..models import OrderListPlaceOtocoPendingBelowPegPriceTypeEnum
from ..models import OrderListPlaceOtocoPendingBelowPegOffsetTypeEnum
from ..models import OrderPlaceSideEnum
from ..models import OrderPlaceTypeEnum
from ..models import OrderPlaceTimeInForceEnum
from ..models import OrderPlaceNewOrderRespTypeEnum
from ..models import OrderPlaceSelfTradePreventionModeEnum
from ..models import OrderPlacePegPriceTypeEnum
from ..models import OrderPlacePegOffsetTypeEnum
from ..models import OrderTestSideEnum
from ..models import OrderTestTypeEnum
from ..models import OrderTestTimeInForceEnum
from ..models import OrderTestNewOrderRespTypeEnum
from ..models import OrderTestSelfTradePreventionModeEnum
from ..models import OrderTestPegPriceTypeEnum
from ..models import OrderTestPegOffsetTypeEnum
from ..models import SorOrderPlaceSideEnum
from ..models import SorOrderPlaceTypeEnum
from ..models import SorOrderPlaceTimeInForceEnum
from ..models import SorOrderPlaceNewOrderRespTypeEnum
from ..models import SorOrderPlaceSelfTradePreventionModeEnum
from ..models import SorOrderTestSideEnum
from ..models import SorOrderTestTypeEnum
from ..models import SorOrderTestTimeInForceEnum
from ..models import SorOrderTestNewOrderRespTypeEnum
from ..models import SorOrderTestSelfTradePreventionModeEnum

from typing import Optional, Union


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

    def __init__(
        self,
        websocket_api: WebSocketAPIBase,
        signer: Signers = None,
    ) -> None:
        self.websocket_api = websocket_api
        self.signer = signer

    async def open_orders_cancel_all(
        self,
        symbol: Union[str, None],
        id: Optional[str] = None,
        recv_window: Optional[float] = None,
    ) -> WebsocketApiResponse[OpenOrdersCancelAllResponse]:
        """
            WebSocket Cancel open orders
            /openOrders.cancelAll
            https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/trading-requests#cancel-open-orders-trade

            Cancel all open orders on a symbol.
        This includes orders that are part of an order list.
        Weight: 1

            Args:
                    symbol (Union[str, None]):
                    id (Optional[str] = None): Unique WebSocket request ID.
                    recv_window (Optional[float] = None): The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.

            Returns:
                WebsocketApiResponse[OpenOrdersCancelAllResponse]

            Raises:
                RequiredError: If a required parameter is missing.

        """

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

        params = {
            "symbol": symbol,
            **({"id": id} if id is not None else {}),
            **({"recv_window": recv_window} if recv_window is not None else {}),
        }

        payload = {
            "method": "/openOrders.cancelAll".replace("/", "", 1),
            "params": params,
        }

        return await self.websocket_api.send_signed_message(
            payload=payload,
            response_model=OpenOrdersCancelAllResponse,
            signer=self.signer,
        )

    async def order_amend_keep_priority(
        self,
        symbol: Union[str, None],
        new_qty: Union[float, None],
        id: Optional[str] = None,
        order_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        new_client_order_id: Optional[str] = None,
        recv_window: Optional[float] = None,
    ) -> WebsocketApiResponse[OrderAmendKeepPriorityResponse]:
        """
            WebSocket Order Amend Keep Priority
            /order.amend.keepPriority
            https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/trading-requests#order-amend-keep-priority-trade

            Reduce the quantity of an existing open order.

        This adds 0 orders to the `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter.

        Read [Order Amend Keep Priority FAQ](faqs/order_amend_keep_priority.md) to learn more.
        Weight: 4

            Args:
                    symbol (Union[str, None]):
                    new_qty (Union[float, None]): `newQty` must be greater than 0 and less than the order's quantity.
                    id (Optional[str] = None): Unique WebSocket request ID.
                    order_id (Optional[int] = None): `orderId`or`origClientOrderId`mustbesent
                    orig_client_order_id (Optional[str] = None): `orderId`or`origClientOrderId`mustbesent
                    new_client_order_id (Optional[str] = None): The new client order ID for the order after being amended. <br> If not sent, one will be randomly generated. <br> It is possible to reuse the current clientOrderId by sending it as the `newClientOrderId`.
                    recv_window (Optional[float] = None): The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.

            Returns:
                WebsocketApiResponse[OrderAmendKeepPriorityResponse]

            Raises:
                RequiredError: If a required parameter is missing.

        """

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

        params = {
            "symbol": symbol,
            "new_qty": new_qty,
            **({"id": id} if id is not None else {}),
            **({"order_id": order_id} if order_id is not None else {}),
            **(
                {"orig_client_order_id": orig_client_order_id}
                if orig_client_order_id is not None
                else {}
            ),
            **(
                {"new_client_order_id": new_client_order_id}
                if new_client_order_id is not None
                else {}
            ),
            **({"recv_window": recv_window} if recv_window is not None else {}),
        }

        payload = {
            "method": "/order.amend.keepPriority".replace("/", "", 1),
            "params": params,
        }

        return await self.websocket_api.send_signed_message(
            payload=payload,
            response_model=OrderAmendKeepPriorityResponse,
            signer=self.signer,
        )

    async def order_cancel(
        self,
        symbol: Union[str, None],
        id: Optional[str] = None,
        order_id: Optional[int] = None,
        orig_client_order_id: Optional[str] = None,
        new_client_order_id: Optional[str] = None,
        cancel_restrictions: Optional[OrderCancelCancelRestrictionsEnum] = None,
        recv_window: Optional[float] = None,
    ) -> WebsocketApiResponse[OrderCancelResponse]:
        """
            WebSocket Cancel order
            /order.cancel
            https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/trading-requests#cancel-order-trade

            Cancel an active order.
        Weight: 1

            Args:
                    symbol (Union[str, None]):
                    id (Optional[str] = None): Unique WebSocket request ID.
                    order_id (Optional[int] = None): `orderId`or`origClientOrderId`mustbesent
                    orig_client_order_id (Optional[str] = None): `orderId`or`origClientOrderId`mustbesent
                    new_client_order_id (Optional[str] = None): The new client order ID for the order after being amended. <br> If not sent, one will be randomly generated. <br> It is possible to reuse the current clientOrderId by sending it as the `newClientOrderId`.
                    cancel_restrictions (Optional[OrderCancelCancelRestrictionsEnum] = None):
                    recv_window (Optional[float] = None): The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.

            Returns:
                WebsocketApiResponse[OrderCancelResponse]

            Raises:
                RequiredError: If a required parameter is missing.

        """

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

        params = {
            "symbol": symbol,
            **({"id": id} if id is not None else {}),
            **({"order_id": order_id} if order_id is not None else {}),
            **(
                {"orig_client_order_id": orig_client_order_id}
                if orig_client_order_id is not None
                else {}
            ),
            **(
                {"new_client_order_id": new_client_order_id}
                if new_client_order_id is not None
                else {}
            ),
            **(
                {"cancel_restrictions": cancel_restrictions}
                if cancel_restrictions is not None
                else {}
            ),
            **({"recv_window": recv_window} if recv_window is not None else {}),
        }

        payload = {
            "method": "/order.cancel".replace("/", "", 1),
            "params": params,
        }

        return await self.websocket_api.send_signed_message(
            payload=payload, response_model=OrderCancelResponse, signer=self.signer
        )

    async def order_cancel_replace(
        self,
        symbol: Union[str, None],
        cancel_replace_mode: Union[OrderCancelReplaceCancelReplaceModeEnum, None],
        side: Union[OrderCancelReplaceSideEnum, None],
        type: Union[OrderCancelReplaceTypeEnum, None],
        id: Optional[str] = None,
        cancel_order_id: Optional[int] = None,
        cancel_orig_client_order_id: Optional[str] = None,
        cancel_new_client_order_id: Optional[str] = None,
        time_in_force: Optional[OrderCancelReplaceTimeInForceEnum] = None,
        price: Optional[float] = None,
        quantity: Optional[float] = None,
        quote_order_qty: Optional[float] = None,
        new_client_order_id: Optional[str] = None,
        new_order_resp_type: Optional[OrderCancelReplaceNewOrderRespTypeEnum] = None,
        stop_price: Optional[float] = None,
        trailing_delta: Optional[float] = None,
        iceberg_qty: Optional[float] = None,
        strategy_id: Optional[int] = None,
        strategy_type: Optional[int] = None,
        self_trade_prevention_mode: Optional[
            OrderCancelReplaceSelfTradePreventionModeEnum
        ] = None,
        cancel_restrictions: Optional[OrderCancelReplaceCancelRestrictionsEnum] = None,
        order_rate_limit_exceeded_mode: Optional[
            OrderCancelReplaceOrderRateLimitExceededModeEnum
        ] = None,
        peg_price_type: Optional[OrderCancelReplacePegPriceTypeEnum] = None,
        peg_offset_value: Optional[int] = None,
        peg_offset_type: Optional[OrderCancelReplacePegOffsetTypeEnum] = None,
        recv_window: Optional[float] = None,
    ) -> WebsocketApiResponse[OrderCancelReplaceResponse]:
        """
            WebSocket Cancel and replace order
            /order.cancelReplace
            https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/trading-requests#cancel-and-replace-order-trade

            Cancel an existing order and immediately place a new order instead of the canceled one.

        A new order that was not attempted (i.e. when `newOrderResult: NOT_ATTEMPTED`), will still increase the unfilled order count by 1.
        Weight: 1

            Args:
                    symbol (Union[str, None]):
                    cancel_replace_mode (Union[OrderCancelReplaceCancelReplaceModeEnum, None]):
                    side (Union[OrderCancelReplaceSideEnum, None]):
                    type (Union[OrderCancelReplaceTypeEnum, None]):
                    id (Optional[str] = None): Unique WebSocket request ID.
                    cancel_order_id (Optional[int] = None): Cancel order by orderId
                    cancel_orig_client_order_id (Optional[str] = None):
                    cancel_new_client_order_id (Optional[str] = None): New ID for the canceled order. Automatically generated if not sent
                    time_in_force (Optional[OrderCancelReplaceTimeInForceEnum] = None):
                    price (Optional[float] = None):
                    quantity (Optional[float] = None):
                    quote_order_qty (Optional[float] = None):
                    new_client_order_id (Optional[str] = None): The new client order ID for the order after being amended. <br> If not sent, one will be randomly generated. <br> It is possible to reuse the current clientOrderId by sending it as the `newClientOrderId`.
                    new_order_resp_type (Optional[OrderCancelReplaceNewOrderRespTypeEnum] = None):
                    stop_price (Optional[float] = None):
                    trailing_delta (Optional[float] = None): See Trailing Stop order FAQ
                    iceberg_qty (Optional[float] = None):
                    strategy_id (Optional[int] = None): Arbitrary numeric value identifying the order within an order strategy.
                    strategy_type (Optional[int] = None): Arbitrary numeric value identifying the order strategy.
                        Values smaller than 1000000 are reserved and cannot be used.
                    self_trade_prevention_mode (Optional[OrderCancelReplaceSelfTradePreventionModeEnum] = None):
                    cancel_restrictions (Optional[OrderCancelReplaceCancelRestrictionsEnum] = None):
                    order_rate_limit_exceeded_mode (Optional[OrderCancelReplaceOrderRateLimitExceededModeEnum] = None):
                    peg_price_type (Optional[OrderCancelReplacePegPriceTypeEnum] = None):
                    peg_offset_value (Optional[int] = None): Price level to peg the price to (max: 100)
             See Pegged Orders
                    peg_offset_type (Optional[OrderCancelReplacePegOffsetTypeEnum] = None):
                    recv_window (Optional[float] = None): The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.

            Returns:
                WebsocketApiResponse[OrderCancelReplaceResponse]

            Raises:
                RequiredError: If a required parameter is missing.

        """

        if symbol is None:
            raise RequiredError(
                field="symbol", error_message="Missing required parameter 'symbol'"
            )
        if cancel_replace_mode is None:
            raise RequiredError(
                field="cancel_replace_mode",
                error_message="Missing required parameter 'cancel_replace_mode'",
            )
        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'"
            )

        params = {
            "symbol": symbol,
            "cancel_replace_mode": cancel_replace_mode,
            "side": side,
            "type": type,
            **({"id": id} if id is not None else {}),
            **(
                {"cancel_order_id": cancel_order_id}
                if cancel_order_id is not None
                else {}
            ),
            **(
                {"cancel_orig_client_order_id": cancel_orig_client_order_id}
                if cancel_orig_client_order_id is not None
                else {}
            ),
            **(
                {"cancel_new_client_order_id": cancel_new_client_order_id}
                if cancel_new_client_order_id is not None
                else {}
            ),
            **({"time_in_force": time_in_force} if time_in_force is not None else {}),
            **({"price": price} if price is not None else {}),
            **({"quantity": quantity} if quantity is not None else {}),
            **(
                {"quote_order_qty": quote_order_qty}
                if quote_order_qty is not None
                else {}
            ),
            **(
                {"new_client_order_id": new_client_order_id}
                if new_client_order_id is not None
                else {}
            ),
            **(
                {"new_order_resp_type": new_order_resp_type}
                if new_order_resp_type is not None
                else {}
            ),
            **({"stop_price": stop_price} if stop_price is not None else {}),
            **(
                {"trailing_delta": trailing_delta} if trailing_delta is not None else {}
            ),
            **({"iceberg_qty": iceberg_qty} if iceberg_qty is not None else {}),
            **({"strategy_id": strategy_id} if strategy_id is not None else {}),
            **({"strategy_type": strategy_type} if strategy_type is not None else {}),
            **(
                {"self_trade_prevention_mode": self_trade_prevention_mode}
                if self_trade_prevention_mode is not None
                else {}
            ),
            **(
                {"cancel_restrictions": cancel_restrictions}
                if cancel_restrictions is not None
                else {}
            ),
            **(
                {"order_rate_limit_exceeded_mode": order_rate_limit_exceeded_mode}
                if order_rate_limit_exceeded_mode is not None
                else {}
            ),
            **(
                {"peg_price_type": peg_price_type} if peg_price_type is not None else {}
            ),
            **(
                {"peg_offset_value": peg_offset_value}
                if peg_offset_value is not None
                else {}
            ),
            **(
                {"peg_offset_type": peg_offset_type}
                if peg_offset_type is not None
                else {}
            ),
            **({"recv_window": recv_window} if recv_window is not None else {}),
        }

        payload = {
            "method": "/order.cancelReplace".replace("/", "", 1),
            "params": params,
        }

        return await self.websocket_api.send_signed_message(
            payload=payload,
            response_model=OrderCancelReplaceResponse,
            signer=self.signer,
        )

    async def order_list_cancel(
        self,
        symbol: Union[str, None],
        id: Optional[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[float] = None,
    ) -> WebsocketApiResponse[OrderListCancelResponse]:
        """
            WebSocket Cancel Order list
            /orderList.cancel
            https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/trading-requests#cancel-order-list-trade

            Cancel an active order list.
        Weight: 1

            Args:
                    symbol (Union[str, None]):
                    id (Optional[str] = None): Unique WebSocket request ID.
                    order_list_id (Optional[int] = None): Cancel order list by orderListId
                    list_client_order_id (Optional[str] = None):
                    new_client_order_id (Optional[str] = None): The new client order ID for the order after being amended. <br> If not sent, one will be randomly generated. <br> It is possible to reuse the current clientOrderId by sending it as the `newClientOrderId`.
                    recv_window (Optional[float] = None): The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.

            Returns:
                WebsocketApiResponse[OrderListCancelResponse]

            Raises:
                RequiredError: If a required parameter is missing.

        """

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

        params = {
            "symbol": symbol,
            **({"id": id} if id is not None else {}),
            **({"order_list_id": order_list_id} if order_list_id is not None else {}),
            **(
                {"list_client_order_id": list_client_order_id}
                if list_client_order_id is not None
                else {}
            ),
            **(
                {"new_client_order_id": new_client_order_id}
                if new_client_order_id is not None
                else {}
            ),
            **({"recv_window": recv_window} if recv_window is not None else {}),
        }

        payload = {
            "method": "/orderList.cancel".replace("/", "", 1),
            "params": params,
        }

        return await self.websocket_api.send_signed_message(
            payload=payload, response_model=OrderListCancelResponse, signer=self.signer
        )

    async def order_list_place(
        self,
        symbol: Union[str, None],
        side: Union[OrderListPlaceSideEnum, None],
        price: Union[float, None],
        quantity: Union[float, None],
        id: Optional[str] = None,
        list_client_order_id: Optional[str] = None,
        limit_client_order_id: Optional[str] = None,
        limit_iceberg_qty: Optional[float] = None,
        limit_strategy_id: Optional[int] = None,
        limit_strategy_type: Optional[int] = None,
        stop_price: Optional[float] = None,
        trailing_delta: Optional[int] = None,
        stop_client_order_id: Optional[str] = None,
        stop_limit_price: Optional[float] = None,
        stop_limit_time_in_force: Optional[
            OrderListPlaceStopLimitTimeInForceEnum
        ] = None,
        stop_iceberg_qty: Optional[float] = None,
        stop_strategy_id: Optional[int] = None,
        stop_strategy_type: Optional[int] = None,
        new_order_resp_type: Optional[OrderListPlaceNewOrderRespTypeEnum] = None,
        self_trade_prevention_mode: Optional[
            OrderListPlaceSelfTradePreventionModeEnum
        ] = None,
        recv_window: Optional[float] = None,
    ) -> WebsocketApiResponse[OrderListPlaceResponse]:
        """
            WebSocket Place new OCO - Deprecated
            /orderList.place
            https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/trading-requests#place-new-oco---deprecated-trade

            Send in a new one-cancels-the-other (OCO) pair:
        `LIMIT_MAKER` + `STOP_LOSS`/`STOP_LOSS_LIMIT` orders (called *legs*),
        where activation of one order immediately cancels the other.

        This adds 1 order to `EXCHANGE_MAX_ORDERS` filter and the `MAX_NUM_ORDERS` filter
        Weight: 1

        Unfilled Order Count: 1

            Args:
                    symbol (Union[str, None]):
                    side (Union[OrderListPlaceSideEnum, None]):
                    price (Union[float, None]): Price for the limit order
                    quantity (Union[float, None]):
                    id (Optional[str] = None): Unique WebSocket request ID.
                    list_client_order_id (Optional[str] = None):
                    limit_client_order_id (Optional[str] = None): Arbitrary unique ID among open orders for the limit order. Automatically generated if not sent
                    limit_iceberg_qty (Optional[float] = None):
                    limit_strategy_id (Optional[int] = None): Arbitrary numeric value identifying the limit order within an order strategy.
                    limit_strategy_type (Optional[int] = None): <p>Arbitrary numeric value identifying the limit order strategy.</p><p>Values smaller than `1000000` are reserved and cannot be used.</p>
                    stop_price (Optional[float] = None):
                    trailing_delta (Optional[int] = None): See [Trailing Stop order FAQ](faqs/trailing-stop-faq.md)
                    stop_client_order_id (Optional[str] = None): Arbitrary unique ID among open orders for the stop order. Automatically generated if not sent
                    stop_limit_price (Optional[float] = None):
                    stop_limit_time_in_force (Optional[OrderListPlaceStopLimitTimeInForceEnum] = None):
                    stop_iceberg_qty (Optional[float] = None):
                    stop_strategy_id (Optional[int] = None): Arbitrary numeric value identifying the stop order within an order strategy.
                    stop_strategy_type (Optional[int] = None): <p>Arbitrary numeric value identifying the stop order strategy.</p><p>Values smaller than `1000000` are reserved and cannot be used.</p>
                    new_order_resp_type (Optional[OrderListPlaceNewOrderRespTypeEnum] = None):
                    self_trade_prevention_mode (Optional[OrderListPlaceSelfTradePreventionModeEnum] = None):
                    recv_window (Optional[float] = None): The value cannot be greater than `60000`. <br> Supports up to three decimal places of precision (e.g., 6000.346) so that microseconds may be specified.

            Returns:
                WebsocketApiResponse[OrderListPlaceResponse]

            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 price is None:
            raise RequiredError(
                field="price", error_message="Missing required parameter 'price'"
            )
        if quantity is None:
            raise RequiredError(
                field="quantity", error_message="Missing required parameter 'quantity'"
            )

        params = {
            "symbol": symbol,
            "side": side,
            "price": price,
            "quantity": quantity,
            **({"id": id} if id is not None else {}),
            **(
