> For the complete documentation index, see [llms.txt](https://botlyz.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://botlyz.gitbook.io/docs/english/backtest.md).

# Backtest

## Backtest definition

A backtest is a **simulation of your strategy on real historical data**. Botlyz lets you test your configuration before deploying it in live mode, in order to check its consistency and understand its past behavior.

Important: a backtest is **not a promise**. Past performance is no guarantee of future results. Market conditions change constantly (volatility, liquidity, behavior of other participants), and strong historical performance does not guarantee any future return. Trading carries a risk of loss, which can reach the entirety of the capital committed. See [Risk warning](/docs/english/avertissement-risques.md).

## How to run a backtest

In [the no-code Builder](/docs/english/le-builder.md), once your strategy is built, you can test it immediately.

### Step 1: configure the backtest parameters

The parameters area at the top of the Builder offers:

* **Strategy**: if you are testing from the strategy list (otherwise selected by default)
* **Pair**: the asset to test (e.g. BTC, ETH, SOL, HYPE, etc.)
* **Timeframe**: the time resolution of the candles (1m, 5m, 15m, 30m, 1h)
* **Date range**: from/to (displayed by default according to the data available for the pair)
* **Initial capital**: the starting capital of the simulation in dollars (e.g. 1000)
* **Leverage**: from 1 to 20x (1 = no leverage, capital committed as is)
* **Allocation**: the percentage of capital committed per trade (from 1 to 100%)

You can also click on **⚙ Edit default parameters** to adjust:

* The strategy-specific parameters (e.g. moving-average period, envelope width)
* The stop-loss (%) applied to each position

These overrides only apply to the current backtest; to use them in deployment, you will need to configure them and then sign the new configuration with your wallet. See [Risk parameters](/docs/english/parametres-de-risque.md).

### Step 2: run the simulation

Click on the **▶ Run** button. A loading window is displayed during the computation (duration: from a few seconds to a few tens of seconds, depending on the range and the timeframe).

The backtest engine:

1. Loads all the historical candles of the chosen pair and timeframe
2. Computes the entry and exit signals at each candle
3. Simulates the opening and closing of positions according to the signals
4. Applies the **fees** (0.10% = 10 bps)
5. Applies the **slippage** (2 bps by default, modeling the gap between buy/sell price and the execution speed)
6. Records the capital after each trade

You can cancel the computation at any time by clicking on **Cancel**.

### Important note on deployment validation

When you run the validation of a strategy to deploy it (**Validate for deployment** button), Botlyz also runs an automatic backtest in the background. This validation backtest:

* Uses the default capital ($1000) and a leverage of 1x
* Checks that the configuration compiles and generates entries
* Confirms that your strategy has no logic error

This is not a performance backtest, just a technical check.

## Reading the results

Once the backtest is finished, you have access to three sections.

### 1. Key statistics (colored tiles)

**Backtest result over the period**: the total return as a percentage

* Green (positive): gains
* Red (negative): losses

**Max drawdown (worst drop)**: the maximum decline of the capital from a peak

* Expressed as a negative percentage
* Closer to 0, less volatile; lower, riskier

**Worst trade**: the percentage lost on the single worst trade

**Profit factor**: the ratio of total gains to total losses

* Greater than 1.0: more gains than losses
* Less than 1.0: more losses than gains
* N/A if no trade or error

These thresholds describe only the past behavior over the chosen period; a profit factor greater than 1.0 over the history predicts no future result.

**Win rate**: the percentage of winning trades (closed positive)

**Trades**: the total number of positions opened and closed

**Final equity**: the final capital after all the trades

**Sharpe**: the Sharpe ratio, which measures the historical return relative to the volatility over the tested period. The higher it is, the more regular the past return was relative to the risk; it is neither a target nor a guarantee.

These indicators describe past behavior. None of them constitutes a forecast of future gains.

### 2. Equity curve (Capital evolution)

A chart shows the evolution of your capital over time, candle by candle.

* The horizontal axis: time
* The vertical axis: capital in dollars
* The highs and lows of the curve reflect the gains and losses of each position
* A flat curve: few or no trades
* A rising curve reflects a historically positive result over the tested period; a falling curve, a negative result. This past behavior is in no way indicative of future results.

The tooltip displays the exact capital at each point.

### 3. Full statistics (table)

The detailed table includes dozens of metrics (Return on Invested Capital, Calmar Ratio, Expectancy, etc.). Hover your mouse over the labels to read a brief explanation of each statistic.

## Role of slippage and fees

The backtest applies two costs to model execution in real trading.

### Fees (fees\_bps)

**By default: 10 bps = 0.10%**

In the backtest, these fees correspond to **Botlyz's protocol fee**, capped at 10 bps (0.10%). It is a protocol fee, collected and paid out by the Lighter platform through its "partner attribution" mechanism, and not a Botlyz invoice or commission. Botlyz takes no commission on your gains.

Furthermore, the Lighter platform's own fees (trading fees, funding) apply independently of Botlyz. For details, see [Fees](/docs/english/frais.md).

In the backtest, the protocol fee is applied to each entry AND each exit of a position.

**Example:** a $1000 trade represents 1000 × 0.0010 = $1 at entry and $1 at exit, i.e. $2 in total for the complete cycle.

### Slippage (slippage\_bps)

**By default: 2 bps = 0.02%**

Slippage models the gap between the theoretical price (candle close) and the actual execution price:

* **Buy/sell gap (bid/ask)**: the difference between the buy and sell price on Lighter
* **Execution delay**: the price can move while your order is being filled
* **Market depth**: the larger your order, the more slippage tends to increase

You can adjust the slippage in the backtest (from 0 to 50 bps) to explore different scenarios:

* **Low slippage (0 to 1 bps)**: very liquid market, small order size
* **Standard slippage (2 to 5 bps)**: medium order, normal market
* **High slippage (10 to 50 bps)**: large order or illiquid market

### Impact on realism

The backtest uses the **timeframe close** as the theoretical price, then adjusts it with the slippage.

**Concrete example:**

* 1h candle close = $100
* Slippage = 2 bps (0.02%)
* Actual execution price ≈ 100 × (1 + 0.0002) = $100.02 (buy) or 100 × (1 − 0.0002) = $99.98 (sell)

The more you increase the slippage (and the fees), the closer the backtest gets to realistic conditions. A backtest without fees or slippage is too optimistic.

## Important warnings

### Past performance is no guarantee of future results

A good backtest over 6 months of history guarantees nothing for the next 6 months. The reasons include:

* **Market regime changes**: a strategy suited to an uptrend can lose in a directionless market
* **Liquidity evolution**: Lighter and the pairs evolve; the order book changes
* **Overfitting**: your strategy may be too optimized on the history ("curve fitting")
* **Extreme events (black swan)**: crashes, gaps, cascading liquidations, sometimes not captured by the standard slippage

### The backtest is a simulation

Reality can differ from the backtest for several reasons:

* **Candle resolution**: the backtest computes at each candle close, whereas the real market evolves continuously
* **Liquidity**: Lighter's order book may lack depth; your order may be partially filled
* **Risk management**: the backtest applies a % stop-loss to the position, but in case of a violent gap or cascading liquidation, the actual price may be far less favorable
* **Fees**: the value of 0.10% is fixed in the backtest; the actual parameters may evolve over time

### Trading carries a risk of loss

By running a strategy in live mode, you expose yourself in particular to:

* the loss of all your committed capital (up to 100% in case of an unfavorable market)
* a liquidation if the leverage is too high and the market reverses abruptly
* an unavailability during a market or connection outage

**You alone are responsible for your trading decisions and the management of your capital.** Botlyz is an automation software editor: the tool is non-custodial, your funds and your keys stay with you, the API keys are trade-only (no withdrawal possible) and you sign your configuration (EIP-712). See [Security and non-custodial](/docs/english/securite-non-custodial.md).

## Using the backtest effectively

### Best practices

1. **Test over several periods**: do not rely on a single backtest. Run the same strategy over a different period (previous year, different month) to check its stability.
2. **Increase slippage gradually**: start at 2 bps, then test with 5 bps and 10 bps to measure the strategy's sensitivity to real conditions.
3. **Check the number of trades**: a strategy with 3 trades over 1 year is hard to assess. A strategy with 500 trades over 1 year may be over-optimized. Aim for a balance (from 20 to 200 trades depending on the context).
4. **Read the max drawdown**: a 50% drawdown means the capital fell by half at the worst moment. Ask yourself whether you would be willing to endure it.
5. **Consult the full statistics table**: do not look only at the total return. Examine the Sharpe (risk-adjusted return), the Calmar (return relative to drawdown) and the Expectancy (average gain per trade).
6. **Deploy gradually**: if the backtest seems consistent to you, start real trading with low leverage (1x) and reduced capital, then adjust according to the actual results.

### Pitfalls to avoid

* Believing that a good backtest amounts to a guarantee of real gains
* Testing over too short a period (less than 3 months) or too favorable a one (a single bull market)
* Increasing the leverage "because the backtest allows it"
* Ignoring slippage and fees ("idealized" backtest)
* Modifying the strategy after each bad backtest (gradual curve fitting)

## Next steps

Once you have analyzed your backtest:

1. Click on **⚙ Configure this strategy** (button visible after the results)
2. Confirm your final parameters and your leverage
3. Sign the configuration with your wallet (EIP-712)
4. Deploy the strategy in live mode

See [Deploy a strategy](/docs/english/installation-pas-a-pas/deployer-une-strategie.md) and [Signature and transparency](/docs/english/signature-et-transparence.md).

Botlyz then executes the signals on Lighter continuously, according to your approved configuration, without ever being able to withdraw your funds.

If you have questions about interpreting a backtest or about the configuration, see the [FAQ](/docs/english/faq.md) or contact [support](/docs/english/support.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://botlyz.gitbook.io/docs/english/backtest.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
