@quantbrasil/cli 0.1.0-beta.13 → 0.1.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +5 -0
  2. package/dist/cli/index.d.ts +4 -0
  3. package/dist/cli/index.d.ts.map +1 -1
  4. package/dist/cli/index.js +16 -0
  5. package/dist/commands/backtests.d.ts +132 -0
  6. package/dist/commands/backtests.d.ts.map +1 -0
  7. package/dist/commands/backtests.js +445 -0
  8. package/dist/commands/news.d.ts +48 -0
  9. package/dist/commands/news.d.ts.map +1 -0
  10. package/dist/commands/news.js +85 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +2 -0
  14. package/dist/vendor/core/capabilities/backtests.d.ts +173 -0
  15. package/dist/vendor/core/capabilities/backtests.d.ts.map +1 -0
  16. package/dist/vendor/core/capabilities/backtests.js +203 -0
  17. package/dist/vendor/core/capabilities/index.d.ts +2 -0
  18. package/dist/vendor/core/capabilities/index.d.ts.map +1 -1
  19. package/dist/vendor/core/capabilities/index.js +2 -0
  20. package/dist/vendor/core/capabilities/news.d.ts +54 -0
  21. package/dist/vendor/core/capabilities/news.d.ts.map +1 -0
  22. package/dist/vendor/core/capabilities/news.js +65 -0
  23. package/dist/vendor/core/capabilities/registry.d.ts +444 -0
  24. package/dist/vendor/core/capabilities/registry.d.ts.map +1 -1
  25. package/dist/vendor/core/capabilities/registry.js +4 -0
  26. package/dist/vendor/core/capabilities/types.d.ts +1 -1
  27. package/dist/vendor/core/capabilities/types.d.ts.map +1 -1
  28. package/package.json +3 -3
  29. package/skills/quantbrasil/SKILL.md +8 -4
  30. package/skills/quantbrasil/references/backtests.md +170 -0
  31. package/skills/quantbrasil/references/cli.md +42 -0
  32. package/skills/quantbrasil/references/costs.md +6 -1
  33. package/skills/quantbrasil/references/quality-eval-queries.json +30 -0
  34. package/skills/quantbrasil/references/unsupported.md +5 -0
  35. package/skills/quantbrasil/references/workflows.md +43 -0
@@ -0,0 +1,170 @@
1
+ # Backtests
2
+
3
+ Use backtests when the user asks to run a historical simulation for one
4
+ supported strategy and one explicit asset.
5
+
6
+ Backtests are strategy-specific. Always inspect the selected strategy before
7
+ overriding parameters unless the user already gave exact parameter names.
8
+
9
+ ## Commands
10
+
11
+ ```bash
12
+ quantbrasil backtests strategies
13
+ quantbrasil backtests strategies --json
14
+ quantbrasil backtests info ifr2
15
+ quantbrasil backtests info ifr2 --json
16
+ quantbrasil backtests run ifr2 PETR4 --timeframe D1 --from 2025-01-01 --to 2026-01-01
17
+ quantbrasil backtests run ifr2 PRIO3 --timeframe D1 --param rsi=15
18
+ quantbrasil backtests run ifr2 PETR4 --timeframe D1 --param rsi=30 --param window=2 --json
19
+ ```
20
+
21
+ ## Agent Workflow
22
+
23
+ 1. Use `backtests strategies` when the strategy id is unknown.
24
+ 2. Use `backtests info <strategy-id>` before changing parameters.
25
+ 3. Read `selection_guidance`, `timeframe_guidance`, accepted parameter names, defaults, value hints, and parameter guidance from the info output.
26
+ 4. Use `backtests run <strategy-id> <ticker>` for one strategy and one asset.
27
+ 5. Add `--json` to `backtests info` when another agent or script needs defaults; add `--json` to `backtests run` when it needs metrics, parameters, or trade history.
28
+
29
+ If the user says "IFR2 on PRIO3 with value 15", map "value" to the IFR2
30
+ threshold parameter and run:
31
+
32
+ ```bash
33
+ quantbrasil backtests run ifr2 PRIO3 --timeframe D1 --param rsi=15
34
+ ```
35
+
36
+ ## Strategy Selection
37
+
38
+ Use the strategy id returned by `backtests strategies` or `backtests info`.
39
+ Hyphens and underscores are both accepted by the CLI and normalized before the
40
+ request is sent.
41
+
42
+ | Family | Strategy ids | Select when |
43
+ | -------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
44
+ | IFR | `ifr2`, `long_rsi` | The user asks for IFR/RSI, sobrevenda, sobrecompra, or mean reversion by relative strength. Prefer `ifr2` for the classic short-window IFR setup. |
45
+ | Estocástico | `long_stochastic`, `short_stochastic` | The user asks for stochastic oscillator, sobrevendido/sobrecomprado by estocástico, or oscillator mean reversion. |
46
+ | Máximas e mínimas | `maxmin`, `short_maxmin` | The user asks for breakout of recent highs/lows with entry and exit windows. |
47
+ | Padrão 123 | `long_123`, `short_123` | The user asks for pattern 123, reversal/continuation by a technical formation, or stop by candle/amplitude. |
48
+ | Candle | `long_wick_candle`, `short_wick_candle` | The user asks for wick, gap, rejection candle, or candle-body/pavio logic. These are daily/weekly strategies. |
49
+ | Reversão | `long_turnaround` | The user asks for turnaround after a negative sequence or exhaustion move. |
50
+ | Trap | `long_trap`, `long_candle_trap`, `short_candle_trap` | The user asks for trap, false breakout, candle trap, or failure around a moving average/candle. |
51
+ | PFR | `long_pfr`, `short_pfr` | The user asks for Preço de Fechamento de Reversão or a short reversal after failed continuation. |
52
+ | Padrão Shark | `long_shark`, `short_shark` | The user asks for Shark pattern with configurable entry, stop, and target. |
53
+ | Inside Bar | `long_insidebar`, `short_insidebar` | The user asks for inside bar breakout. |
54
+ | Breakout | `long_breakout`, `short_breakout` | The user asks for candle/technical-region breakout with target by risk, percentage, or Fibonacci. |
55
+ | Bandas de Bollinger | `long_open_bb`, `short_open_bb`, `long_reversal_bb`, `short_reversal_bb` | Use opening-band strategies for volatility expansion; use reversal-band strategies for return from extremes. |
56
+ | Horário | `long_by_time`, `short_by_time` | The rule is to enter and exit at fixed intraday times. |
57
+ | Variação atípica | `long_atypical_variation`, `short_atypical_variation` | The user asks for statistically unusual moves by Z-score. |
58
+ | Variação intradiária | `long_intraday_variation`, `short_intraday_variation` | The user asks for intraday percentage variation with entry/exit by variation. These define timeframe internally. |
59
+ | HiLo Activator | `long_hilo_activator`, `short_hilo_activator` | The user asks for HiLo Activator as the trend or signal rule. |
60
+ | Três médias | `long_three_bar`, `short_three_bar` | The user asks for three averages, three-bar style confirmation, or channel/average confirmation. |
61
+ | Supertrend | `long_supertrend`, `short_supertrend` | The user asks for Supertrend or ATR-based trend following. |
62
+ | Canal de Donchian | `long_donchian`, `short_donchian` | The user asks for Donchian channel breakout by high/low window. |
63
+ | Gap Trap | `long_gaptrap`, `short_gaptrap` | The user asks for failed continuation after an intraday gap. Do not use for crypto assets. |
64
+ | Saudade de Casa | `long_sdc`, `short_sdc` | The user asks for return to reference bands after intraday displacement. Do not use for crypto assets. |
65
+
66
+ For direction, choose `long`/compra ids when the user asks for buying,
67
+ recovery, upside, oversold, or upward breakout. Choose `short`/venda ids when
68
+ the user asks for selling, downside, short, overbought, or downward breakout.
69
+
70
+ ## Timeframes and Dates
71
+
72
+ - Most strategies require `--timeframe`; use `backtests info` to confirm.
73
+ - Timeframe values are `M5`, `M15`, `M30`, `H1`, `H2`, `H4`, `D1`, and `W1`.
74
+ - Daily/weekly-only strategies accept only `D1` or `W1`.
75
+ - Intraday-only strategies accept only `M5`, `M15`, `M30`, `H1`, `H2`, or `H4`.
76
+ - Intraday-variation strategies define timeframe internally; omit `--timeframe`.
77
+ - If the user does not specify a timeframe for a generic equity backtest and the strategy allows daily candles, use `D1` and state that assumption.
78
+ - `--from` and `--to` use ISO dates: `AAAA-MM-DD`.
79
+ - When dates are omitted, backend defaults apply.
80
+
81
+ ## Parameter Rules
82
+
83
+ - `backtests info` returns accepted parameter names, defaults, types, enum options, descriptions, `value_hint`, and `agent_guidance`.
84
+ - Do not invent parameter names. If a user gives camelCase or kebab-case, the CLI normalizes it to snake_case.
85
+ - `--param key=value` can be repeated. Keys may be written as `stopInDays`, `stop-in-days`, or `stop_in_days`.
86
+ - `--params-json '{"rsi":30,"window":2}'` is useful when many parameters are set at once.
87
+ - Values in `--param` are parsed as booleans, numbers, or strings.
88
+ - Explicit `--param` values override matching keys from `--params-json`.
89
+ - Prefer defaults unless the user asks to change a parameter or gives a concrete value.
90
+
91
+ ## Common Parameter Glossary
92
+
93
+ Time controls:
94
+
95
+ - `is_day_trade`: forces intraday behavior when the strategy supports it.
96
+ - `min_open_time`: earliest intraday entry time, formatted `HH:MM`; useful for ignoring the opening auction or early volatility.
97
+ - `close_time_limit`: latest intraday close time, formatted `HH:MM`; useful for avoiding positions after the desired trading session.
98
+ - `entry_time`: fixed entry time for by-time strategies.
99
+ - `exit_time`: fixed exit time for by-time strategies.
100
+
101
+ Trend and filters:
102
+
103
+ - `mm50_is_up`: IFR2 trend filter; `true` requires the 50-period moving average to be rising before long entries.
104
+ - `mme80_is_up`: EMA80 directional filter used by RSI/stochastic variants.
105
+ - `traders_eden`: proprietary trend-confirmation filter.
106
+ - `hammer`: requires hammer/wick-style candle confirmation.
107
+ - `inside_bar`: requires inside-bar confirmation.
108
+ - `apply_rsi_filter`: adds RSI confirmation to supported band strategies.
109
+ - `apply_keltner_filter`: adds Keltner-channel confirmation to supported max/min strategies.
110
+ - `ignore_trend_confirmation`: removes the auxiliary trend confirmation when supported.
111
+
112
+ Indicator thresholds and windows:
113
+
114
+ - `rsi`: IFR/RSI threshold. In IFR2, lower values are more selective for long entries; for example `rsi=15`.
115
+ - `rsi_window`: IFR/RSI calculation window.
116
+ - `entry_rsi` and `exit_rsi`: RSI levels for entry and exit in RSI variants.
117
+ - `k_window`: stochastic `%K` calculation window.
118
+ - `mma_window`: moving-average smoothing window.
119
+ - `entry_stochastic` and `exit_stochastic`: stochastic levels for entry and exit.
120
+ - `rolling_avg_type`: `simple` or `ewm`.
121
+ - `rolling_avg_window`: moving-average window used when entry uses a rolling average.
122
+
123
+ Risk, stop, and target:
124
+
125
+ - `stop`: stop rule enum. Inspect `backtests info` for allowed values on the selected strategy.
126
+ - `target`: target/exit rule enum. Inspect `backtests info` for allowed values on the selected strategy.
127
+ - `stop_in_days`: maximum trade duration in candles; on D1 it behaves as daily candles, on intraday it behaves as candles of that timeframe.
128
+ - `stop_in_pct`: percentage stop as a decimal fraction, for example `0.02` for 2%.
129
+ - `target_in_pct`: percentage target as a decimal fraction, for example `0.03` for 3%.
130
+ - `risk_factor`: target/stop multiple for fixed-risk strategies.
131
+ - `fibo_retracement`: Fibonacci retracement used for stop placement when supported.
132
+ - `fibo_extension`: Fibonacci extension used for target projection when supported.
133
+ - `max_risk`: financial risk limit. Prefer the CLI flag `--max-risk` when the user means risk in money.
134
+
135
+ Statistical, channel, and volatility controls:
136
+
137
+ - `zscore_threshold`: minimum absolute Z-score for atypical-variation strategies.
138
+ - `rolling_window`: rolling calculation window for statistical strategies.
139
+ - `std_factor`: standard-deviation multiplier used by statistical targets.
140
+ - `stop_in_std`: stop measured in standard deviations.
141
+ - `num_std`: number of standard deviations for Bollinger bands.
142
+ - `atr_window` and `atr_multiplier`: ATR window and multiplier for Supertrend.
143
+ - `top_channel_window`, `bottom_channel_window`, and `channel_window`: channel lookback windows for channel/breakout strategies.
144
+ - `keltner_window` and `keltner_multiplier`: Keltner-channel calculation controls.
145
+
146
+ Pattern-specific controls:
147
+
148
+ - `body_pct`: minimum candle body fraction for wick/candle strategies.
149
+ - `gap_pct`: minimum gap size as a decimal fraction.
150
+ - `negative_sequence`: number of negative candles required before turnaround.
151
+ - `exhaustion_pct`: minimum exhaustion move before a turnaround setup.
152
+ - `candles_above`: persistence requirement above a moving average.
153
+ - `target_band`: `middle` or `opposite` target band for Saudade de Casa.
154
+ - `entry_variation` and `exit_variation`: intraday percentage variation thresholds. The sign matters; negative entry variation means a drop before long entry.
155
+ - `entry_window`, `exit_window`, and `window`: generic lookback windows whose exact meaning depends on the selected strategy; inspect `backtests info` before overriding.
156
+
157
+ ## Output
158
+
159
+ Human output summarizes return, drawdown, EV, win rate, operations, profit
160
+ factor, score when available, and the saved backtest id.
161
+
162
+ JSON output includes the full saved backtest response, including parameters and
163
+ trade history.
164
+
165
+ ## Unsupported
166
+
167
+ - batch backtests
168
+ - backtest ranking across many strategies or assets
169
+ - automatic screening-to-backtest chaining
170
+ - comparing two saved backtests from the CLI
@@ -46,6 +46,22 @@ Valid `--sections`:
46
46
  - `fundamentals`
47
47
  - `rankings`
48
48
 
49
+ ## News
50
+
51
+ ```bash
52
+ quantbrasil news asset PETR4
53
+ quantbrasil news asset PETR4 --window 7 --limit 10
54
+ quantbrasil news asset PETR4 --json
55
+ ```
56
+
57
+ Rules:
58
+
59
+ - use `news asset` when the user asks for recent saved RSS news about one explicit ticker
60
+ - `--window` is the lookback window in calendar days and defaults to `30`
61
+ - `--limit` is the maximum number of articles and defaults to `20`
62
+ - the response is based on direct ticker mentions stored by QuantBrasil, not sentiment or article scraping
63
+ - use `--json` when another step needs to parse sources, dates, URLs, or mentioned tickers
64
+
49
65
  ## Rankings
50
66
 
51
67
  ```bash
@@ -158,6 +174,32 @@ Example query JSON:
158
174
  Load [`screening.md`](./screening.md) for detailed screening examples, including
159
175
  IFR14, IFR2, and logical `AND` JSON payloads.
160
176
 
177
+ ## Backtests
178
+
179
+ ```bash
180
+ quantbrasil backtests strategies
181
+ quantbrasil backtests strategies --json
182
+ quantbrasil backtests info ifr2
183
+ quantbrasil backtests info long-rsi --json
184
+ quantbrasil backtests run ifr2 PETR4 --timeframe D1 --from 2025-01-01 --to 2026-01-01
185
+ quantbrasil backtests run ifr2 PETR4 --timeframe D1 --param rsi=30 --param window=2
186
+ quantbrasil backtests run long-rsi VALE3 --timeframe D1 --params-json '{"entry":"rolling_avg","rollingAvgType":"simple","rollingAvgWindow":20}'
187
+ quantbrasil backtests run long-intraday-variation PETR4 --from 2025-01-01 --to 2025-12-31 --json
188
+ ```
189
+
190
+ Rules:
191
+
192
+ - use `backtests strategies` to discover strategy ids
193
+ - use `backtests info <strategy-id>` to inspect motivation, selection guidance, timeframe guidance, accepted parameters, defaults, value hints, parameter guidance, types, options, and allowed timeframes
194
+ - use `backtests run <strategy-id> <ticker>` for one strategy and one asset
195
+ - use `--timeframe` unless `backtests info` says the strategy has an internal timeframe
196
+ - `--param key=value` can be repeated; `--params-json` accepts an object of parameters
197
+ - `--param` values override matching keys from `--params-json`
198
+ - use `--json` when metrics, parameters, or trade history will feed another step
199
+ - batch backtests, backtest rankings, saved-backtest comparison, and automatic screening-to-backtest chaining are not public CLI commands
200
+
201
+ Load [`backtests.md`](./backtests.md) for detailed backtest workflow guidance.
202
+
161
203
  ## Cointegration
162
204
 
163
205
  ```bash
@@ -12,10 +12,13 @@ Current guidance uses backend qualitative classes only:
12
12
 
13
13
  - `market assets` is lowest-cost discovery path
14
14
  - `market price` is narrow read path
15
+ - `news asset` is a standard narrow read path for recent ticker news
15
16
  - `assets overview` is richer and should use minimal `--sections`
16
17
  - `screening universes` is a discovery path for saved screening universes
17
18
  - `screening indicators` is a discovery path for supported screening JSON
18
19
  - `screening run` is a heavy read and should be targeted to one selected universe
20
+ - `backtests strategies` and `backtests info` are discovery paths
21
+ - `backtests run` is heavy and should be targeted to one selected strategy and ticker
19
22
  - `cointegration pair` is a heavy read and should be targeted to one explicit pair
20
23
  - `rankings return` is a heavy read and should be targeted to one explicit system ranking and date range
21
24
  - holding metrics (`historical-return`, `beta`, `var`) are heaviest current public reads
@@ -24,11 +27,13 @@ Current guidance uses backend qualitative classes only:
24
27
 
25
28
  - prefer narrow command that answers question
26
29
  - prefer `market price` over `assets overview` for quote-only requests
30
+ - prefer `news asset` over web search for QuantBrasil-supported recent ticker news
27
31
  - run `screening universes` before `screening run` when the universe selector is not known
28
32
  - run `screening indicators` before `screening run` when the indicator JSON is not known
33
+ - run `backtests info` before changing strategy parameters
29
34
  - run `rankings list` before `rankings return` when return support or the system slug is not known
30
35
  - prefer one holding metric call targeted to actual question
31
- - do not chain multiple heavy holding metric, ranking return, screening, or cointegration calls unless user asked for them
36
+ - do not chain multiple heavy holding metric, ranking return, screening, backtest, or cointegration calls unless user asked for them
32
37
  - use `--json` only when structured output needed
33
38
 
34
39
  ## Safe defaults
@@ -14,6 +14,11 @@
14
14
  "should_trigger": true,
15
15
  "expected_behavior": "Use assets overview with only valid sections: price,fundamentals,rankings."
16
16
  },
17
+ {
18
+ "query": "Quais são as notícias recentes de PETR4?",
19
+ "should_trigger": true,
20
+ "expected_behavior": "Use quantbrasil news asset PETR4, cite source/date, and do not infer sentiment."
21
+ },
17
22
  {
18
23
  "query": "Mostra valuation e resumo da PETR4 pela CLI.",
19
24
  "should_trigger": true,
@@ -54,6 +59,31 @@
54
59
  "should_trigger": true,
55
60
  "expected_behavior": "Use screening run with one explicit --system selector and a ScreenerRequest JSON payload."
56
61
  },
62
+ {
63
+ "query": "Quais estratégias de backtest posso rodar pela CLI?",
64
+ "should_trigger": true,
65
+ "expected_behavior": "Use backtests strategies and present supported strategy ids; do not invent unsupported batch workflows."
66
+ },
67
+ {
68
+ "query": "Explique os parâmetros da estratégia IFR2 antes de rodar.",
69
+ "should_trigger": true,
70
+ "expected_behavior": "Load backtests guidance and use quantbrasil backtests info ifr2 to inspect defaults, selection guidance, timeframe guidance, value hints, parameter descriptions, and allowed timeframes."
71
+ },
72
+ {
73
+ "query": "Rode backtest de IFR2 para PRIO3 com valor 15.",
74
+ "should_trigger": true,
75
+ "expected_behavior": "Load backtests guidance, map the IFR2 value to rsi=15, and use quantbrasil backtests run ifr2 PRIO3 --timeframe D1 --param rsi=15 unless the user specifies another timeframe."
76
+ },
77
+ {
78
+ "query": "Rode um backtest de IFR2 para PETR4 no diário.",
79
+ "should_trigger": true,
80
+ "expected_behavior": "Load backtests guidance and use quantbrasil backtests run ifr2 PETR4 --timeframe D1, adding dates only if the user provides or asks for a specific period."
81
+ },
82
+ {
83
+ "query": "Rode backtests em lote e rankeie as melhores estratégias para PETR4.",
84
+ "should_trigger": true,
85
+ "expected_behavior": "Load unsupported guidance; explain that public CLI supports individual backtest runs, not batch backtests or strategy rankings."
86
+ },
57
87
  {
58
88
  "query": "Rode cointegração entre PETR4 e VALE3.",
59
89
  "should_trigger": true,
@@ -7,6 +7,10 @@ Unsupported in the public CLI:
7
7
  - value-based position input for traded assets
8
8
  - ad-hoc ticker-list screening
9
9
  - scanning all cointegrated pairs in a universe
10
+ - batch backtests
11
+ - backtest rankings across many strategies or assets
12
+ - comparing saved backtests from the CLI
13
+ - automatic screening-to-backtest chaining
10
14
 
11
15
  Not a supported pattern:
12
16
 
@@ -22,6 +26,7 @@ Use the public surface only:
22
26
  - `market`
23
27
  - `assets`
24
28
  - `cointegration`
29
+ - `backtests`
25
30
  - `screening`
26
31
  - `watchlists`
27
32
  - `holdings`
@@ -4,6 +4,7 @@
4
4
 
5
5
  - asset price, quote, or daily move → `market price`
6
6
  - supported assets, tickers, or market universe → `market assets`
7
+ - recent news, headlines, or articles for one ticker → `news asset`
7
8
  - asset performance, technicals, risk, fundamentals, or ranking → `assets overview`
8
9
  - current ordered asset lists such as Magic Formula, momentum, Low Risk, or user rankings → `rankings list`, then `rankings current`
9
10
  - historical return of ranking strategies such as Magic Formula or Momentum → `rankings list`, then `rankings return`
@@ -11,6 +12,7 @@
11
12
  - holding details or changes → `holdings ...`
12
13
  - holding return, beta, risk, VaR, or comparison → `holdings historical-return|beta|var`
13
14
  - indicator screening over saved asset sets → `screening universes`, `screening indicators` when needed, then `screening run`
15
+ - one strategy backtest for one explicit asset → `backtests strategies`, `backtests info`, then `backtests run`
14
16
  - cointegration or Long & Short between two explicit assets → `cointegration pair`
15
17
 
16
18
  ## Find supported ticker, then get price
@@ -44,6 +46,23 @@ Do not use generic web or finance search for QuantBrasil-supported market data
44
46
  unless the CLI is unavailable, the requested data is outside the supported
45
47
  surface, or the user explicitly asks for an external source.
46
48
 
49
+ ## Get recent ticker news
50
+
51
+ Use this when the user asks for news, headlines, articles, or recent updates
52
+ about one explicit ticker.
53
+
54
+ ```bash
55
+ quantbrasil news asset PETR4
56
+ quantbrasil news asset PETR4 --window 7 --limit 10
57
+ ```
58
+
59
+ Rules:
60
+
61
+ - news results are saved RSS items that directly mentioned supported tickers
62
+ - cite source and publication date when summarizing results
63
+ - do not infer sentiment or recommendations from the news list
64
+ - use generic web search only if the user asks for external/current web research beyond QuantBrasil's stored news
65
+
47
66
  ## Cost-aware `assets overview` section choice
48
67
 
49
68
  Keep `--sections` minimal.
@@ -150,6 +169,30 @@ Rules:
150
169
  - do not invent a universe scan command for "quais pares cointegrados"; the public CLI currently supports explicit pairs
151
170
  - use `--json` if the z-score or beta series will feed another calculation
152
171
 
172
+ ## Run one backtest
173
+
174
+ Use this when the user asks to run a historical strategy simulation for one
175
+ explicit asset.
176
+
177
+ ```bash
178
+ quantbrasil backtests strategies
179
+ quantbrasil backtests info ifr2
180
+ quantbrasil backtests run ifr2 PETR4 --timeframe D1 --from 2025-01-01 --to 2026-01-01
181
+ quantbrasil backtests run ifr2 PRIO3 --timeframe D1 --param rsi=15
182
+ quantbrasil backtests run ifr2 PETR4 --timeframe D1 --param rsi=30 --param window=2 --json
183
+ ```
184
+
185
+ Rules:
186
+
187
+ - use `backtests strategies` if the user names a strategy informally
188
+ - use `backtests info` before setting or explaining parameters
189
+ - read `selection_guidance`, `timeframe_guidance`, defaults, `value_hint`, and `agent_guidance` before choosing overrides
190
+ - for IFR2, a generic "value" usually maps to `rsi`; for example "IFR2 on PRIO3 with value 15" means `--param rsi=15`
191
+ - run one strategy and one asset at a time
192
+ - do not invent batch backtests, backtest rankings, or saved-backtest comparison commands
193
+ - do not chain screening results into backtests automatically; ask for an explicit next step when needed
194
+ - use `--json` when another step needs the full saved backtest response or trade history
195
+
153
196
  ## Analyze a theoretical composition
154
197
 
155
198
  Create a holding with target weights, then run holding metrics on its id.