Skip to content
Closed
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
164 changes: 164 additions & 0 deletions artifacts/apidocs/schemas/api_bulk_orders_request.md

Large diffs are not rendered by default.

163 changes: 163 additions & 0 deletions artifacts/apidocs/schemas/api_bulk_orders_response.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

|Name<br>`Lite`|Type|Required<br>`Default`| Description |
|-|-|-|-|
|redemption_queue<br>`rq` |[VaultRedemptionRequest]|True|Outstanding vault redemption requests, ordered by descending priority. Excludes requests that have not yet aged past the minmimum redemption period.|
|redemption_queue<br>`rq` |[VaultRedemptionRequest]|True|Outstanding vault redemption requests, ordered by descending priority. Excludes requests that have not yet aged past the minimum redemption period.|
|pending_redemption_token_count<br>`pr` |string|True|Number of shares eligible for automated redemption (held in queue for at least the minimum redemption period).|
|urgent_redemption_token_count<br>`ur` |string|True|Number of shares nearing the maximum redemption period (>= 90% of maximum redemption period).|
|auto_redeemable_balance<br>`ar` |string|True|Amount available for automated redemption request servicing (in USD).|
Expand Down
1,280 changes: 1,280 additions & 0 deletions artifacts/apidocs/trading_api.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions artifacts/pysdk/grvt_raw_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ async def cancel_on_disconnect_v1(
return GrvtError(**resp)
return from_dict(types.AckResponse, resp, Config(cast=[Enum]))

async def bulk_orders_v1(
self, req: types.ApiBulkOrdersRequest
) -> types.ApiBulkOrdersResponse | GrvtError:
resp = await self._post(True, self.td_rpc + "/full/v1/bulk_order", req)
if resp.get("code"):
return GrvtError(**resp)
return from_dict(types.ApiBulkOrdersResponse, resp, Config(cast=[Enum]))

async def fill_history_v1(
self, req: types.ApiFillHistoryRequest
) -> types.ApiFillHistoryResponse | GrvtError:
Expand Down
8 changes: 8 additions & 0 deletions artifacts/pysdk/grvt_raw_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ def cancel_on_disconnect_v1(
return GrvtError(**resp)
return from_dict(types.AckResponse, resp, Config(cast=[Enum]))

def bulk_orders_v1(
self, req: types.ApiBulkOrdersRequest
) -> types.ApiBulkOrdersResponse | GrvtError:
resp = self._post(True, self.td_rpc + "/full/v1/bulk_order", req)
if resp.get("code"):
return GrvtError(**resp)
return from_dict(types.ApiBulkOrdersResponse, resp, Config(cast=[Enum]))

def fill_history_v1(
self, req: types.ApiFillHistoryRequest
) -> types.ApiFillHistoryResponse | GrvtError:
Expand Down
64 changes: 63 additions & 1 deletion artifacts/pysdk/grvt_raw_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1935,6 +1935,68 @@ class ApiCancelOnDisconnectRequest:
countdown_time: str | None = None


@dataclass
class ApiBulkOrdersRequest:
"""
Usage Parameters

* Rate Limits
- If N orders are created, it will consume N create_order rate limit tokens
- If M orders are cancelled, it will consume 1 cancel_order rate limit tokens

• Usage Pattern
- This can be used as BulkCreate if no cancellations are supplied
- This can be used as BulkCancel if no creations are supplied
- This can be used as BulkReplace if both creations and cancellations are supplied

* Order Replacement
- For a pair of create and cancel payloads at the same index:
* If they belong to the same inst/side/price
* And the created order has an order_size smaller than the book_size of the cancelled order
* The created order will replace the cancelled order, and retain its priority in the orderbook
- For instance, to replace 2 orders, place 1 order, and cancel 2 orders:
* orders = <replace_1, replace_2, create_1>
* order_ids = <replace_1, replace_2, cancel_1, cancel_2>

* Speed Bump
- The highest speed_bump level applies across all sub-payloads and will be applied on the BulkOrder
- To ensure that creations/cancellations are not speed bumped, ensure that all orders have post_only = true

* Restrictions
- This is only available to API users
- All create orders must use the same instrument
- TPSL (Take Profit / Stop Loss) orders are not supported
"""

# The subaccount ID of the user creating the request
sub_account_id: str
# Orders to create or replace, supply up to 20 orders
orders: list[Order]
# The order IDs of the orders to cancel or replace, supply up to 20 orderIDs (if both orderIDs and clientOrderIDs are provided, we will reject the payload)
order_i_ds: list[str]
# The client order IDs of the orders to cancel or replace, supply up to 20 clientOrderIDs (if both orderIDs and clientOrderIDs are provided, we will reject the payload)
client_order_i_ds: list[str]
"""
Specifies the time-to-live (in milliseconds) for this cancellation.
During this period, any order creation with a matching `client_order_id` will be cancelled and not be added to the GRVT matching engine.
This mechanism helps mitigate time-of-flight issues where cancellations might arrive before the corresponding orders.
Hence, cancellation by `order_id` ignores this field as the exchange can only assign `order_id`s to already-processed order creations.
The duration cannot be negative, is rounded down to the nearest 100ms (e.g., `'670'` -> `'600'`, `'30'` -> `'0'`) and capped at 5 seconds (i.e., `'5000'`).
Value of `'0'` or omission results in the default time-to-live value being applied.
If the caller requests multiple successive cancellations for a given order, such that the time-to-live windows overlap, only the first request will be considered.

"""
time_to_live_ms: str | None = None


@dataclass
class ApiBulkOrdersResponse:
# The orders in same order as requested
orders: list[Order]
# A list of acks for the cancelled orders
cancel_acks: list[Ack]


@dataclass
class WSOrderFeedSelectorV1:
"""
Expand Down Expand Up @@ -2607,7 +2669,7 @@ class ApiVaultViewRedemptionQueueResponse:

"""

# Outstanding vault redemption requests, ordered by descending priority. Excludes requests that have not yet aged past the minmimum redemption period.
# Outstanding vault redemption requests, ordered by descending priority. Excludes requests that have not yet aged past the minimum redemption period.
redemption_queue: list[VaultRedemptionRequest]
# Number of shares eligible for automated redemption (held in queue for at least the minimum redemption period).
pending_redemption_token_count: str
Expand Down
Loading