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

place_order()

Place a new trading order.
Parameters:
  • symbol (str): Stock symbol (e.g., “AAPL”, “TSLA”)
  • quantity (int): Number of shares
  • side (str): “buy” or “sell”
  • order_type (str): “market”, “limit”, “stop”, or “stop_limit”
  • price (float, optional): Limit price for limit orders
  • stop_price (float, optional): Stop price for stop orders
  • time_in_force (str): “day”, “gtc”, “ioc”, “fok”
Returns: Order object

update_order()

Modify an existing order.
Parameters:
  • order_id (str): Order ID to update
  • quantity (int, optional): New quantity
  • price (float, optional): New limit price
Returns: Updated order object

cancel_order()

Cancel an active order.
Parameters:
  • order_id (str): Order ID to cancel
Returns: Cancellation result object

preview_order()

Preview order cost and impact before placing.
Parameters: Same as place_order() Returns: Order preview object 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

Error Handling

Response Objects

Order Object

Preview Object

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 time_in_force 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