Skip to main content

Why Cost Modeling Matters

A strategy that trades 2× daily with 0.04% taker fees on Binance futures pays ~29% annually in fees alone. Ignoring this — or using a flat 0.1% assumption — produces backtests that have no resemblance to reality. ClyptQ models costs at the venue level: each exchange-account pair has its own CostModel with maker/taker fees, slippage, and tick size.

CostModelSpec

CostModelSpec is the user-facing configuration for cost modeling. It’s specified per AccountSpec:

Fields

How Fees Are Calculated

For INSTANT mode, market orders always pay the taker_fee. Limit orders always pay the maker_fee. For LATENT mode (orderbook simulation), maker/taker is determined dynamically:
  • Maker: limit price is better than best bid/ask (order rests in book)
  • Taker: limit price crosses the spread (order fills immediately)

How Slippage Is Applied

Slippage is applied only to market orders in INSTANT mode. In LATENT mode with orderbook data, slippage emerges naturally from walking the orderbook — no fixed slippage is needed.

Fee Resolution Priority

ClyptQ resolves fees through VenueFeeResolver with a clear priority chain:

1. User Override (Highest Priority)

If you specify a CostModelSpec in your AccountSpec, it takes absolute precedence:
This is the recommended approach for VIP traders who know their exact fee tier.

2. CCXT Auto-Fetch

For crypto exchanges without explicit overrides, ClyptQ fetches current fee schedules from the exchange API via CCXT:
Auto-fetch returns the default tier (non-VIP) rates. If you have VIP status, use a manual override.

3. Fallback Default

If all resolution methods fail, the fallback matches typical Tier 0 futures rates:

Orderbook-Based Execution (LATENT Mode)

When orderbook data is available, BacktestFactory uses the BacktestSimulator to match orders against the book:
This captures:
  • Price impact: large orders walk the book and get progressively worse prices
  • Partial fills: if liquidity is insufficient, only available quantity fills
  • Maker/taker detection: limit orders that rest in the book pay maker fees

Example: Full Cost Configuration

Cost Impact Analysis

To understand how much costs affect your strategy, compare backtests with different cost configurations:
If the gap between zero-cost and realistic-cost backtests is more than 50% of your total return, the strategy is likely cost-dominated and may not be profitable after fees. Focus on reducing trade frequency or improving signal quality.

Exchange Specifics

Per-exchange fee tables, minimum order amounts, and market type support

Execution Pipeline

How Intention → Delta → Order → Fill works with cost models