TypeScript SDK — Margin Reference
Methods for querying margin account status, borrow rates, and previewing margin orders. All methods are on client.margin.
Every method in this namespace is a POST mutation — the SDK will not automatically retry on failure.
See the API Specifications for full request/response schemas.
getMarginAccount
POST /v1/margin/account · Authenticated
Retrieve your margin account summary — collateral, leverage, buying/selling power, and liquidation risk. The response is a MarginAccountSummary where monetary fields are MoneyAmount objects with currency and value properties. Requires the Trader, Fund Manager, or Auditor role. OAuth scope: balances:read. For Master API keys, include the account field in the request body to target a specific sub-account.
Code
Tip: Monetary fields (
marginAssetValue,availableCollateral,notionalValue,totalBorrowed,buyingPower,sellingPower,reservedBuyOrders,reservedSellOrders) areMoneyAmountobjects with.currencyand.value(decimal string). Theleveragefield is a plain decimal string. See Data Types.
getMarginRates
POST /v1/margin/rates · Authenticated
Retrieve current margin borrow rates for all eligible currencies. Requires the Trader, Fund Manager, or Auditor role. OAuth scope: balances:read.
Code
Caveat: The
lastUpdatedfield in each rate entry is abiginttimestamp. The SDK deserializes it automatically.
Tip: Borrow rates are decimal strings. Three granularities are provided: hourly (
borrowRate), daily (borrowRateDaily), and annual (borrowRateAnnual).
previewMarginOrder
POST /v1/margin/order/preview · Authenticated
Preview the margin impact of a hypothetical order before placing it. Returns pre-order and post-order risk statistics as MarginRiskStats objects, allowing you to see how the order would affect your margin account.
Code
Tip: Use this before
client.trading.createNewOrder()to understand the margin impact of a trade. The preview does not place any order or reserve any margin.
Tip: Both
preorderandpostorderareMarginRiskStatsobjects. While they share the same monetary field pattern (MoneyAmountobjects with.currencyand.value),MarginRiskStatsis a distinct type fromMarginAccountSummary— the set of fields may differ. Check the API Specifications for the exact schema.
What's next
- Perpetuals Reference — perpetual-contract margin and positions (separate margin system)
- Trading: Order Lifecycle — place orders after previewing
- Data Types — decimal strings and bigint handling
- Error Handling — error types and metadata