FAQ
Home
Support Center
FAQ
Crypto Derivatives
Futures Contracts
Classic Portfolio Margin
How to Use the Binance Classic Portfolio Margin Program APIs

How to Use the Binance Classic Portfolio Margin Program APIs

2022-04-18 06:15
Last updated on 2023-05-05
The Binance Classic Portfolio Margin Program is available via the Binance Futures API connectivity suite and is open to users who have enabled the Binance Futures API trading interface. The existing trading API endpoints on the Cross Margin, USDⓈ-M Futures, and COIN-M Futures markets remain available under the Binance Classic Portfolio Margin Program and are consistent with the regular account trading practices.
Please note that the Classic Portfolio Margin API endpoints are compatible with Binance Classic Portfolio Margin, and will not be available for Portfolio Margin (unless under exceptional circumstances). Please refer to this article for a comprehensive distinction between Classic Portfolio Margin and Portfolio Margin.
For a full list of endpoints available for Portfolio Margin, please refer to Binance Portfolio Margin API.

Binance Classic Portfolio Margin Program API details

In addition to the Binance standard API endpoints, additional dedicated endpoints are added under the Binance Classic Portfolio Margin Program, providing the following outputs:
1. uniMMR, Classic Portfolio Margin Account Status
2. Bankruptcy Loan Record (GET) and Repayment (POST)
3. Collateral Rate per symbol
4. Notional Limit Value per contract
5. Additional Classic Portfolio Margin Program API Exceptions
6. Classic Portfolio Margin Account Information (USER_DATA)
7. Classic Portfolio Margin Interest History (USER_DATA)
8. Classic Portfolio Margin Interest Rate (USER_DATA)
9. Error codes

1. uniMMR and Classic Portfolio Margin Account Status

The requests below will return the corresponding outputs:
Field
Description
uniMMR
Unified Margin Maintenance margin ratio
accountEquity
Unified margin account equity, in USD
actualEquity
Unified margin account actual equity (without collateral rate) in USD
accountMaintMargin
Unified Margin Maintenance Margin, the required margin for open position and loan, in USD
accountStatus
Unified Margin Account current status: "NORMAL", "MARGIN_CALL", "SUPPLY_MARGIN", "REDUCE_ONLY", "ACTIVE_LIQUIDATION", "FORCE_LIQUIDATION", "BANKRUPTED"
API Parameters:
Name
Type
Mandatory
recvWindow
LONG
NO
timestamp
LONG
YES
API Responses:
Response Type
Response Content
Normal Response
{
"uniMMR": "1.87987800",
"accountEquity": "122607.35137903",
"actualEquity": "142607.35137903",
"accountMaintMargin": "23.72469206",
"accountStatus": "NORMAL"
}
When the account hasn’t enabled the Classic Portfolio Margin Program
{
"code":-21001,
"msg": "invalid request: request ID is not a Classic Portfolio Margin Account"
}

2. Classic Portfolio Margin Bankruptcy Loan

  • Classic Portfolio Margin Bankruptcy Loan Record
The requests below will return the corresponding outputs:
Field
Description
asset
Loan asset by default (USDT)
amount
Classic Portfolio Margin bankruptcy loan amount in USDT
API Parameters:
NameTypeMandatory
recvWindowLONGNO
timestampLONGYES
API Responses:
Response Type
Response Content
Normal Response
{
"asset": "USDT",
"amount": "579.45",
}
The user doesn’t have any Classic Portfolio Margin Bankruptcy Loan
{
"error code": -21004,
"msg":"No outstanding pmLoan"
}
  • Classic Portfolio Margin Bankruptcy Loan Repayment
API Parameters:
NameTypeMandatory
recvWindowLONGNO
timestampLONGYES
API Responses:
Response Type
Response Content
Normal Response
{
"tranId": 58203331886213504
}
The user’s Spot Wallet doesn’t have enough USDT to repay the Classic Portfolio Margin Bankruptcy Loan{
"error code": -21005,
"msg":"No enough USDT to repay pmLoan"
}
The user’s Classic Portfolio Margin Bankruptcy Loan repayment is in process{
"error code": -21006,
"msg":"Had pmLoan repayment in process"

}
The user failed to repay the Classic Portfolio Margin Bankruptcy Loan since liquidation was in process{
"error code": -21007,
"msg":"Post fail since liquidation is in process"

}

3. Classic Portfolio Margin Collateral Rate (MARKET_DATA)

The requests below will return the corresponding outputs:
Field
Description
asset
Collateral asset type
collateralRate
Corresponding collateral rate
API Responses:
Response Type
Response Content
Normal Response
{
"asset": "USDT",
"collateralRate": "1.0000",
}

4. Classic Portfolio Margin Notional Limits Value per Symbol (MARKET_DATA)

The requests below will return the corresponding outputs:
Field
Description
Symbol
Symbol
notionalLimit
Classic Portfolio Margin Notional Limit in USDT
API Parameters:
NameTypeMandatory
symbolSTRINGNO
API Responses:
Response Type
Response Content
Normal Response
{
"notionalLimits": [ // Classic Portfolio Margin notional limit
{
"symbol": "BTCUSDT", // Symbol
"notionalLimit": "100000000" // Classic Portfolio Margin Notional Limit in USDT
},
{
"symbol": "ETHUSDT",
"notionalLimit": "20000000"
},
]
}
GET /dapi/v1/pmExchangeInfo
API Parameters:
NameTypeMandatory
symbolSTRINGNO
pairSTRINGNO
API Responses:
Response Type
Response Content
Normal Response
{
"notionalLimits": [ // Classic Portfolio Margin notional limit
{
"symbol": "BTCUSD_PERP", // Symbol
"pair": "BTCUSD", // Pair
" notionalLimit": "500" // Classic Portfolio Margin Notional Limit in coin
},
{
"symbol": "BTCUSD_220624",
"pair": "BTCUSD",
" notionalLimit": "200"
}
]
}

5. Additional Classic Portfolio Margin Program API Exceptions

Client Status
Response Content
If the user transfers assets from the Margin Wallet to the Futures Wallet
/sapi/v1/asset/transfer:
{
"error code": -21002,
"msg":"Classic Portfolio Margin Account doesn't support transfer from margin to futures”

}
If the margin assets failed to retrieve in time
/sapi/v1/margin/maxTransferable
/sapi/v1/asset/transfer
/sapi/v1/margin/transfer
/sapi/v1/future/transfer
{
"error code": -21003,
"msg":"fail to retrieve margin assets”

}
If the margin assets are not updated by the system in time
/sapi/v1/margin/maxBorrowable/sapi/v1/margin/loan
/sapi/v1/margin/order with MARGIN_BUY
{
"error code": -21003,
"msg":"fail to retrieve margin assets”

}

6. Classic Portfolio Margin Current Account Information

The requests below will return the corresponding outputs:
Field
Description
maxWithdrawAmountUSD
The maximum amount that can be transferred out of the Classic Portfolio Margin Account in USD (as per the estimated conversion value)*
maxWithdrawAmount
The maximum amount that can be transferred out of the Classic Portfolio Margin Account*
*i.e., Transfer to the user’s Spot Wallet
API Parameters:
NameTypeMandatory
assetSTRINGYES
recvWindowLONGNO
API Responses:
Response Type
Response Content
Normal Response
{
"maxWithdrawAmountUSD": "25347.92083245", // Classic Portfolio Margin maximum virtual amount for transfer out in USD
"asset": "BTC", // asset name
"maxWithdrawAmount": "1.33663654", // maximum amount for transfer out
}

7. Classic Portfolio Margin Interest History (USER_DATA)

API Parameters:
NameTypeMandatory
assetSTRINGNO
startTimeLONGNO
endTimeLONGNO
sizeLONGDefault:10 Max:100
recvWindowLONGNO
timestampLONGYES
API Responses:
Response Type
Response Content
Normal Response
[
{
"asset": "USDT",
"interest": "0.00000604",
"principal": "0.04902887",
"interestRate": "0.00012329",
"type": "UM_NEGATIVE_BALANCE",
"interestAccruedTime": 1678924800000
}
]

8. Classic Portfolio Margin Interest Rate (USER_DATA)

API Parameters:
NameTypeMandatory
assetSTRINGNO
recvWindow LONGNO
timestampLONGYES
API Responses:
Response Type
Response Content
Normal Response
[
{
"asset": "USDT",
"dailyInterest": "0.00012329", //daily interest rate
"yearlyInterest": "0.045" //annual interest rate
}
]
}

9. Error Codes

If you encounter the error code "-21003" from the API endpoint or the error message "NET_ASSET_MUST_LTE_RATIO" from the GUI, please try to transfer a tiny amount of any asset to your Cross Margin Wallet, and the error will be fixed after the transfer.