Core Concepts
Trade Intents

Trade Intents

Self-contained execution instructions for stateless routing.

Overview

A Trade Intent is a self-contained, fully specified instruction that contains all parameters required for execution. Trade Intents are the core primitive in SnipeRoute's stateless routing architecture.

Every Trade Intent is independent and complete. SnipeRoute does not maintain strategy state or context between intents.

Trade Intent Structure

Required Fields

FieldTypeDescription
intent_idstringUnique identifier from upstream platform (idempotency key)
symbolstringTrading symbol (e.g., "AAPL", "TSLA")
sidestringOrder side: "buy" or "sell"
quantitynumberNumber of shares/units to trade
order_typestringOrder type: "market", "limit", "stop", "stop_limit"
broker_idstringID of the user's connected broker account

Optional Fields

FieldTypeRequired WhenDescription
limit_pricenumberorder_type is "limit" or "stop_limit"Limit price for execution
stop_pricenumberorder_type is "stop" or "stop_limit"Stop trigger price
time_in_forcestringOptional"day", "gtc", "ioc", "fok" (default: "day")
extended_hoursbooleanOptionalAllow trading in extended hours (default: false)

Example Trade Intents

Market Buy Order

{
  "intent_id": "trade_001",
  "symbol": "AAPL",
  "side": "buy",
  "quantity": 10,
  "order_type": "market",
  "broker_id": "my_alpaca"
}

Limit Sell Order

{
  "intent_id": "trade_002",
  "symbol": "TSLA",
  "side": "sell",
  "quantity": 5,
  "order_type": "limit",
  "limit_price": 250.00,
  "time_in_force": "gtc",
  "broker_id": "my_schwab"
}

Stop-Limit Buy Order

{
  "intent_id": "trade_003",
  "symbol": "NVDA",
  "side": "buy",
  "quantity": 20,
  "order_type": "stop_limit",
  "stop_price": 500.00,
  "limit_price": 505.00,
  "time_in_force": "day",
  "broker_id": "my_ibkr"
}

Stateless Routing

SnipeRoute does not maintain state between Trade Intents:

  • No stored strategies
  • No position tracking
  • No portfolio context
  • No order dependencies

Each Trade Intent is processed independently.

Example: Independent Intents

# Intent 1: Buy 10 shares of AAPL
intent_1 = TradeIntentRequest(
    intent_id="trade_001",
    symbol="AAPL",
    side=OrderSide.BUY,
    quantity=Decimal("10"),
    order_type=OrderType.MARKET,
    broker_id="my_alpaca"
)
 
# Intent 2: Buy 5 more shares of AAPL
intent_2 = TradeIntentRequest(
    intent_id="trade_002",
    symbol="AAPL",
    side=OrderSide.BUY,
    quantity=Decimal("5"),
    order_type=OrderType.MARKET,
    broker_id="my_alpaca"
)
 
# Intent 2 does NOT depend on Intent 1
# SnipeRoute does not aggregate or optimize across intents
# Each is routed independently to the broker

Idempotency

The intent_id field serves as an idempotency key. If you submit the same intent_id twice, SnipeRoute will:

  1. Accept the first submission
  2. Reject the second submission with 409 Conflict

This prevents accidental duplicate orders.

Example: Idempotent Submission

# First submission
intent = TradeIntentRequest(
    intent_id="trade_001",
    symbol="AAPL",
    side=OrderSide.BUY,
    quantity=Decimal("10"),
    order_type=OrderType.MARKET,
    broker_id="my_alpaca"
)
 
response_1 = await client.create_intent(intent)
# Succeeds: 201 Created
 
response_2 = await client.create_intent(intent)
# Fails: 409 Conflict (duplicate intent_id)
⚠️

The intent_id must be unique across all Trade Intents for a given user. Use a UUID or timestamp-based ID to ensure uniqueness.

Trade Intent Lifecycle

1

Submitted

Trade Intent is submitted to SnipeRoute via API or Python SDK.

2

Validated

SnipeRoute validates the intent structure and broker connectivity.

3

Routed

Intent is routed to the specified broker via OAuth-authenticated API call.

4

Pending

Broker acknowledges the order and begins processing.

5

Filled / Partially Filled / Rejected

Broker executes the order (or rejects it) and SnipeRoute receives status updates.

Status Values

StatusDescription
pendingOrder submitted to broker, awaiting execution
filledOrder fully executed
partially_filledOrder partially executed
canceledOrder canceled before full execution
rejectedBroker rejected the order
failedRouting or validation failed

Order Types

Market Order

Executes immediately at the best available price.

{
  "order_type": "market"
}

Use when: You want immediate execution and don't care about the exact price.

Limit Order

Executes at a specified price or better.

{
  "order_type": "limit",
  "limit_price": 175.00
}

Use when: You want to control the maximum price you pay (buy) or minimum price you receive (sell).

Stop Order

Triggers a market order when the stop price is reached.

{
  "order_type": "stop",
  "stop_price": 170.00
}

Use when: You want to exit a position if the price moves against you (stop-loss).

Stop-Limit Order

Triggers a limit order when the stop price is reached.

{
  "order_type": "stop_limit",
  "stop_price": 170.00,
  "limit_price": 168.00
}

Use when: You want to control both the trigger price and the execution price.

Time in Force

ValueDescription
dayOrder valid until end of trading day (default)
gtcGood-till-canceled (valid until filled or manually canceled)
iocImmediate-or-cancel (fill immediately or cancel)
fokFill-or-kill (fill entire order immediately or cancel)

Validation Rules

Limit Orders Must Have limit_price
{
  "order_type": "limit",
  "limit_price": 175.00  // Required
}
Stop Orders Must Have stop_price
{
  "order_type": "stop",
  "stop_price": 170.00  // Required
}
Stop-Limit Orders Must Have Both
{
  "order_type": "stop_limit",
  "stop_price": 170.00,   // Required
  "limit_price": 168.00   // Required
}
Quantity Must Be Positive
{
  "quantity": 10  // Must be > 0
}

Next Steps