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

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.
package/README.md CHANGED
@@ -78,6 +78,7 @@ quantbrasil rankings current --system momentum-90d --top 20
78
78
  quantbrasil rankings current --system magic-formula --top 10
79
79
  quantbrasil rankings current --system low-risk --top 30
80
80
  quantbrasil rankings current --id 123 --top 20
81
+ quantbrasil rankings return --system magic-formula --from 2024-01-18 --to 2026-05-25 --top 20 --rebalance quarterly
81
82
  quantbrasil screening universes
82
83
  quantbrasil screening indicators
83
84
  quantbrasil screening run --system acoes-mais-liquidas --query-file ./screening.json
@@ -92,14 +92,29 @@ function resolveErrorDetail(payload) {
92
92
  return validationDetails.join("; ");
93
93
  }
94
94
  }
95
+ const nestedDetailMessage = resolveObjectMessage(detail);
96
+ if (nestedDetailMessage) {
97
+ return nestedDetailMessage;
98
+ }
95
99
  if (typeof message === "string" && message.trim()) {
96
100
  return message;
97
101
  }
98
102
  if (typeof error === "string" && error.trim()) {
99
103
  return error;
100
104
  }
105
+ const nestedErrorMessage = resolveObjectMessage(error);
106
+ if (nestedErrorMessage) {
107
+ return nestedErrorMessage;
108
+ }
101
109
  return null;
102
110
  }
111
+ function resolveObjectMessage(value) {
112
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
113
+ return null;
114
+ }
115
+ const message = value.message;
116
+ return typeof message === "string" && message.trim() ? message : null;
117
+ }
103
118
  function formatValidationDetail(value) {
104
119
  if (!value || typeof value !== "object" || Array.isArray(value)) {
105
120
  return null;
@@ -4,7 +4,7 @@ import { runCointegrationPairCommand } from "../commands/cointegration.js";
4
4
  import { runMarketAssetsCommand, runMarketPriceCommand } from "../commands/market.js";
5
5
  import { runInitCommand } from "../commands/init.js";
6
6
  import { runHoldingCreateCommand, runHoldingBetaCommand, runHoldingGetCommand, runHoldingHistoricalReturnCommand, runHoldingListCommand, runHoldingRenameCommand, runHoldingSetPositionsCommand, runHoldingSetTargetsCommand, runHoldingVarCommand, runWatchlistAddAssetsCommand, runWatchlistCreateCommand, runWatchlistGetCommand, runWatchlistListCommand, runWatchlistRemoveAssetsCommand, runWatchlistRenameCommand } from "../commands/portfolios.js";
7
- import { runRankingsCurrentCommand, runRankingsListCommand } from "../commands/rankings.js";
7
+ import { runRankingsCurrentCommand, runRankingsListCommand, runRankingsReturnCommand } from "../commands/rankings.js";
8
8
  import { runScreeningIndicatorsCommand, runScreeningRunCommand, runScreeningUniversesCommand } from "../commands/screening.js";
9
9
  import { runSkillsInstallCommand } from "../commands/skills.js";
10
10
  import { runStatusCommand } from "../commands/status.js";
@@ -31,7 +31,7 @@ export { runAssetOverviewCommand } from "../commands/assets.js";
31
31
  export { runCapabilitiesCommand, runStatusCommand };
32
32
  export { runInitCommand };
33
33
  export { runMarketAssetsCommand, runMarketPriceCommand };
34
- export { runRankingsCurrentCommand, runRankingsListCommand };
34
+ export { runRankingsCurrentCommand, runRankingsListCommand, runRankingsReturnCommand, };
35
35
  export { runCointegrationPairCommand };
36
36
  export { runScreeningIndicatorsCommand, runScreeningRunCommand, runScreeningUniversesCommand, };
37
37
  export { runHoldingBetaCommand, runHoldingCreateCommand, runHoldingGetCommand, runHoldingHistoricalReturnCommand, runHoldingListCommand, runHoldingRenameCommand, runHoldingSetPositionsCommand, runHoldingSetTargetsCommand, runHoldingVarCommand, runWatchlistAddAssetsCommand, runWatchlistCreateCommand, runWatchlistGetCommand, runWatchlistListCommand, runWatchlistRemoveAssetsCommand, runWatchlistRenameCommand, };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,OAAO,EACL,KAAK,qBAAqB,EAE1B,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGL,2BAA2B,EAC5B,MAAM,8BAA8B,CAAC;AACtC,OA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,aAAc,SAAQ,iBAAiB;IACtD,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAsFzE;AAeD,wBAAsB,GAAG,CACvB,IAAI,WAAe,EACnB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAoCD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,CAAC;AACzD,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,GACzB,CAAC;AACF,OAAO,EAAE,2BAA2B,EAAE,CAAC;AACvC,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,4BAA4B,GAC7B,CAAC;AACF,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,iCAAiC,EACjC,qBAAqB,EACrB,uBAAuB,EACvB,6BAA6B,EAC7B,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,EAC5B,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,+BAA+B,EAC/B,yBAAyB,GAC1B,CAAC;AACF,OAAO,EAAE,uBAAuB,EAAE,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
package/dist/cli/index.js CHANGED
@@ -7,7 +7,7 @@ import { registerCointegrationCommands, runCointegrationPairCommand, } from "../
7
7
  import { registerMarketCommands, runMarketAssetsCommand, runMarketPriceCommand, } from "../commands/market.js";
8
8
  import { registerInitCommand, runInitCommand, } from "../commands/init.js";
9
9
  import { registerPortfoliosCommands, runHoldingCreateCommand, runHoldingBetaCommand, runHoldingGetCommand, runHoldingHistoricalReturnCommand, runHoldingListCommand, runHoldingRenameCommand, runHoldingSetPositionsCommand, runHoldingSetTargetsCommand, runHoldingVarCommand, runWatchlistAddAssetsCommand, runWatchlistCreateCommand, runWatchlistGetCommand, runWatchlistListCommand, runWatchlistRemoveAssetsCommand, runWatchlistRenameCommand, } from "../commands/portfolios.js";
10
- import { registerRankingsCommands, runRankingsCurrentCommand, runRankingsListCommand, } from "../commands/rankings.js";
10
+ import { registerRankingsCommands, runRankingsCurrentCommand, runRankingsListCommand, runRankingsReturnCommand, } from "../commands/rankings.js";
11
11
  import { registerScreeningCommands, runScreeningIndicatorsCommand, runScreeningRunCommand, runScreeningUniversesCommand, } from "../commands/screening.js";
12
12
  import { registerSkillsCommands, runSkillsInstallCommand, } from "../commands/skills.js";
13
13
  import { registerStatusFlag, runStatusCommand, } from "../commands/status.js";
@@ -162,7 +162,7 @@ export { runAssetOverviewCommand } from "../commands/assets.js";
162
162
  export { runCapabilitiesCommand, runStatusCommand };
163
163
  export { runInitCommand };
164
164
  export { runMarketAssetsCommand, runMarketPriceCommand };
165
- export { runRankingsCurrentCommand, runRankingsListCommand };
165
+ export { runRankingsCurrentCommand, runRankingsListCommand, runRankingsReturnCommand, };
166
166
  export { runCointegrationPairCommand };
167
167
  export { runScreeningIndicatorsCommand, runScreeningRunCommand, runScreeningUniversesCommand, };
168
168
  export { runHoldingBetaCommand, runHoldingCreateCommand, runHoldingGetCommand, runHoldingHistoricalReturnCommand, runHoldingListCommand, runHoldingRenameCommand, runHoldingSetPositionsCommand, runHoldingSetTargetsCommand, runHoldingVarCommand, runWatchlistAddAssetsCommand, runWatchlistCreateCommand, runWatchlistGetCommand, runWatchlistListCommand, runWatchlistRemoveAssetsCommand, runWatchlistRenameCommand, };
@@ -14,6 +14,22 @@ export interface RankingsCurrentCommandOptions {
14
14
  top?: string;
15
15
  json?: boolean;
16
16
  }
17
+ export interface RankingsReturnCommandOptions {
18
+ system?: string;
19
+ from?: string;
20
+ to?: string;
21
+ top?: string;
22
+ rebalance?: string;
23
+ weight?: string;
24
+ indexFilter?: string;
25
+ json?: boolean;
26
+ }
27
+ export interface RankingReturnSimulationOut {
28
+ [key: string]: JsonValue;
29
+ supported: boolean;
30
+ earliest_start_date: string | null;
31
+ max_top_n: number | null;
32
+ }
17
33
  export interface RankingMetricOut {
18
34
  [key: string]: JsonValue;
19
35
  key: string;
@@ -31,6 +47,7 @@ export interface RankingDefinitionOut {
31
47
  metrics: RankingMetricOut[];
32
48
  latest_as_of: string | null;
33
49
  total_assets: number | null;
50
+ return_simulation: RankingReturnSimulationOut;
34
51
  }
35
52
  export interface RankingsListResponse {
36
53
  [key: string]: JsonValue;
@@ -66,6 +83,51 @@ export interface RankingCurrentResponse {
66
83
  count: number;
67
84
  rows: RankingCurrentRowOut[];
68
85
  }
86
+ export interface RankingReturnAssetAllocation {
87
+ [key: string]: JsonValue;
88
+ ticker: string;
89
+ weight: number;
90
+ ranking_position: number;
91
+ }
92
+ export interface RankingReturnRebalance {
93
+ [key: string]: JsonValue;
94
+ date: string;
95
+ portfolio: RankingReturnAssetAllocation[];
96
+ }
97
+ export interface RankingReturnAssetReturn {
98
+ [key: string]: JsonValue;
99
+ ticker: string;
100
+ return_value: number;
101
+ weight: number;
102
+ contribution: number;
103
+ }
104
+ export interface RankingReturnPeriodReturn {
105
+ [key: string]: JsonValue;
106
+ start_date: string;
107
+ end_date: string;
108
+ total_return: number;
109
+ asset_returns: RankingReturnAssetReturn[];
110
+ }
111
+ export interface RankingReturnResult {
112
+ [key: string]: JsonValue;
113
+ total_return: number;
114
+ annualized_return: number;
115
+ start_date: string;
116
+ end_date: string;
117
+ top_n: number;
118
+ rebalance_frequency: string;
119
+ rebalance_dates: RankingReturnRebalance[];
120
+ period_returns: RankingReturnPeriodReturn[];
121
+ ibov_return: number;
122
+ ibov_annualized_return: number;
123
+ }
124
+ export interface RankingReturnResponse {
125
+ [key: string]: JsonValue;
126
+ ok: boolean;
127
+ summary_markdown: string;
128
+ ranking: RankingDefinitionOut;
129
+ result: RankingReturnResult;
130
+ }
69
131
  export interface RankingsCommandContext extends CliInvokeContext {
70
132
  io?: RankingsCommandIO;
71
133
  }
@@ -75,8 +137,11 @@ type JsonRecord = {
75
137
  export declare function registerRankingsCommands(program: Command, context?: RankingsCommandContext): void;
76
138
  export declare function runRankingsListCommand(options: RankingsListCommandOptions, context?: RankingsCommandContext): Promise<void>;
77
139
  export declare function runRankingsCurrentCommand(options: RankingsCurrentCommandOptions, context?: RankingsCommandContext): Promise<void>;
140
+ export declare function runRankingsReturnCommand(options: RankingsReturnCommandOptions, context?: RankingsCommandContext): Promise<void>;
78
141
  export declare function buildRankingsCurrentInput(options: RankingsCurrentCommandOptions): JsonRecord;
142
+ export declare function buildRankingsReturnInput(options: RankingsReturnCommandOptions): JsonRecord;
79
143
  export declare function formatRankingsListHuman(data: RankingsListResponse, theme?: import("../cli/terminal.js").TerminalTheme): string;
80
144
  export declare function formatRankingCurrentHuman(data: RankingCurrentResponse, theme?: import("../cli/terminal.js").TerminalTheme): string;
145
+ export declare function formatRankingReturnHuman(data: RankingReturnResponse, theme?: import("../cli/terminal.js").TerminalTheme): string;
81
146
  export {};
82
147
  //# sourceMappingURL=rankings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rankings.d.ts","sourceRoot":"","sources":["../../src/commands/rankings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE9E,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,M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BAA6B,EACtC,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,4BAA4B,EACrC,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,6BAA6B,GACrC,UAAU,CAuBZ;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,4BAA4B,GACpC,UAAU,CA6BZ;AAED,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,oBAAoB,EAC1B,KAAK,6CAAsC,GAC1C,MAAM,CAaR;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,sBAAsB,EAC5B,KAAK,6CAAsC,GAC1C,MAAM,CAwCR;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,qBAAqB,EAC3B,KAAK,6CAAsC,GAC1C,MAAM,CA4BR"}
@@ -1,3 +1,4 @@
1
+ import { rankingReturnIndexFilterValues, rankingReturnRebalanceValues, rankingReturnWeightingValues, } from "../vendor/core/capabilities/index.js";
1
2
  import { invokeCliCapability } from "../cli/client.js";
2
3
  import { createCliValidationError } from "../cli/errors.js";
3
4
  import { createTerminalTheme } from "../cli/terminal.js";
@@ -22,6 +23,20 @@ export function registerRankingsCommands(program, context = {}) {
22
23
  .action(async (options) => {
23
24
  await runRankingsCurrentCommand(options, context);
24
25
  });
26
+ rankingsCommand
27
+ .command("return")
28
+ .description("Calcula o retorno histórico de um ranking do sistema")
29
+ .requiredOption("--system <slug>", "Slug do ranking do sistema")
30
+ .requiredOption("--from <date>", "Data inicial em AAAA-MM-DD")
31
+ .requiredOption("--to <date>", "Data final em AAAA-MM-DD")
32
+ .option("--top <n>", "Número de ativos em cada rebalanceamento", "20")
33
+ .requiredOption("--rebalance <frequency>", "Frequência: weekly, monthly, bimonthly, quarterly, semiannually ou annually")
34
+ .option("--weight <method>", "Método de ponderação", "equal")
35
+ .option("--index-filter <filter>", "Filtro: NONE, IBOV, IBX100 ou SMLL", "NONE")
36
+ .option("--json", "Exibe saída JSON")
37
+ .action(async (options) => {
38
+ await runRankingsReturnCommand(options, context);
39
+ });
25
40
  }
26
41
  export async function runRankingsListCommand(options, context = {}) {
27
42
  const stdout = context.io?.stdout ?? process.stdout;
@@ -52,6 +67,21 @@ export async function runRankingsCurrentCommand(options, context = {}) {
52
67
  }
53
68
  stdout.write(`${formatRankingCurrentHuman(response.data, theme)}\n`);
54
69
  }
70
+ export async function runRankingsReturnCommand(options, context = {}) {
71
+ const stdout = context.io?.stdout ?? process.stdout;
72
+ const theme = createTerminalTheme(stdout, context.env ?? process.env);
73
+ const response = await invokeCliCapability({
74
+ capability: "rankings.return",
75
+ input: buildRankingsReturnInput(options),
76
+ env: context.env,
77
+ fetch: context.fetch,
78
+ });
79
+ if (options.json) {
80
+ stdout.write(`${JSON.stringify(response.data, null, 2)}\n`);
81
+ return;
82
+ }
83
+ stdout.write(`${formatRankingReturnHuman(response.data, theme)}\n`);
84
+ }
55
85
  export function buildRankingsCurrentInput(options) {
56
86
  const hasId = options.id !== undefined;
57
87
  const hasSystem = options.system !== undefined;
@@ -69,6 +99,22 @@ export function buildRankingsCurrentInput(options) {
69
99
  }
70
100
  return input;
71
101
  }
102
+ export function buildRankingsReturnInput(options) {
103
+ const startDate = parseIsoDateOption(options.from, "--from");
104
+ const endDate = parseIsoDateOption(options.to, "--to");
105
+ if (startDate >= endDate) {
106
+ throw createCliValidationError("--from deve ser anterior a --to.");
107
+ }
108
+ return {
109
+ system_id: normalizeRequiredString(options.system, "--system"),
110
+ start_date: startDate,
111
+ end_date: endDate,
112
+ top_n: parseRankingReturnTopOption(options.top),
113
+ rebalance_frequency: parseEnumOption(options.rebalance, "--rebalance", rankingReturnRebalanceValues),
114
+ weighting_method: parseEnumOption(options.weight ?? "equal", "--weight", rankingReturnWeightingValues),
115
+ index_filter: parseEnumOption(options.indexFilter ?? "NONE", "--index-filter", rankingReturnIndexFilterValues),
116
+ };
117
+ }
72
118
  export function formatRankingsListHuman(data, theme = createTerminalTheme(process.stdout)) {
73
119
  const lines = [
74
120
  theme.label("Rankings"),
@@ -108,6 +154,33 @@ export function formatRankingCurrentHuman(data, theme = createTerminalTheme(proc
108
154
  lines.push(...formatRankingRows(data.rows, data.ranking.order_metric.label));
109
155
  return lines.join("\n");
110
156
  }
157
+ export function formatRankingReturnHuman(data, theme = createTerminalTheme(process.stdout)) {
158
+ const result = data.result;
159
+ const alpha = result.total_return - result.ibov_return;
160
+ const lines = [
161
+ theme.label("Retorno de ranking"),
162
+ "",
163
+ `${theme.bold(data.ranking.name)} ${theme.dim("(sistema)")}`,
164
+ `${theme.label("Sistema:")} ${data.ranking.id}`,
165
+ `${theme.label("Período:")} ${formatDatePtBr(result.start_date)} a ${formatDatePtBr(result.end_date)}`,
166
+ `${theme.label("Top:")} ${formatInteger(result.top_n)}`,
167
+ `${theme.label("Rebalanceamento:")} ${formatRebalanceFrequency(result.rebalance_frequency)}`,
168
+ "",
169
+ `${theme.label("Retorno total:")} ${formatPercentage(result.total_return)}`,
170
+ `${theme.label("Retorno anualizado:")} ${formatPercentage(result.annualized_return)}`,
171
+ `${theme.label("IBOV no período:")} ${formatPercentage(result.ibov_return)}`,
172
+ `${theme.label("IBOV anualizado:")} ${formatPercentage(result.ibov_annualized_return)}`,
173
+ `${theme.label("Alfa vs IBOV:")} ${formatPercentagePoints(alpha)}`,
174
+ "",
175
+ `${theme.label("Rebalanceamentos:")} ${formatInteger(result.rebalance_dates.length)}`,
176
+ `${theme.label("Períodos calculados:")} ${formatInteger(result.period_returns.length)}`,
177
+ ];
178
+ if (data.summary_markdown.trim()) {
179
+ lines.push("");
180
+ lines.push(data.summary_markdown);
181
+ }
182
+ return lines.join("\n");
183
+ }
111
184
  function formatRankingGroup(title, rankings, theme) {
112
185
  const lines = [
113
186
  `${theme.label(title)} ${theme.dim(`(${formatInteger(rankings.length)})`)}`,
@@ -139,6 +212,9 @@ function formatRankingGroup(title, rankings, theme) {
139
212
  lines.push(` ${theme.label("Ativos:")} ${formatInteger(ranking.total_assets)}`);
140
213
  }
141
214
  lines.push(` ${theme.label("Uso:")} ${formatRankingUsage(ranking)}`);
215
+ if (ranking.kind === "SYSTEM") {
216
+ lines.push(` ${theme.label("Retorno:")} ${formatRankingReturnUsage(ranking)}`);
217
+ }
142
218
  }
143
219
  return lines;
144
220
  }
@@ -158,6 +234,15 @@ function formatRankingUsage(ranking) {
158
234
  }
159
235
  return `quantbrasil rankings current --system ${ranking.id} --top 20`;
160
236
  }
237
+ function formatRankingReturnUsage(ranking) {
238
+ if (!ranking.return_simulation.supported) {
239
+ return "indisponível";
240
+ }
241
+ return `quantbrasil rankings return --system ${ranking.id} --from ${formatRankingReturnUsageStartDate(ranking)} --to AAAA-MM-DD --top 20 --rebalance quarterly`;
242
+ }
243
+ function formatRankingReturnUsageStartDate(ranking) {
244
+ return ranking.return_simulation.earliest_start_date ?? "AAAA-MM-DD";
245
+ }
161
246
  function formatRankingKind(kind) {
162
247
  return kind === "SYSTEM" ? "sistema" : "usuário";
163
248
  }
@@ -194,12 +279,76 @@ function formatMetricValue(metric) {
194
279
  }
195
280
  return String(metric.value);
196
281
  }
282
+ function formatPercentage(value) {
283
+ return `${formatNumber(value * 100)}%`;
284
+ }
285
+ function formatPercentagePoints(value) {
286
+ const prefix = value > 0 ? "+" : value < 0 ? "-" : "";
287
+ return `${prefix}${formatNumber(Math.abs(value * 100))} p.p.`;
288
+ }
289
+ function formatDatePtBr(value) {
290
+ const match = /^(\d{4})-(\d{2})-(\d{2})/.exec(value);
291
+ if (!match) {
292
+ return value;
293
+ }
294
+ return `${match[3]}/${match[2]}/${match[1]}`;
295
+ }
296
+ function formatRebalanceFrequency(value) {
297
+ switch (value) {
298
+ case "weekly":
299
+ return "semanal";
300
+ case "monthly":
301
+ return "mensal";
302
+ case "bimonthly":
303
+ return "bimestral";
304
+ case "quarterly":
305
+ return "trimestral";
306
+ case "semiannually":
307
+ return "semestral";
308
+ case "annually":
309
+ return "anual";
310
+ default:
311
+ return value;
312
+ }
313
+ }
197
314
  function parseTopOption(rawTop) {
198
315
  if (rawTop === undefined) {
199
316
  return 20;
200
317
  }
201
318
  return parsePositiveInteger(rawTop, "--top");
202
319
  }
320
+ function parseRankingReturnTopOption(rawTop) {
321
+ const parsed = parseTopOption(rawTop);
322
+ if (parsed > 30) {
323
+ throw createCliValidationError("--top deve ser menor ou igual a 30.");
324
+ }
325
+ return parsed;
326
+ }
327
+ function parseIsoDateOption(rawValue, label) {
328
+ const normalized = normalizeRequiredString(rawValue, label);
329
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(normalized)) {
330
+ throw createCliValidationError(`${label} deve usar o formato AAAA-MM-DD.`);
331
+ }
332
+ const parsed = new Date(`${normalized}T00:00:00.000Z`);
333
+ if (Number.isNaN(parsed.getTime())) {
334
+ throw createCliValidationError(`${label} deve ser uma data válida.`);
335
+ }
336
+ const [year, month, day] = normalized.split("-").map(Number);
337
+ if (parsed.getUTCFullYear() !== year ||
338
+ parsed.getUTCMonth() + 1 !== month ||
339
+ parsed.getUTCDate() !== day) {
340
+ throw createCliValidationError(`${label} deve ser uma data válida.`);
341
+ }
342
+ return normalized;
343
+ }
344
+ function parseEnumOption(rawValue, label, allowedValues) {
345
+ const normalized = normalizeRequiredString(rawValue, label);
346
+ const match = allowedValues.find(value => value === normalized);
347
+ if (!match) {
348
+ throw createCliValidationError(`${label} deve ser um destes valores: ${allowedValues.join(", ")}.`);
349
+ }
350
+ return match;
351
+ }
203
352
  function parsePositiveInteger(rawValue, label) {
204
353
  const normalized = normalizeRequiredString(rawValue, label);
205
354
  const parsed = Number.parseInt(normalized, 10);
@@ -1,3 +1,6 @@
1
+ export declare const rankingReturnRebalanceValues: readonly ["weekly", "monthly", "bimonthly", "quarterly", "semiannually", "annually"];
2
+ export declare const rankingReturnWeightingValues: readonly ["equal"];
3
+ export declare const rankingReturnIndexFilterValues: readonly ["NONE", "IBOV", "IBX100", "SMLL"];
1
4
  export declare const rankingsCapabilities: readonly [{
2
5
  readonly id: "rankings.list";
3
6
  readonly kind: "read";
@@ -79,5 +82,94 @@ export declare const rankingsCapabilities: readonly [{
79
82
  readonly title: "Consultar ranking atual";
80
83
  };
81
84
  readonly outputModes: readonly ["json", "human"];
85
+ }, {
86
+ readonly id: "rankings.return";
87
+ readonly kind: "read";
88
+ readonly visibility: readonly ["cli", "opencode"];
89
+ readonly description: "Calcula o retorno histórico de uma estratégia baseada em ranking do sistema.";
90
+ readonly http: {
91
+ readonly method: "POST";
92
+ readonly path: "/api/desk/tools/rankings/return";
93
+ readonly inputMode: "json_body";
94
+ readonly schemas: {
95
+ readonly request: "RankingReturnRequest";
96
+ readonly response: "RankingReturnResponse";
97
+ };
98
+ };
99
+ readonly cli: {
100
+ readonly group: "rankings";
101
+ readonly command: "return";
102
+ readonly summary: "Calcula o retorno histórico de um ranking do sistema.";
103
+ readonly positional: readonly [];
104
+ readonly options: readonly [{
105
+ readonly kind: "option";
106
+ readonly flag: "--system";
107
+ readonly name: "system_id";
108
+ readonly type: "string";
109
+ readonly required: true;
110
+ readonly placeholder: "SLUG";
111
+ readonly description: "Slug de ranking do sistema com histórico de rebalanceamento, por exemplo magic-formula ou momentum-90d.";
112
+ }, {
113
+ readonly kind: "option";
114
+ readonly flag: "--from";
115
+ readonly name: "start_date";
116
+ readonly type: "string";
117
+ readonly required: true;
118
+ readonly placeholder: "AAAA-MM-DD";
119
+ readonly description: "Data inicial em ISO 8601.";
120
+ }, {
121
+ readonly kind: "option";
122
+ readonly flag: "--to";
123
+ readonly name: "end_date";
124
+ readonly type: "string";
125
+ readonly required: true;
126
+ readonly placeholder: "AAAA-MM-DD";
127
+ readonly description: "Data final em ISO 8601.";
128
+ }, {
129
+ readonly kind: "option";
130
+ readonly flag: "--top";
131
+ readonly name: "top_n";
132
+ readonly type: "integer";
133
+ readonly required: false;
134
+ readonly placeholder: "N";
135
+ readonly defaultValue: 20;
136
+ readonly description: "Número de ativos no ranking a cada rebalanceamento.";
137
+ }, {
138
+ readonly kind: "option";
139
+ readonly flag: "--rebalance";
140
+ readonly name: "rebalance_frequency";
141
+ readonly type: "enum";
142
+ readonly required: true;
143
+ readonly placeholder: "weekly|monthly|bimonthly|quarterly|semiannually|annually";
144
+ readonly enumValues: readonly ["weekly", "monthly", "bimonthly", "quarterly", "semiannually", "annually"];
145
+ readonly description: "Frequência de rebalanceamento da estratégia.";
146
+ }, {
147
+ readonly kind: "option";
148
+ readonly flag: "--weight";
149
+ readonly name: "weighting_method";
150
+ readonly type: "enum";
151
+ readonly required: false;
152
+ readonly placeholder: "equal";
153
+ readonly defaultValue: "equal";
154
+ readonly enumValues: readonly ["equal"];
155
+ readonly description: "Método de ponderação dos ativos.";
156
+ }, {
157
+ readonly kind: "option";
158
+ readonly flag: "--index-filter";
159
+ readonly name: "index_filter";
160
+ readonly type: "enum";
161
+ readonly required: false;
162
+ readonly placeholder: "NONE|IBOV|IBX100|SMLL";
163
+ readonly defaultValue: "NONE";
164
+ readonly enumValues: readonly ["NONE", "IBOV", "IBX100", "SMLL"];
165
+ readonly description: "Filtro de índice aplicado ao universo do ranking.";
166
+ }];
167
+ readonly examples: readonly ["quantbrasil rankings return --system magic-formula --from 2024-01-18 --to 2026-05-25 --top 20 --rebalance quarterly", "quantbrasil rankings return --system momentum-90d --from 2024-01-01 --to 2026-01-01 --top 10 --rebalance monthly --json"];
168
+ };
169
+ readonly tool: {
170
+ readonly name: "qb_rankings_return";
171
+ readonly title: "Calcular retorno de ranking";
172
+ };
173
+ readonly outputModes: readonly ["json", "human"];
82
174
  }];
83
175
  //# sourceMappingURL=rankings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rankings.d.ts","sourceRoot":"","sources":["../../src/capabilities/rankings.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiGmB,CAAC"}
1
+ {"version":3,"file":"rankings.d.ts","sourceRoot":"","sources":["../../src/capabilities/rankings.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,4BAA4B,sFAO/B,CAAC;AACX,eAAO,MAAM,4BAA4B,oBAAqB,CAAC;AAC/D,eAAO,MAAM,8BAA8B,6CAKjC,CAAC;AAEX,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyMmB,CAAC"}
@@ -1,5 +1,20 @@
1
1
  import { publicRuntimeVisibility, standardOutputModes } from "./shared.js";
2
2
  const rankingSelectorExclusiveGroup = "ranking_selector";
3
+ export const rankingReturnRebalanceValues = [
4
+ "weekly",
5
+ "monthly",
6
+ "bimonthly",
7
+ "quarterly",
8
+ "semiannually",
9
+ "annually",
10
+ ];
11
+ export const rankingReturnWeightingValues = ["equal"];
12
+ export const rankingReturnIndexFilterValues = [
13
+ "NONE",
14
+ "IBOV",
15
+ "IBX100",
16
+ "SMLL",
17
+ ];
3
18
  export const rankingsCapabilities = [
4
19
  {
5
20
  id: "rankings.list",
@@ -93,4 +108,105 @@ export const rankingsCapabilities = [
93
108
  },
94
109
  outputModes: standardOutputModes,
95
110
  },
111
+ {
112
+ id: "rankings.return",
113
+ kind: "read",
114
+ visibility: publicRuntimeVisibility,
115
+ description: "Calcula o retorno histórico de uma estratégia baseada em ranking do sistema.",
116
+ http: {
117
+ method: "POST",
118
+ path: "/api/desk/tools/rankings/return",
119
+ inputMode: "json_body",
120
+ schemas: {
121
+ request: "RankingReturnRequest",
122
+ response: "RankingReturnResponse",
123
+ },
124
+ },
125
+ cli: {
126
+ group: "rankings",
127
+ command: "return",
128
+ summary: "Calcula o retorno histórico de um ranking do sistema.",
129
+ positional: [],
130
+ options: [
131
+ {
132
+ kind: "option",
133
+ flag: "--system",
134
+ name: "system_id",
135
+ type: "string",
136
+ required: true,
137
+ placeholder: "SLUG",
138
+ description: "Slug de ranking do sistema com histórico de rebalanceamento, por exemplo magic-formula ou momentum-90d.",
139
+ },
140
+ {
141
+ kind: "option",
142
+ flag: "--from",
143
+ name: "start_date",
144
+ type: "string",
145
+ required: true,
146
+ placeholder: "AAAA-MM-DD",
147
+ description: "Data inicial em ISO 8601.",
148
+ },
149
+ {
150
+ kind: "option",
151
+ flag: "--to",
152
+ name: "end_date",
153
+ type: "string",
154
+ required: true,
155
+ placeholder: "AAAA-MM-DD",
156
+ description: "Data final em ISO 8601.",
157
+ },
158
+ {
159
+ kind: "option",
160
+ flag: "--top",
161
+ name: "top_n",
162
+ type: "integer",
163
+ required: false,
164
+ placeholder: "N",
165
+ defaultValue: 20,
166
+ description: "Número de ativos no ranking a cada rebalanceamento.",
167
+ },
168
+ {
169
+ kind: "option",
170
+ flag: "--rebalance",
171
+ name: "rebalance_frequency",
172
+ type: "enum",
173
+ required: true,
174
+ placeholder: "weekly|monthly|bimonthly|quarterly|semiannually|annually",
175
+ enumValues: rankingReturnRebalanceValues,
176
+ description: "Frequência de rebalanceamento da estratégia.",
177
+ },
178
+ {
179
+ kind: "option",
180
+ flag: "--weight",
181
+ name: "weighting_method",
182
+ type: "enum",
183
+ required: false,
184
+ placeholder: "equal",
185
+ defaultValue: "equal",
186
+ enumValues: rankingReturnWeightingValues,
187
+ description: "Método de ponderação dos ativos.",
188
+ },
189
+ {
190
+ kind: "option",
191
+ flag: "--index-filter",
192
+ name: "index_filter",
193
+ type: "enum",
194
+ required: false,
195
+ placeholder: "NONE|IBOV|IBX100|SMLL",
196
+ defaultValue: "NONE",
197
+ enumValues: rankingReturnIndexFilterValues,
198
+ description: "Filtro de índice aplicado ao universo do ranking.",
199
+ },
200
+ ],
201
+ examples: [
202
+ "quantbrasil rankings return --system magic-formula --from 2024-01-18 --to 2026-05-25 --top 20 --rebalance quarterly",
203
+ "quantbrasil rankings return --system momentum-90d --from 2024-01-01 --to 2026-01-01 --top 10 --rebalance monthly --json",
204
+ ],
205
+ },
206
+ tool: {
207
+ name: "qb_rankings_return",
208
+ title: "Calcular retorno de ranking",
209
+ },
210
+ outputModes: standardOutputModes,
211
+ },
96
212
  ];
@@ -219,6 +219,95 @@ export declare const capabilityRegistry: readonly [{
219
219
  readonly title: "Consultar ranking atual";
220
220
  };
221
221
  readonly outputModes: readonly ["json", "human"];
222
+ }, {
223
+ readonly id: "rankings.return";
224
+ readonly kind: "read";
225
+ readonly visibility: readonly ["cli", "opencode"];
226
+ readonly description: "Calcula o retorno histórico de uma estratégia baseada em ranking do sistema.";
227
+ readonly http: {
228
+ readonly method: "POST";
229
+ readonly path: "/api/desk/tools/rankings/return";
230
+ readonly inputMode: "json_body";
231
+ readonly schemas: {
232
+ readonly request: "RankingReturnRequest";
233
+ readonly response: "RankingReturnResponse";
234
+ };
235
+ };
236
+ readonly cli: {
237
+ readonly group: "rankings";
238
+ readonly command: "return";
239
+ readonly summary: "Calcula o retorno histórico de um ranking do sistema.";
240
+ readonly positional: readonly [];
241
+ readonly options: readonly [{
242
+ readonly kind: "option";
243
+ readonly flag: "--system";
244
+ readonly name: "system_id";
245
+ readonly type: "string";
246
+ readonly required: true;
247
+ readonly placeholder: "SLUG";
248
+ readonly description: "Slug de ranking do sistema com histórico de rebalanceamento, por exemplo magic-formula ou momentum-90d.";
249
+ }, {
250
+ readonly kind: "option";
251
+ readonly flag: "--from";
252
+ readonly name: "start_date";
253
+ readonly type: "string";
254
+ readonly required: true;
255
+ readonly placeholder: "AAAA-MM-DD";
256
+ readonly description: "Data inicial em ISO 8601.";
257
+ }, {
258
+ readonly kind: "option";
259
+ readonly flag: "--to";
260
+ readonly name: "end_date";
261
+ readonly type: "string";
262
+ readonly required: true;
263
+ readonly placeholder: "AAAA-MM-DD";
264
+ readonly description: "Data final em ISO 8601.";
265
+ }, {
266
+ readonly kind: "option";
267
+ readonly flag: "--top";
268
+ readonly name: "top_n";
269
+ readonly type: "integer";
270
+ readonly required: false;
271
+ readonly placeholder: "N";
272
+ readonly defaultValue: 20;
273
+ readonly description: "Número de ativos no ranking a cada rebalanceamento.";
274
+ }, {
275
+ readonly kind: "option";
276
+ readonly flag: "--rebalance";
277
+ readonly name: "rebalance_frequency";
278
+ readonly type: "enum";
279
+ readonly required: true;
280
+ readonly placeholder: "weekly|monthly|bimonthly|quarterly|semiannually|annually";
281
+ readonly enumValues: readonly ["weekly", "monthly", "bimonthly", "quarterly", "semiannually", "annually"];
282
+ readonly description: "Frequência de rebalanceamento da estratégia.";
283
+ }, {
284
+ readonly kind: "option";
285
+ readonly flag: "--weight";
286
+ readonly name: "weighting_method";
287
+ readonly type: "enum";
288
+ readonly required: false;
289
+ readonly placeholder: "equal";
290
+ readonly defaultValue: "equal";
291
+ readonly enumValues: readonly ["equal"];
292
+ readonly description: "Método de ponderação dos ativos.";
293
+ }, {
294
+ readonly kind: "option";
295
+ readonly flag: "--index-filter";
296
+ readonly name: "index_filter";
297
+ readonly type: "enum";
298
+ readonly required: false;
299
+ readonly placeholder: "NONE|IBOV|IBX100|SMLL";
300
+ readonly defaultValue: "NONE";
301
+ readonly enumValues: readonly ["NONE", "IBOV", "IBX100", "SMLL"];
302
+ readonly description: "Filtro de índice aplicado ao universo do ranking.";
303
+ }];
304
+ readonly examples: readonly ["quantbrasil rankings return --system magic-formula --from 2024-01-18 --to 2026-05-25 --top 20 --rebalance quarterly", "quantbrasil rankings return --system momentum-90d --from 2024-01-01 --to 2026-01-01 --top 10 --rebalance monthly --json"];
305
+ };
306
+ readonly tool: {
307
+ readonly name: "qb_rankings_return";
308
+ readonly title: "Calcular retorno de ranking";
309
+ };
310
+ readonly outputModes: readonly ["json", "human"];
222
311
  }, {
223
312
  readonly id: "screening.universes";
224
313
  readonly kind: "read";
@@ -1244,6 +1333,95 @@ export declare function getCapabilityById(id: CapabilityId): {
1244
1333
  readonly title: "Consultar ranking atual";
1245
1334
  };
1246
1335
  readonly outputModes: readonly ["json", "human"];
1336
+ } | {
1337
+ readonly id: "rankings.return";
1338
+ readonly kind: "read";
1339
+ readonly visibility: readonly ["cli", "opencode"];
1340
+ readonly description: "Calcula o retorno histórico de uma estratégia baseada em ranking do sistema.";
1341
+ readonly http: {
1342
+ readonly method: "POST";
1343
+ readonly path: "/api/desk/tools/rankings/return";
1344
+ readonly inputMode: "json_body";
1345
+ readonly schemas: {
1346
+ readonly request: "RankingReturnRequest";
1347
+ readonly response: "RankingReturnResponse";
1348
+ };
1349
+ };
1350
+ readonly cli: {
1351
+ readonly group: "rankings";
1352
+ readonly command: "return";
1353
+ readonly summary: "Calcula o retorno histórico de um ranking do sistema.";
1354
+ readonly positional: readonly [];
1355
+ readonly options: readonly [{
1356
+ readonly kind: "option";
1357
+ readonly flag: "--system";
1358
+ readonly name: "system_id";
1359
+ readonly type: "string";
1360
+ readonly required: true;
1361
+ readonly placeholder: "SLUG";
1362
+ readonly description: "Slug de ranking do sistema com histórico de rebalanceamento, por exemplo magic-formula ou momentum-90d.";
1363
+ }, {
1364
+ readonly kind: "option";
1365
+ readonly flag: "--from";
1366
+ readonly name: "start_date";
1367
+ readonly type: "string";
1368
+ readonly required: true;
1369
+ readonly placeholder: "AAAA-MM-DD";
1370
+ readonly description: "Data inicial em ISO 8601.";
1371
+ }, {
1372
+ readonly kind: "option";
1373
+ readonly flag: "--to";
1374
+ readonly name: "end_date";
1375
+ readonly type: "string";
1376
+ readonly required: true;
1377
+ readonly placeholder: "AAAA-MM-DD";
1378
+ readonly description: "Data final em ISO 8601.";
1379
+ }, {
1380
+ readonly kind: "option";
1381
+ readonly flag: "--top";
1382
+ readonly name: "top_n";
1383
+ readonly type: "integer";
1384
+ readonly required: false;
1385
+ readonly placeholder: "N";
1386
+ readonly defaultValue: 20;
1387
+ readonly description: "Número de ativos no ranking a cada rebalanceamento.";
1388
+ }, {
1389
+ readonly kind: "option";
1390
+ readonly flag: "--rebalance";
1391
+ readonly name: "rebalance_frequency";
1392
+ readonly type: "enum";
1393
+ readonly required: true;
1394
+ readonly placeholder: "weekly|monthly|bimonthly|quarterly|semiannually|annually";
1395
+ readonly enumValues: readonly ["weekly", "monthly", "bimonthly", "quarterly", "semiannually", "annually"];
1396
+ readonly description: "Frequência de rebalanceamento da estratégia.";
1397
+ }, {
1398
+ readonly kind: "option";
1399
+ readonly flag: "--weight";
1400
+ readonly name: "weighting_method";
1401
+ readonly type: "enum";
1402
+ readonly required: false;
1403
+ readonly placeholder: "equal";
1404
+ readonly defaultValue: "equal";
1405
+ readonly enumValues: readonly ["equal"];
1406
+ readonly description: "Método de ponderação dos ativos.";
1407
+ }, {
1408
+ readonly kind: "option";
1409
+ readonly flag: "--index-filter";
1410
+ readonly name: "index_filter";
1411
+ readonly type: "enum";
1412
+ readonly required: false;
1413
+ readonly placeholder: "NONE|IBOV|IBX100|SMLL";
1414
+ readonly defaultValue: "NONE";
1415
+ readonly enumValues: readonly ["NONE", "IBOV", "IBX100", "SMLL"];
1416
+ readonly description: "Filtro de índice aplicado ao universo do ranking.";
1417
+ }];
1418
+ readonly examples: readonly ["quantbrasil rankings return --system magic-formula --from 2024-01-18 --to 2026-05-25 --top 20 --rebalance quarterly", "quantbrasil rankings return --system momentum-90d --from 2024-01-01 --to 2026-01-01 --top 10 --rebalance monthly --json"];
1419
+ };
1420
+ readonly tool: {
1421
+ readonly name: "qb_rankings_return";
1422
+ readonly title: "Calcular retorno de ranking";
1423
+ };
1424
+ readonly outputModes: readonly ["json", "human"];
1247
1425
  } | {
1248
1426
  readonly id: "screening.universes";
1249
1427
  readonly kind: "read";
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/capabilities/registry.ts"],"names":[],"mappings":"AAOA,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.11",
3
+ "version": "0.1.0-beta.13",
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",
@@ -25,7 +25,7 @@ Use this skill when the user asks for market or investing data/actions that Quan
25
25
  - asset discovery: `quantbrasil market assets`
26
26
  - price lookup: `quantbrasil market price <ticker>`
27
27
  - richer asset analysis: `quantbrasil assets overview <ticker> --sections ...`
28
- - ranked asset lists: `quantbrasil rankings list|current ...`
28
+ - ranked asset lists and ranking returns: `quantbrasil rankings list|current|return ...`
29
29
  - watchlist details and changes: `quantbrasil watchlists ...`
30
30
  - holding details and historical return: `quantbrasil holdings ...`
31
31
  - indicator screening over saved universes: `quantbrasil screening universes|indicators|run ...`
@@ -56,6 +56,8 @@ quantbrasil rankings current --system magic-formula --top 10
56
56
  quantbrasil rankings current --system low-risk --top 30
57
57
  quantbrasil rankings current --id 123 --top 20
58
58
  quantbrasil rankings current --system momentum-90d --top 20 --json
59
+ quantbrasil rankings return --system magic-formula --from 2024-01-18 --to 2026-05-25 --top 20 --rebalance quarterly
60
+ quantbrasil rankings return --system momentum-90d --from 2024-01-01 --to 2026-01-01 --top 10 --rebalance monthly --json
59
61
  ```
60
62
 
61
63
  Rules:
@@ -63,9 +65,12 @@ Rules:
63
65
  - use `rankings list` to discover rankings before using ids
64
66
  - system rankings use slugs such as `magic-formula`, `momentum-90d`, `dividend-yield`, `low-risk`, and `momentum-double`
65
67
  - user rankings use the numeric id returned by `rankings list`
66
- - use exactly one selector: `--system <slug>` or `--id <id>`
67
- - `--top` controls how many ranked assets are returned
68
+ - `current` uses exactly one selector: `--system <slug>` or `--id <id>`
69
+ - `return` uses only `--system <slug>`, explicit `--from` / `--to` dates, and `--rebalance`
70
+ - `--top` controls how many ranked assets are returned or held at each rebalance
68
71
  - `current` returns the ordered rows and the metric used to order the ranking
72
+ - `return` returns simulated historical performance and rebalance/period details
73
+ - Low Risk supports `current`, but not `return`
69
74
  - use `--json` when the result will be parsed by an agent or script
70
75
 
71
76
  ## Watchlists and holdings
@@ -17,6 +17,7 @@ Current guidance uses backend qualitative classes only:
17
17
  - `screening indicators` is a discovery path for supported screening JSON
18
18
  - `screening run` is a heavy read and should be targeted to one selected universe
19
19
  - `cointegration pair` is a heavy read and should be targeted to one explicit pair
20
+ - `rankings return` is a heavy read and should be targeted to one explicit system ranking and date range
20
21
  - holding metrics (`historical-return`, `beta`, `var`) are heaviest current public reads
21
22
 
22
23
  ## Agent rules
@@ -25,8 +26,9 @@ Current guidance uses backend qualitative classes only:
25
26
  - prefer `market price` over `assets overview` for quote-only requests
26
27
  - run `screening universes` before `screening run` when the universe selector is not known
27
28
  - run `screening indicators` before `screening run` when the indicator JSON is not known
29
+ - run `rankings list` before `rankings return` when return support or the system slug is not known
28
30
  - prefer one holding metric call targeted to actual question
29
- - do not chain multiple heavy holding metric, screening, or cointegration calls unless user asked for them
31
+ - do not chain multiple heavy holding metric, ranking return, screening, or cointegration calls unless user asked for them
30
32
  - use `--json` only when structured output needed
31
33
 
32
34
  ## Safe defaults
@@ -3,6 +3,8 @@
3
3
  Use rankings for order-first questions: Magic Formula, momentum leaders,
4
4
  dividend-yield leaders, Low Risk, Momentum Double, or saved user rankings. A
5
5
  ranking returns an ordered asset list plus the metric used to order it.
6
+ Use ranking return when the question asks how a ranking-based strategy performed
7
+ over a historical period with rebalancing.
6
8
 
7
9
  ## Discovery
8
10
 
@@ -43,6 +45,30 @@ Rules:
43
45
  - use `--json` when another step needs to parse tickers, rank, score, or metric values
44
46
  - do not use `factor:<id>` in command syntax; ranking fatorial is a saved user ranking and uses `--id <id>`
45
47
 
48
+ ## Ranking return
49
+
50
+ Use this when the user asks how much a ranking strategy returned over time,
51
+ such as Magic Formula top 20 rebalanced quarterly.
52
+
53
+ ```bash
54
+ quantbrasil rankings return --system magic-formula --from 2024-01-18 --to 2026-05-25 --top 20 --rebalance quarterly
55
+ quantbrasil rankings return --system momentum-90d --from 2024-01-01 --to 2026-01-01 --top 10 --rebalance monthly
56
+ ```
57
+
58
+ Rules:
59
+
60
+ - use `rankings list` first when the system slug or return support is unclear
61
+ - `return` accepts `--system` only
62
+ - `--from` and `--to` are required explicit ISO dates
63
+ - do not use `--id`; saved user rankings do not support historical return in the public CLI
64
+ - do not use `--period`; ranking return requires explicit dates
65
+ - supported rebalance values are `weekly`, `monthly`, `bimonthly`, `quarterly`, `semiannually`, and `annually`
66
+ - supported weighting is `equal`
67
+ - `--index-filter` accepts `NONE`, `IBOV`, `IBX100`, or `SMLL`
68
+ - system rankings with return support currently include Magic Formula, Dividend Yield, Momentum, and Momentum Double
69
+ - Low Risk can be queried with `rankings current`, but does not support `rankings return`
70
+ - use `--json` when another step needs rebalance portfolios or period-level returns
71
+
46
72
  ## Ranking vs screening
47
73
 
48
74
  Use rankings when the user starts from an ordered list:
@@ -6,6 +6,7 @@
6
6
  - supported assets, tickers, or market universe → `market assets`
7
7
  - asset performance, technicals, risk, fundamentals, or ranking → `assets overview`
8
8
  - current ordered asset lists such as Magic Formula, momentum, Low Risk, or user rankings → `rankings list`, then `rankings current`
9
+ - historical return of ranking strategies such as Magic Formula or Momentum → `rankings list`, then `rankings return`
9
10
  - watchlist details or changes → `watchlists ...`
10
11
  - holding details or changes → `holdings ...`
11
12
  - holding return, beta, risk, VaR, or comparison → `holdings historical-return|beta|var`
@@ -76,6 +77,7 @@ quantbrasil rankings current --system momentum-90d --top 20
76
77
  quantbrasil rankings current --system magic-formula --top 10
77
78
  quantbrasil rankings current --system low-risk --top 30
78
79
  quantbrasil rankings current --id 123 --top 20
80
+ quantbrasil rankings return --system magic-formula --from 2024-01-18 --to 2026-05-25 --top 20 --rebalance quarterly
79
81
  ```
80
82
 
81
83
  Rules:
@@ -85,6 +87,9 @@ Rules:
85
87
  - user rankings use their numeric id from `rankings list`
86
88
  - use exactly one selector: `--system <slug>` or `--id <id>`
87
89
  - do not call user rankings "factor:" in command syntax; ranking fatorial is a saved user ranking
90
+ - use `rankings return` for supported system rankings when the user asks historical return with rebalancing
91
+ - `rankings return` requires explicit `--from` and `--to` dates and does not accept user ranking ids
92
+ - Low Risk supports current ranking lookup, but not return simulation
88
93
  - use `--json` if another step needs to parse tickers, ranks, or ordering metrics
89
94
  - do not route ranking-first questions through screening unless the user asks for indicator conditions
90
95