☷ Order Management

Limit Order API
for AI Agents

Market orders fill instantly but at whatever price the market gives you. Limit orders fill at the price you specify โ€” or not at all. For AI agents running systematic strategies, limit orders are the difference between a controlled entry and an imprecise one. Purple Flea's order API gives agents complete programmatic control over placement, modification, and cancellation.


Market Orders vs. Limit Orders

Understanding the tradeoffs that determine which order type your agent should use.

A market order says "buy or sell immediately at the best available price." It guarantees execution but not price. In liquid markets during normal conditions, the difference is small. But in volatile markets โ€” exactly the conditions where your agent is most likely to be trading a signal โ€” the difference can be significant. This price difference between the expected fill and the actual fill is called slippage.

A limit order says "buy at this price or lower, sell at this price or higher." It guarantees price but not execution. If the market never reaches your limit price, the order simply waits โ€” or expires, depending on the time-in-force setting. For strategies that rely on specific entry levels (support/resistance, VWAP, opening range), limit orders are essential.

Maker vs. taker economics matter at scale. Market orders consume liquidity โ€” they fill against existing resting orders in the book and pay the taker fee. Limit orders that rest in the book add liquidity and pay the maker fee, which is lower (or sometimes even negative โ€” a rebate). An agent placing 200 trades per day at $1,000 average notional will save hundreds of dollars monthly by using limit orders instead of market orders for non-urgent entries.

Post-only orders enforce maker status. With post_only=True, if your limit order would immediately match and execute as a taker, it is cancelled instead of filled. This guarantees you always pay the maker fee โ€” critical for fee-sensitive systematic agents.


Order Types Supported

Four order types covering every programmatic trading use case.

📻
Core
Limit Order

The foundational order type. Specify a market, side, size, and price. The order rests in the book until it fills at your specified price or better, or until you cancel it or the time-in-force expires.

order_type: "limit"
price: 42500.00

🔒
Conditional
Stop-Limit Order

A two-stage order: define a trigger price and a limit price. When the market reaches the trigger, a limit order is placed at your specified limit price. Combines the conditional activation of a stop with the price control of a limit โ€” essential for breakout strategies.

order_type: "stop_limit"
stop_price: 43000.00
limit_price: 43100.00

🆕
Maker-Only
Post-Only Order

A limit order with a guarantee: if placing the order would cause an immediate match (making it a taker), the order is rejected or cancelled automatically. Your agent will only ever pay the maker fee โ€” 0.02% โ€” never the taker fee. Fee-optimal for high-frequency systematic agents.

order_type: "limit"
post_only: True

Expiry Control
Time-in-Force (GTC / IOC / FOK)

Control how long a limit order remains active. GTC (Good Till Canceled) rests indefinitely. IOC (Immediate-or-Cancel) fills whatever is available immediately and cancels the rest. FOK (Fill-or-Kill) requires complete fill or full cancellation โ€” no partial fills.

time_in_force: "GTC" | "IOC" | "FOK"

GTC
Good Till Canceled
Order remains open until filled or explicitly canceled. Use for patient entries where timing is not critical but price level is.
IOC
Immediate or Cancel
Fills whatever quantity is available at the limit price right now, then cancels the remainder. Useful for partial fills without a resting order.
FOK
Fill or Kill
Must fill entirely in a single transaction at the limit price or be fully canceled. Use when partial fills would be harmful to your strategy's position sizing logic.
GTT
Good Till Time
Order expires at a specified Unix timestamp. Useful for agents that open orders at the start of a session and want automatic cleanup at session end.

Python Example

Place a post-only GTC limit order, then modify the price โ€” all programmatically.

Python purpleflea SDK v2+
import purpleflea

client = purpleflea.TradingClient(api_key="YOUR_KEY")

# Place a buy limit order below current market
limit_order = client.place_order(
    market="ETH-PERP",
    side="buy",
    size=0.5,
    order_type="limit",
    price=2800.00,
    time_in_force="GTC",   # Good Till Canceled
    post_only=True           # Only fills as maker
)

print(f"Limit order placed: {limit_order['order_id']}")
print(f"Status: {limit_order['status']}"# "open"

# Modify the limit price
updated = client.modify_order(
    order_id=limit_order["order_id"],
    new_price=2750.00
)
Response 200 OK
{
  "order_id": "ord_4a7c8f2d",
  "market": "ETH-PERP",
  "side": "buy",
  "size": 0.5,
  "order_type": "limit",
  "price": 2800.00,
  "time_in_force": "GTC",
  "post_only": true,
  "status": "open",
  "filled_size": 0.0,
  "created_at": "2026-03-04T08:22:14Z"
}
Cancel Order
# Cancel the order before it fills
result = client.cancel_order(order_id="ord_4a7c8f2d")
print(result["status"])  # "canceled"

# Cancel all open orders on a market
client.cancel_all_orders(market="ETH-PERP")

Order Lifecycle

Every limit order moves through a predictable set of states your agent can monitor.

OPEN
Resting in book
PARTIAL
Partially filled
FILLED
Fully executed
CANCELED
Manually or TIF
EXPIRED
GTT time reached

Your agent can query order status at any time via client.get_order(order_id) or receive push updates by registering a webhook. Status transitions are atomic โ€” you will never observe an order in an ambiguous intermediate state.


Why Limit Orders for Agents

Three structural advantages that compound over hundreds of trades.

1

Price Control

An agent operating at scale with precise price targets โ€” VWAP anchors, Fibonacci levels, fair value gaps โ€” cannot afford random execution prices. Limit orders ensure the strategy fills exactly where the signal says to fill, or not at all. This preserves the edge that the strategy was built on.

2

Maker Rebates

Purple Flea charges 0.02% maker fee and 0.05% taker fee. On a $10,000 notional position, that is $2 vs $5 per trade โ€” a $3 difference. Over 500 monthly trades, that is $1,500 in saved fees simply by using post-only limit orders instead of market orders. Fee minimization is a real alpha source at agent scale.

3

Avoid Slippage

In a $500M BTC order book, even moderate-sized market orders move the price. A 2 BTC market buy in thin conditions might fill at an average price 0.3% above the mid. A limit order at the same mid simply waits. For agents trading larger sizes, slippage elimination often exceeds total fee savings in dollar terms.


Order Execution Performance

Infrastructure benchmarks that matter for systematic agents.

<1ms
Order Processing
0.02%
Maker Fee
99.9%
Uptime SLA

Additional Order Management Features

The full toolkit your agent needs to manage a live order book.

🔄 Batch Order Placement
Place up to 20 orders in a single API call using client.place_orders_batch(). Reduces round-trip latency for agents that need to set up an entire order ladder in a single operation. All orders are submitted atomically.
📋 Order Book Snapshot
Query the full order book depth for any market at any time. Essential for agents that want to calculate expected slippage before placing large orders, or that place orders at specific depth levels relative to current book structure.
🕐 Scheduled Orders
Submit an order now but activate it at a future Unix timestamp. Your agent can pre-schedule opening orders for specific market sessions or news events without needing to be online at that exact moment.
📈 Fill Notifications
Register webhook endpoints to receive instant push notification when any order transitions state โ€” open, partial fill, full fill, cancellation, or expiry. Eliminates polling loops and lets your agent react to fills within 50ms of execution.

Start Trading with Precise Orders

Limit orders are the foundation of every serious agent trading strategy. Get your API key and place your first limit order in under five minutes.