Skip to main content
Drift supports multiple order types including market, limit, trigger, and oracle orders. This guide covers how to place each type using the SDK.

Order Types

Market Orders

Execute immediately at the best available price

Limit Orders

Execute at a specified price or better

Trigger Orders

Activate when a condition is met

Oracle Orders

Reference oracle price with offset

Placing a Market Order

Market orders execute immediately at the best available price:

Market Order with Price Limits

Set a maximum acceptable price to prevent slippage:

Placing a Limit Order

Limit orders execute only at your specified price or better:

Post-Only Orders

Ensure your order only adds liquidity (maker fee):
Post-only orders are rejected if they would match immediately. Use PostOnlyParams.TRY_POST_ONLY to allow fallback to taker.

Reduce-Only Orders

Limit orders to only reduce existing positions:

Placing a Trigger Order

Trigger orders (stop-loss/take-profit) activate when a price condition is met:

Stop-Loss Order

Take-Profit Order

Trigger Limit Orders

Combine trigger activation with limit execution:

Placing an Oracle Order

Oracle orders reference the oracle price with an offset:

Spot Market Orders

Place orders on spot markets (lending/borrowing):

Scale Orders

Place multiple orders across a price range:

Order Parameters

number
required
Market index (0 = SOL-PERP, 1 = BTC-PERP, etc.)
PositionDirection
required
PositionDirection.LONG or PositionDirection.SHORT
BN
required
Amount in base asset (use BASE_PRECISION for standard precision)
BN
Limit price (use PRICE_PRECISION for $1 = 1,000,000)
MarketType
MarketType.PERP or MarketType.SPOT (default: PERP)
boolean
If true, order can only reduce existing positions
PostOnlyParams
MUST_POST_ONLY, TRY_POST_ONLY, or NONE
boolean
If true, cancel unfilled portion immediately
BN
Price at which trigger order activates
OrderTriggerCondition
ABOVE or BELOW for trigger orders
BN
Price offset from oracle for oracle orders
BN
Unix timestamp for order expiration
number
Custom order ID for tracking (1-255)

Best Practices

  • Market orders: When you need immediate execution
  • Limit orders: When you want price control and maker fees
  • Trigger orders: For risk management (stop-loss/take-profit)
  • Oracle orders: For fair pricing relative to oracle

Examples

Opening a Leveraged Long Position

Closing a Position

Next Steps

Modify Orders

Learn to modify existing orders

Cancel Orders

Cancel individual or all orders

Manage Positions

Monitor and manage open positions

Order Params API

Complete order parameters reference