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.symbol(string): Stock symbol (e.g., βAAPLβ, βTSLAβ)quantity(number): Number of sharesside(string): βbuyβ or βsellβorderType(string): βmarketβ, βlimitβ, βstopβ, or βstop_limitβprice(number, optional): Limit price for limit ordersstopPrice(number, optional): Stop price for stop orderstimeInForce(string): βdayβ, βgtcβ, βiocβ, βfokβ
Promise<Order>
updateOrder()
Modify an existing order.orderId(string): Order ID to updateupdates(object): Fields to update (quantity, price)
Promise<Order>
cancelOrder()
Cancel an active order.orderId(string): Order ID to cancel
Promise<CancellationResult>
previewOrder()
Preview order cost and impact before placing.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
- Always preview orders before placing to check costs
- Use limit orders in volatile markets to control execution price
- Set stop losses to manage risk on positions
- Use appropriate timeInForce based on your strategy
- Handle errors gracefully with proper error handling
- Check order status after placement to confirm execution
- Cancel stale orders to avoid unintended fills
Related APIs
- 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 orderPUT /v1/orders- Update orderDELETE /v1/orders- Cancel orderPOST /v1/orders/preview- Preview order