Developers

Algo order history

List a sub-account's finished algo orders, one row per algo order, newest first.

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.

Returns one row per terminated or filled parent algo order, not per sub-order.

Pagination works as follows:

  • We perform a reverse chronological lookup, starting from end_time. If end_time is not set, we start from the most recent data.
  • The lookup is limited to limit records. If more data is requested, the response will contain a next cursor for you to query the next page.
  • If a cursor is provided, it will be used to fetch results from that point onwards.
  • Pagination will continue until the start_time is reached. If start_time is not set, pagination will continue as far back as our data retention policy allows.
SDKclient.algo_order_history(...)
HTTPPOST https://trades.testnet.grvt.io/full/v1/algo_order_history, or /lite/v1/algo_order_history for lite names (the SDKs' default)
WebSocketmethod v1/algo_order_history on wss://trades.testnet.grvt.io/ws/full, or /ws/lite for lite names
AuthSession required (Authentication)
RetriesRead: the SDKs retry retryable errors (rules)
Contract idalgo_order.algo_order_history (RPCAlgoOrderHistoryV1)

Request

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

  • sub_account_idlite name sastring (uint64)required#
    The sub-account ID to filter by
  • typelite name tarray<enum AlgoOrderType>optionaldefault all#
    The algo order type filter to apply. If nil, this defaults to all types. Otherwise, only entries matching the filter will be returned
    1 value
    CHASE (details).
  • start_timelite name ststring (int64 unix ns)optionaldefault 0#
    The start time to apply in nanoseconds. If nil, this defaults to all start times. Otherwise, only entries matching the filter will be returned
  • end_timelite name etstring (int64 unix ns)optionaldefault now()#
    The end time to apply in nanoseconds. If nil, this defaults to all end times. Otherwise, only entries matching the filter will be returned
  • limitlite name linteger (uint32)optionaldefault 500#
    The limit to query for. Defaults to 500; Max 1000
  • cursorlite name cstringoptional#
    The cursor to indicate when to start the query from

Response

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

  • resultlite name rarray<AlgoOrder>required#
    The algo orders matching the request filter
    10 fields of AlgoOrder
    • algo_order_idlite name aostring (uint128)optionaldefault 0#
      Set by the server. The exchange's 128-bit id for the algo order.
    • sub_account_idlite name sastring (uint64)required#
      The sub-account initiating the algo order
    • typelite name tenum AlgoOrderTyperequired#
      The type of the algo order
      1 value
      CHASE (details).
    • post_onlylite name pobooloptionaldefault false#
      If True, every sub-order must be a maker order. Chase orders are always post-only
    • reduce_onlylite name robooloptionaldefault false#
      If True, every sub-order must reduce the position size, or be cancelled
    • leglite name lobject AlgoOrderLegrequired#
      The single leg traded by this algo order
      3 fields of AlgoOrderLeg
      • instrumentlite name istring (instrument name)required#
        The instrument to trade
      • sizelite name sstringrequired#
        The total number of assets to trade across all sub-orders. Decimal string, e.g. "0.01"; up to the instrument's base_decimals.
      • is_buying_assetlite name ibboolrequired#
        Specifies if the algo order is a buy or sell
    • metadatalite name mobject AlgoOrderMetadatarequired#
      Algo order metadata, including the type-specific parameters
      6 fields of AlgoOrderMetadata
      • client_order_idlite name costring (uint64)required#
        Your own id for the algo order, unique among the sub-account's open algo orders. You can cancel the algo order by it.
      • create_timelite name ctstring (int64 unix ns)optionaldefault 0#
        Set by the server. Time at which the algo order was received by Grvt in unix nanoseconds
      • triggerlite name tobject TriggerOrderMetadataoptional#
        Trigger fields. If set, the algo order stays pending until the trigger price is crossed
        2 fields of TriggerOrderMetadata
        • trigger_typelite name ttenum TriggerTyperequired#
          Type of the trigger order. eg: Take Profit, Stop Loss, etc
          3 values
          UNSPECIFIED, TAKE_PROFIT, STOP_LOSS (details).
        • tpsllite name tobject TPSLOrderMetadatarequired#
          Contains metadata for Take Profit (TP) and Stop Loss (SL) trigger orders. Fields: see TPSLOrderMetadata.
      • brokerlite name benum BrokerTagoptional#
        Specifies the broker who brokered the algo order
        4 values
        UNSPECIFIED, COIN_ROUTES, ALERTATRON, ORIGAMI (details).
      • expirylite name estring (int64 unix ns)optionaldefault 0#
        Time at which the algo order expires, expressed in unix nanoseconds. Defaults to and must be capped at 90 days
      • chaselite name cobject ChaseAlgoOrderMetadataoptional#
        Chase order parameters. Set only when the algo order type is CHASE
        3 fields of ChaseAlgoOrderMetadata
        • chase_price_modelite name cpenum ChasePriceModerequired#
          How the chase price is determined at each re-price tick
          1 value
          BEST_BID_ASK (details).
        • max_distancelite name mdstringrequired#
          The maximum distance the chase price can move away from the reference price, as an absolute price distance in quote currency units. Decimal string, e.g. "65000.5"; up to 9 decimals. Always absolute: when the user picks a percentage, the client converts it and sends the result here.
        • max_distance_bpslite name md1integer (uint32)optionaldefault 0#
          The max distance as a percentage in basis points (1 bp = 0.01%, 100% = 10000), as the user entered it. 0 if the user entered an absolute distance. Informational only, for display and history. maxDistance is what is enforced.
    • statelite name sobject AlgoOrderStateoptional#
      Set by the server. The current state of the algo order
      8 fields of AlgoOrderState
      • statuslite name senum OrderStatusrequired#
        The status of the algo order
        5 values
        PENDING, OPEN, FILLED, REJECTED, CANCELLED (details).
      • reject_reasonlite name rrenum OrderRejectReasonrequired#
        The reason for rejection or cancellation
        76 values
        UNSPECIFIED, CLIENT_CANCEL, CLIENT_BULK_CANCEL, CLIENT_SESSION_END, MARKET_CANCEL, IOC_CANCEL, AON_CANCEL, FOK_CANCEL, EXPIRED, FAIL_POST_ONLY, FAIL_REDUCE_ONLY, MM_PROTECTION, SELF_TRADE_PROTECTION, SELF_MATCHED_SUBACCOUNT, OVERLAPPING_CLIENT_ORDER_ID, BELOW_MARGIN, LIQUIDATION, INSTRUMENT_INVALID, INSTRUMENT_DEACTIVATED, SYSTEM_FAILOVER, UNAUTHORISED, SESSION_KEY_EXPIRED, SUB_ACCOUNT_NOT_FOUND, NO_TRADE_PERMISSION, UNSUPPORTED_TIME_IN_FORCE, MULTI_LEGGED_ORDER, EXCEED_MAX_POSITION_SIZE, EXCEED_MAX_SIGNATURE_EXPIRATION, MARKET_ORDER_WITH_LIMIT_PRICE, CLIENT_CANCEL_ON_DISCONNECT_TRIGGERED, OCO_COUNTER_PART_TRIGGERED, REDUCE_ONLY_LIMIT, CLIENT_REPLACE, DERISK_MUST_BE_IOC, DERISK_MUST_BE_REDUCE_ONLY, DERISK_NOT_SUPPORTED, INVALID_ORDER_TYPE, CURRENCY_NOT_DEFINED, INVALID_CHAIN_ID, BUILDER_ORDER_FEE_EXCEED, BUILDER_ORDER_FEE_NEGATIVE, BUILDER_ORDER_BUILDER_NOT_AUTHORIZED, BUILDER_ORDER_BUILDER_NOT_EXIST, TRADE_PRICE_WORSE_THAN_BANKRUPTCY_PRICE, TOO_MANY_MAKER_ORDERS, REDUCE_ONLY_NOT_SUPPORTED_FOR_SPOT_ORDER, TPSL_NOT_SUPPORTED_FOR_SPOT_ORDER, SPOT_ORDER_NOT_SUPPORTED, INSUFFICIENT_BALANCE, SPOT_TRADING_BLOCKED_DURING_SOCIALIZED_LOSS, BELOW_MARGIN_WITH_PENALTY_DEVIATION, CORPORATE_ACTION, NOT_QUALIFIED_MAKER, PRIVATE_QUOTE_REQUIRES_RFQ, STABLE_PERP_REQUIRES_PRICE_BOUND, UNSUPPORTED_TRIGGER_BY, RFQ_NOT_FOUND, RESTING_ORDER_WOULD_CROSS, SESSION_CLOSED, RFQ_TERMINATED, STABLE_PERP_REQUIRES_MULTI_ASSET_MODE, BORROW_LIMIT_EXCEEDED_AFTER_TRADE, UNDEPLOYED_LOAN_AUTO_EXCHANGE, LIQUIDATION_AUTO_EXCHANGE, USDC_COLLATERAL_DISABLED, SFP_POST_ONLY_NOT_ALLOWED, VAULT_NON_QUOTE_INVESTMENT_CURRENCY, RFQ_ID_REQUIRES_STABLE_PERP, RFQ_PRIVATE_POOL_NOT_SUPPORTED, RFQ_REQUIRES_IOC, RFQ_MISMATCH, RFQ_ALREADY_BOUND, RFQ_MAKER_MUST_BE_ECN, FOK_NOT_SUPPORTED, MARKET_ORDER_NOT_SUPPORTED, STABLE_PERP_ORDER_NOT_SUPPORTED (details).
      • traded_sizelite name tsstringrequired#
        The total number of assets traded across all sub-orders
      • avg_fill_pricelite name afstringrequired#
        The average fill price across all sub-orders
      • trigger_timelite name ttstring (int64 unix ns)optionaldefault 0#
        Time at which the algo order was triggered in unix nanoseconds, 0 if not triggered yet
      • update_timelite name utstring (int64 unix ns)required#
        Time at which the algo order was updated by Grvt in unix nanoseconds
      • chaselite name cobject ChaseOrderStateoptional#
        Chase order state. Set only when the algo order type is CHASE
        1 field of ChaseOrderState
        • reprice_countlite name rcinteger (uint32)required#
          The number of successful re-prices of this algo order's sub-orders
      • last_sub_order_idlite name lsstring (uint128)required#
        The latest sub-order placed for this algo order, 0 until the first sub-order is placed
    • builderlite name bstring (0x address)required#
      The main account ID of the builder
    • builder_feelite name bfstringrequired#
      Builder fee charged for every sub-order, expressed as a percentage (e.g., 0.001 means 0.001%).
  • nextlite name nstringrequired#
    The cursor to indicate when to start the query from

Errors

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

6 errors any call can return; none specific to this one
1000Unauthorized401
You need to authenticate prior to using this functionality
1001Forbidden403
You are not authorized to access this functionality
1002InternalServer500
Internal Server Error
1003InvalidRequest400
Request could not be processed due to malformed syntax
1006RateLimit429retryable
You have surpassed the allocated rate limit for your tier
1008IPNotWhitelisted401
Your IP has not been whitelisted for access

Example

Example code
import os

from grvt import Grvt

with Grvt(
    env=os.environ.get("GRVT_ENV", "testnet"),
    api_key=os.environ["GRVT_API_KEY"],
) as client:
    resp = client.algo_order_history(
        sub_account_id=os.environ["GRVT_SUB_ACCOUNT_ID"],
        limit=500,
    )
    print(resp)

Raw HTTP (set GRVT_DOMAIN, see Environments; GRVT_COOKIE and GRVT_ACCOUNT_ID come from login):

With full field names:

curl -sS "https://trades.testnet.grvt.io/full/v1/algo_order_history" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "sub_account_id": "$GRVT_SUB_ACCOUNT_ID",
  "limit": 500
}
EOF

With lite field names:

curl -sS "https://trades.testnet.grvt.io/lite/v1/algo_order_history" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "sa": "$GRVT_SUB_ACCOUNT_ID",
  "l": 500
}
EOF
Build request
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