"""
Binance Derivatives Trading Portfolio Margin REST API

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

Do not edit the class manually.
"""

import requests
from typing import Optional, 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.trade_api import TradeApi
from .api.user_data_streams_api import UserDataStreamsApi

from .models import AccountBalanceResponse
from .models import AccountInformationResponse
from .models import BnbTransferResponse
from .models import ChangeAutoRepayFuturesStatusResponse
from .models import ChangeCmInitialLeverageResponse
from .models import ChangeCmPositionModeResponse
from .models import ChangeUmInitialLeverageResponse
from .models import ChangeUmPositionModeResponse
from .models import CmNotionalAndLeverageBracketsResponse
from .models import FundAutoCollectionResponse
from .models import FundCollectionByAssetResponse
from .models import GetAutoRepayFuturesStatusResponse
from .models import GetCmAccountDetailResponse
from .models import GetCmCurrentPositionModeResponse
from .models import GetCmIncomeHistoryResponse
from .models import GetDownloadIdForUmFuturesOrderHistoryResponse
from .models import GetDownloadIdForUmFuturesTradeHistoryResponse
from .models import GetDownloadIdForUmFuturesTransactionHistoryResponse
from .models import GetMarginBorrowLoanInterestHistoryResponse
from .models import GetUmAccountDetailResponse
from .models import GetUmAccountDetailV2Response
from .models import GetUmCurrentPositionModeResponse
from .models import GetUmFuturesOrderDownloadLinkByIdResponse
from .models import GetUmFuturesTradeDownloadLinkByIdResponse
from .models import GetUmFuturesTransactionDownloadLinkByIdResponse
from .models import GetUmIncomeHistoryResponse
from .models import GetUserCommissionRateForCmResponse
from .models import GetUserCommissionRateForUmResponse
from .models import MarginMaxBorrowResponse
from .models import PortfolioMarginUmTradingQuantitativeRulesIndicatorsResponse
from .models import QueryCmPositionInformationResponse
from .models import QueryMarginLoanRecordResponse
from .models import QueryMarginMaxWithdrawResponse
from .models import QueryMarginRepayRecordResponse
from .models import QueryPortfolioMarginNegativeBalanceInterestHistoryResponse
from .models import QueryUmPositionInformationResponse
from .models import QueryUserNegativeBalanceAutoExchangeRecordResponse
from .models import QueryUserRateLimitResponse
from .models import RepayFuturesNegativeBalanceResponse
from .models import UmFuturesAccountConfigurationResponse
from .models import UmFuturesSymbolConfigurationResponse
from .models import UmNotionalAndLeverageBracketsResponse

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


from .models import StartUserDataStreamResponse


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


T = TypeVar("T")


class DerivativesTradingPortfolioMarginRestAPI:
    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._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_balance(
        self,
        asset: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[AccountBalanceResponse]:
        """
                Account Balance(USER_DATA)

                Query account balance

        Weight: 20

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

                Returns:
                    ApiResponse[AccountBalanceResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.account_balance(asset, recv_window)

    def account_information(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[AccountInformationResponse]:
        """
                Account Information(USER_DATA)

                Query account information

        Weight: 20

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

                Returns:
                    ApiResponse[AccountInformationResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.account_information(recv_window)

    def bnb_transfer(
        self,
        amount: Union[float, None],
        transfer_side: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[BnbTransferResponse]:
        """
                BNB transfer (TRADE)

                Transfer BNB in and out of UM

        * The endpoint can only be called 10 times per 10 minutes in a rolling manner

        Weight: 750

                Args:
                    amount (Union[float, None]):
                    transfer_side (Union[str, None]): "TO_UM","FROM_UM"
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[BnbTransferResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.bnb_transfer(amount, transfer_side, recv_window)

    def change_auto_repay_futures_status(
        self,
        auto_repay: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ChangeAutoRepayFuturesStatusResponse]:
        """
                Change Auto-repay-futures Status(TRADE)

                Change Auto-repay-futures Status

        Weight: 750

                Args:
                    auto_repay (Union[str, None]): Default: `true`; `false` for turn off the auto-repay futures negative balance function
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[ChangeAutoRepayFuturesStatusResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.change_auto_repay_futures_status(
            auto_repay, recv_window
        )

    def change_cm_initial_leverage(
        self,
        symbol: Union[str, None],
        leverage: Union[int, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ChangeCmInitialLeverageResponse]:
        """
                Change CM Initial Leverage (TRADE)

                Change user's initial leverage of specific symbol in CM.

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

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.change_cm_initial_leverage(
            symbol, leverage, recv_window
        )

    def change_cm_position_mode(
        self,
        dual_side_position: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ChangeCmPositionModeResponse]:
        """
                Change CM Position Mode(TRADE)

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

        Weight: 1

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

                Returns:
                    ApiResponse[ChangeCmPositionModeResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.change_cm_position_mode(dual_side_position, recv_window)

    def change_um_initial_leverage(
        self,
        symbol: Union[str, None],
        leverage: Union[int, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ChangeUmInitialLeverageResponse]:
        """
                Change UM Initial Leverage(TRADE)

                Change user's initial leverage of specific symbol in UM.

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

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.change_um_initial_leverage(
            symbol, leverage, recv_window
        )

    def change_um_position_mode(
        self,
        dual_side_position: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ChangeUmPositionModeResponse]:
        """
                Change UM Position Mode(TRADE)

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

        Weight: 1

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

                Returns:
                    ApiResponse[ChangeUmPositionModeResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.change_um_position_mode(dual_side_position, recv_window)

    def cm_notional_and_leverage_brackets(
        self,
        symbol: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[CmNotionalAndLeverageBracketsResponse]:
        """
                CM Notional and Leverage Brackets(USER_DATA)

                Query CM notional and leverage brackets

        Weight: 1

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

                Returns:
                    ApiResponse[CmNotionalAndLeverageBracketsResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.cm_notional_and_leverage_brackets(symbol, recv_window)

    def fund_auto_collection(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[FundAutoCollectionResponse]:
        """
                Fund Auto-collection(TRADE)

                Fund collection for Portfolio Margin

        * The BNB would not be collected from UM-PM account to the Portfolio Margin account.
        * You can only use this function 500 times per hour in a rolling manner.

        Weight: 750

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

                Returns:
                    ApiResponse[FundAutoCollectionResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.fund_auto_collection(recv_window)

    def fund_collection_by_asset(
        self,
        asset: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[FundCollectionByAssetResponse]:
        """
                Fund Collection by Asset(TRADE)

                Transfers specific asset from Futures Account to Margin account

        * The BNB transfer is not be supported

        Weight: 30

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

                Returns:
                    ApiResponse[FundCollectionByAssetResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.fund_collection_by_asset(asset, recv_window)

    def get_auto_repay_futures_status(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetAutoRepayFuturesStatusResponse]:
        """
                Get Auto-repay-futures Status(USER_DATA)

                Query Auto-repay-futures Status

        Weight: 30

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

                Returns:
                    ApiResponse[GetAutoRepayFuturesStatusResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.get_auto_repay_futures_status(recv_window)

    def get_cm_account_detail(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetCmAccountDetailResponse]:
        """
                Get CM Account Detail(USER_DATA)

                Get current CM account asset and position information.

        Weight: 5

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

                Returns:
                    ApiResponse[GetCmAccountDetailResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.get_cm_account_detail(recv_window)

    def get_cm_current_position_mode(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetCmCurrentPositionModeResponse]:
        """
                Get CM Current Position Mode(USER_DATA)

                Get user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol in CM

        Weight: 30

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

                Returns:
                    ApiResponse[GetCmCurrentPositionModeResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.get_cm_current_position_mode(recv_window)

    def get_cm_income_history(
        self,
        symbol: Optional[str] = None,
        income_type: Optional[str] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        page: Optional[int] = None,
        limit: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetCmIncomeHistoryResponse]:
        """
                Get CM Income History(USER_DATA)

                Get CM Income History


        * If `incomeType` is not sent, all kinds of flow will be returned
        * "trandId" is unique in the same "incomeType" for a user
        * The interval between `startTime` and `endTime` can not exceed 200 days:
        * If `startTime` and `endTime` are not sent, the last 200 days will be returned

        Weight: 30

                Args:
                    symbol (Optional[str] = None):
                    income_type (Optional[str] = None): TRANSFER, WELCOME_BONUS, REALIZED_PNL, FUNDING_FEE, COMMISSION, INSURANCE_CLEAR, REFERRAL_KICKBACK, COMMISSION_REBATE, API_REBATE, CONTEST_REWARD, CROSS_COLLATERAL_TRANSFER, OPTIONS_PREMIUM_FEE, OPTIONS_SETTLE_PROFIT, INTERNAL_TRANSFER, AUTO_EXCHANGE, DELIVERED_SETTELMENT, COIN_SWAP_DEPOSIT, COIN_SWAP_WITHDRAW, POSITION_LIMIT_INCREASE_FEE
                    start_time (Optional[int] = None): Timestamp in ms to get funding from INCLUSIVE.
                    end_time (Optional[int] = None): Timestamp in ms to get funding until INCLUSIVE.
                    page (Optional[int] = None):
                    limit (Optional[int] = None): Default 100; max 1000
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetCmIncomeHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.get_cm_income_history(
            symbol, income_type, start_time, end_time, page, limit, recv_window
        )

    def get_download_id_for_um_futures_order_history(
        self,
        start_time: Union[int, None],
        end_time: Union[int, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetDownloadIdForUmFuturesOrderHistoryResponse]:
        """
                Get Download Id For UM Futures Order History (USER_DATA)

                Get download id for UM futures order history

        * Request Limitation is 10 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: 1500

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

                Returns:
                    ApiResponse[GetDownloadIdForUmFuturesOrderHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

    def get_download_id_for_um_futures_trade_history(
        self,
        start_time: Union[int, None],
        end_time: Union[int, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetDownloadIdForUmFuturesTradeHistoryResponse]:
        """
                Get Download Id For UM Futures Trade History (USER_DATA)

                Get download id for UM futures trade 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: 1500

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

                Returns:
                    ApiResponse[GetDownloadIdForUmFuturesTradeHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

    def get_download_id_for_um_futures_transaction_history(
        self,
        start_time: Union[int, None],
        end_time: Union[int, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetDownloadIdForUmFuturesTransactionHistoryResponse]:
        """
                Get Download Id For UM Futures Transaction History (USER_DATA)

                Get download id for UM futures 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: 1500

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

                Returns:
                    ApiResponse[GetDownloadIdForUmFuturesTransactionHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

    def get_margin_borrow_loan_interest_history(
        self,
        asset: Optional[str] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        current: Optional[int] = None,
        size: Optional[int] = None,
        archived: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetMarginBorrowLoanInterestHistoryResponse]:
        """
                Get Margin Borrow/Loan Interest History(USER_DATA)

                Get Margin Borrow/Loan Interest History


        * Response in descending order
        * The max interval between startTime and endTime is 30 days. It is a MUST to ensure data correctness.
        * If `startTime` and `endTime` not sent, return records of the last 7 days by default
        * If `startTime` is sent and `endTime` is not sent, the records from `startTime` to the present will be returned; if `startTime` is more than 30 days ago, the records of the past 30 days will be returned.
        * If `startTime` is not sent and `endTime` is sent, the records of the 7 days before `endTime` is returned.
        * Type in response has 5 enums:
        * `PERIODIC` interest charged per hour
        * `ON_BORROW` first interest charged on borrow
        * `PERIODIC_CONVERTED` interest charged per hour converted into BNB
        * `ON_BORROW_CONVERTED` first interest charged on borrow converted into BNB
        * `PORTFOLIO` Portfolio Margin negative balance daily interest

        Weight: 1

                Args:
                    asset (Optional[str] = None):
                    start_time (Optional[int] = None): Timestamp in ms to get funding from INCLUSIVE.
                    end_time (Optional[int] = None): Timestamp in ms to get funding until INCLUSIVE.
                    current (Optional[int] = None): Currently querying page. Start from 1. Default:1
                    size (Optional[int] = None): Default:10 Max:100
                    archived (Optional[str] = None): Default: `false`. Set to `true` for archived data from 6 months ago
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetMarginBorrowLoanInterestHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.get_margin_borrow_loan_interest_history(
            asset, start_time, end_time, current, size, archived, recv_window
        )

    def get_um_account_detail(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetUmAccountDetailResponse]:
        """
                Get UM Account Detail(USER_DATA)

                Get current UM account asset and position information.

        Weight: 5

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

                Returns:
                    ApiResponse[GetUmAccountDetailResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.get_um_account_detail(recv_window)

    def get_um_account_detail_v2(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetUmAccountDetailV2Response]:
        """
                Get UM Account Detail V2(USER_DATA)

                Get current UM account asset and position information.

        Weight: 5

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

                Returns:
                    ApiResponse[GetUmAccountDetailV2Response]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.get_um_account_detail_v2(recv_window)

    def get_um_current_position_mode(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetUmCurrentPositionModeResponse]:
        """
                Get UM Current Position Mode(USER_DATA)

                Get user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol in UM

        Weight: 30

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

                Returns:
                    ApiResponse[GetUmCurrentPositionModeResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.get_um_current_position_mode(recv_window)

    def get_um_futures_order_download_link_by_id(
        self,
        download_id: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetUmFuturesOrderDownloadLinkByIdResponse]:
        """
                Get UM Futures Order Download Link by Id(USER_DATA)

                Get UM futures order download link by Id

        * Download link expiration: 24h

        Weight: 10

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

                Returns:
                    ApiResponse[GetUmFuturesOrderDownloadLinkByIdResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        return self._accountApi.get_um_futures_order_download_link_by_id(
            download_id, recv_window
        )

    def get_um_futures_trade_download_link_by_id(
        self,
