# Backtesting

Source: https://finnyai.tech/docs/backtesting

Backtesting simulates a generated strategy against historical market data. The goal isn't to prove it works live — it's to catch weak assumptions before you commit further.

## Run a backtest

```
/backtest
```

Finny uses **yfinance** to fetch real OHLCV data for any supported ticker.

## Performance metrics

- **Sharpe Ratio** — Risk-adjusted return per unit of volatility. Above 1.0 is generally considered good.
- **Max Drawdown** — Largest peak-to-trough decline. Lower is better.
- **Win Rate** — Percentage of profitable trades. Context-dependent — a 40% win rate can be profitable with high reward-to-risk ratios.
- **Profit Factor** — Gross profit divided by gross loss. Above 1.0 means net profitable; above 2.0 is strong.

## Data source

Historical data is pulled from Yahoo Finance via the `yfinance` Python library:

```bash
pip install yfinance
```

## Limitations

Backtests can mislead when a strategy has lookahead bias, overfit parameters, poor liquidity assumptions, missing fees, or unrealistic fills. Treat every result as research, not investment advice.
