Skip to main content

Overview

The Orders API allows you to execute trades, modify existing orders, cancel orders, and preview orders before execution. All order operations require proper authentication and trading permissions.

Class Reference

Methods

placeOrder()

Place a new trading order.
Parameters:
  • symbol (string): Stock symbol (e.g., “AAPL”, “TSLA”)
  • quantity (number): Number of shares
  • side (string): “buy” or “sell”
  • orderType (string): “market”, “limit”, “stop”, or “stop_limit”
  • price (number, optional): Limit price for limit orders
  • stopPrice (number, optional): Stop price for stop orders
  • timeInForce (string): “day”, “gtc”, “ioc”, “fok”
Returns: Promise<Order>

updateOrder()

Modify an existing order.
Parameters:
  • orderId (string): Order ID to update
  • updates (object): Fields to update (quantity, price)
Returns: Promise<Order>

cancelOrder()

Cancel an active order.
Parameters:
  • orderId (string): Order ID to cancel
Returns: Promise<CancellationResult>

previewOrder()

Preview order cost and impact before placing.
Parameters: Same as placeOrder() Returns: Promise<OrderPreview> with cost estimates

Order Types

Market Orders

Buy or sell immediately at the best available price:

Limit Orders

Buy or sell at a specified price or better:

Stop Orders

Trigger a market order when price reaches stop price:

Stop-Limit Orders

Trigger a limit order when stop price is reached:

Time in Force

Day Orders (DAY)

Order is active only for the current trading day:

Good ‘Til Cancelled (GTC)

Order remains active until filled or cancelled:

Immediate or Cancel (IOC)

Fill immediately, cancel any unfilled portion:

Fill or Kill (FOK)

Fill entire order immediately or cancel:

Multi-Leg Orders

For complex options strategies:

Examples

Preview Before Trading

Always preview orders to check costs:

Bracket Order Strategy

Place entry with automatic profit target and stop loss:

Modify Order

Update quantity or price of pending order:

Cancel Orders

TypeScript Types

Error Handling

Best Practices

  1. Always preview orders before placing to check costs
  2. Use limit orders in volatile markets to control execution price
  3. Set stop losses to manage risk on positions
  4. Use appropriate timeInForce based on your strategy
  5. Handle errors gracefully with proper error handling
  6. Check order status after placement to confirm execution
  7. Cancel stale orders to avoid unintended fills
  • Accounts - Check account balances and positions before trading
  • Market Data - Get current prices for order placement
  • Users - Retrieve trading accounts

API Endpoints

This SDK wraps the following REST API endpoints:
  • POST /v1/orders - Place order
  • PUT /v1/orders - Update order
  • DELETE /v1/orders - Cancel order
  • POST /v1/orders/preview - Preview order