BinanceMarginData: Margin Market Data Retrieval
BinanceMarginData: Margin Market Data Retrieval
Details
Provides methods for retrieving margin-specific market data from Binance, including cross/isolated margin pairs, price indices, interest rate history, and margin data summaries.
Inherits from BinanceBase. All methods support both synchronous and
asynchronous execution depending on the async parameter at construction.
Purpose and Scope
Margin Pairs: Retrieve available cross and isolated margin trading pairs.
Price Index: Access margin price index for a symbol.
Interest Rates: Get historical interest rate data for margin borrowing.
Margin Data: Retrieve cross and isolated margin data including borrowing limits and interest rates.
Usage
Most methods require authentication (valid API key and secret).
get_price_index is a public endpoint requiring no authentication.
Endpoints Covered
| Method | Endpoint | Auth |
| get_all_pairs | GET /sapi/v1/margin/allPairs | Yes |
| get_isolated_pairs | GET /sapi/v1/margin/isolated/allPairs | Yes |
| get_price_index | GET /sapi/v1/margin/priceIndex | No |
| get_interest_rate_history | GET /sapi/v1/margin/interestRateHistory | Yes |
| get_cross_margin_data | GET /sapi/v1/margin/crossMarginData | Yes |
| get_isolated_margin_data | GET /sapi/v1/margin/isolatedMarginData | Yes |
Super class
binance::BinanceBase -> BinanceMarginData
Methods
Inherited methods
Method get_all_pairs()
Get All Cross Margin Pairs
Retrieves a list of all cross margin trading pairs available on Binance.
Returns
data.table (or promise<data.table> if async = TRUE) with columns:
base(character): Base asset code (e.g.,"BTC").id(integer): Pair identifier.is_buy_allowed(logical): Whether buying is allowed.is_margin_trade(logical): Whether margin trading is enabled.is_sell_allowed(logical): Whether selling is allowed.quote(character): Quote asset code (e.g.,"USDT").symbol(character): Trading pair identifier (e.g.,"BTCUSDT").
Method get_isolated_pairs()
Get All Isolated Margin Pairs
Retrieves a list of all isolated margin trading pairs available on Binance.
Returns
data.table (or promise<data.table> if async = TRUE) with columns:
symbol(character): Trading pair identifier (e.g.,"BTCUSDT").base(character): Base asset code (e.g.,"BTC").quote(character): Quote asset code (e.g.,"USDT").is_margin_trade(logical): Whether margin trading is enabled.is_buy_allowed(logical): Whether buying is allowed.is_sell_allowed(logical): Whether selling is allowed.
Method get_price_index()
Get Margin Price Index
Retrieves the margin price index for a given symbol. This is a public endpoint that does not require authentication.
Method get_interest_rate_history()
Get Interest Rate History
Retrieves historical interest rate data for a given asset.
Usage
BinanceMarginData$get_interest_rate_history(
asset,
vipLevel = NULL,
startTime = NULL,
endTime = NULL,
recvWindow = NULL
)Arguments
assetCharacter; asset code (e.g.,
"BTC").vipLevelInteger or NULL; VIP level to query. Defaults to user's VIP level.
startTimeNumeric or NULL; start time in milliseconds.
endTimeNumeric or NULL; end time in milliseconds.
recvWindowInteger or NULL; request validity window in milliseconds.
Method get_cross_margin_data()
Get Cross Margin Data
Retrieves cross margin data including borrowing limits and interest rates.
JSON Response
[
{
"vipLevel": 0,
"coin": "BTC",
"transferIn": true,
"transferOut": true,
"borrowable": true,
"dailyInterest": "0.00026125",
"yearlyInterest": "0.0953",
"marginablePairs": ["BTCUSDT", "BTCBUSD"]
},
{
"vipLevel": 0,
"coin": "ETH",
"transferIn": true,
"transferOut": true,
"borrowable": true,
"dailyInterest": "0.00027400",
"yearlyInterest": "0.1000",
"marginablePairs": ["ETHUSDT", "ETHBUSD", "ETHBTC"]
}
]Arguments
vipLevelInteger or NULL; VIP level to query. Defaults to user's VIP level.
coinCharacter or NULL; specific coin to query (e.g.,
"BTC").recvWindowInteger or NULL; request validity window in milliseconds.
Returns
data.table (or promise<data.table> if async = TRUE) with columns:
vip_level(integer): VIP level tier.coin(character): Coin code (e.g.,"BTC").transfer_in(logical): Whether transfer in is allowed.transfer_out(logical): Whether transfer out is allowed.borrowable(logical): Whether borrowing is allowed.daily_interest(character): Daily interest rate as string.yearly_interest(character): Yearly interest rate as string.marginable_pairs(list): List of marginable trading pairs.
Method get_isolated_margin_data()
Get Isolated Margin Data
Retrieves isolated margin data including leverage and borrowing limits.
JSON Response
[
{
"vipLevel": 0,
"symbol": "BTCUSDT",
"leverage": "10",
"data": [
{
"coin": "BTC",
"dailyInterest": "0.00026125",
"borrowLimit": "9.00000000"
},
{
"coin": "USDT",
"dailyInterest": "0.000475",
"borrowLimit": "270000.00000000"
}
]
},
{
"vipLevel": 0,
"symbol": "ETHUSDT",
"leverage": "10",
"data": [
{
"coin": "ETH",
"dailyInterest": "0.00027400",
"borrowLimit": "90.00000000"
},
{
"coin": "USDT",
"dailyInterest": "0.000475",
"borrowLimit": "270000.00000000"
}
]
}
]Usage
BinanceMarginData$get_isolated_margin_data(
vipLevel = NULL,
symbol = NULL,
recvWindow = NULL
)Arguments
vipLevelInteger or NULL; VIP level to query. Defaults to user's VIP level.
symbolCharacter or NULL; specific symbol to query (e.g.,
"BTCUSDT").recvWindowInteger or NULL; request validity window in milliseconds.
Examples
if (FALSE) { # \dontrun{
# Synchronous usage
margin <- BinanceMarginData$new()
pairs <- margin$get_all_pairs()
print(pairs)
# Public endpoint (no auth needed)
margin_pub <- BinanceMarginData$new()
idx <- margin_pub$get_price_index("BTCUSDT")
print(idx)
# Asynchronous usage
margin_async <- BinanceMarginData$new(async = TRUE)
main <- coro::async(function() {
pairs <- await(margin_async$get_all_pairs())
print(pairs)
})
main()
while (!later::loop_empty()) later::run_now()
} # }
## ------------------------------------------------
## Method `BinanceMarginData$get_all_pairs`
## ------------------------------------------------
if (FALSE) { # \dontrun{
margin <- BinanceMarginData$new()
pairs <- margin$get_all_pairs()
print(pairs)
} # }
## ------------------------------------------------
## Method `BinanceMarginData$get_isolated_pairs`
## ------------------------------------------------
if (FALSE) { # \dontrun{
margin <- BinanceMarginData$new()
pairs <- margin$get_isolated_pairs()
print(pairs)
} # }
## ------------------------------------------------
## Method `BinanceMarginData$get_price_index`
## ------------------------------------------------
if (FALSE) { # \dontrun{
margin <- BinanceMarginData$new()
idx <- margin$get_price_index("BTCUSDT")
print(idx)
} # }
## ------------------------------------------------
## Method `BinanceMarginData$get_interest_rate_history`
## ------------------------------------------------
if (FALSE) { # \dontrun{
margin <- BinanceMarginData$new()
history <- margin$get_interest_rate_history("BTC")
print(history)
} # }
## ------------------------------------------------
## Method `BinanceMarginData$get_cross_margin_data`
## ------------------------------------------------
if (FALSE) { # \dontrun{
margin <- BinanceMarginData$new()
data <- margin$get_cross_margin_data()
print(data)
} # }
## ------------------------------------------------
## Method `BinanceMarginData$get_isolated_margin_data`
## ------------------------------------------------
if (FALSE) { # \dontrun{
margin <- BinanceMarginData$new()
data <- margin$get_isolated_margin_data()
print(data)
} # }