"""
Binance Derivatives Trading Options REST API

OpenAPI Specification for the Binance Derivatives Trading Options 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.
"""

import requests
from typing import Optional, List, TypeVar, Union
from binance_common.configuration import ConfigurationRestAPI
from binance_common.models import ApiResponse
from binance_common.signature import Signers
from binance_common.utils import send_request
from .api.account_api import AccountApi
from .api.market_data_api import MarketDataApi
from .api.market_maker_block_trade_api import MarketMakerBlockTradeApi
from .api.market_maker_endpoints_api import MarketMakerEndpointsApi
from .api.trade_api import TradeApi
from .api.user_data_streams_api import UserDataStreamsApi

from .models import AccountFundingFlowResponse
from .models import GetDownloadIdForOptionTransactionHistoryResponse
from .models import GetOptionTransactionHistoryDownloadLinkByIdResponse
from .models import OptionAccountInformationResponse
from .models import OptionMarginAccountInformationResponse
from .models import CheckServerTimeResponse
from .models import ExchangeInformationResponse
from .models import HistoricalExerciseRecordsResponse
from .models import IndexPriceTickerResponse
from .models import KlineCandlestickDataResponse
from .models import OldTradesLookupResponse
from .models import OpenInterestResponse
from .models import OptionMarkPriceResponse
from .models import OrderBookResponse
from .models import RecentBlockTradesListResponse
from .models import RecentTradesListResponse

from .models import Ticker24hrPriceChangeStatisticsResponse
from .models import AcceptBlockTradeOrderResponse
from .models import AccountBlockTradeListResponse

from .models import ExtendBlockTradeOrderResponse
from .models import NewBlockTradeOrderResponse
from .models import QueryBlockTradeDetailsResponse
from .models import QueryBlockTradeOrderResponse
from .models import AutoCancelAllOpenOrdersResponse
from .models import GetAutoCancelAllOpenOrdersResponse
from .models import GetMarketMakerProtectionConfigResponse
from .models import ResetMarketMakerProtectionConfigResponse
from .models import SetAutoCancelAllOpenOrdersResponse
from .models import SetMarketMakerProtectionConfigResponse
from .models import AccountTradeListResponse
from .models import CancelAllOptionOrdersByUnderlyingResponse
from .models import CancelAllOptionOrdersOnSpecificSymbolResponse
from .models import CancelMultipleOptionOrdersResponse
from .models import CancelOptionOrderResponse
from .models import NewOrderResponse
from .models import OptionPositionInformationResponse
from .models import PlaceMultipleOrdersResponse
from .models import QueryCurrentOpenOptionOrdersResponse
from .models import QueryOptionOrderHistoryResponse
from .models import QuerySingleOrderResponse
from .models import UserExerciseRecordResponse


from .models import StartUserDataStreamResponse


from .models import NewOrderSideEnum
from .models import NewOrderTypeEnum
from .models import NewOrderTimeInForceEnum
from .models import NewOrderNewOrderRespTypeEnum


from .models import PlaceMultipleOrdersOrdersParameterInner

T = TypeVar("T")


class DerivativesTradingOptionsRestAPI:
    def __init__(
        self,
        configuration: ConfigurationRestAPI,
    ) -> None:
        self.configuration = configuration
        self._session = requests.Session()
        self._signer = (
            Signers.get_signer(
                configuration.private_key, configuration.private_key_passphrase
            )
            if configuration.private_key is not None
            else None
        )

        self._accountApi = AccountApi(self.configuration, self._session, self._signer)
        self._marketDataApi = MarketDataApi(
            self.configuration, self._session, self._signer
        )
        self._marketMakerBlockTradeApi = MarketMakerBlockTradeApi(
            self.configuration, self._session, self._signer
        )
        self._marketMakerEndpointsApi = MarketMakerEndpointsApi(
            self.configuration, self._session, self._signer
        )
        self._tradeApi = TradeApi(self.configuration, self._session, self._signer)
        self._userDataStreamsApi = UserDataStreamsApi(
            self.configuration, self._session, self._signer
        )

    def send_request(
        self,
        endpoint: str,
        method: str,
        query_params: Optional[dict] = None,
        body_params: Optional[dict] = None,
    ) -> ApiResponse[T]:
        """
        Sends an request to the Binance REST API.

        Args:
            endpoint (str): The API endpoint path to send the request to.
            method (str): The HTTP method to use for the request (e.g. "GET", "POST", "PUT", "DELETE").
            query_params (Optional[dict]): The request payload as a dictionary, or None if no payload is required.
            body_params (Optional[dict]): The request body as a dictionary, or None if no body is required.

        Returns:
            ApiResponse[T]: The API response, where T is the expected response type.
        """
        return send_request[T](
            self._session,
            self.configuration,
            method,
            endpoint,
            query_params,
            body_params,
        )

    def send_signed_request(
        self,
        endpoint: str,
        method: str,
        query_params: Optional[dict] = None,
        body_params: Optional[dict] = None,
    ) -> ApiResponse[T]:
        """
        Sends a signed request to the Binance REST API.

        Args:
            endpoint (str): The API endpoint path to send the request to.
            method (str): The HTTP method to use for the request (e.g. "GET", "POST", "PUT", "DELETE").
            query_params (Optional[dict]): The request payload as a dictionary, or None if no payload is required.
            body_params (Optional[dict]): The request body as a dictionary, or None if no body is required.

        Returns:
            ApiResponse[T]: The API response, where T is the expected response type.
        """
        return send_request[T](
            self._session,
            self.configuration,
            method,
            endpoint,
            query_params,
            body_params,
            is_signed=True,
            signer=self._signer,
        )

    def account_funding_flow(
        self,
        currency: Union[str, None],
        record_id: Optional[int] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[AccountFundingFlowResponse]:
        """
                Account Funding Flow (USER_DATA)

                Query account funding flows.

        Weight: 1

                Args:
                    currency (Union[str, None]): Asset type, only support USDT  as of now
                    record_id (Optional[int] = None): Return the recordId and subsequent data, the latest data is returned by default, e.g 100000
                    start_time (Optional[int] = None): Start Time, e.g 1593511200000
                    end_time (Optional[int] = None): End Time, e.g 1593512200000
                    limit (Optional[int] = None): Number of result sets returned Default:100 Max:1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[AccountFundingFlowResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.account_funding_flow(
            currency, record_id, start_time, end_time, limit, recv_window
        )

    def get_download_id_for_option_transaction_history(
        self,
        start_time: Union[int, None],
        end_time: Union[int, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetDownloadIdForOptionTransactionHistoryResponse]:
        """
                Get Download Id For Option Transaction History (USER_DATA)

                Get download id for option transaction history

        * Request Limitation is 5 times per month, shared by > front end download page and rest api
        * The time between `startTime` and `endTime` can not be longer than 1 year

        Weight: 5

                Args:
                    start_time (Union[int, None]): Timestamp in ms
                    end_time (Union[int, None]): Timestamp in ms
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetDownloadIdForOptionTransactionHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.get_download_id_for_option_transaction_history(
            start_time, end_time, recv_window
        )

    def get_option_transaction_history_download_link_by_id(
        self,
        download_id: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetOptionTransactionHistoryDownloadLinkByIdResponse]:
        """
                Get Option Transaction History Download Link by Id (USER_DATA)

                Get option transaction history download Link by Id

        * Download link expiration: 24h

        Weight: 5

                Args:
                    download_id (Union[str, None]): get by download id api
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetOptionTransactionHistoryDownloadLinkByIdResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.get_option_transaction_history_download_link_by_id(
            download_id, recv_window
        )

    def option_account_information(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[OptionAccountInformationResponse]:
        """
                Option Account Information(TRADE)

                Get current account information.

        Weight: 3

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

                Returns:
                    ApiResponse[OptionAccountInformationResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.option_account_information(recv_window)

    def option_margin_account_information(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[OptionMarginAccountInformationResponse]:
        """
                Option Margin Account Information (USER_DATA)

                Get current account information.

        Weight: 3

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

                Returns:
                    ApiResponse[OptionMarginAccountInformationResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.option_margin_account_information(recv_window)

    def check_server_time(
        self,
    ) -> ApiResponse[CheckServerTimeResponse]:
        """
                Check Server Time

                Test connectivity to the Rest API and get the current server time.

        Weight: 1

                Args:

                Returns:
                    ApiResponse[CheckServerTimeResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketDataApi.check_server_time()

    def exchange_information(
        self,
    ) -> ApiResponse[ExchangeInformationResponse]:
        """
                Exchange Information

                Current exchange trading rules and symbol information

        Weight: 1

                Args:

                Returns:
                    ApiResponse[ExchangeInformationResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketDataApi.exchange_information()

    def historical_exercise_records(
        self,
        underlying: Optional[str] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
    ) -> ApiResponse[HistoricalExerciseRecordsResponse]:
        """
                Historical Exercise Records

                Get historical exercise records.
        * REALISTIC_VALUE_STRICKEN -> Exercised
        * EXTRINSIC_VALUE_EXPIRED -> Expired OTM

        Weight: 3

                Args:
                    underlying (Optional[str] = None): underlying, e.g BTCUSDT
                    start_time (Optional[int] = None): Start Time, e.g 1593511200000
                    end_time (Optional[int] = None): End Time, e.g 1593512200000
                    limit (Optional[int] = None): Number of result sets returned Default:100 Max:1000

                Returns:
                    ApiResponse[HistoricalExerciseRecordsResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketDataApi.historical_exercise_records(
            underlying, start_time, end_time, limit
        )

    def index_price_ticker(
        self,
        underlying: Union[str, None],
    ) -> ApiResponse[IndexPriceTickerResponse]:
        """
                Index Price Ticker

                Get spot index price for option underlying.

        Weight: 1

                Args:
                    underlying (Union[str, None]): Option underlying, e.g BTCUSDT

                Returns:
                    ApiResponse[IndexPriceTickerResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketDataApi.index_price_ticker(underlying)

    def kline_candlestick_data(
        self,
        symbol: Union[str, None],
        interval: Union[str, None],
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        limit: Optional[int] = None,
    ) -> ApiResponse[KlineCandlestickDataResponse]:
        """
                Kline/Candlestick Data

                Kline/candlestick bars for an option symbol.
        Klines are uniquely identified by their open time.

        * If startTime and endTime are not sent, the most recent klines are returned.

        Weight: 1

                Args:
                    symbol (Union[str, None]): Option trading pair, e.g BTC-200730-9000-C
                    interval (Union[str, None]): Time interval
                    start_time (Optional[int] = None): Start Time, e.g 1593511200000
                    end_time (Optional[int] = None): End Time, e.g 1593512200000
                    limit (Optional[int] = None): Number of result sets returned Default:100 Max:1000

                Returns:
                    ApiResponse[KlineCandlestickDataResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketDataApi.kline_candlestick_data(
            symbol, interval, start_time, end_time, limit
        )

    def old_trades_lookup(
        self,
        symbol: Union[str, None],
        from_id: Optional[int] = None,
        limit: Optional[int] = None,
    ) -> ApiResponse[OldTradesLookupResponse]:
        """
                Old Trades Lookup (MARKET_DATA)

                Get older market historical trades.

        Weight: 20

                Args:
                    symbol (Union[str, None]): Option trading pair, e.g BTC-200730-9000-C
                    from_id (Optional[int] = None): The UniqueId ID from which to return. The latest deal record is returned by default
                    limit (Optional[int] = None): Number of result sets returned Default:100 Max:1000

                Returns:
                    ApiResponse[OldTradesLookupResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketDataApi.old_trades_lookup(symbol, from_id, limit)

    def open_interest(
        self,
        underlying_asset: Union[str, None],
        expiration: Union[str, None],
    ) -> ApiResponse[OpenInterestResponse]:
        """
                Open Interest

                Get open interest for specific underlying asset on specific expiration date.

        Weight: 0

                Args:
                    underlying_asset (Union[str, None]): underlying asset, e.g ETH/BTC
                    expiration (Union[str, None]): expiration date, e.g 221225

                Returns:
                    ApiResponse[OpenInterestResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketDataApi.open_interest(underlying_asset, expiration)

    def option_mark_price(
        self,
        symbol: Optional[str] = None,
    ) -> ApiResponse[OptionMarkPriceResponse]:
        """
                Option Mark Price

                Option mark price and greek info.

        Weight: 5

                Args:
                    symbol (Optional[str] = None): Option trading pair, e.g BTC-200730-9000-C

                Returns:
                    ApiResponse[OptionMarkPriceResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketDataApi.option_mark_price(symbol)

    def order_book(
        self,
        symbol: Union[str, None],
        limit: Optional[int] = None,
    ) -> ApiResponse[OrderBookResponse]:
        """
                Order Book

                Check orderbook depth on specific symbol

        Weight: limit         | weight
        ------------  | ------------
        5, 10, 20, 50 | 2
        100           | 5
        500           | 10
        1000          | 20

                Args:
                    symbol (Union[str, None]): Option trading pair, e.g BTC-200730-9000-C
                    limit (Optional[int] = None): Number of result sets returned Default:100 Max:1000

                Returns:
                    ApiResponse[OrderBookResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketDataApi.order_book(symbol, limit)

    def recent_block_trades_list(
        self,
        symbol: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> ApiResponse[RecentBlockTradesListResponse]:
        """
                Recent Block Trades List

                Get recent block trades

        Weight: 5

                Args:
                    symbol (Optional[str] = None): Option trading pair, e.g BTC-200730-9000-C
                    limit (Optional[int] = None): Number of result sets returned Default:100 Max:1000

                Returns:
                    ApiResponse[RecentBlockTradesListResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketDataApi.recent_block_trades_list(symbol, limit)

    def recent_trades_list(
        self,
        symbol: Union[str, None],
        limit: Optional[int] = None,
    ) -> ApiResponse[RecentTradesListResponse]:
        """
                Recent Trades List

                Get recent market trades

        Weight: 5

                Args:
                    symbol (Union[str, None]): Option trading pair, e.g BTC-200730-9000-C
                    limit (Optional[int] = None): Number of result sets returned Default:100 Max:1000

                Returns:
                    ApiResponse[RecentTradesListResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketDataApi.recent_trades_list(symbol, limit)

    def test_connectivity(
        self,
    ) -> ApiResponse[None]:
        """
                Test Connectivity

                Test connectivity to the Rest API.

        Weight: 1

                Args:

                Returns:
                    ApiResponse[None]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketDataApi.test_connectivity()

    def ticker24hr_price_change_statistics(
        self,
        symbol: Optional[str] = None,
    ) -> ApiResponse[Ticker24hrPriceChangeStatisticsResponse]:
        """
                24hr Ticker Price Change Statistics

                24 hour rolling window price change statistics.

        Weight: 5

                Args:
                    symbol (Optional[str] = None): Option trading pair, e.g BTC-200730-9000-C

                Returns:
                    ApiResponse[Ticker24hrPriceChangeStatisticsResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketDataApi.ticker24hr_price_change_statistics(symbol)

    def accept_block_trade_order(
        self,
        block_order_matching_key: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[AcceptBlockTradeOrderResponse]:
        """
                Accept Block Trade Order (TRADE)

                Accept a block trade order

        Weight: 5

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

                Returns:
                    ApiResponse[AcceptBlockTradeOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketMakerBlockTradeApi.accept_block_trade_order(
            block_order_matching_key, recv_window
        )

    def account_block_trade_list(
        self,
        end_time: Optional[int] = None,
        start_time: Optional[int] = None,
        underlying: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[AccountBlockTradeListResponse]:
        """
                Account Block Trade List (USER_DATA)

                Gets block trades for a specific account.

        Weight: 5

                Args:
                    end_time (Optional[int] = None): End Time, e.g 1593512200000
                    start_time (Optional[int] = None): Start Time, e.g 1593511200000
                    underlying (Optional[str] = None): underlying, e.g BTCUSDT
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[AccountBlockTradeListResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketMakerBlockTradeApi.account_block_trade_list(
            end_time, start_time, underlying, recv_window
        )

    def cancel_block_trade_order(
        self,
        block_order_matching_key: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[None]:
        """
                Cancel Block Trade Order (TRADE)

                Cancel a block trade order.

        Weight: 5

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

                Returns:
                    ApiResponse[None]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketMakerBlockTradeApi.cancel_block_trade_order(
            block_order_matching_key, recv_window
        )

    def extend_block_trade_order(
        self,
        block_order_matching_key: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ExtendBlockTradeOrderResponse]:
        """
                Extend Block Trade Order (TRADE)

                Extends a block trade expire time by 30 mins from the current time.

        Weight: 5

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

                Returns:
                    ApiResponse[ExtendBlockTradeOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketMakerBlockTradeApi.extend_block_trade_order(
            block_order_matching_key, recv_window
        )

    def new_block_trade_order(
        self,
        liquidity: Union[str, None],
        legs: Union[List[object], None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[NewBlockTradeOrderResponse]:
        """
                New Block Trade Order (TRADE)

                Send in a new block trade order.

        Weight: 5

                Args:
                    liquidity (Union[str, None]): Taker or Maker
                    legs (Union[List[object], None]): Max 1 (only single leg supported), list of legs parameters in JSON; example: eapi/v1/block/order/create?orders=[{"symbol":"BTC-210115-35000-C", "price":"100","quantity":"0.0002","side":"BUY","type":"LIMIT"}]
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[NewBlockTradeOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketMakerBlockTradeApi.new_block_trade_order(
            liquidity, legs, recv_window
        )

    def query_block_trade_details(
        self,
        block_order_matching_key: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryBlockTradeDetailsResponse]:
        """
                Query Block Trade Details (USER_DATA)

                Query block trade details; returns block trade details from counterparty's perspective.

        Weight: 5

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

                Returns:
                    ApiResponse[QueryBlockTradeDetailsResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketMakerBlockTradeApi.query_block_trade_details(
            block_order_matching_key, recv_window
        )

    def query_block_trade_order(
        self,
        block_order_matching_key: Optional[str] = None,
        end_time: Optional[int] = None,
        start_time: Optional[int] = None,
        underlying: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryBlockTradeOrderResponse]:
        """
                Query Block Trade Order (TRADE)

                Check block trade order status.

        Weight: 5

                Args:
                    block_order_matching_key (Optional[str] = None): If specified, returns the specific block trade associated with the blockOrderMatchingKey
                    end_time (Optional[int] = None): End Time, e.g 1593512200000
                    start_time (Optional[int] = None): Start Time, e.g 1593511200000
                    underlying (Optional[str] = None): underlying, e.g BTCUSDT
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryBlockTradeOrderResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketMakerBlockTradeApi.query_block_trade_order(
            block_order_matching_key, end_time, start_time, underlying, recv_window
        )

    def auto_cancel_all_open_orders(
        self,
        underlyings: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[AutoCancelAllOpenOrdersResponse]:
        """
                Auto-Cancel All Open Orders (Kill-Switch) Heartbeat (TRADE)

                This endpoint resets the time from which the countdown will begin to the time this messaged is received.  It should be called repeatedly as heartbeats.  Multiple heartbeats can be updated at once by specifying the underlying symbols as a list (ex. BTCUSDT,ETHUSDT) in the underlyings parameter.

        * The response will only include underlying symbols where the heartbeat has been successfully updated.

        Weight: 10

                Args:
                    underlyings (Union[str, None]): Option Underlying Symbols, e.g BTCUSDT,ETHUSDT
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[AutoCancelAllOpenOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketMakerEndpointsApi.auto_cancel_all_open_orders(
            underlyings, recv_window
        )

    def get_auto_cancel_all_open_orders(
        self,
        underlying: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetAutoCancelAllOpenOrdersResponse]:
        """
                Get Auto-Cancel All Open Orders (Kill-Switch) Config (TRADE)

                This endpoint returns the auto-cancel parameters for each underlying symbol. Note only active auto-cancel parameters will be returned, if countdownTime is set to 0 (ie. countdownTime has been turned off), the underlying symbol and corresponding countdownTime parameter will not be returned in the response.

        * countdownTime = 0 means the function is disabled.

        Weight: 1

                Args:
                    underlying (Optional[str] = None): underlying, e.g BTCUSDT
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetAutoCancelAllOpenOrdersResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketMakerEndpointsApi.get_auto_cancel_all_open_orders(
            underlying, recv_window
        )

    def get_market_maker_protection_config(
        self,
        underlying: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetMarketMakerProtectionConfigResponse]:
        """
                Get Market Maker Protection Config (TRADE)

                Get config for MMP.

        Weight: 1

                Args:
                    underlying (Optional[str] = None): underlying, e.g BTCUSDT
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetMarketMakerProtectionConfigResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketMakerEndpointsApi.get_market_maker_protection_config(
            underlying, recv_window
        )

    def reset_market_maker_protection_config(
        self,
        underlying: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ResetMarketMakerProtectionConfigResponse]:
        """
                Reset Market Maker Protection Config (TRADE)

                Reset MMP, start MMP order again.

        Weight: 1

                Args:
                    underlying (Optional[str] = None): underlying, e.g BTCUSDT
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[ResetMarketMakerProtectionConfigResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._marketMakerEndpointsApi.reset_market_maker_protection_config(
            underlying, recv_window
        )

    def set_auto_cancel_all_open_orders(
        self,
        underlying: Union[str, None],
        countdown_time: Union[int, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[SetAutoCancelAllOpenOrdersResponse]:
        """
                Set Auto-Cancel All Open Orders (Kill-Switch) Config (TRADE)

