Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
294 changes: 294 additions & 0 deletions artifacts/apidocs/market_data_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,300 @@ LITE ENDPOINT: lite/v1/currency
```
</section>
<hr class="solid">
### Get Margin Rules
```
FULL ENDPOINT: full/v1/margin_rules
LITE ENDPOINT: lite/v1/margin_rules
```

=== "Request"
<section markdown="1" style="float: left; width: 70%; padding-right: 10px;">
-8<- "docs/schemas/api_get_margin_rules_request.md"
</section>
<section markdown="1" style="float: right; width: 30%;">
!!! question "Query"
**Full Request**
``` { .json .copy }
{
"instrument": "BTC_USDT_Perp"
}
```
**Lite Request**
``` { .json .copy }
{
"i": "BTC_USDT_Perp"
}
```
</section>
=== "Response"
<section markdown="1" style="float: left; width: 70%; padding-right: 10px;">
-8<- "docs/schemas/api_get_margin_rules_response.md"
</section>
<section markdown="1" style="float: right; width: 30%;">
!!! success
**Full Response**
``` { .json .copy }
{
"instrument": "BTC_USDT_Perp",
"max_position_size": "100.0",
"risk_brackets": [{
"tier": 1,
"notional_floor": "0",
"notional_cap": "600000",
"maintenance_margin_rate": "0.01",
"initial_margin_rate": "0.02",
"max_leverage": 50,
"cumulative_maintenance_amount": "0"
}]
}
```
**Lite Response**
``` { .json .copy }
{
"i": "BTC_USDT_Perp",
"mp": "100.0",
"rb": [{
"t": 1,
"nf": "0",
"nc": "600000",
"mm": "0.01",
"im": "0.02",
"ml": 50,
"cm": "0"
}]
}
```
</section>
=== "Errors"
<section markdown="1" style="float: left; width: 70%; padding-right: 10px;">
!!! info "Error Codes"
|Code|HttpStatus| Description |
|-|-|-|
|1002|500|Internal Server Error|
|1003|400|Request could not be processed due to malformed syntax|
|3000|400|Instrument is invalid|
|1004|404|Data Not Found|
|1006|429|You have surpassed the allocated rate limit for your tier|
</section>
<section markdown="1" style="float: right; width: 30%;">
!!! failure
**Full Error Response**
``` { .json .copy }
{
"request_id":1,
"code":1002,
"message":"Internal Server Error",
"status":500
}
```
**Lite Error Response**
``` { .json .copy }
{
"ri":1,
"c":1002,
"m":"Internal Server Error",
"s":500
}
```
</section>
=== "Try it out"
=== "DEV"
<section markdown="1" style="float: left; width: 50%; padding-right: 10px;">
!!! example "REST Full"
``` { .bash .copy }
curl --location 'https://market-data.dev.gravitymarkets.io/full/v1/margin_rules' \
--data '{
"instrument": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Full"
``` { .bash .copy }
wscat -c "wss://market-data.dev.gravitymarkets.io/ws/full" \
-x '
{
"jsonrpc": "2.0",
"method": "v1/margin_rules",
"params": {
"instrument": "BTC_USDT_Perp"
},
"id": 123
}
' -w 360
```
</section>
<section markdown="1" style="float: right; width: 50%;">
!!! example "REST Lite"
``` { .bash .copy }
curl --location 'https://market-data.dev.gravitymarkets.io/lite/v1/margin_rules' \
--data '{
"i": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Lite"
``` { .bash .copy }
wscat -c "wss://market-data.dev.gravitymarkets.io/ws/lite" \
-x '
{
"j": "2.0",
"m": "v1/margin_rules",
"p": {
"i": "BTC_USDT_Perp"
},
"i": 123
}
' -w 360
```
</section>
=== "STAGING"
<section markdown="1" style="float: left; width: 50%; padding-right: 10px;">
!!! example "REST Full"
``` { .bash .copy }
curl --location 'https://market-data.staging.gravitymarkets.io/full/v1/margin_rules' \
--data '{
"instrument": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Full"
``` { .bash .copy }
wscat -c "wss://market-data.staging.gravitymarkets.io/ws/full" \
-x '
{
"jsonrpc": "2.0",
"method": "v1/margin_rules",
"params": {
"instrument": "BTC_USDT_Perp"
},
"id": 123
}
' -w 360
```
</section>
<section markdown="1" style="float: right; width: 50%;">
!!! example "REST Lite"
``` { .bash .copy }
curl --location 'https://market-data.staging.gravitymarkets.io/lite/v1/margin_rules' \
--data '{
"i": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Lite"
``` { .bash .copy }
wscat -c "wss://market-data.staging.gravitymarkets.io/ws/lite" \
-x '
{
"j": "2.0",
"m": "v1/margin_rules",
"p": {
"i": "BTC_USDT_Perp"
},
"i": 123
}
' -w 360
```
</section>
=== "TESTNET"
<section markdown="1" style="float: left; width: 50%; padding-right: 10px;">
!!! example "REST Full"
``` { .bash .copy }
curl --location 'https://market-data.testnet.grvt.io/full/v1/margin_rules' \
--data '{
"instrument": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Full"
``` { .bash .copy }
wscat -c "wss://market-data.testnet.grvt.io/ws/full" \
-x '
{
"jsonrpc": "2.0",
"method": "v1/margin_rules",
"params": {
"instrument": "BTC_USDT_Perp"
},
"id": 123
}
' -w 360
```
</section>
<section markdown="1" style="float: right; width: 50%;">
!!! example "REST Lite"
``` { .bash .copy }
curl --location 'https://market-data.testnet.grvt.io/lite/v1/margin_rules' \
--data '{
"i": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Lite"
``` { .bash .copy }
wscat -c "wss://market-data.testnet.grvt.io/ws/lite" \
-x '
{
"j": "2.0",
"m": "v1/margin_rules",
"p": {
"i": "BTC_USDT_Perp"
},
"i": 123
}
' -w 360
```
</section>
=== "PROD"
<section markdown="1" style="float: left; width: 50%; padding-right: 10px;">
!!! example "REST Full"
``` { .bash .copy }
curl --location 'https://market-data.grvt.io/full/v1/margin_rules' \
--data '{
"instrument": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Full"
``` { .bash .copy }
wscat -c "wss://market-data.grvt.io/ws/full" \
-x '
{
"jsonrpc": "2.0",
"method": "v1/margin_rules",
"params": {
"instrument": "BTC_USDT_Perp"
},
"id": 123
}
' -w 360
```
</section>
<section markdown="1" style="float: right; width: 50%;">
!!! example "REST Lite"
``` { .bash .copy }
curl --location 'https://market-data.grvt.io/lite/v1/margin_rules' \
--data '{
"i": "BTC_USDT_Perp"
}
'
```
!!! example "JSONRPC Lite"
``` { .bash .copy }
wscat -c "wss://market-data.grvt.io/ws/lite" \
-x '
{
"j": "2.0",
"m": "v1/margin_rules",
"p": {
"i": "BTC_USDT_Perp"
},
"i": 123
}
' -w 360
```
</section>
<hr class="solid">
## Ticker
### Mini Ticker
```
Expand Down
5 changes: 4 additions & 1 deletion artifacts/apidocs/schemas/aggregated_account_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
|total_equity<br>`te` |string|True|Total equity of the main (+ sub) account, denominated in USD|
|spot_balances<br>`sb` |[SpotBalance]|True|The list of spot assets owned by this main (+ sub) account, and their balances|
|vault_investments<br>`vi` |[VaultInvestment]|True|The list of vault investments held by this main account|
|total_sub_account_balance<br>`ts` |string|True|Total balance of the sub accounts, denominated in USD|
|total_sub_account_balance<br>`ts` |string|True|Deprecated: Use totalSubAccountEquity instead|
|total_sub_account_equity<br>`ts1` |string|True|Total equity of the sub accounts, denominated in USD|
|total_vault_investments_balance<br>`tv` |string|True|Total amount of the vault investments, denominated in USD|
|total_sub_account_available_balance<br>`ts2` |string|True|Total available balance of the main account, denominated in USD|
??? info "[SpotBalance](/../../schemas/spot_balance)"
|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
|total_equity<br>`te` |string|True|Total equity of the main (+ sub) account, denominated in USD|
|spot_balances<br>`sb` |[SpotBalance]|True|The list of spot assets owned by this main (+ sub) account, and their balances|
|vault_investments<br>`vi` |[VaultInvestment]|True|The list of vault investments held by this main account|
|total_sub_account_balance<br>`ts` |string|True|Total balance of the sub accounts, denominated in USD|
|total_sub_account_balance<br>`ts` |string|True|Deprecated: Use totalSubAccountEquity instead|
|total_sub_account_equity<br>`ts1` |string|True|Total equity of the sub accounts, denominated in USD|
|total_vault_investments_balance<br>`tv` |string|True|Total amount of the vault investments, denominated in USD|
|total_sub_account_available_balance<br>`ts2` |string|True|Total available balance of the main account, denominated in USD|
??? info "[SpotBalance](/../../schemas/spot_balance)"
|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
Expand Down
6 changes: 6 additions & 0 deletions artifacts/apidocs/schemas/api_get_margin_rules_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
!!! info "[ApiGetMarginRulesRequest](/../../schemas/api_get_margin_rules_request)"
API request payload to get margin rules for a particular instrument<br>

|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
|instrument<br>`i` |string|True|The instrument to query margin rules for|
18 changes: 18 additions & 0 deletions artifacts/apidocs/schemas/api_get_margin_rules_response.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
!!! info "[ApiGetMarginRulesResponse](/../../schemas/api_get_margin_rules_response)"
API response payload for margin rules of a particular instrument<br>

|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
|instrument<br>`i` |string|True|The instrument name|
|max_position_size<br>`mp` |string|True|The maximum position size, expressed in base asset decimal units|
|risk_brackets<br>`rb` |[RiskBracket]|True|List of risk brackets defining margin requirements at different notional tiers|
??? info "[RiskBracket](/../../schemas/risk_bracket)"
|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
|tier<br>`t` |integer|True|1-indexed tier number|
|notional_floor<br>`nf` |string|True|Lower bound of notional value (inclusive) in quote currency|
|notional_cap<br>`nc` |string|True|Upper bound of notional value (exclusive) in quote currency, empty for last tier|
|maintenance_margin_rate<br>`mm` |string|True|Maintenance margin rate as a decimal (e.g., '0.01' for 1%)|
|initial_margin_rate<br>`im` |string|True|Initial margin rate as a decimal (e.g., '0.02' for 2%)|
|max_leverage<br>`ml` |integer|True|Maximum leverage allowed at this tier (floor of 1 / initial_margin_rate)|
|cumulative_maintenance_amount<br>`cm` |string|True|Cumulative maintenance margin amount in quote currency|
10 changes: 10 additions & 0 deletions artifacts/apidocs/schemas/risk_bracket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
!!! info "[RiskBracket](/../../schemas/risk_bracket)"
|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
|tier<br>`t` |integer|True|1-indexed tier number|
|notional_floor<br>`nf` |string|True|Lower bound of notional value (inclusive) in quote currency|
|notional_cap<br>`nc` |string|True|Upper bound of notional value (exclusive) in quote currency, empty for last tier|
|maintenance_margin_rate<br>`mm` |string|True|Maintenance margin rate as a decimal (e.g., '0.01' for 1%)|
|initial_margin_rate<br>`im` |string|True|Initial margin rate as a decimal (e.g., '0.02' for 2%)|
|max_leverage<br>`ml` |integer|True|Maximum leverage allowed at this tier (floor of 1 / initial_margin_rate)|
|cumulative_maintenance_amount<br>`cm` |string|True|Cumulative maintenance margin amount in quote currency|
11 changes: 9 additions & 2 deletions artifacts/apidocs/trading_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ LITE ENDPOINT: lite/v1/create_order
|3006|500|Instrument's quote currency does not have a valid balance decimal configuration|
|2400|400|Reduce only order with no position|
|2401|400|Reduce only order must not increase position size|
|2402|400|Reduce only order size exceeds maximum allowed value|
</section>
<section markdown="1" style="float: right; width: 30%;">
!!! failure
Expand Down Expand Up @@ -8184,7 +8185,10 @@ LITE ENDPOINT: lite/v1/aggregated_account_summary
"num_lp_tokens": 1000000,
"share_price": 1000000
}],
"total_sub_account_balance": "3945034.23"
"total_sub_account_balance": "3945034.23",
"total_sub_account_equity": "3945034.23",
"total_vault_investments_balance": "3945034.23",
"total_sub_account_available_balance": "3945034.23"
}
}
```
Expand All @@ -8204,7 +8208,10 @@ LITE ENDPOINT: lite/v1/aggregated_account_summary
"nl": 1000000,
"sp": 1000000
}],
"ts": "3945034.23"
"ts": "3945034.23",
"ts1": "3945034.23",
"tv": "3945034.23",
"ts2": "3945034.23"
}
}
```
Expand Down
Loading