models

Backtesting

Precision and Control

Backtesting is a crucial step in algorithm development, allowing you to verify that your trading logic is being executed correctly. Any performance metrics should be disregarded as they are meaningless.

Spectral Alpha's backtesting engine provides granular control and flexibility, empowering you to conduct thorough and insightful tests.

Costs & Slippage: Simulating Real-World Trading Conditions

To ensure your backtests accurately reflect real-world trading, Spectral Alpha allows you to incorporate trading costs and slippage into your simulations.

Detailed Asset Settings

Each asset available on the platform has detailed settings for:

  • Spread: The difference between the bid and ask price.
  • Slippage: The difference between the expected price of a trade and the price at which it is actually executed.
  • Swap Rates: The interest rate differential paid or earned for holding positions overnight.
  • Overnight Margin Costs: The cost of borrowing funds to hold leveraged positions overnight.

Customizable Settings

You can adjust these cost and slippage settings for each algorithm, providing flexibility to:

  • Simulate Different Market Conditions: Account for varying liquidity levels or broker-specific costs.
  • Create Specialized Algorithms: Develop strategies optimized for different market environments.

Example:

You could create one algorithm with higher slippage settings to simulate trading during volatile market periods and another with lower slippage for more stable conditions.

Excluding Costs During Training

Importantly, costs and slippage are not factored in during parameter training. This prevents potential artifacts that could skew the optimization results. By excluding these costs during training, you ensure that the algorithm's parameters are optimized solely based on the underlying market dynamics and your trading logic.

Controls

Once you've defined your trading logic, you can proceed to backtest your algorithm using the following controls:

Parameters

The backtesting engine utilizes the same logic controls as the Model Builder (Signal, Filter, Stops, etc.). This ensures consistency between your strategy development and backtesting environments.

Max Open Position

This setting controls the position limits of your algorithm during the backtest.

  • Greater than 0 (Default): Limits the net directional exposure to the specified number (e.g., a value of 2 allows a maximum of 2 long or 2 short positions).
  • 0 (Special Use Case): Allows unlimited positions, with each new signal in the opposite direction closing all existing positions. This is useful for training continuous exposure models or strategies where all signals should be taken.
  • -1 (Special Use Case): New signals update the stop-loss and exit levels of existing trades rather than opening new trades. This is useful for strategies that involve adjusting existing positions based on new signals.

Hedging

When activated, this setting allows the algorithm to hold opposing directional trades simultaneously (e.g., both long and short positions). This is useful for creating continuous exposure models or strategies that aim to profit from volatility or market neutrality.

By carefully configuring these backtesting controls, you can create a testing environment that accurately reflects your intended trading strategy and provides meaningful insights into its potential behaviour.