Skip to main content

Pre-Trade API

The Pre-Trade API provides comprehensive analysis before order execution, answering two key questions:
  1. Can we trade? - Validation (balance, limits, symbol, market status)
  2. What will it cost? - Analytics (fees, slippage, impact, liquidity)

Key Features

  • Balance validation: Check sufficient funds in quote (buy) or base (sell) currency
  • Daily limit enforcement: Prevent exceeding configured trading limits
  • Symbol validation: Verify trading pair exists and is tradeable
  • Order size checks: Validate against exchange min/max constraints
  • Liquidity analysis: Order size vs depth, ADV, time-to-fill estimates
  • Cost estimation: Fees + slippage + market impact with confidence scoring
  • Scenario analysis: Size sensitivity and taker vs maker comparison
  • Trader summary: Human-readable output with warnings

POST /order-execution/pretrade/analyze

Perform comprehensive pre-trade analysis including validation, liquidity metrics, cost estimation, and optional scenario analysis.

Request Body (JSON)

  • symbol (string, required): Trading pair in CCXT format (e.g., “BTC/USDT”)
  • side (string, required): Order side: “buy” or “sell”
  • quantity (number, required): Order quantity in base currency (e.g., 0.5 for 0.5 BTC)
  • exchange_account_ids (array, required): List of exchange account IDs to check (e.g., [“gateio-001”, “binance-sandbox-001”])
  • order_type (string, optional): Order type: “market”, “limit”, or “algo”. Default: “market”
  • limit_price (number, optional): Limit price for limit orders (required if order_type is “limit”)
  • urgency (string, optional): Order urgency: “low”, “normal”, or “high”. Affects scenario analysis. Default: “normal”
  • include_scenarios (boolean, optional): Whether to include size sensitivity and taker/maker scenario analysis. Default: false

Request Example

Response Example (Validation Passed)

Response Example (Validation Failed)

Validation Checks

Warning Codes


POST /order-execution/pretrade/validate

Perform quick validation without full cost analysis. Use this for fast pre-flight checks.

Request Body (JSON)

  • symbol (string, required): Trading pair in CCXT format
  • side (string, required): Order side: “buy” or “sell”
  • quantity (number, required): Order quantity in base currency
  • exchange_account_ids (array, required): List of exchange account IDs to validate against

Request Example

Response Example


GET /order-execution/pretrade/liquidity

Get current liquidity metrics for a trading pair. Requires an active orderbook subscription.

Query Parameters

  • symbol (string, required): Trading pair in CCXT format (e.g., “BTC/USDT”)

Request Example

Response Example (With Orderbook Data)

Response Example (No Orderbook Data)


GET /order-execution/pretrade/fees

Get fee schedule for a venue, account, or all configured venues. Supports account-specific fees including VIP tiers, negotiated rates, and pair-specific overrides.

Query Parameters

  • venue (string, optional): Exchange venue name. Returns default venue fees from static configuration.
  • exchange_account_id (string, optional): Exchange account ID for account-specific fees. When provided, returns actual fees for the account including VIP tier rates from exchange API, negotiated rates from database overrides, and pair-specific fees if symbol is also provided.
  • symbol (string, optional): Trading pair for pair-specific fees. Only used with exchange_account_id.

Fee Resolution Priority

When exchange_account_id is provided, fees are resolved in this order:
  1. Pair-specific DB override: fee_overrides.pairs.{symbol} in exchange_accounts collection
  2. Account-level DB override: fee_overrides.maker_bps/taker_bps in exchange_accounts collection
  3. Exchange API: VIP tier from fetch_trading_fees() or fetch_trading_fee(symbol)
  4. Static config: Default venue fees from configuration

Request Examples

Response Example (Account-Specific Fees)

Response Example (Single Venue - Static Config)

Response Example (All Venues)

Fee Sources

Default Fee Schedule

Database Fee Overrides

Account-specific fees can be configured in the exchange_accounts collection:

Cost Model

The pre-trade cost estimation uses the following model:

Total Cost

Slippage Calculation

Slippage is calculated by walking the orderbook:

Market Impact Model

Uses a square-root model:
Impact examples:
  • Order = 1% ADV: impact ~5 bps
  • Order = 4% ADV: impact ~10 bps
  • Order = 9% ADV: impact ~15 bps

Confidence Scoring

Confidence starts at 1.0 and is reduced by: Confidence labels:
  • Greater than 0.8: “High”
  • 0.5 - 0.8: “Medium”
  • Less than 0.5: “Low”