From 85cd00407d4627109b1c7805d796b8743aeb8e22 Mon Sep 17 00:00:00 2001 From: keithang-grvt Date: Mon, 10 Nov 2025 11:55:40 +0800 Subject: [PATCH] [RFC] Update API docs and specs --- artifacts/apidocs/market_data_api.md | 60 ++++++++----- .../schemas/api_create_order_request.md | 1 - .../schemas/api_create_order_response.md | 1 - artifacts/apidocs/schemas/api_funding_rate.md | 9 ++ .../schemas/api_funding_rate_request.md | 10 +++ .../schemas/api_funding_rate_response.md | 7 +- .../apidocs/schemas/api_get_order_response.md | 1 - .../schemas/api_open_orders_response.md | 1 - .../schemas/api_order_history_response.md | 1 - .../apidocs/schemas/api_positions_response.md | 2 +- .../api_sub_account_history_response.md | 2 +- .../api_sub_account_summary_response.md | 2 +- .../schemas/funding_rate_aggregation_type.md | 9 ++ artifacts/apidocs/schemas/order.md | 1 - artifacts/apidocs/schemas/order_metadata.md | 1 - artifacts/apidocs/schemas/positions.md | 2 +- artifacts/apidocs/schemas/sub_account.md | 2 +- .../apidocs/schemas/ws_order_feed_data_v1.md | 1 - .../schemas/ws_positions_feed_data_v1.md | 2 +- artifacts/apidocs/trading_api.md | 78 ++++++----------- artifacts/apidocs/trading_streams.md | 6 +- artifacts/pysdk/grvt_raw_types.py | 25 ++++-- src/codegen/apispec.json | 86 +++++++++++++++---- 23 files changed, 193 insertions(+), 117 deletions(-) create mode 100644 artifacts/apidocs/schemas/api_funding_rate.md create mode 100644 artifacts/apidocs/schemas/funding_rate_aggregation_type.md diff --git a/artifacts/apidocs/market_data_api.md b/artifacts/apidocs/market_data_api.md index a254fe2..d78e338 100644 --- a/artifacts/apidocs/market_data_api.md +++ b/artifacts/apidocs/market_data_api.md @@ -3317,7 +3317,8 @@ LITE ENDPOINT: lite/v1/funding "start_time": "1697788800000000000", "end_time": "1697788800000000000", "limit": 500, - "cursor": "" + "cursor": "", + "agg_type": "FUNDING_INTERVAL" } ``` **Lite Request** @@ -3327,7 +3328,8 @@ LITE ENDPOINT: lite/v1/funding "st": "1697788800000000000", "et": "1697788800000000000", "l": 500, - "c": "" + "c": "", + "at": "FUNDING_INTERVAL" } ``` @@ -3345,7 +3347,8 @@ LITE ENDPOINT: lite/v1/funding "funding_rate": 0.0003, "funding_time": "1697788800000000000", "mark_price": "65038.01", - "funding_rate_8_h_avg": 0.0003 + "funding_rate_8_h_avg": 0.0003, + "funding_interval_hours": 8 }], "next": "Qw0918=" } @@ -3358,7 +3361,8 @@ LITE ENDPOINT: lite/v1/funding "fr": 0.0003, "ft": "1697788800000000000", "mp": "65038.01", - "fr1": 0.0003 + "fr1": 0.0003, + "fi": 8 }], "n": "Qw0918=" } @@ -3405,7 +3409,8 @@ LITE ENDPOINT: lite/v1/funding "start_time": "1697788800000000000", "end_time": "1697788800000000000", "limit": 500, - "cursor": "" + "cursor": "", + "agg_type": "FUNDING_INTERVAL" } ' ``` @@ -3421,7 +3426,8 @@ LITE ENDPOINT: lite/v1/funding "start_time": "1697788800000000000", "end_time": "1697788800000000000", "limit": 500, - "cursor": "" + "cursor": "", + "agg_type": "FUNDING_INTERVAL" }, "id": 123 } @@ -3437,7 +3443,8 @@ LITE ENDPOINT: lite/v1/funding "st": "1697788800000000000", "et": "1697788800000000000", "l": 500, - "c": "" + "c": "", + "at": "FUNDING_INTERVAL" } ' ``` @@ -3453,7 +3460,8 @@ LITE ENDPOINT: lite/v1/funding "st": "1697788800000000000", "et": "1697788800000000000", "l": 500, - "c": "" + "c": "", + "at": "FUNDING_INTERVAL" }, "i": 123 } @@ -3470,7 +3478,8 @@ LITE ENDPOINT: lite/v1/funding "start_time": "1697788800000000000", "end_time": "1697788800000000000", "limit": 500, - "cursor": "" + "cursor": "", + "agg_type": "FUNDING_INTERVAL" } ' ``` @@ -3486,7 +3495,8 @@ LITE ENDPOINT: lite/v1/funding "start_time": "1697788800000000000", "end_time": "1697788800000000000", "limit": 500, - "cursor": "" + "cursor": "", + "agg_type": "FUNDING_INTERVAL" }, "id": 123 } @@ -3502,7 +3512,8 @@ LITE ENDPOINT: lite/v1/funding "st": "1697788800000000000", "et": "1697788800000000000", "l": 500, - "c": "" + "c": "", + "at": "FUNDING_INTERVAL" } ' ``` @@ -3518,7 +3529,8 @@ LITE ENDPOINT: lite/v1/funding "st": "1697788800000000000", "et": "1697788800000000000", "l": 500, - "c": "" + "c": "", + "at": "FUNDING_INTERVAL" }, "i": 123 } @@ -3535,7 +3547,8 @@ LITE ENDPOINT: lite/v1/funding "start_time": "1697788800000000000", "end_time": "1697788800000000000", "limit": 500, - "cursor": "" + "cursor": "", + "agg_type": "FUNDING_INTERVAL" } ' ``` @@ -3551,7 +3564,8 @@ LITE ENDPOINT: lite/v1/funding "start_time": "1697788800000000000", "end_time": "1697788800000000000", "limit": 500, - "cursor": "" + "cursor": "", + "agg_type": "FUNDING_INTERVAL" }, "id": 123 } @@ -3567,7 +3581,8 @@ LITE ENDPOINT: lite/v1/funding "st": "1697788800000000000", "et": "1697788800000000000", "l": 500, - "c": "" + "c": "", + "at": "FUNDING_INTERVAL" } ' ``` @@ -3583,7 +3598,8 @@ LITE ENDPOINT: lite/v1/funding "st": "1697788800000000000", "et": "1697788800000000000", "l": 500, - "c": "" + "c": "", + "at": "FUNDING_INTERVAL" }, "i": 123 } @@ -3600,7 +3616,8 @@ LITE ENDPOINT: lite/v1/funding "start_time": "1697788800000000000", "end_time": "1697788800000000000", "limit": 500, - "cursor": "" + "cursor": "", + "agg_type": "FUNDING_INTERVAL" } ' ``` @@ -3616,7 +3633,8 @@ LITE ENDPOINT: lite/v1/funding "start_time": "1697788800000000000", "end_time": "1697788800000000000", "limit": 500, - "cursor": "" + "cursor": "", + "agg_type": "FUNDING_INTERVAL" }, "id": 123 } @@ -3632,7 +3650,8 @@ LITE ENDPOINT: lite/v1/funding "st": "1697788800000000000", "et": "1697788800000000000", "l": 500, - "c": "" + "c": "", + "at": "FUNDING_INTERVAL" } ' ``` @@ -3648,7 +3667,8 @@ LITE ENDPOINT: lite/v1/funding "st": "1697788800000000000", "et": "1697788800000000000", "l": 500, - "c": "" + "c": "", + "at": "FUNDING_INTERVAL" }, "i": 123 } diff --git a/artifacts/apidocs/schemas/api_create_order_request.md b/artifacts/apidocs/schemas/api_create_order_request.md index 206a49d..80a66ad 100644 --- a/artifacts/apidocs/schemas/api_create_order_request.md +++ b/artifacts/apidocs/schemas/api_create_order_request.md @@ -59,7 +59,6 @@ |create_time
`ct` |string|False
`0`|[Filled by GRVT Backend] Time at which the order was received by GRVT in unix nanoseconds| |trigger
`t` |TriggerOrderMetadata|False
``|Trigger fields are used to support any type of trigger order such as TP/SL| |broker
`b` |BrokerTag|False
``|Specifies the broker who brokered the order| - |allow_crossing
`ac` |boolean|False
`false`|Specifies if post only order is allowed to cross the orderbook| ??? info "[TriggerOrderMetadata](/../../schemas/trigger_order_metadata)" Contains metadata related to trigger orders, such as Take Profit (TP) or Stop Loss (SL).

Trigger orders are used to automatically execute an order when a predefined price condition is met, allowing traders to implement risk management strategies.


diff --git a/artifacts/apidocs/schemas/api_create_order_response.md b/artifacts/apidocs/schemas/api_create_order_response.md index efdd10e..3cf7199 100644 --- a/artifacts/apidocs/schemas/api_create_order_response.md +++ b/artifacts/apidocs/schemas/api_create_order_response.md @@ -57,7 +57,6 @@ |create_time
`ct` |string|False
`0`|[Filled by GRVT Backend] Time at which the order was received by GRVT in unix nanoseconds| |trigger
`t` |TriggerOrderMetadata|False
``|Trigger fields are used to support any type of trigger order such as TP/SL| |broker
`b` |BrokerTag|False
``|Specifies the broker who brokered the order| - |allow_crossing
`ac` |boolean|False
`false`|Specifies if post only order is allowed to cross the orderbook| ??? info "[TriggerOrderMetadata](/../../schemas/trigger_order_metadata)" Contains metadata related to trigger orders, such as Take Profit (TP) or Stop Loss (SL).

Trigger orders are used to automatically execute an order when a predefined price condition is met, allowing traders to implement risk management strategies.


diff --git a/artifacts/apidocs/schemas/api_funding_rate.md b/artifacts/apidocs/schemas/api_funding_rate.md new file mode 100644 index 0000000..b59945f --- /dev/null +++ b/artifacts/apidocs/schemas/api_funding_rate.md @@ -0,0 +1,9 @@ +!!! info "[ApiFundingRate](/../../schemas/api_funding_rate)" + |Name
`Lite`|Type|Required
`Default`| Description | + |-|-|-|-| + |instrument
`i` |string|True|The readable instrument name:| + |funding_rate
`fr` |string|True|The funding rate of the instrument, expressed in percentage points| + |funding_time
`ft` |string|True|The funding timestamp of the funding rate, expressed in unix nanoseconds| + |mark_price
`mp` |string|True|The mark price of the instrument at funding timestamp, expressed in `9` decimals| + |funding_rate_8_h_avg
`fr1` |string|True|Deprecated: Refer to `funding_rate` instead. Will be removed in a future release.| + |funding_interval_hours
`fi` |integer|True|Funding interval in hours (e.g. 1/4/8/etc).| diff --git a/artifacts/apidocs/schemas/api_funding_rate_request.md b/artifacts/apidocs/schemas/api_funding_rate_request.md index 6389aa5..3f7a18c 100644 --- a/artifacts/apidocs/schemas/api_funding_rate_request.md +++ b/artifacts/apidocs/schemas/api_funding_rate_request.md @@ -8,3 +8,13 @@ |end_time
`et` |string|False
`now()`|End time of funding rate in unix nanoseconds| |limit
`l` |integer|False
`500`|The limit to query for. Defaults to 500; Max 1000| |cursor
`c` |string|False
`''`|The cursor to indicate when to start the query from| + |agg_type
`at` |FundingRateAggregationType|False
`'FUNDING_INTERVAL'`|Aggregation method for historical funding rate observations. Defaults to using the instrument-specific funding interval.| + ??? info "[FundingRateAggregationType](/../../schemas/funding_rate_aggregation_type)" + Specifies different methods of aggregating historical funding rates
+ + |Value| Description | + |-|-| + |`FUNDING_INTERVAL` = 1|Default value -- one record returned per funding interval. Query instruments endpoint to learn funding interval of each instrument.| + |`ONE_HOURLY` = 2|Returns one record per hour -- normalizes all funding rates to 1h durations, so `fundingRate` value is cumulative and can exceed a funding interval's configured cap / floor.| + |`FOUR_HOURLY` = 3|Returns one record per 4 hours -- normalizes all funding rates to 4h durations, so `fundingRate` value is cumulative and can exceed a funding interval's configured cap / floor.| + |`EIGHT_HOURLY` = 4|Returns one record for eight hours -- normalizes all funding rates to 8h durations, so `fundingRate` value is cumulative and can exceed a funding interval's configured cap / floor.| diff --git a/artifacts/apidocs/schemas/api_funding_rate_response.md b/artifacts/apidocs/schemas/api_funding_rate_response.md index 01e2a1c..61b703a 100644 --- a/artifacts/apidocs/schemas/api_funding_rate_response.md +++ b/artifacts/apidocs/schemas/api_funding_rate_response.md @@ -1,13 +1,14 @@ !!! info "[ApiFundingRateResponse](/../../schemas/api_funding_rate_response)" |Name
`Lite`|Type|Required
`Default`| Description | |-|-|-|-| - |result
`r` |[FundingRate]|True|The funding rate result set for given interval| + |result
`r` |[ApiFundingRate]|True|The funding rate result set for given interval| |next
`n` |string|False
`''`|The cursor to indicate when to start the next query from| - ??? info "[FundingRate](/../../schemas/funding_rate)" + ??? info "[ApiFundingRate](/../../schemas/api_funding_rate)" |Name
`Lite`|Type|Required
`Default`| Description | |-|-|-|-| |instrument
`i` |string|True|The readable instrument name:| |funding_rate
`fr` |string|True|The funding rate of the instrument, expressed in percentage points| |funding_time
`ft` |string|True|The funding timestamp of the funding rate, expressed in unix nanoseconds| |mark_price
`mp` |string|True|The mark price of the instrument at funding timestamp, expressed in `9` decimals| - |funding_rate_8_h_avg
`fr1` |string|True|The 8h average funding rate of the instrument, expressed in percentage points| + |funding_rate_8_h_avg
`fr1` |string|True|Deprecated: Refer to `funding_rate` instead. Will be removed in a future release.| + |funding_interval_hours
`fi` |integer|True|Funding interval in hours (e.g. 1/4/8/etc).| diff --git a/artifacts/apidocs/schemas/api_get_order_response.md b/artifacts/apidocs/schemas/api_get_order_response.md index e0af755..7ce9251 100644 --- a/artifacts/apidocs/schemas/api_get_order_response.md +++ b/artifacts/apidocs/schemas/api_get_order_response.md @@ -57,7 +57,6 @@ |create_time
`ct` |string|False
`0`|[Filled by GRVT Backend] Time at which the order was received by GRVT in unix nanoseconds| |trigger
`t` |TriggerOrderMetadata|False
``|Trigger fields are used to support any type of trigger order such as TP/SL| |broker
`b` |BrokerTag|False
``|Specifies the broker who brokered the order| - |allow_crossing
`ac` |boolean|False
`false`|Specifies if post only order is allowed to cross the orderbook| ??? info "[TriggerOrderMetadata](/../../schemas/trigger_order_metadata)" Contains metadata related to trigger orders, such as Take Profit (TP) or Stop Loss (SL).

Trigger orders are used to automatically execute an order when a predefined price condition is met, allowing traders to implement risk management strategies.


diff --git a/artifacts/apidocs/schemas/api_open_orders_response.md b/artifacts/apidocs/schemas/api_open_orders_response.md index 4f40d02..071ca49 100644 --- a/artifacts/apidocs/schemas/api_open_orders_response.md +++ b/artifacts/apidocs/schemas/api_open_orders_response.md @@ -59,7 +59,6 @@ |create_time
`ct` |string|False
`0`|[Filled by GRVT Backend] Time at which the order was received by GRVT in unix nanoseconds| |trigger
`t` |TriggerOrderMetadata|False
``|Trigger fields are used to support any type of trigger order such as TP/SL| |broker
`b` |BrokerTag|False
``|Specifies the broker who brokered the order| - |allow_crossing
`ac` |boolean|False
`false`|Specifies if post only order is allowed to cross the orderbook| ??? info "[TriggerOrderMetadata](/../../schemas/trigger_order_metadata)" Contains metadata related to trigger orders, such as Take Profit (TP) or Stop Loss (SL).

Trigger orders are used to automatically execute an order when a predefined price condition is met, allowing traders to implement risk management strategies.


diff --git a/artifacts/apidocs/schemas/api_order_history_response.md b/artifacts/apidocs/schemas/api_order_history_response.md index ed6c595..0357300 100644 --- a/artifacts/apidocs/schemas/api_order_history_response.md +++ b/artifacts/apidocs/schemas/api_order_history_response.md @@ -58,7 +58,6 @@ |create_time
`ct` |string|False
`0`|[Filled by GRVT Backend] Time at which the order was received by GRVT in unix nanoseconds| |trigger
`t` |TriggerOrderMetadata|False
``|Trigger fields are used to support any type of trigger order such as TP/SL| |broker
`b` |BrokerTag|False
``|Specifies the broker who brokered the order| - |allow_crossing
`ac` |boolean|False
`false`|Specifies if post only order is allowed to cross the orderbook| ??? info "[TriggerOrderMetadata](/../../schemas/trigger_order_metadata)" Contains metadata related to trigger orders, such as Take Profit (TP) or Stop Loss (SL).

Trigger orders are used to automatically execute an order when a predefined price condition is met, allowing traders to implement risk management strategies.


diff --git a/artifacts/apidocs/schemas/api_positions_response.md b/artifacts/apidocs/schemas/api_positions_response.md index ca3e365..a4d6886 100644 --- a/artifacts/apidocs/schemas/api_positions_response.md +++ b/artifacts/apidocs/schemas/api_positions_response.md @@ -21,4 +21,4 @@ |est_liquidation_price
`el` |string|True|The estimated liquidation price| |leverage
`l` |string|True|The current leverage value for this position| |cumulative_fee
`cf` |string|True|The cumulative fee paid on the position, expressed in quote asset decimal units| - |cumulative_realized_funding_payment
`cr` |string|True|The cumulative realized funding payment of the position, expressed in quote asset decimal units| + |cumulative_realized_funding_payment
`cr` |string|True|The cumulative realized funding payment of the position, expressed in quote asset decimal units. Positive if paid, negative if received| diff --git a/artifacts/apidocs/schemas/api_sub_account_history_response.md b/artifacts/apidocs/schemas/api_sub_account_history_response.md index 6159968..7192109 100644 --- a/artifacts/apidocs/schemas/api_sub_account_history_response.md +++ b/artifacts/apidocs/schemas/api_sub_account_history_response.md @@ -52,4 +52,4 @@ |est_liquidation_price
`el` |string|True|The estimated liquidation price| |leverage
`l` |string|True|The current leverage value for this position| |cumulative_fee
`cf` |string|True|The cumulative fee paid on the position, expressed in quote asset decimal units| - |cumulative_realized_funding_payment
`cr` |string|True|The cumulative realized funding payment of the position, expressed in quote asset decimal units| + |cumulative_realized_funding_payment
`cr` |string|True|The cumulative realized funding payment of the position, expressed in quote asset decimal units. Positive if paid, negative if received| diff --git a/artifacts/apidocs/schemas/api_sub_account_summary_response.md b/artifacts/apidocs/schemas/api_sub_account_summary_response.md index da7152c..69c0f37 100644 --- a/artifacts/apidocs/schemas/api_sub_account_summary_response.md +++ b/artifacts/apidocs/schemas/api_sub_account_summary_response.md @@ -53,4 +53,4 @@ |est_liquidation_price
`el` |string|True|The estimated liquidation price| |leverage
`l` |string|True|The current leverage value for this position| |cumulative_fee
`cf` |string|True|The cumulative fee paid on the position, expressed in quote asset decimal units| - |cumulative_realized_funding_payment
`cr` |string|True|The cumulative realized funding payment of the position, expressed in quote asset decimal units| + |cumulative_realized_funding_payment
`cr` |string|True|The cumulative realized funding payment of the position, expressed in quote asset decimal units. Positive if paid, negative if received| diff --git a/artifacts/apidocs/schemas/funding_rate_aggregation_type.md b/artifacts/apidocs/schemas/funding_rate_aggregation_type.md new file mode 100644 index 0000000..5d508e8 --- /dev/null +++ b/artifacts/apidocs/schemas/funding_rate_aggregation_type.md @@ -0,0 +1,9 @@ +!!! info "[FundingRateAggregationType](/../../schemas/funding_rate_aggregation_type)" + Specifies different methods of aggregating historical funding rates
+ + |Value| Description | + |-|-| + |`FUNDING_INTERVAL` = 1|Default value -- one record returned per funding interval. Query instruments endpoint to learn funding interval of each instrument.| + |`ONE_HOURLY` = 2|Returns one record per hour -- normalizes all funding rates to 1h durations, so `fundingRate` value is cumulative and can exceed a funding interval's configured cap / floor.| + |`FOUR_HOURLY` = 3|Returns one record per 4 hours -- normalizes all funding rates to 4h durations, so `fundingRate` value is cumulative and can exceed a funding interval's configured cap / floor.| + |`EIGHT_HOURLY` = 4|Returns one record for eight hours -- normalizes all funding rates to 8h durations, so `fundingRate` value is cumulative and can exceed a funding interval's configured cap / floor.| diff --git a/artifacts/apidocs/schemas/order.md b/artifacts/apidocs/schemas/order.md index aaee1e4..320c520 100644 --- a/artifacts/apidocs/schemas/order.md +++ b/artifacts/apidocs/schemas/order.md @@ -53,7 +53,6 @@ |create_time
`ct` |string|False
`0`|[Filled by GRVT Backend] Time at which the order was received by GRVT in unix nanoseconds| |trigger
`t` |TriggerOrderMetadata|False
``|Trigger fields are used to support any type of trigger order such as TP/SL| |broker
`b` |BrokerTag|False
``|Specifies the broker who brokered the order| - |allow_crossing
`ac` |boolean|False
`false`|Specifies if post only order is allowed to cross the orderbook| ??? info "[TriggerOrderMetadata](/../../schemas/trigger_order_metadata)" Contains metadata related to trigger orders, such as Take Profit (TP) or Stop Loss (SL).

Trigger orders are used to automatically execute an order when a predefined price condition is met, allowing traders to implement risk management strategies.


diff --git a/artifacts/apidocs/schemas/order_metadata.md b/artifacts/apidocs/schemas/order_metadata.md index e933a37..471ce7b 100644 --- a/artifacts/apidocs/schemas/order_metadata.md +++ b/artifacts/apidocs/schemas/order_metadata.md @@ -7,7 +7,6 @@ |create_time
`ct` |string|False
`0`|[Filled by GRVT Backend] Time at which the order was received by GRVT in unix nanoseconds| |trigger
`t` |TriggerOrderMetadata|False
``|Trigger fields are used to support any type of trigger order such as TP/SL| |broker
`b` |BrokerTag|False
``|Specifies the broker who brokered the order| - |allow_crossing
`ac` |boolean|False
`false`|Specifies if post only order is allowed to cross the orderbook| ??? info "[TriggerOrderMetadata](/../../schemas/trigger_order_metadata)" Contains metadata related to trigger orders, such as Take Profit (TP) or Stop Loss (SL).

Trigger orders are used to automatically execute an order when a predefined price condition is met, allowing traders to implement risk management strategies.


diff --git a/artifacts/apidocs/schemas/positions.md b/artifacts/apidocs/schemas/positions.md index 8209b48..589ab70 100644 --- a/artifacts/apidocs/schemas/positions.md +++ b/artifacts/apidocs/schemas/positions.md @@ -17,4 +17,4 @@ |est_liquidation_price
`el` |string|True|The estimated liquidation price| |leverage
`l` |string|True|The current leverage value for this position| |cumulative_fee
`cf` |string|True|The cumulative fee paid on the position, expressed in quote asset decimal units| - |cumulative_realized_funding_payment
`cr` |string|True|The cumulative realized funding payment of the position, expressed in quote asset decimal units| + |cumulative_realized_funding_payment
`cr` |string|True|The cumulative realized funding payment of the position, expressed in quote asset decimal units. Positive if paid, negative if received| diff --git a/artifacts/apidocs/schemas/sub_account.md b/artifacts/apidocs/schemas/sub_account.md index 786cd91..28dc97c 100644 --- a/artifacts/apidocs/schemas/sub_account.md +++ b/artifacts/apidocs/schemas/sub_account.md @@ -47,4 +47,4 @@ |est_liquidation_price
`el` |string|True|The estimated liquidation price| |leverage
`l` |string|True|The current leverage value for this position| |cumulative_fee
`cf` |string|True|The cumulative fee paid on the position, expressed in quote asset decimal units| - |cumulative_realized_funding_payment
`cr` |string|True|The cumulative realized funding payment of the position, expressed in quote asset decimal units| + |cumulative_realized_funding_payment
`cr` |string|True|The cumulative realized funding payment of the position, expressed in quote asset decimal units. Positive if paid, negative if received| diff --git a/artifacts/apidocs/schemas/ws_order_feed_data_v1.md b/artifacts/apidocs/schemas/ws_order_feed_data_v1.md index 59d36c3..296767e 100644 --- a/artifacts/apidocs/schemas/ws_order_feed_data_v1.md +++ b/artifacts/apidocs/schemas/ws_order_feed_data_v1.md @@ -60,7 +60,6 @@ |create_time
`ct` |string|False
`0`|[Filled by GRVT Backend] Time at which the order was received by GRVT in unix nanoseconds| |trigger
`t` |TriggerOrderMetadata|False
``|Trigger fields are used to support any type of trigger order such as TP/SL| |broker
`b` |BrokerTag|False
``|Specifies the broker who brokered the order| - |allow_crossing
`ac` |boolean|False
`false`|Specifies if post only order is allowed to cross the orderbook| ??? info "[TriggerOrderMetadata](/../../schemas/trigger_order_metadata)" Contains metadata related to trigger orders, such as Take Profit (TP) or Stop Loss (SL).

Trigger orders are used to automatically execute an order when a predefined price condition is met, allowing traders to implement risk management strategies.


diff --git a/artifacts/apidocs/schemas/ws_positions_feed_data_v1.md b/artifacts/apidocs/schemas/ws_positions_feed_data_v1.md index b4999bf..b8e7814 100644 --- a/artifacts/apidocs/schemas/ws_positions_feed_data_v1.md +++ b/artifacts/apidocs/schemas/ws_positions_feed_data_v1.md @@ -24,4 +24,4 @@ |est_liquidation_price
`el` |string|True|The estimated liquidation price| |leverage
`l` |string|True|The current leverage value for this position| |cumulative_fee
`cf` |string|True|The cumulative fee paid on the position, expressed in quote asset decimal units| - |cumulative_realized_funding_payment
`cr` |string|True|The cumulative realized funding payment of the position, expressed in quote asset decimal units| + |cumulative_realized_funding_payment
`cr` |string|True|The cumulative realized funding payment of the position, expressed in quote asset decimal units. Positive if paid, negative if received| diff --git a/artifacts/apidocs/trading_api.md b/artifacts/apidocs/trading_api.md index 2ff0714..a3a48b3 100644 --- a/artifacts/apidocs/trading_api.md +++ b/artifacts/apidocs/trading_api.md @@ -49,8 +49,7 @@ LITE ENDPOINT: lite/v1/create_order "close_position": false } }, - "broker": "BROKER_CODE", - "allow_crossing": null + "broker": "BROKER_CODE" } } } @@ -90,8 +89,7 @@ LITE ENDPOINT: lite/v1/create_order "cp": false } }, - "b": "BROKER_CODE", - "ac": null + "b": "BROKER_CODE" } } } @@ -139,8 +137,7 @@ LITE ENDPOINT: lite/v1/create_order "close_position": false } }, - "broker": "BROKER_CODE", - "allow_crossing": null + "broker": "BROKER_CODE" }, "state": { "status": "PENDING", @@ -189,8 +186,7 @@ LITE ENDPOINT: lite/v1/create_order "cp": false } }, - "b": "BROKER_CODE", - "ac": null + "b": "BROKER_CODE" }, "s1": { "s": "PENDING", @@ -329,8 +325,7 @@ LITE ENDPOINT: lite/v1/create_order "close_position": false } }, - "broker": "BROKER_CODE", - "allow_crossing": null + "broker": "BROKER_CODE" } } } @@ -378,8 +373,7 @@ LITE ENDPOINT: lite/v1/create_order "close_position": false } }, - "broker": "BROKER_CODE", - "allow_crossing": null + "broker": "BROKER_CODE" } } }, @@ -427,8 +421,7 @@ LITE ENDPOINT: lite/v1/create_order "cp": false } }, - "b": "BROKER_CODE", - "ac": null + "b": "BROKER_CODE" } } } @@ -476,8 +469,7 @@ LITE ENDPOINT: lite/v1/create_order "cp": false } }, - "b": "BROKER_CODE", - "ac": null + "b": "BROKER_CODE" } } }, @@ -526,8 +518,7 @@ LITE ENDPOINT: lite/v1/create_order "close_position": false } }, - "broker": "BROKER_CODE", - "allow_crossing": null + "broker": "BROKER_CODE" } } } @@ -575,8 +566,7 @@ LITE ENDPOINT: lite/v1/create_order "close_position": false } }, - "broker": "BROKER_CODE", - "allow_crossing": null + "broker": "BROKER_CODE" } } }, @@ -624,8 +614,7 @@ LITE ENDPOINT: lite/v1/create_order "cp": false } }, - "b": "BROKER_CODE", - "ac": null + "b": "BROKER_CODE" } } } @@ -673,8 +662,7 @@ LITE ENDPOINT: lite/v1/create_order "cp": false } }, - "b": "BROKER_CODE", - "ac": null + "b": "BROKER_CODE" } } }, @@ -723,8 +711,7 @@ LITE ENDPOINT: lite/v1/create_order "close_position": false } }, - "broker": "BROKER_CODE", - "allow_crossing": null + "broker": "BROKER_CODE" } } } @@ -772,8 +759,7 @@ LITE ENDPOINT: lite/v1/create_order "close_position": false } }, - "broker": "BROKER_CODE", - "allow_crossing": null + "broker": "BROKER_CODE" } } }, @@ -821,8 +807,7 @@ LITE ENDPOINT: lite/v1/create_order "cp": false } }, - "b": "BROKER_CODE", - "ac": null + "b": "BROKER_CODE" } } } @@ -870,8 +855,7 @@ LITE ENDPOINT: lite/v1/create_order "cp": false } }, - "b": "BROKER_CODE", - "ac": null + "b": "BROKER_CODE" } } }, @@ -920,8 +904,7 @@ LITE ENDPOINT: lite/v1/create_order "close_position": false } }, - "broker": "BROKER_CODE", - "allow_crossing": null + "broker": "BROKER_CODE" } } } @@ -969,8 +952,7 @@ LITE ENDPOINT: lite/v1/create_order "close_position": false } }, - "broker": "BROKER_CODE", - "allow_crossing": null + "broker": "BROKER_CODE" } } }, @@ -1018,8 +1000,7 @@ LITE ENDPOINT: lite/v1/create_order "cp": false } }, - "b": "BROKER_CODE", - "ac": null + "b": "BROKER_CODE" } } } @@ -1067,8 +1048,7 @@ LITE ENDPOINT: lite/v1/create_order "cp": false } }, - "b": "BROKER_CODE", - "ac": null + "b": "BROKER_CODE" } } }, @@ -1884,8 +1864,7 @@ LITE ENDPOINT: lite/v1/order "close_position": false } }, - "broker": "BROKER_CODE", - "allow_crossing": null + "broker": "BROKER_CODE" }, "state": { "status": "PENDING", @@ -1934,8 +1913,7 @@ LITE ENDPOINT: lite/v1/order "cp": false } }, - "b": "BROKER_CODE", - "ac": null + "b": "BROKER_CODE" }, "s1": { "s": "PENDING", @@ -2320,8 +2298,7 @@ LITE ENDPOINT: lite/v1/open_orders "close_position": false } }, - "broker": "BROKER_CODE", - "allow_crossing": null + "broker": "BROKER_CODE" }, "state": { "status": "PENDING", @@ -2370,8 +2347,7 @@ LITE ENDPOINT: lite/v1/open_orders "cp": false } }, - "b": "BROKER_CODE", - "ac": null + "b": "BROKER_CODE" }, "s1": { "s": "PENDING", @@ -2778,8 +2754,7 @@ LITE ENDPOINT: lite/v1/order_history "close_position": false } }, - "broker": "BROKER_CODE", - "allow_crossing": null + "broker": "BROKER_CODE" }, "state": { "status": "PENDING", @@ -2829,8 +2804,7 @@ LITE ENDPOINT: lite/v1/order_history "cp": false } }, - "b": "BROKER_CODE", - "ac": null + "b": "BROKER_CODE" }, "s1": { "s": "PENDING", diff --git a/artifacts/apidocs/trading_streams.md b/artifacts/apidocs/trading_streams.md index a78d9e4..fcdd183 100644 --- a/artifacts/apidocs/trading_streams.md +++ b/artifacts/apidocs/trading_streams.md @@ -141,8 +141,7 @@ STREAM: v1.order "close_position": false } }, - "broker": "BROKER_CODE", - "allow_crossing": null + "broker": "BROKER_CODE" }, "state": { "status": "PENDING", @@ -194,8 +193,7 @@ STREAM: v1.order "cp": false } }, - "b": "BROKER_CODE", - "ac": null + "b": "BROKER_CODE" }, "s1": { "s": "PENDING", diff --git a/artifacts/pysdk/grvt_raw_types.py b/artifacts/pysdk/grvt_raw_types.py index 5686c0d..d2fbe54 100644 --- a/artifacts/pysdk/grvt_raw_types.py +++ b/artifacts/pysdk/grvt_raw_types.py @@ -77,6 +77,17 @@ class CandlestickType(Enum): MID = "MID" +class FundingRateAggregationType(Enum): + # Default value -- one record returned per funding interval. Query instruments endpoint to learn funding interval of each instrument. + FUNDING_INTERVAL = "FUNDING_INTERVAL" + # Returns one record per hour -- normalizes all funding rates to 1h durations, so `fundingRate` value is cumulative and can exceed a funding interval's configured cap / floor. + ONE_HOURLY = "ONE_HOURLY" + # Returns one record per 4 hours -- normalizes all funding rates to 4h durations, so `fundingRate` value is cumulative and can exceed a funding interval's configured cap / floor. + FOUR_HOURLY = "FOUR_HOURLY" + # Returns one record for eight hours -- normalizes all funding rates to 8h durations, so `fundingRate` value is cumulative and can exceed a funding interval's configured cap / floor. + EIGHT_HOURLY = "EIGHT_HOURLY" + + class InstrumentSettlementPeriod(Enum): # Instrument settles through perpetual funding cycles PERPETUAL = "PERPETUAL" @@ -379,7 +390,7 @@ class Positions: leverage: str # The cumulative fee paid on the position, expressed in quote asset decimal units cumulative_fee: str - # The cumulative realized funding payment of the position, expressed in quote asset decimal units + # The cumulative realized funding payment of the position, expressed in quote asset decimal units. Positive if paid, negative if received cumulative_realized_funding_payment: str @@ -1573,10 +1584,12 @@ class ApiFundingRateRequest: limit: int | None = None # The cursor to indicate when to start the query from cursor: str | None = None + # Aggregation method for historical funding rate observations. Defaults to using the instrument-specific funding interval. + agg_type: FundingRateAggregationType | None = None @dataclass -class FundingRate: +class ApiFundingRate: # The readable instrument name: instrument: str # The funding rate of the instrument, expressed in percentage points @@ -1585,14 +1598,16 @@ class FundingRate: funding_time: str # The mark price of the instrument at funding timestamp, expressed in `9` decimals mark_price: str - # The 8h average funding rate of the instrument, expressed in percentage points + # Deprecated: Refer to `funding_rate` instead. Will be removed in a future release. funding_rate_8_h_avg: str + # Funding interval in hours (e.g. 1/4/8/etc). + funding_interval_hours: int @dataclass class ApiFundingRateResponse: # The funding rate result set for given interval - result: list[FundingRate] + result: list[ApiFundingRate] # The cursor to indicate when to start the next query from next: str | None = None @@ -1728,8 +1743,6 @@ class OrderMetadata: trigger: TriggerOrderMetadata | None = None # Specifies the broker who brokered the order broker: BrokerTag | None = None - # Specifies if post only order is allowed to cross the orderbook - allow_crossing: bool | None = None @dataclass diff --git a/src/codegen/apispec.json b/src/codegen/apispec.json index 2a01dc5..25d0a0a 100644 --- a/src/codegen/apispec.json +++ b/src/codegen/apispec.json @@ -3111,7 +3111,7 @@ "optional": false, "example": "'100000.20'", "comment": [ - "The cumulative realized funding payment of the position, expressed in quote asset decimal units" + "The cumulative realized funding payment of the position, expressed in quote asset decimal units. Positive if paid, negative if received" ] } ], @@ -8013,6 +8013,20 @@ "comment": [ "The cursor to indicate when to start the query from" ] + }, + { + "name": "agg_type", + "lite_name": "at", + "semantic_type": "FundingRateAggregationType", + "json_type": "FundingRateAggregationType", + "index": 5, + "array_depth": 0, + "optional": true, + "default": "'FUNDING_INTERVAL'", + "example": "'FUNDING_INTERVAL'", + "comment": [ + "Aggregation method for historical funding rate observations. Defaults to using the instrument-specific funding interval." + ] } ], "comment": [ @@ -8022,7 +8036,7 @@ ] }, { - "name": "FundingRate", + "name": "ApiFundingRate", "is_root": false, "fields": [ { @@ -8087,7 +8101,20 @@ "optional": false, "example": "0.0003", "comment": [ - "The 8h average funding rate of the instrument, expressed in percentage points" + "Deprecated: Refer to `funding_rate` instead. Will be removed in a future release." + ] + }, + { + "name": "funding_interval_hours", + "lite_name": "fi", + "semantic_type": "uint8", + "json_type": "integer", + "index": 5, + "array_depth": 0, + "optional": false, + "example": "8", + "comment": [ + "Funding interval in hours (e.g. 1/4/8/etc)." ] } ], @@ -8100,8 +8127,8 @@ { "name": "result", "lite_name": "r", - "semantic_type": "FundingRate", - "json_type": "FundingRate", + "semantic_type": "ApiFundingRate", + "json_type": "ApiFundingRate", "index": 0, "array_depth": 1, "optional": false, @@ -8586,19 +8613,6 @@ "comment": [ "Specifies the broker who brokered the order" ] - }, - { - "name": "allow_crossing", - "lite_name": "ac", - "semantic_type": "bool", - "json_type": "boolean", - "index": 7, - "array_depth": 0, - "optional": true, - "default": "false", - "comment": [ - "Specifies if post only order is allowed to cross the orderbook" - ] } ], "comment": [ @@ -12562,6 +12576,42 @@ ], "comment": [] }, + { + "name": "FundingRateAggregationType", + "values": [ + { + "name": "FUNDING_INTERVAL", + "value": 1, + "comment": [ + "Default value -- one record returned per funding interval. Query instruments endpoint to learn funding interval of each instrument." + ] + }, + { + "name": "ONE_HOURLY", + "value": 2, + "comment": [ + "Returns one record per hour -- normalizes all funding rates to 1h durations, so `fundingRate` value is cumulative and can exceed a funding interval's configured cap / floor." + ] + }, + { + "name": "FOUR_HOURLY", + "value": 3, + "comment": [ + "Returns one record per 4 hours -- normalizes all funding rates to 4h durations, so `fundingRate` value is cumulative and can exceed a funding interval's configured cap / floor." + ] + }, + { + "name": "EIGHT_HOURLY", + "value": 4, + "comment": [ + "Returns one record for eight hours -- normalizes all funding rates to 8h durations, so `fundingRate` value is cumulative and can exceed a funding interval's configured cap / floor." + ] + } + ], + "comment": [ + "Specifies different methods of aggregating historical funding rates" + ] + }, { "name": "InstrumentSettlementPeriod", "values": [