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

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.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/cli/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAEb,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAA8B,MAAM,aAAa,CAAC;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,8BAA8B;IAC7C,UAAU,EAAE,YAAY,CAAC;IACzB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,wBAAsB,sBAAsB,CAC1C,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,eAAe,CAAC,CAU1B;AAED,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EACvE,OAAO,EAAE,8BAA8B,+DAyBxC;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,QAAQ,CAgElE"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/cli/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAEb,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAA8B,MAAM,aAAa,CAAC;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,8BAA8B;IAC7C,UAAU,EAAE,YAAY,CAAC;IACzB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,wBAAsB,sBAAsB,CAC1C,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,eAAe,CAAC,CAU1B;AAED,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EACvE,OAAO,EAAE,8BAA8B,+DAyBxC;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,QAAQ,CAmElE"}
@@ -50,7 +50,10 @@ export function mapCliDeskHttpError(error) {
50
50
  return createHttpValidationError(error, detail);
51
51
  }
52
52
  if (error.status === 429) {
53
- return new CliError("rate_limited", detail ?? "Rate limit exceeded. Wait before retrying.", buildHttpErrorOptions(error, "backend"));
53
+ return new CliError("rate_limited", detail ?? "Rate limit exceeded. Wait before retrying.", {
54
+ ...buildHttpErrorOptions(error, "backend"),
55
+ retryAfterSeconds: resolveRetryAfterSeconds(error.body),
56
+ });
54
57
  }
55
58
  if (detail) {
56
59
  return new CliError(error.status >= 502 && error.status <= 504
@@ -115,6 +118,29 @@ function resolveObjectMessage(value) {
115
118
  const message = value.message;
116
119
  return typeof message === "string" && message.trim() ? message : null;
117
120
  }
121
+ function resolveRetryAfterSeconds(payload) {
122
+ for (const candidate of resolveErrorObjects(payload)) {
123
+ const value = candidate.retry_after_seconds;
124
+ if (typeof value === "number" && Number.isFinite(value) && value > 0) {
125
+ return Math.ceil(value);
126
+ }
127
+ }
128
+ return undefined;
129
+ }
130
+ function resolveErrorObjects(payload) {
131
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
132
+ return [];
133
+ }
134
+ const root = payload;
135
+ const objects = [root];
136
+ for (const key of ["detail", "error"]) {
137
+ const value = root[key];
138
+ if (value && typeof value === "object" && !Array.isArray(value)) {
139
+ objects.push(value);
140
+ }
141
+ }
142
+ return objects;
143
+ }
118
144
  function formatValidationDetail(value) {
119
145
  if (!value || typeof value !== "object" || Array.isArray(value)) {
120
146
  return null;
@@ -7,6 +7,7 @@ export interface CliErrorOptions extends ErrorOptions {
7
7
  status?: number;
8
8
  path?: string;
9
9
  requestId?: string;
10
+ retryAfterSeconds?: number;
10
11
  }
11
12
  export interface CliErrorPayload {
12
13
  ok: false;
@@ -18,6 +19,7 @@ export interface CliErrorPayload {
18
19
  status?: number;
19
20
  path?: string;
20
21
  request_id?: string;
22
+ retry_after_seconds?: number;
21
23
  };
22
24
  }
23
25
  export declare class CliError extends Error {
@@ -27,6 +29,7 @@ export declare class CliError extends Error {
27
29
  readonly status?: number;
28
30
  readonly path?: string;
29
31
  readonly requestId?: string;
32
+ readonly retryAfterSeconds?: number;
30
33
  constructor(code: CliErrorCode, message: string, options: CliErrorOptions);
31
34
  }
32
35
  export declare function createCliValidationError(message: string): CliError;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/cli/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,4MAYlB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5D,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,SAAS,GACT,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,YAAY,CAAC;AAEjB,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,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C;IACnC,SAAgB,iBAAiB,CAAC,EAAE,MAAM,CAAC;gBAE/B,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe;CAW1E;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAIlE;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAI9D;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAIpE;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAItE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAqC1D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAEpE;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAM7D;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,QAAQ,GAAG,eAAe,CA4BrE"}
@@ -18,6 +18,7 @@ export class CliError extends Error {
18
18
  status;
19
19
  path;
20
20
  requestId;
21
+ retryAfterSeconds;
21
22
  constructor(code, message, options) {
22
23
  super(message, options);
23
24
  this.name = "CliError";
@@ -27,6 +28,7 @@ export class CliError extends Error {
27
28
  this.status = options.status;
28
29
  this.path = options.path;
29
30
  this.requestId = options.requestId;
31
+ this.retryAfterSeconds = options.retryAfterSeconds;
30
32
  }
31
33
  }
32
34
  export function createCliValidationError(message) {
@@ -85,6 +87,9 @@ export function shouldEmitJsonError(argv) {
85
87
  return argv.includes("--json");
86
88
  }
87
89
  export function formatCliErrorMessage(error) {
90
+ if (error.code === "rate_limited" && error.retryAfterSeconds !== undefined) {
91
+ return `[${error.code}] ${error.message} Tente novamente em ${error.retryAfterSeconds}s.`;
92
+ }
88
93
  return `[${error.code}] ${error.message}`;
89
94
  }
90
95
  export function buildCliErrorPayload(error) {
@@ -106,6 +111,9 @@ export function buildCliErrorPayload(error) {
106
111
  if (error.requestId !== undefined) {
107
112
  payload.error.request_id = error.requestId;
108
113
  }
114
+ if (error.retryAfterSeconds !== undefined) {
115
+ payload.error.retry_after_seconds = error.retryAfterSeconds;
116
+ }
109
117
  return payload;
110
118
  }
111
119
  function isCommanderError(error) {
@@ -11,6 +11,9 @@ export interface BacktestsStrategiesCommandOptions {
11
11
  export interface BacktestsInfoCommandOptions {
12
12
  json?: boolean;
13
13
  }
14
+ export interface BacktestsGetCommandOptions {
15
+ json?: boolean;
16
+ }
14
17
  export interface BacktestsRunCommandOptions {
15
18
  timeframe?: string;
16
19
  from?: string;
@@ -77,9 +80,54 @@ export interface ScorePercentiles {
77
80
  percentile_75: number | null;
78
81
  percentile_95: number | null;
79
82
  }
83
+ export interface BacktestDetailResponse {
84
+ [key: string]: JsonValue;
85
+ id: number;
86
+ origin: string | null;
87
+ asset_id: number;
88
+ timeframe_id: string;
89
+ batch_id: number | null;
90
+ start_date: string;
91
+ end_date: string;
92
+ initial_capital: number;
93
+ fixed_capital: boolean | null;
94
+ num_operations: number;
95
+ num_gains: number | null;
96
+ pct_gains: number;
97
+ avg_gains: number | null;
98
+ avg_losses: number | null;
99
+ avg_candles: number | null;
100
+ pct_profit: number;
101
+ profit_factor: number | null;
102
+ drawdown: number;
103
+ ev: number;
104
+ trade_history: JsonValue[];
105
+ best_win_streak: number | null;
106
+ worst_loss_streak: number | null;
107
+ created_at: string;
108
+ is_favorite: boolean;
109
+ max_risk: number | null;
110
+ ticker: string;
111
+ type: string;
112
+ strategy_id: string;
113
+ setup_id: number;
114
+ parameters: Record<string, JsonValue>;
115
+ alert_id: number | null;
116
+ alert_status: string | null;
117
+ can_monitor: boolean;
118
+ score: number | null;
119
+ score_percentiles: ScorePercentiles | null;
120
+ suspicious: boolean;
121
+ }
122
+ export interface BacktestGetResponse {
123
+ [key: string]: JsonValue;
124
+ ok: boolean;
125
+ backtest: BacktestDetailResponse;
126
+ }
80
127
  export interface SaveBacktestResponse {
81
128
  [key: string]: JsonValue;
82
129
  id: number | null;
130
+ origin: string | null;
83
131
  setup_id: number;
84
132
  timeframe_id: string;
85
133
  strategy_id: string;
@@ -122,11 +170,14 @@ type JsonRecord = {
122
170
  export declare function registerBacktestsCommands(program: Command, context?: BacktestsCommandContext): void;
123
171
  export declare function runBacktestsStrategiesCommand(options: BacktestsStrategiesCommandOptions, context?: BacktestsCommandContext): Promise<void>;
124
172
  export declare function runBacktestsInfoCommand(strategyId: string, options: BacktestsInfoCommandOptions, context?: BacktestsCommandContext): Promise<void>;
173
+ export declare function runBacktestsGetCommand(backtestId: string, options: BacktestsGetCommandOptions, context?: BacktestsCommandContext): Promise<void>;
125
174
  export declare function runBacktestsRunCommand(strategyId: string, ticker: string, options: BacktestsRunCommandOptions, context?: BacktestsCommandContext): Promise<void>;
126
175
  export declare function buildBacktestsInfoInput(strategyId: string): JsonRecord;
176
+ export declare function buildBacktestsGetInput(backtestId: string): JsonRecord;
127
177
  export declare function buildBacktestsRunInput(strategyId: string, ticker: string, options: BacktestsRunCommandOptions): JsonRecord;
128
178
  export declare function formatBacktestStrategiesHuman(data: BacktestStrategiesResponse, theme?: import("../cli/terminal.js").TerminalTheme): string;
129
179
  export declare function formatBacktestStrategyHuman(data: BacktestStrategyResponse, theme?: import("../cli/terminal.js").TerminalTheme): string;
130
180
  export declare function formatBacktestRunHuman(data: BacktestRunResponse, theme?: import("../cli/terminal.js").TerminalTheme): string;
181
+ export declare function formatBacktestGetHuman(data: BacktestGetResponse, theme?: import("../cli/terminal.js").TerminalTheme): string;
131
182
  export {};
132
183
  //# sourceMappingURL=backtests.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"backtests.d.ts","sourceRoot":"","sources":["../../src/commands/backtests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,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AAC,IAAI,CAAC,CAgBf;AAED,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,0BAA0B,EACnC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,0BAA0B,EACnC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAItE;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAIrE;AAED,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,0BAA0B,GAClC,UAAU,CAoCZ;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,0BAA0B,EAChC,KAAK,6CAAsC,GAC1C,MAAM,CAsBR;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,wBAAwB,EAC9B,KAAK,6CAAsC,GAC1C,MAAM,CAqCR;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,mBAAmB,EACzB,KAAK,6CAAsC,GAC1C,MAAM,CAgDR;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,mBAAmB,EACzB,KAAK,6CAAsC,GAC1C,MAAM,CA4CR"}
@@ -20,6 +20,14 @@ export function registerBacktestsCommands(program, context = {}) {
20
20
  .action(async (strategyId, options) => {
21
21
  await runBacktestsInfoCommand(strategyId, options, context);
22
22
  });
23
+ backtestsCommand
24
+ .command("get")
25
+ .description("Mostra um backtest salvo por ID")
26
+ .argument("<backtest-id>", "ID do backtest")
27
+ .option("--json", "Exibe saída JSON")
28
+ .action(async (backtestId, options) => {
29
+ await runBacktestsGetCommand(backtestId, options, context);
30
+ });
23
31
  backtestsCommand
24
32
  .command("run")
25
33
  .description("Executa e salva um backtest para o usuário autenticado")
@@ -67,6 +75,21 @@ export async function runBacktestsInfoCommand(strategyId, options, context = {})
67
75
  }
68
76
  stdout.write(`${formatBacktestStrategyHuman(response.data, theme)}\n`);
69
77
  }
78
+ export async function runBacktestsGetCommand(backtestId, options, context = {}) {
79
+ const stdout = context.io?.stdout ?? process.stdout;
80
+ const theme = createTerminalTheme(stdout, context.env ?? process.env);
81
+ const response = await invokeCliCapability({
82
+ capability: "backtests.get",
83
+ input: buildBacktestsGetInput(backtestId),
84
+ env: context.env,
85
+ fetch: context.fetch,
86
+ });
87
+ if (options.json) {
88
+ stdout.write(`${JSON.stringify(response.data, null, 2)}\n`);
89
+ return;
90
+ }
91
+ stdout.write(`${formatBacktestGetHuman(response.data, theme)}\n`);
92
+ }
70
93
  export async function runBacktestsRunCommand(strategyId, ticker, options, context = {}) {
71
94
  const stdout = context.io?.stdout ?? process.stdout;
72
95
  const theme = createTerminalTheme(stdout, context.env ?? process.env);
@@ -87,6 +110,11 @@ export function buildBacktestsInfoInput(strategyId) {
87
110
  strategy_id: normalizeStrategyId(strategyId),
88
111
  };
89
112
  }
113
+ export function buildBacktestsGetInput(backtestId) {
114
+ return {
115
+ backtest_id: parsePositiveIntegerArgument(backtestId, "ID do backtest"),
116
+ };
117
+ }
90
118
  export function buildBacktestsRunInput(strategyId, ticker, options) {
91
119
  const input = {
92
120
  strategy_id: normalizeStrategyId(strategyId),
@@ -200,6 +228,42 @@ export function formatBacktestRunHuman(data, theme = createTerminalTheme(process
200
228
  }
201
229
  return lines.join("\n");
202
230
  }
231
+ export function formatBacktestGetHuman(data, theme = createTerminalTheme(process.stdout)) {
232
+ const backtest = data.backtest;
233
+ const lines = [
234
+ theme.label("Backtest"),
235
+ "",
236
+ `${theme.bold(backtest.ticker)} ${theme.dim(`- ${backtest.strategy_id}`)}`,
237
+ `${theme.label("ID:")} ${backtest.id}`,
238
+ `${theme.label("Origem:")} ${formatBacktestOrigin(backtest.origin)}`,
239
+ `${theme.label("Setup:")} ${backtest.setup_id}`,
240
+ `${theme.label("Timeframe:")} ${backtest.timeframe_id}`,
241
+ `${theme.label("Período:")} ${formatDatePtBr(backtest.start_date)} a ${formatDatePtBr(backtest.end_date)}`,
242
+ `${theme.label("Capital inicial:")} ${formatCurrency(backtest.initial_capital)}`,
243
+ "",
244
+ `${theme.label("Retorno total:")} ${formatPercentage(backtest.pct_profit)}`,
245
+ `${theme.label("Drawdown:")} ${formatPercentage(backtest.drawdown)}`,
246
+ `${theme.label("EV:")} ${formatPercentage(backtest.ev)}`,
247
+ `${theme.label("Taxa de acerto:")} ${formatPercentage(backtest.pct_gains)}`,
248
+ `${theme.label("Operações:")} ${formatInteger(backtest.num_operations)}`,
249
+ `${theme.label("Profit factor:")} ${formatNullableNumber(backtest.profit_factor)}`,
250
+ ];
251
+ if (backtest.score !== null) {
252
+ lines.push(`${theme.label("Score:")} ${formatNumber(backtest.score)}`);
253
+ }
254
+ if (Object.keys(backtest.parameters).length > 0) {
255
+ lines.push(`${theme.label("Parâmetros:")} ${formatParameterRecord(backtest.parameters)}`);
256
+ }
257
+ if (backtest.suspicious) {
258
+ lines.push("");
259
+ lines.push(theme.warning("Resultado marcado como suspeito pelo backend."));
260
+ }
261
+ if (backtest.trade_history.length > 0) {
262
+ lines.push("");
263
+ lines.push("Use --json para inspecionar o histórico completo de operações.");
264
+ }
265
+ return lines.join("\n");
266
+ }
203
267
  function collectRepeatedOption(value, previous) {
204
268
  return [...previous, value];
205
269
  }
@@ -291,6 +355,13 @@ function normalizeTicker(ticker) {
291
355
  }
292
356
  return normalized;
293
357
  }
358
+ function parsePositiveIntegerArgument(value, label) {
359
+ const parsed = Number(value);
360
+ if (!Number.isInteger(parsed) || parsed <= 0) {
361
+ throw createCliValidationError(`${label} deve ser um inteiro positivo.`);
362
+ }
363
+ return parsed;
364
+ }
294
365
  function appendStrategyGroup(lines, theme, title, strategies) {
295
366
  lines.push("");
296
367
  lines.push(`${theme.label(title)} ${theme.dim(`(${formatInteger(strategies.length)})`)}`);
@@ -410,6 +481,15 @@ function formatJsonScalar(value) {
410
481
  function formatScalar(value) {
411
482
  return typeof value === "string" ? JSON.stringify(value) : String(value);
412
483
  }
484
+ function formatBacktestOrigin(origin) {
485
+ if (!origin) {
486
+ return "não informado";
487
+ }
488
+ if (origin === "tool") {
489
+ return "ferramenta";
490
+ }
491
+ return origin;
492
+ }
413
493
  function formatDatePtBr(value) {
414
494
  const match = /^(\d{4})-(\d{2})-(\d{2})/.exec(value);
415
495
  if (!match) {
@@ -60,6 +60,40 @@ export declare const backtestCapabilities: readonly [{
60
60
  readonly title: "Get backtest strategy info";
61
61
  };
62
62
  readonly outputModes: readonly ["json", "human"];
63
+ }, {
64
+ readonly id: "backtests.get";
65
+ readonly kind: "read";
66
+ readonly visibility: readonly ["cli", "opencode"];
67
+ readonly description: "Retorna um backtest salvo por ID, respeitando o usuário autenticado.";
68
+ readonly http: {
69
+ readonly method: "POST";
70
+ readonly path: "/api/desk/tools/backtests/get";
71
+ readonly inputMode: "json_body";
72
+ readonly schemas: {
73
+ readonly request: "BacktestGetRequest";
74
+ readonly response: "BacktestGetResponse";
75
+ };
76
+ };
77
+ readonly cli: {
78
+ readonly group: "backtests";
79
+ readonly command: "get";
80
+ readonly summary: "Mostra um backtest salvo por ID.";
81
+ readonly positional: readonly [{
82
+ readonly kind: "positional";
83
+ readonly name: "backtest_id";
84
+ readonly type: "integer";
85
+ readonly required: true;
86
+ readonly placeholder: "ID";
87
+ readonly description: "ID do backtest salvo.";
88
+ }];
89
+ readonly options: readonly [];
90
+ readonly examples: readonly ["quantbrasil backtests get 123"];
91
+ };
92
+ readonly tool: {
93
+ readonly name: "qb_backtests_get";
94
+ readonly title: "Get backtest";
95
+ };
96
+ readonly outputModes: readonly ["json", "human"];
63
97
  }, {
64
98
  readonly id: "backtests.run";
65
99
  readonly kind: "mutation";
@@ -1 +1 @@
1
- {"version":3,"file":"backtests.d.ts","sourceRoot":"","sources":["../../src/capabilities/backtests.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB,6DAS1B,CAAC;AAEX,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkMmB,CAAC"}
1
+ {"version":3,"file":"backtests.d.ts","sourceRoot":"","sources":["../../src/capabilities/backtests.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB,6DAS1B,CAAC;AAWX,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+NmB,CAAC"}
@@ -9,6 +9,14 @@ export const backtestTimeframeValues = [
9
9
  "D1",
10
10
  "W1",
11
11
  ];
12
+ const backtestIdPositional = {
13
+ kind: "positional",
14
+ name: "backtest_id",
15
+ type: "integer",
16
+ required: true,
17
+ placeholder: "ID",
18
+ description: "ID do backtest salvo.",
19
+ };
12
20
  export const backtestCapabilities = [
13
21
  {
14
22
  id: "backtests.strategies",
@@ -75,6 +83,34 @@ export const backtestCapabilities = [
75
83
  },
76
84
  outputModes: standardOutputModes,
77
85
  },
86
+ {
87
+ id: "backtests.get",
88
+ kind: "read",
89
+ visibility: publicRuntimeVisibility,
90
+ description: "Retorna um backtest salvo por ID, respeitando o usuário autenticado.",
91
+ http: {
92
+ method: "POST",
93
+ path: "/api/desk/tools/backtests/get",
94
+ inputMode: "json_body",
95
+ schemas: {
96
+ request: "BacktestGetRequest",
97
+ response: "BacktestGetResponse",
98
+ },
99
+ },
100
+ cli: {
101
+ group: "backtests",
102
+ command: "get",
103
+ summary: "Mostra um backtest salvo por ID.",
104
+ positional: [backtestIdPositional],
105
+ options: [],
106
+ examples: ["quantbrasil backtests get 123"],
107
+ },
108
+ tool: {
109
+ name: "qb_backtests_get",
110
+ title: "Get backtest",
111
+ },
112
+ outputModes: standardOutputModes,
113
+ },
78
114
  {
79
115
  id: "backtests.run",
80
116
  kind: "mutation",
@@ -251,6 +251,40 @@ export declare const capabilityRegistry: readonly [{
251
251
  readonly title: "Get backtest strategy info";
252
252
  };
253
253
  readonly outputModes: readonly ["json", "human"];
254
+ }, {
255
+ readonly id: "backtests.get";
256
+ readonly kind: "read";
257
+ readonly visibility: readonly ["cli", "opencode"];
258
+ readonly description: "Retorna um backtest salvo por ID, respeitando o usuário autenticado.";
259
+ readonly http: {
260
+ readonly method: "POST";
261
+ readonly path: "/api/desk/tools/backtests/get";
262
+ readonly inputMode: "json_body";
263
+ readonly schemas: {
264
+ readonly request: "BacktestGetRequest";
265
+ readonly response: "BacktestGetResponse";
266
+ };
267
+ };
268
+ readonly cli: {
269
+ readonly group: "backtests";
270
+ readonly command: "get";
271
+ readonly summary: "Mostra um backtest salvo por ID.";
272
+ readonly positional: readonly [{
273
+ readonly kind: "positional";
274
+ readonly name: "backtest_id";
275
+ readonly type: "integer";
276
+ readonly required: true;
277
+ readonly placeholder: "ID";
278
+ readonly description: "ID do backtest salvo.";
279
+ }];
280
+ readonly options: readonly [];
281
+ readonly examples: readonly ["quantbrasil backtests get 123"];
282
+ };
283
+ readonly tool: {
284
+ readonly name: "qb_backtests_get";
285
+ readonly title: "Get backtest";
286
+ };
287
+ readonly outputModes: readonly ["json", "human"];
254
288
  }, {
255
289
  readonly id: "backtests.run";
256
290
  readonly kind: "mutation";
@@ -1587,6 +1621,40 @@ export declare function getCapabilityById(id: CapabilityId): {
1587
1621
  readonly title: "Get backtest strategy info";
1588
1622
  };
1589
1623
  readonly outputModes: readonly ["json", "human"];
1624
+ } | {
1625
+ readonly id: "backtests.get";
1626
+ readonly kind: "read";
1627
+ readonly visibility: readonly ["cli", "opencode"];
1628
+ readonly description: "Retorna um backtest salvo por ID, respeitando o usuário autenticado.";
1629
+ readonly http: {
1630
+ readonly method: "POST";
1631
+ readonly path: "/api/desk/tools/backtests/get";
1632
+ readonly inputMode: "json_body";
1633
+ readonly schemas: {
1634
+ readonly request: "BacktestGetRequest";
1635
+ readonly response: "BacktestGetResponse";
1636
+ };
1637
+ };
1638
+ readonly cli: {
1639
+ readonly group: "backtests";
1640
+ readonly command: "get";
1641
+ readonly summary: "Mostra um backtest salvo por ID.";
1642
+ readonly positional: readonly [{
1643
+ readonly kind: "positional";
1644
+ readonly name: "backtest_id";
1645
+ readonly type: "integer";
1646
+ readonly required: true;
1647
+ readonly placeholder: "ID";
1648
+ readonly description: "ID do backtest salvo.";
1649
+ }];
1650
+ readonly options: readonly [];
1651
+ readonly examples: readonly ["quantbrasil backtests get 123"];
1652
+ };
1653
+ readonly tool: {
1654
+ readonly name: "qb_backtests_get";
1655
+ readonly title: "Get backtest";
1656
+ };
1657
+ readonly outputModes: readonly ["json", "human"];
1590
1658
  } | {
1591
1659
  readonly id: "backtests.run";
1592
1660
  readonly kind: "mutation";
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/capabilities/registry.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEjD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantbrasil/cli",
3
- "version": "0.1.0-beta.14",
3
+ "version": "0.1.0-beta.15",
4
4
  "type": "module",
5
5
  "description": "Public QuantBrasil CLI for deterministic operations",
6
6
  "repository": {
@@ -41,8 +41,8 @@
41
41
  "typescript": "^5.3.3",
42
42
  "vitest": "^3.2.4",
43
43
  "@repo/core": "0.0.0",
44
- "@repo/typescript-config": "0.0.0",
45
- "@repo/eslint-config": "0.0.0"
44
+ "@repo/eslint-config": "0.0.0",
45
+ "@repo/typescript-config": "0.0.0"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "pnpm --filter @repo/core build && pnpm run clean && tsc && node scripts/vendor-core.mjs",
@@ -31,7 +31,7 @@ Use this skill when the user asks for market or investing data/actions that Quan
31
31
  - watchlist details and changes: `quantbrasil watchlists ...`
32
32
  - holding details and historical return: `quantbrasil holdings ...`
33
33
  - indicator screening over saved universes: `quantbrasil screening universes|indicators|run ...`
34
- - individual backtests: `quantbrasil backtests strategies|info|run ...`
34
+ - individual backtests: `quantbrasil backtests strategies|info|get|run ...`
35
35
  - pair cointegration: `quantbrasil cointegration pair <base_asset> <comparison_asset>`
36
36
  - holding metrics: `quantbrasil holdings historical-return|beta|var ...`
37
37
  - Use `--json` when output will be parsed by agent or script
@@ -13,6 +13,8 @@ quantbrasil backtests strategies
13
13
  quantbrasil backtests strategies --json
14
14
  quantbrasil backtests info ifr2
15
15
  quantbrasil backtests info ifr2 --json
16
+ quantbrasil backtests get 123
17
+ quantbrasil backtests get 123 --json
16
18
  quantbrasil backtests run ifr2 PETR4 --timeframe D1 --from 2025-01-01 --to 2026-01-01
17
19
  quantbrasil backtests run ifr2 PRIO3 --timeframe D1 --param rsi=15
18
20
  quantbrasil backtests run ifr2 PETR4 --timeframe D1 --param rsi=30 --param window=2 --json
@@ -23,8 +25,9 @@ quantbrasil backtests run ifr2 PETR4 --timeframe D1 --param rsi=30 --param windo
23
25
  1. Use `backtests strategies` when the strategy id is unknown.
24
26
  2. Use `backtests info <strategy-id>` before changing parameters.
25
27
  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
+ 4. Use `backtests get <backtest-id>` when the user asks to retrieve a saved backtest by ID.
29
+ 5. Use `backtests run <strategy-id> <ticker>` for one strategy and one asset.
30
+ 6. Add `--json` to `backtests info` when another agent or script needs defaults; add `--json` to `backtests get` or `backtests run` when it needs metrics, parameters, or trade history.
28
31
 
29
32
  If the user says "IFR2 on PRIO3 with value 15", map "value" to the IFR2
30
33
  threshold parameter and run:
@@ -94,7 +97,7 @@ Time controls:
94
97
 
95
98
  - `is_day_trade`: forces intraday behavior when the strategy supports it.
96
99
  - `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.
100
+ - `close_time_limit`: latest allowed close time for the intraday entry candle, formatted `HH:MM`; blocks new entries after the desired session cutoff but is not a timed exit order.
98
101
  - `entry_time`: fixed entry time for by-time strategies.
99
102
  - `exit_time`: fixed exit time for by-time strategies.
100
103
 
@@ -181,6 +181,8 @@ quantbrasil backtests strategies
181
181
  quantbrasil backtests strategies --json
182
182
  quantbrasil backtests info ifr2
183
183
  quantbrasil backtests info long-rsi --json
184
+ quantbrasil backtests get 123
185
+ quantbrasil backtests get 123 --json
184
186
  quantbrasil backtests run ifr2 PETR4 --timeframe D1 --from 2025-01-01 --to 2026-01-01
185
187
  quantbrasil backtests run ifr2 PETR4 --timeframe D1 --param rsi=30 --param window=2
186
188
  quantbrasil backtests run long-rsi VALE3 --timeframe D1 --params-json '{"entry":"rolling_avg","rollingAvgType":"simple","rollingAvgWindow":20}'
@@ -191,6 +193,7 @@ Rules:
191
193
 
192
194
  - use `backtests strategies` to discover strategy ids
193
195
  - use `backtests info <strategy-id>` to inspect motivation, selection guidance, timeframe guidance, accepted parameters, defaults, value hints, parameter guidance, types, options, and allowed timeframes
196
+ - use `backtests get <backtest-id>` to retrieve a saved backtest visible to the authenticated API key
194
197
  - use `backtests run <strategy-id> <ticker>` for one strategy and one asset
195
198
  - use `--timeframe` unless `backtests info` says the strategy has an internal timeframe
196
199
  - `--param key=value` can be repeated; `--params-json` accepts an object of parameters
@@ -17,7 +17,7 @@ Current guidance uses backend qualitative classes only:
17
17
  - `screening universes` is a discovery path for saved screening universes
18
18
  - `screening indicators` is a discovery path for supported screening JSON
19
19
  - `screening run` is a heavy read and should be targeted to one selected universe
20
- - `backtests strategies` and `backtests info` are discovery paths
20
+ - `backtests strategies`, `backtests info`, and `backtests get` are standard read paths
21
21
  - `backtests run` is heavy and should be targeted to one selected strategy and ticker
22
22
  - `cointegration pair` is a heavy read and should be targeted to one explicit pair
23
23
  - `rankings return` is a heavy read and should be targeted to one explicit system ranking and date range
@@ -13,6 +13,7 @@
13
13
  - holding return, beta, risk, VaR, or comparison → `holdings historical-return|beta|var`
14
14
  - indicator screening over saved asset sets → `screening universes`, `screening indicators` when needed, then `screening run`
15
15
  - one strategy backtest for one explicit asset → `backtests strategies`, `backtests info`, then `backtests run`
16
+ - retrieve one saved backtest by ID → `backtests get`
16
17
  - cointegration or Long & Short between two explicit assets → `cointegration pair`
17
18
 
18
19
  ## Find supported ticker, then get price
@@ -177,6 +178,7 @@ explicit asset.
177
178
  ```bash
178
179
  quantbrasil backtests strategies
179
180
  quantbrasil backtests info ifr2
181
+ quantbrasil backtests get 123
180
182
  quantbrasil backtests run ifr2 PETR4 --timeframe D1 --from 2025-01-01 --to 2026-01-01
181
183
  quantbrasil backtests run ifr2 PRIO3 --timeframe D1 --param rsi=15
182
184
  quantbrasil backtests run ifr2 PETR4 --timeframe D1 --param rsi=30 --param window=2 --json
@@ -186,6 +188,7 @@ Rules:
186
188
 
187
189
  - use `backtests strategies` if the user names a strategy informally
188
190
  - use `backtests info` before setting or explaining parameters
191
+ - use `backtests get` when the user asks for an existing saved backtest by ID
189
192
  - read `selection_guidance`, `timeframe_guidance`, defaults, `value_hint`, and `agent_guidance` before choosing overrides
190
193
  - for IFR2, a generic "value" usually maps to `rsi`; for example "IFR2 on PRIO3 with value 15" means `--param rsi=15`
191
194
  - run one strategy and one asset at a time