Developers

Get margin rules

Get one instrument's margin rules (maximum position size and risk brackets).

On this page

URLs and generated code samples on this page: Testnet (chain ID 326). Other code on this page doesn't change: it stays on testnet until you switch it in your code. Tutorials, signing cases and live tools always use testnet.

SDKclient.get_margin_rules(...)
HTTPPOST https://market-data.testnet.grvt.io/full/v1/margin_rules, or /lite/v1/margin_rules for lite names (the SDKs' default)
WebSocketmethod v1/margin_rules on wss://market-data.testnet.grvt.io/ws/full, or /ws/lite for lite names
AuthNone (public)
RetriesRead: the SDKs retry retryable errors (rules)
Contract idinstrument.get_margin_rules (RPCGetMarginRulesV1)

Request

Body type ApiGetMarginRulesRequest. Fields the server fills are left out.

  • instrumentlite name istring (instrument name)required#
    The instrument to query margin rules for

Response

Body type ApiGetMarginRulesResponse (the same object is the JSON-RPC result over WebSocket).

  • instrumentlite name istring (instrument name)required#
    The instrument name
  • max_position_sizelite name mpstringrequired#
    The maximum position size. Decimal string, e.g. "0.01"; up to the instrument's base_decimals.
  • risk_bracketslite name rbarray<RiskBracket>required#
    List of risk brackets defining margin requirements at different notional tiers
    7 fields of RiskBracket
    • tierlite name tinteger (uint32)required#
      1-indexed tier number
    • notional_floorlite name nfstringrequired#
      Lower bound of notional value (inclusive) in quote currency
    • notional_caplite name ncstringoptional#
      Upper bound of notional value (exclusive) in quote currency, omitted for last tier
    • maintenance_margin_ratelite name mmstringrequired#
      Maintenance margin rate as a decimal (e.g., '0.01' for 1%)
    • initial_margin_ratelite name imstringrequired#
      Initial margin rate as a decimal (e.g., '0.02' for 2%)
    • max_leveragelite name mlinteger (uint32)required#
      Maximum leverage allowed at this tier (floor of 1 / initial_margin_rate)
    • cumulative_maintenance_amountlite name cmstringrequired#
      Cumulative maintenance margin amount in quote currency

Errors

Errors come back as {"code", "message", "status"} (lite {"c", "m", "s"}) with the HTTP status. Codes this call can return (all error codes):

3000InvalidInstrument400
Instrument is invalid
Plus 4 errors any call can return
1002InternalServer500
Internal Server Error
1003InvalidRequest400
Request could not be processed due to malformed syntax
1004NotFound404
Data Not Found
1006RateLimit429retryable
You have surpassed the allocated rate limit for your tier

Example

Example code
from grvt import Grvt

with Grvt(env="testnet") as client:
    resp = client.get_margin_rules(
        instrument="BTC_USDT_Perp",
    )
    print(resp)

Raw HTTP (set GRVT_DOMAIN, see Environments):

With full field names:

curl -sS "https://market-data.testnet.grvt.io/full/v1/margin_rules" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "instrument": "BTC_USDT_Perp"
}
EOF

With lite field names:

curl -sS "https://market-data.testnet.grvt.io/lite/v1/margin_rules" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "i": "BTC_USDT_Perp"
}
EOF
Run on testnet
esc

↑ ↓ move↵ open⇧↵ open .mdTry an error code like 2002

Keyboard shortcuts

⌘ K
Search the docs
/
Search
l
Next code language (Python → TypeScript → Go → Rust → curl → WebSocket)
j / k
Next / previous page
t
Light / dark theme
?
This help
Esc
Close dialogs and drawers