/** * Trading Order Types * * Types for trading operations and order management. */ /** * Standard order structure used across all order-related responses. * This represents the complete order information as returned by the API. * * @remarks * Order lifecycle statuses: `SUBMITTED` → (`PARTIALLY_FILLED`) → `FILLED` → `SETTLED_ON_CHAIN` * Legacy backends may still emit `SETTLED`. * Orders can transition to `CANCELLED`, `REJECTED`, or `EXPIRED` at various stages. * Fee fields are only populated after order fills occur. * * @example * To calculate remaining quantity: * ```typescript * const remaining = parseFloat(order.quantity) - parseFloat(order.filled_quantity); * ``` */ export interface Order { /** Order identifier (UUID) */ id: string; /** Trading pair ID (UUID format, e.g., "456e7890-e12b-12d3-a456-426614174000") */ trading_pair_id: string; /** Order side (BUY or SELL) */ side: OrderSide; /** Order type - see OrderType for all supported types */ order_type: OrderType; /** Order status - see OrderStatus for lifecycle details */ status: OrderStatus; /** Order price - null for market orders, required for limit orders */ price?: string; /** Order quantity (base currency amount) */ quantity: string; /** Filled quantity (base currency amount, "0" if unfilled) */ filled_quantity: string; /** Average fill price - only populated after order has fills */ average_fill_price?: string; /** Trading mode (SPOT or MARGIN) */ trading_mode: TradingMode; /** Time in force - GTC, IOC, FOK, or GTD */ time_in_force?: TimeInForce; /** Order creation timestamp (ISO 8601) */ created_at: string; /** Order last update timestamp (ISO 8601) */ updated_at?: string; /** Optional expiration date for GTD orders (ISO 8601, max 1 year) */ expiration_date?: string; /** Application taker fee in basis points (e.g., "100" = 1%) - populated after fills */ application_taker_fee?: string; /** Monaco protocol taker fee in basis points - populated after fills */ monaco_taker_fee?: string; /** Monaco protocol maker rebate in basis points - populated after fills */ monaco_maker_rebate?: string; /** Total taker fees paid in quote currency - populated after fills */ total_taker_fees?: string; /** Total payment for taker including fees in quote currency - populated after fills */ taker_total_payment?: string; /** Total receipt for maker after rebates in quote currency - populated after fills */ maker_total_receipt?: string; /** Margin account ID for margin/perp orders */ margin_account_id?: string; /** Position side for margin/perp orders */ position_side?: PositionSide; /** Leverage used for margin/perp orders */ leverage?: string; /** Whether the order can only reduce existing exposure */ reduce_only?: boolean; /** Position ID linked to the order, when available */ position_id?: string; } /** * Role of the creator or order */ export type OrderRole = "maker" | "taker"; /** * Order side for trading operations */ export type OrderSide = "BUY" | "SELL"; /** * Position side for margin/perp trading */ export type PositionSide = "LONG" | "SHORT" | "NONE"; /** * Order type for different order strategies * - LIMIT: Execute only at specified price or better * - MARKET: Execute immediately at current market price * - STOP_LOSS: Stop loss order triggered at trigger price * - TAKE_PROFIT: Take profit order triggered at trigger price * - STOP_LIMIT: Stop order that becomes a limit order when triggered * - TRAILING_STOP: Stop order that trails the market price */ export type OrderType = "LIMIT" | "MARKET"; /** * Source-of-truth order status values used by runtime validation schemas. */ export declare const ORDER_STATUS_VALUES: readonly ["SUBMITTED", "PARTIALLY_FILLED", "FILLED", "SETTLED_ON_CHAIN", "SETTLED", "CANCELLED", "REJECTED", "EXPIRED"]; /** * Order status for different order states * * Order lifecycle progression: * - SUBMITTED: Order submitted to the matching engine for processing * - PARTIALLY_FILLED: Order has been partially executed * - FILLED: Order has been completely executed (pre-commit) * - SETTLED_ON_CHAIN: Order settlement has been finalized on-chain * - SETTLED: Legacy settled status from older backend versions * - CANCELLED: Order was canceled by user or system * - REJECTED: Order was rejected due to validation failure * - EXPIRED: Order expired based on time constraints */ export type OrderStatus = (typeof ORDER_STATUS_VALUES)[number]; /** * Trading mode */ export type TradingMode = "SPOT" | "MARGIN"; /** * Time in force for order execution * - GTC: Good Till Cancel - remains active until filled or canceled * - IOC: Immediate or Cancel - execute immediately and cancel unfilled portion * - FOK: Fill or Kill - execute completely or cancel entirely * - GTD: Good Till Date - remains active until specified expiration date */ export type TimeInForce = "GTC" | "IOC" | "FOK" | "GTD"; /** * Conditional TP/SL condition type. */ export type ConditionalOrderConditionType = "STOP_LOSS" | "TAKE_PROFIT"; /** * Conditional order trigger source. v1 supports mark-price triggers. */ export type ConditionalOrderTriggerSource = "MARK_PRICE"; /** * Conditional TP/SL lifecycle state. */ export type ConditionalOrderState = "ACTIVE" | "TRIGGERING" | "TRIGGERED" | "CANCELLED" | "EXPIRED" | "FAILED";