@@ -11246,3 +11246,212 @@ def gift_card_create_dual_token(self, **params):
1124611246 return self ._request_margin_api (
1124711247 "post" , "giftcard/buyCode" , signed = True , data = params
1124811248 )
11249+
11250+ ####################################################
11251+ # Borrow and repay Endpoints
11252+ ####################################################
11253+
11254+ def margin_next_hourly_interest_rate (self , ** params ):
11255+ """Get future hourly interest rate (USER_DATA)
11256+
11257+ https://developers.binance.com/docs/margin_trading/borrow-and-repay
11258+
11259+ :param assets: required - List of assets, separated by commas, up to 20
11260+ :type assets: str
11261+ :param isIsolated: required - for isolated margin or not, "TRUE", "FALSE"
11262+ :type isIsolated: bool
11263+
11264+ :returns: API response
11265+
11266+ .. code-block:: python
11267+ [
11268+ {
11269+ "asset": "BTC",
11270+ "nextHourlyInterestRate": "0.00000571"
11271+ },
11272+ {
11273+ "asset": "ETH",
11274+ "nextHourlyInterestRate": "0.00000578"
11275+ }
11276+ ]
11277+ """
11278+ return self ._request_margin_api (
11279+ "get" , "margin/next-hourly-interest-rate" , signed = True , data = params
11280+ )
11281+
11282+ def margin_interest_history (self , ** params ):
11283+ """Get Interest History (USER_DATA)
11284+
11285+ https://developers.binance.com/docs/margin_trading/borrow-and-repay/Get-Interest-History
11286+
11287+ :param asset: optional
11288+ :type asset: str
11289+ :param isolatedSymbol: optional - isolated symbol
11290+ :type isolatedSymbol: str
11291+ :param startTime: optional
11292+ :type startTime: int
11293+ :param endTime: optional
11294+ :type endTime: int
11295+ :param current: optional - Currently querying page. Start from 1. Default:1
11296+ :type current: int
11297+ :param size: optional - Default:10 Max:100
11298+ :type size: int
11299+
11300+ :returns: API response
11301+
11302+ .. code-block:: python
11303+ {
11304+ "rows": [
11305+ {
11306+ "txId": 1352286576452864727,
11307+ "interestAccuredTime": 1672160400000,
11308+ "asset": "USDT",
11309+ "rawAsset": “USDT”, // will not be returned for isolated margin
11310+ "principal": "45.3313",
11311+ "interest": "0.00024995",
11312+ "interestRate": "0.00013233",
11313+ "type": "ON_BORROW",
11314+ "isolatedSymbol": "BNBUSDT" // isolated symbol, will not be returned for crossed margin
11315+ }
11316+ ],
11317+ "total": 1
11318+ }
11319+
11320+ """
11321+ return self ._request_margin_api (
11322+ "get" , "margin/interestHistory" , signed = True , data = params
11323+ )
11324+
11325+ def margin_borrow_repay (self , ** params ):
11326+ """Margin Account Borrow/Repay (MARGIN)
11327+
11328+ https://developers.binance.com/docs/margin_trading/borrow-and-repay/Margin-Account-Borrow-Repay
11329+
11330+ :param asset: required
11331+ :type asset: str
11332+ :param amount: required
11333+ :type amount: float
11334+ :param isIsolated: optional - for isolated margin or not, "TRUE", "FALSE", default "FALSE"
11335+ :type isIsolated: str
11336+ :param symbol: optional - isolated symbol
11337+ :type symbol: str
11338+ :param type: str
11339+ :type type: str - BORROW or REPAY
11340+
11341+ :returns: API response
11342+ .. code-block:: python
11343+ {
11344+ //transaction id
11345+ "tranId": 100000001
11346+ }
11347+
11348+ """
11349+ return self ._request_margin_api (
11350+ "post" , "margin/borrow-repay" , signed = True , data = params
11351+ )
11352+
11353+ def margin_get_borrow_repay_records (self , ** params ):
11354+ """Query Query borrow/repay records in Margin account (USER_DATA)
11355+
11356+ https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Borrow-Repay
11357+
11358+ :param asset: required
11359+ :type asset: str
11360+ :param isolatedSymbol: optional - isolated symbol
11361+ :type isolatedSymbol: str
11362+ :param txId: optional - the tranId in POST /sapi/v1/margin/loan
11363+ :type txId: int
11364+ :param startTime: optional
11365+ :type startTime: int
11366+ :param endTime: optional
11367+ :type endTime: int
11368+ :param current: optional - Currently querying page. Start from 1. Default:1
11369+ :type current: int
11370+ :param size: optional - Default:10 Max:100
11371+ :type size: int
11372+
11373+ :returns: API response
11374+
11375+ .. code-block:: python
11376+ {
11377+ "rows": [
11378+ {
11379+ "type": "AUTO", // AUTO,MANUAL for Cross Margin Borrow; MANUAL,AUTO,BNB_AUTO_REPAY,POINT_AUTO_REPAY for Cross Margin Repay; AUTO,MANUAL for Isolated Margin Borrow/Repay;
11380+ "isolatedSymbol": "BNBUSDT", // isolated symbol, will not be returned for crossed margin
11381+ "amount": "14.00000000", // Total amount borrowed/repaid
11382+ "asset": "BNB",
11383+ "interest": "0.01866667", // Interest repaid
11384+ "principal": "13.98133333", // Principal repaid
11385+ "status": "CONFIRMED", //one of PENDING (pending execution), CONFIRMED (successfully execution), FAILED (execution failed, nothing happened to your account);
11386+ "timestamp": 1563438204000,
11387+ "txId": 2970933056
11388+ }
11389+ ],
11390+ "total": 1
11391+ }
11392+
11393+ """
11394+ return self ._request_margin_api (
11395+ "get" , "margin/borrow-repay" , signed = True , data = params
11396+ )
11397+
11398+ def margin_interest_rate_history (self , ** params ):
11399+ """Query Margin Interest Rate History (USER_DATA)
11400+
11401+ https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Margin-Interest-Rate-History
11402+
11403+ :param asset: required
11404+ :type asset: str
11405+ :param vipLevel: optional
11406+ :type vipLevel: int
11407+ :param startTime: optional
11408+ :type startTime: int
11409+ :param endTime: optional
11410+ :type endTime: int
11411+
11412+ :returns: API response
11413+
11414+ .. code-block:: python
11415+ [
11416+ {
11417+ "asset": "BTC",
11418+ "dailyInterestRate": "0.00025000",
11419+ "timestamp": 1611544731000,
11420+ "vipLevel": 1
11421+ },
11422+ {
11423+ "asset": "BTC",
11424+ "dailyInterestRate": "0.00035000",
11425+ "timestamp": 1610248118000,
11426+ "vipLevel": 1
11427+ }
11428+ ]
11429+
11430+ """
11431+ return self ._request_margin_api (
11432+ "get" , "margin/interestRateHistory" , signed = True , data = params
11433+ )
11434+
11435+ def margin_max_borrowable (self , ** params ):
11436+ """Query Max Borrow (USER_DATA)
11437+
11438+ https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Max-Borrow
11439+
11440+ :param asset: required
11441+ :type asset: str
11442+ :param isolatedSymbol: optional - isolated symbol
11443+ :type isolatedSymbol: str
11444+
11445+ :returns: API response
11446+
11447+ .. code-block:: python
11448+
11449+ {
11450+ "amount": "1.69248805", // account's currently max borrowable amount with sufficient system availability
11451+ "borrowLimit": "60" // max borrowable amount limited by the account level
11452+ }
11453+
11454+ """
11455+ return self ._request_margin_api (
11456+ "get" , "margin/maxBorrowable" , signed = True , data = params
11457+ )
0 commit comments