Overview
The LFG SDK supports various order types for trading perpetual contracts. This guide covers everything from placing basic market orders to managing complex trading strategies.Short-Term Orders
Fast orders that expire in blocks (~seconds to minutes)
Long-Term Orders
Traditional limit orders with time-based expiration (hours to days)
Order Types
Short-Term Orders
Short-term orders are ideal for:- Market-making strategies
- High-frequency trading
- Quick in-and-out trades
- Time-sensitive opportunities
- Expire based on block height
- Lower gas costs
- Faster execution
- Typical lifespan: seconds to minutes
Long-Term Orders
Long-term orders are ideal for:- Position building
- Swing trading
- Limit orders that can wait
- Strategy orders
- Expire based on timestamp
- Standard gas costs
- Can stay on orderbook for days
- Typical lifespan: hours to 28 days
Placing Short-Term Orders
Basic Short-Term Order
SubaccountInfo
required
The subaccount placing the order
string
required
Market identifier (e.g.,
"ETH-USD", "BTC-USD")OrderSide
required
OrderSide.BUY or OrderSide.SELLnumber
required
Limit price in quote currency (USD). Set to market price for market orders.
number
required
Order size in base currency (e.g., ETH, BTC)
number
required
Unique identifier for this order (0 to 2^32-1)
number
required
Block height when order expires. Must be greater than current block.
Order_TimeInForce
required
Order time in force policy. Use
TIME_IN_FORCE_UNSPECIFIED for most cases.boolean
required
If
true, order can only reduce position size (not increase it)Sell Order Example
Market Order (Short-Term)
Placing Long-Term Orders
Basic Long-Term Order
OrderType
required
OrderType.LIMIT, OrderType.MARKET, OrderType.STOP_LIMIT, or
OrderType.STOP_MARKETOrderTimeInForce
required
OrderTimeInForce.GTT- Good-til-time (most common) -OrderTimeInForce.IOC- Immediate or cancel -OrderTimeInForce.FOK- Fill or kill
number
required
Seconds from now until order expires (max 28 days)
OrderExecution
required
OrderExecution.DEFAULT, OrderExecution.POST_ONLY, or OrderExecution.IOCboolean
required
If
true, order will only execute as maker (adds liquidity)boolean
required
If
true, order can only reduce existing positionPost-Only Orders
Post-only orders ensure you’re always a maker:Post-only orders are rejected if they would immediately match and execute as a
taker. This guarantees maker rebates.
Reduce-Only Orders
Reduce-only orders can only close existing positions:Canceling Orders
Cancel Short-Term Order
Cancel Long-Term Order
Querying Orders
Get All Orders for Subaccount
Filter Orders by Market
Filter Orders by Status
Get Order by ID
Advanced Trading Strategies
Grid Trading Bot
Stop-Loss Order
Best Practices
Generate Unique Client IDs
Generate Unique Client IDs
Always use unique client IDs for each order:Or use a counter with your bot instance:
Handle Order Expiration
Handle Order Expiration
Short-term orders expire quickly. Always check if enough blocks remain:
Store Order Metadata
Store Order Metadata
Keep track of your orders for cancellation and monitoring:
Implement Order Retry Logic
Implement Order Retry Logic
Network issues can cause order placement to fail:
Next Steps
Manage Balances
Query positions and account balances
Transfers
Deposit and withdraw funds
Market Data
Query orderbooks and market statistics
Order Types Reference
Complete order types documentation