/** * Trading Types * * Types for trading operations including order placement and management. */ import type { BaseAPI } from "../api/index"; import type { OrderSide, PositionSide, TimeInForce, TradingMode } from "./orders"; import type { BatchCancelOrdersResponse, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchReplaceOrderParams, BatchReplaceOrdersResponse, CancelConditionalOrderResponse, CancelOrderResponse, CreateConditionalOrderParams, CreateConditionalOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ReplaceOrderResponse } from "./responses"; /** * Trading API interface. * Provides methods for placing and managing orders. * Handles order placement, cancellation, and execution. */ export interface TradingAPI extends BaseAPI { /** * Places a limit order on the order book. * @param tradingPairId - Trading pair UUID * @param side - Order side ("BUY" or "SELL") * @param quantity - Order quantity as string * @param price - Order price as string * @param options - Optional parameters for the limit order * @param options.tradingMode - Trading mode (e.g., "SPOT") * @param options.timeInForce - Time in force ("GTC", "IOC", or "FOK") * @returns Promise resolving to the order result */ placeLimitOrder(tradingPairId: string, side: OrderSide, quantity: string, price: string, options?: { tradingMode?: TradingMode; useMasterBalance?: boolean; expirationDate?: string; timeInForce?: TimeInForce; marginAccountId?: string; positionSide?: PositionSide; leverage?: string; reduceOnly?: boolean; }): Promise; /** * Places a market order for immediate execution. * @param tradingPairId - Trading pair UUID * @param side - Order side ("BUY" or "SELL") * @param quantity - Order quantity as string * @param options - Optional parameters for the market order * @param options.tradingMode - Trading mode (e.g., "SPOT") * @param options.slippageTolerance - Slippage tolerance as decimal (e.g., 0.01 for 1%, 0 for best price only, undefined for unlimited slippage) * @returns Promise resolving to the order result */ placeMarketOrder(tradingPairId: string, side: OrderSide, quantity: string, options?: { tradingMode?: TradingMode; slippageTolerance?: number; marginAccountId?: string; positionSide?: PositionSide; leverage?: string; reduceOnly?: boolean; }): Promise; /** * Cancels an existing order. * @param orderId - ID of the order to cancel * @returns Promise resolving to the cancellation result */ cancelOrder(orderId: string): Promise; /** * Creates a standalone conditional TP/SL order. */ createConditionalOrder(params: CreateConditionalOrderParams): Promise; /** * Cancels an active conditional TP/SL order. */ cancelConditionalOrder(conditionalOrderId: string): Promise; /** * Lists conditional TP/SL orders for the authenticated user. */ listConditionalOrders(params?: ListConditionalOrdersParams): Promise; /** * Batch cancels specific orders by their IDs. * @param orderIds - Array of order IDs to cancel * @returns Promise resolving to the batch cancellation result */ batchCancel(orderIds: string[]): Promise; /** * Cancels all active orders, optionally filtered by trading pair. * @param tradingPairId - Optional trading pair ID to filter cancellation * @returns Promise resolving to the batch cancellation result */ batchCancelAll(tradingPairId?: string): Promise; /** * Replaces an existing order with new parameters. * Updates the order with new price, quantity, and balance settings. * @param orderId - ID of the order to replace * @param newOrder - New order parameters * @param newOrder.price - New order price as string (optional) * @param newOrder.quantity - New order quantity as string * @param newOrder.useMasterBalance - Whether to use master balance (optional, defaults to false) * @returns Promise resolving to a `ReplaceOrderResponse` */ replaceOrder(orderId: string, newOrder: { price?: string; quantity?: string; useMasterBalance?: boolean; }): Promise; /** * Batch creates multiple orders in a single request. * Each order is validated and processed through the matching engine. * @param orders - Array of order parameters to create * @returns Promise resolving to the batch creation result */ batchCreate(orders: BatchCreateOrderParams[]): Promise; /** * Batch replaces multiple orders in a single request. * Each order is canceled and re-created with new parameters. * @param orders - Array of order replacement parameters * @returns Promise resolving to the batch replacement result */ batchReplace(orders: BatchReplaceOrderParams[]): Promise; /** * Gets paginated orders based on query parameters. * @param params - Query parameters for filtering orders * @param params.status - Filter by order status (optional) * @param params.trading_pair_id - Filter by trading pair UUID (optional) * @param params.page - Page number for pagination (optional) * @param params.page_size - Number of orders per page (optional) * @returns Promise resolving to the paginated orders result */ getPaginatedOrders(params?: GetPaginatedOrdersParams): Promise; /** * Gets a single order by its ID. * @param orderId - ID of the order to retrieve * @returns Promise resolving to the order details */ getOrder(orderId: string): Promise; } export type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, Order, OrderRole, OrderSide, OrderStatus, OrderType, PositionSide, TimeInForce, TradingMode, } from "./orders"; export { ORDER_STATUS_VALUES } from "./orders"; export type { BatchCancelError, BatchCancelOrdersResponse, BatchCancelResult, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchCreateResult, BatchError, BatchReplaceOrderParams, BatchReplaceOrdersResponse, BatchReplaceResult, CancelConditionalOrderResponse, CancelOrderResponse, ConditionalOrder, CreateConditionalOrderParams, CreateConditionalOrderResponse, CreateOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, MatchResult, ReplaceOrderResponse, UpdatedFields, } from "./responses";