DocsBacktest Engineexecution

Commissions & Fees

The backtest engine simulates realistic trading costs to prevent overly optimistic results. Both commissions and slippage are applied automatically.

Commission Model

A percentage-based fee is applied on both entry and exit of every trade:

fee = (tradeAmount * feePercent) / 100
ParameterDefaultRangeDescription
feePercent0.1%0 - 5%Fee percentage per side

Both Sides

Fees are charged twice per round-trip trade:

  • Entry fee: Applied when a position is opened
  • Exit fee: Applied when a position is closed
Example: $10,000 trade at 0.1% fee
  Entry fee:  $10,000 * 0.001 = $10.00
  Exit fee:   $10,200 * 0.001 = $10.20
  Total fees: $20.20 (0.2% round trip)

Impact on Strategy Design

  • A 0.1% fee (0.2% round trip) means a trade must gain more than 0.2% to be profitable
  • High-frequency strategies (many trades) accumulate significant fee drag
  • Monitor totalFees in results to understand cost impact
Example: 200 trades at $10,000 each, 0.1% fee
  Total fees: 200 * 2 * $10 = $4,000
  Strategy must generate > $4,000 profit to break even

Slippage Model

Slippage simulates the price impact of order execution — real markets don't always fill at the exact price you expect.

fillPrice = basePrice * (1 ± slippagePercent / 100)

Slippage is always applied in the adverse direction:

  • Buying: Price moves up (you pay more)
  • Selling: Price moves down (you receive less)
ParameterDefaultRangeDescription
slippagePercent0%0 - 10%Price impact per fill

Slippage + Fees Together

Both are applied on every fill:

Example: Buy at $50,000 open, 0.05% slippage, 0.1% fee
  Fill price: $50,000 * 1.0005 = $50,025    (slippage)
  Fee:        $50,025 * 0.001  = $50.03      (commission)
  Total cost: $50,025.00 entry + $50.03 fee

Configuring Costs

Set fee and slippage values in the backtest configuration panel. Both parameters appear in the cost settings:

  • Fee %: Commission per side (default 0.1%)
  • Slippage %: Price impact per fill (default 0%)

For realistic crypto exchange simulation:

  • Maker/taker fees: 0.1% is typical for major exchanges
  • Slippage: 0.01% - 0.05% for liquid pairs, higher for illiquid ones

Comparing Gross vs Net

Always check totalProfit (net of fees) against the number of trades:

Gross profit: $5,000
Total fees:   $2,000
Net profit:   $3,000
Fee ratio:    40% of gross profit consumed by fees

If fees consume more than 30% of gross profit, consider:

  • Fewer trades (wider entry/exit criteria)
  • Longer holding periods
  • Removing signals in choppy/sideways markets

Related

feescommissionsslippagecosttrading costs