"""
Binance Derivatives Trading Portfolio Margin Pro REST API

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

Do not edit the class manually.
"""

from typing import Optional, Union
from requests import Session
from binance_common.configuration import ConfigurationRestAPI
from binance_common.errors import RequiredError
from binance_common.models import ApiResponse
from binance_common.signature import Signers
from binance_common.utils import send_request

from ..models import BnbTransferResponse
from ..models import ChangeAutoRepayFuturesStatusResponse
from ..models import FundAutoCollectionResponse
from ..models import FundCollectionByAssetResponse
from ..models import GetAutoRepayFuturesStatusResponse
from ..models import GetDeltaModeStatusResponse
from ..models import GetPortfolioMarginProAccountBalanceResponse
from ..models import GetPortfolioMarginProAccountInfoResponse
from ..models import GetPortfolioMarginProSpanAccountInfoResponse
from ..models import GetTransferableEarnAssetBalanceForPortfolioMarginResponse
from ..models import PortfolioMarginProBankruptcyLoanRepayResponse
from ..models import QueryPortfolioMarginProBankruptcyLoanAmountResponse
from ..models import QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponse
from ..models import QueryPortfolioMarginProNegativeBalanceInterestHistoryResponse
from ..models import RepayFuturesNegativeBalanceResponse
from ..models import SwitchDeltaModeResponse
from ..models import TransferLdusdtRwusdForPortfolioMarginResponse


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

    def __init__(
        self,
        configuration: ConfigurationRestAPI = None,
        session: Session = None,
        signer: Signers = None,
    ) -> None:
        self._configuration = configuration
        self._session = session
        self._signer = signer

    def bnb_transfer(
        self,
        amount: Union[float, None],
        transfer_side: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[BnbTransferResponse]:
        """
                BNB transfer(USER_DATA)
                POST /sapi/v1/portfolio/bnb-transfer
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/BNB-transfer

                BNB transfer can be between Margin Account and USDM Account


        * You can only use this function 2 times per 10 minutes in a rolling manner

        Weight: 1500

                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.

        """

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

        body = {}
        payload = {
            "amount": amount,
            "transfer_side": transfer_side,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v1/portfolio/bnb-transfer",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=BnbTransferResponse,
            is_signed=True,
            signer=self._signer,
        )

    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)
                POST /sapi/v1/portfolio/repay-futures-switch
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Change-Auto-repay-futures-Status

                Change Auto-repay-futures Status

        Weight: 1500

                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.

        """

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

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

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v1/portfolio/repay-futures-switch",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=ChangeAutoRepayFuturesStatusResponse,
            is_signed=True,
            signer=self._signer,
        )

    def fund_auto_collection(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[FundAutoCollectionResponse]:
        """
                Fund Auto-collection(USER_DATA)
                POST /sapi/v1/portfolio/auto-collection
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Fund-Auto-collection

                Transfers all assets from Futures Account to Margin account

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

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

                Returns:
                    ApiResponse[FundAutoCollectionResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v1/portfolio/auto-collection",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=FundAutoCollectionResponse,
            is_signed=True,
            signer=self._signer,
        )

    def fund_collection_by_asset(
        self,
        asset: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[FundCollectionByAssetResponse]:
        """
                Fund Collection by Asset(USER_DATA)
                POST /sapi/v1/portfolio/asset-collection
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Fund-Collection-by-Asset

                Transfers specific asset from Futures Account to Margin account

        * The BNB transfer is not be supported

        Weight: 60

                Args:
                    asset (Union[str, None]): `LDUSDT` and `RWUSD`
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[FundCollectionByAssetResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v1/portfolio/asset-collection",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=FundCollectionByAssetResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_auto_repay_futures_status(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetAutoRepayFuturesStatusResponse]:
        """
                Get Auto-repay-futures Status(USER_DATA)
                GET /sapi/v1/portfolio/repay-futures-switch
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Get-Auto-repay-futures-Status

                Query Auto-repay-futures Status

        Weight: 30

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

                Returns:
                    ApiResponse[GetAutoRepayFuturesStatusResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/portfolio/repay-futures-switch",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetAutoRepayFuturesStatusResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_delta_mode_status(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetDeltaModeStatusResponse]:
        """
                Get Delta Mode Status(USER_DATA)
                GET /sapi/v1/portfolio/delta-mode
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Get-Delta-Mode-Status

                Query the Delta mode status of current account.

        Weight: 1500

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

                Returns:
                    ApiResponse[GetDeltaModeStatusResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/portfolio/delta-mode",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetDeltaModeStatusResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_portfolio_margin_pro_account_balance(
        self,
        asset: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetPortfolioMarginProAccountBalanceResponse]:
        """
                Get Portfolio Margin Pro Account Balance(USER_DATA)
                GET /sapi/v1/portfolio/balance
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Get-Classic-Portfolio-Margin-Balance-Info

                Query Portfolio Margin Pro account balance

        Weight: 20

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

                Returns:
                    ApiResponse[GetPortfolioMarginProAccountBalanceResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/portfolio/balance",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetPortfolioMarginProAccountBalanceResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_portfolio_margin_pro_account_info(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetPortfolioMarginProAccountInfoResponse]:
        """
                Get Portfolio Margin Pro Account Info(USER_DATA)
                GET /sapi/v1/portfolio/account
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Get-Classic-Portfolio-Margin-Account-Info

                Get Portfolio Margin Pro Account Info

        Weight: 5

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

                Returns:
                    ApiResponse[GetPortfolioMarginProAccountInfoResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/portfolio/account",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetPortfolioMarginProAccountInfoResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_portfolio_margin_pro_span_account_info(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetPortfolioMarginProSpanAccountInfoResponse]:
        """
                Get Portfolio Margin Pro SPAN Account Info(USER_DATA)
                GET /sapi/v2/portfolio/account
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Get-Classic-Portfolio-Margin-Account-Info-V2

                Get Portfolio Margin Pro SPAN Account Info (For Portfolio Margin Pro SPAN users only)

        Weight: 5

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

                Returns:
                    ApiResponse[GetPortfolioMarginProSpanAccountInfoResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v2/portfolio/account",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetPortfolioMarginProSpanAccountInfoResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_transferable_earn_asset_balance_for_portfolio_margin(
        self,
        asset: Union[str, None],
        transfer_type: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetTransferableEarnAssetBalanceForPortfolioMarginResponse]:
        """
                Get Transferable Earn Asset Balance for Portfolio Margin (USER_DATA)
                GET /sapi/v1/portfolio/earn-asset-balance
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Get-Transferable-Earn-Asset-Balance-for-Portfolio-Margin

                Get transferable earn asset balance for all types of Portfolio Margin account

        Weight: 1500

                Args:
                    asset (Union[str, None]): `LDUSDT` and `RWUSD`
                    transfer_type (Union[str, None]): `EARN_TO_FUTURE` /`FUTURE_TO_EARN`
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetTransferableEarnAssetBalanceForPortfolioMarginResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        body = {}
        payload = {
            "asset": asset,
            "transfer_type": transfer_type,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/portfolio/earn-asset-balance",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetTransferableEarnAssetBalanceForPortfolioMarginResponse,
            is_signed=True,
            signer=self._signer,
        )

    def portfolio_margin_pro_bankruptcy_loan_repay(
        self,
        var_from: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[PortfolioMarginProBankruptcyLoanRepayResponse]:
        """
                Portfolio Margin Pro Bankruptcy Loan Repay
                POST /sapi/v1/portfolio/repay
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Classic-Portfolio-Margin-Bankruptcy-Loan-Repay

                Repay Portfolio Margin Pro Bankruptcy Loan

        * Please note that the API Key has enabled Spot & Margin Trading permissions to access this endpoint.

        Weight: 3000

                Args:
                    var_from (Optional[str] = None): SPOT or MARGIN，default SPOT
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[PortfolioMarginProBankruptcyLoanRepayResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v1/portfolio/repay",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=PortfolioMarginProBankruptcyLoanRepayResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_portfolio_margin_pro_bankruptcy_loan_amount(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryPortfolioMarginProBankruptcyLoanAmountResponse]:
        """
                Query Portfolio Margin Pro Bankruptcy Loan Amount(USER_DATA)
                GET /sapi/v1/portfolio/pmLoan
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Query-Classic-Portfolio-Margin-Bankruptcy-Loan-Amount

                Query Portfolio Margin Pro Bankruptcy Loan Amount

        * If there’s no classic portfolio margin bankruptcy loan, the amount would be 0

        Weight: 500

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

                Returns:
                    ApiResponse[QueryPortfolioMarginProBankruptcyLoanAmountResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/portfolio/pmLoan",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryPortfolioMarginProBankruptcyLoanAmountResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_portfolio_margin_pro_bankruptcy_loan_repay_history(
        self,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        current: Optional[int] = None,
        size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponse]:
        """
                Query Portfolio Margin Pro Bankruptcy Loan Repay History(USER_DATA)
                GET /sapi/v1/portfolio/pmloan-history
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Query-Portfolio-Margin-Pro-Bankruptcy-Loan-Repay-History

                Query repay history of pmloan for portfolio margin pro.

        * `startTime` and `endTime` cannot be longer than 360 days
        * If `startTime` and `endTime` not sent, return records of the last 30 days by default.
        * If `startTime`is sent and `endTime` is not sent, return records of [startTime, startTime+30d].
        * If `startTime` is not sent and `endTime` is sent, return records of [endTime-30d, endTime].

        Weight: 500

                Args:
                    start_time (Optional[int] = None):
                    end_time (Optional[int] = None):
                    current (Optional[int] = None): Currently querying page. Start from 1. Default:1
                    size (Optional[int] = None): Default:10 Max:100
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/portfolio/pmloan-history",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryPortfolioMarginProBankruptcyLoanRepayHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_portfolio_margin_pro_negative_balance_interest_history(
        self,
        asset: Optional[str] = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[QueryPortfolioMarginProNegativeBalanceInterestHistoryResponse]:
        """
                Query Portfolio Margin Pro Negative Balance Interest History(USER_DATA)
                GET /sapi/v1/portfolio/interest-history
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Query-Classic-Portfolio-Margin-Negative-Balance-Interest-History

                Query interest history of negative balance for portfolio margin.

        Weight: 50

                Args:
                    asset (Optional[str] = None):
                    start_time (Optional[int] = None):
                    end_time (Optional[int] = None):
                    size (Optional[int] = None): Default:10 Max:100
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[QueryPortfolioMarginProNegativeBalanceInterestHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/portfolio/interest-history",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryPortfolioMarginProNegativeBalanceInterestHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def repay_futures_negative_balance(
        self,
        var_from: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[RepayFuturesNegativeBalanceResponse]:
        """
                Repay futures Negative Balance(USER_DATA)
                POST /sapi/v1/portfolio/repay-futures-negative-balance
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Repay-futures-Negative-Balance

                Repay futures Negative Balance

        Weight: 1500

                Args:
                    var_from (Optional[str] = None): SPOT or MARGIN，default SPOT
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[RepayFuturesNegativeBalanceResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v1/portfolio/repay-futures-negative-balance",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=RepayFuturesNegativeBalanceResponse,
            is_signed=True,
            signer=self._signer,
        )

    def switch_delta_mode(
        self,
        delta_enabled: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[SwitchDeltaModeResponse]:
        """
                Switch Delta Mode(TRADE)
                POST /sapi/v1/portfolio/delta-mode
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Switch-Delta-Mode

                Switch the Delta mode for existing PM PRO / PM RETAIL accounts.

        Weight: 1500

                Args:
                    delta_enabled (Union[str, None]): `true` to enable Delta mode; `false` to disable Delta mode
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[SwitchDeltaModeResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v1/portfolio/delta-mode",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=SwitchDeltaModeResponse,
            is_signed=True,
            signer=self._signer,
        )

    def transfer_ldusdt_rwusd_for_portfolio_margin(
        self,
        asset: Union[str, None],
        transfer_type: Union[str, None],
        amount: Union[float, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[TransferLdusdtRwusdForPortfolioMarginResponse]:
        """
                Transfer LDUSDT/RWUSD for Portfolio Margin(TRADE)
                POST /sapi/v1/portfolio/earn-asset-transfer
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Transfer-LDUSDT-Portfolio-Margin

                Transfer LDUSDT/RWUSD as collateral for all types of Portfolio Margin account

        Weight: 1500

                Args:
                    asset (Union[str, None]): `LDUSDT` and `RWUSD`
                    transfer_type (Union[str, None]): `EARN_TO_FUTURE` /`FUTURE_TO_EARN`
                    amount (Union[float, None]):
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[TransferLdusdtRwusdForPortfolioMarginResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v1/portfolio/earn-asset-transfer",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=TransferLdusdtRwusdForPortfolioMarginResponse,
            is_signed=True,
            signer=self._signer,
        )
