> For the complete documentation index, see [llms.txt](https://docs.obside.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.obside.com/agents/backtest-an-agent.md).

# Backtest an agent

## Overview

Before running an agent live, it's recommended to **test its past performance** on historical data. This is called a **backtest**.

The goal is to understand how the agent would have reacted in different market conditions — bullish phases, bearish phases, periods of high volatility, drawdowns, etc.

{% hint style="info" %}
Backtests are relevant for **trading bots** and **investing agents** with deterministic rules. For an **AI trader**, backtesting is less representative since the AI exploits the present context (news, positioning) which can't be faithfully replayed in the past.
{% endhint %}

***

## Launching a backtest

From an agent's page, click **Create a backtest**. A dialog opens in three steps: **Parameters → Fees → Summary**.

### 1. Parameters

#### Backtest period

Define a **start date** and **end date** for your backtest. Only this period will be used to simulate past operations and analyze the agent's performance.

**Presets** are available: last month, last 6 months, last year, last 5 years.

* We have **over 20 years of history** for most assets.
* If the chosen start date predates our price history, the backtest will automatically start at **the earliest date available** in our database.
* Our data is updated **daily** to integrate the latest price changes.

{% hint style="info" %}
Available history depth depends on your plan: **5 years** (Free) and **20 years** (Plus, Pro, Max). See [Pricing](/misc/pricing.md).
{% endhint %}

#### Starting capital

Define a **starting capital** for your backtest.

* **For a trading bot**: starting capital is required, as it evolves dynamically based on gains and losses generated by each trade.
* **For an investing agent**: capital can be defined directly in the description (DCA, conditional purchases, etc.). If an initial amount must be invested in one go, it should also be specified in the description.

{% hint style="success" %}
While the starting capital doesn't affect the trades historically executed, choosing a realistic value helps you better project the evolution.
{% endhint %}

### 2. Fees

For each asset referenced in the agent, you can fine-tune the trading conditions applied during the simulation:

* **Commission** — as a percentage, a flat fee, or per contract.
* **Spread** — as a percentage or a flat amount.
* **Swap fees** — overnight financing costs for held positions.
* **Leverage** — the leverage applied to the asset.

{% hint style="success" %}
Default values are pre-filled per asset. Tuning fees to match your broker makes the backtest more realistic, especially for high-frequency strategies where costs add up.
{% endhint %}

### 3. Summary

Review the period, starting capital and per-asset configuration, then **run** the backtest. Results appear automatically as soon as the run completes.

***

## Backtest results

Once the backtest is complete, you can access several tabs to analyze performance:

* **Metrics** — dozens of detailed indicators (return, CAGR, max drawdown, Sharpe, Sortino, win rate, profit factor, expectancy, etc.) plus the **Obside Score**.
* **Performance** — capital curve over the period, with monthly and yearly performance and drawdown views.
* **Chart** — TradingView visualization of all entry and exit points, with the reason for each trade.
* **Trades** — full list of executed operations, exportable.

{% hint style="info" %}
The **Obside Score** estimates the quality of a backtest by combining performance, risk and statistical reliability. See [Obside Score](/misc/obside-score.md).
{% endhint %}

***

## Iterating on the agent

If the backtest results aren't satisfactory, you can **continue the conversation** in the chat linked to the agent to adjust its description, then run a new backtest with the same parameters or different ones.
