# 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:

### 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: 2 years (Free), 5 years (Core), 15 years (Plus), 20 years (Pro). 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. Target assets

For each asset referenced in the agent, choose the **exact symbol** to use for the backtest. This lets the agent run on the precise assets available at the targeted broker or exchange.

### 3. Target exchange

Choose the **exchange or broker** for the backtest. The fees and market specifications of that platform are then applied automatically.

{% hint style="success" %}
You can also choose the **Historical** option to use Obside's warehouse data, without depending on a specific exchange.
{% endhint %}

***

## Backtest results

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

* **Metrics** — dozens of detailed indicators (return, drawdown, Sharpe ratio, win rate, etc.).
* **Performance** — capital evolution curve over the period.
* **Trades** — full list of executed operations, exportable.
* **Chart** — TradingView visualization of all entry and exit points, with the reason for each trade.

{% 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.obside.com/agents/backtest-an-agent.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
