Skip to Content

Trading Workflows

This page is for builders who want to execute trades programmatically (with or without a bot). It focuses on the core SDK flow: connect → read markets → place orders → manage risk → manage collateral.

Step 1: Set up the SDK + wallet

You’ll create a DriftClient, connect to RPC, and initialize your wallet and environment.

Step 2: Read markets + oracles

Fetch market metadata, oracle prices, and subscriptions before trading.

Step 3: Place and cancel orders

Use order helpers for limit/market/oracle/trigger orders, and handle cancels/edits.

Step 4: Monitor PnL and risk

Track margin, health, and PnL before and after trades.

Step 5: Manage collateral and exits

Deposit/withdraw collateral, settle PnL, and close positions safely.

Last updated on