# Strategies & backtests

Write, change and test strategies on past prices. Nothing here trades.

## list_strategies

Your strategies and the ready-made templates, with the market, timeframe and last test of each.

Marks: Reads only.

### Inputs

Takes no inputs.

What the AI app reads: List the user's strategies and the ready-made templates (id, name, market, timeframe, last test).

## get_strategy

One strategy’s full rules: entry, exit, position sizing and risk management.

Marks: Reads only.

### Inputs

- `strategyId`: text (not empty, up to 100 characters), required. From `list_strategies`.

What the AI app reads: A strategy's full rules: entry, exit, position sizing and risk management.

## create_strategy

Saves a new strategy from rules the AI app writes with you.

Marks: Makes changes.

### Inputs

- `name`: text (not empty, up to 120 characters), required.
- `description`: text (up to 2,000 characters).
- `symbol`: text (2–40 characters). A market as the exchange names it, like `BTC-PERP`, `HYPE-SPOT` or `xyz:AAPL-PERP`. Default `BTC-PERP`.
- `timeframe`: text (a number then m, h, d or w, like `15m` or `4h`). Default `1h`.
- `direction`: one of `long`, `short`, `both`. Default `long`.
- `config`: object, any keys, required.

What the AI app reads: Save a new strategy. `config` = { entry: {combinator: "and"|"or", rules: [{id, field, operator, value}]}, exit: {same}, indicators: {RSI_14: {function: "rsi", params: {length: 14}}, …}, positionSizing: {method: "percentEquity", riskPercent: 1, maxPositionPercent: 100}, riskManagement: {stopLoss: {type: "percent", percent: 2}, takeProfit: {type: "percent", percent: 4}, trailingStop: {enabled: false}, maxDrawdown: null} }. Example entry rule: {id: "r1", field: "RSI_14", operator: "crossesAbove", value: 30}. Copy the shape of an existing strategy (get_strategy) when unsure, and run edge_check_rules on the config before saving — it names anything missing (no stop, no size, an indicator used but not set up).

## update_strategy

Changes a saved strategy: its name, rules, market, timeframe or direction.

Marks: Makes changes.

### Inputs

- `strategyId`: text (not empty, up to 100 characters), required. From `list_strategies`.
- `name`: text (not empty, up to 120 characters).
- `symbol`: text (2–40 characters). A market as the exchange names it, like `BTC-PERP`, `HYPE-SPOT` or `xyz:AAPL-PERP`.
- `timeframe`: text (a number then m, h, d or w, like `15m` or `4h`).
- `direction`: one of `long`, `short`, `both`.
- `config`: object, any keys.

What the AI app reads: Change a saved strategy (name, rules, market, timeframe, direction). `config` = { entry: {combinator: "and"|"or", rules: [{id, field, operator, value}]}, exit: {same}, indicators: {RSI_14: {function: "rsi", params: {length: 14}}, …}, positionSizing: {method: "percentEquity", riskPercent: 1, maxPositionPercent: 100}, riskManagement: {stopLoss: {type: "percent", percent: 2}, takeProfit: {type: "percent", percent: 4}, trailingStop: {enabled: false}, maxDrawdown: null} }. Example entry rule: {id: "r1", field: "RSI_14", operator: "crossesAbove", value: 30}. Copy the shape of an existing strategy (get_strategy) when unsure, and run edge_check_rules on the config before saving — it names anything missing (no stop, no size, an indicator used but not set up).

## run_backtest

Tests a strategy on past prices between two dates; returns the results and the last few trades.

Marks: Saves the test with the strategy.

### Inputs

- `strategyId`: text (not empty, up to 100 characters), required. From `list_strategies`.
- `startDate`: date (YYYY-MM-DD), required. ISO date, e.g. 2026-01-01.
- `endDate`: date (YYYY-MM-DD), required. ISO date, e.g. 2026-06-01.
- `initialCapital`: number (above 0, up to 1,000,000,000). Default `10000`.
- `leverage`: number (above 0, up to 50).
- `tradesShown`: whole number (0 to 50). Default `10`.

What the AI app reads: Test a strategy on past prices between two dates (ISO, e.g. 2026-01-01). Returns the results (return, drawdown, win rate, profit factor, …), the trade count and the last few trades. A long range can take a minute.

## list_backtests

A strategy’s past backtests, newest first.

Marks: Reads only.

### Inputs

- `strategyId`: text (not empty, up to 100 characters), required. From `list_strategies`.
- `limit`: whole number (1 to 50). Default `10`.

What the AI app reads: A strategy's past backtests, newest first (id, market, dates, results). Use an id with get_backtest or the edge tools.

## get_backtest

One saved backtest’s results and its last few trades.

Marks: Reads only.

### Inputs

- `backtestId`: text (not empty, up to 100 characters), required. From `list_backtests` or `run_backtest`.
- `tradesShown`: whole number (0 to 50). Default `10`.

What the AI app reads: One saved backtest: its results, trade count and the last few trades.

Updated: 2026-10-20

Web page: https://buildtrade.app/docs/tools/strategies/
