@quantbrasil/cli 0.1.0-beta.2 → 0.1.0-beta.4
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 +14 -11
- package/dist/cli/index.d.ts +2 -3
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -10
- package/dist/commands/portfolios.d.ts +133 -8
- package/dist/commands/portfolios.d.ts.map +1 -1
- package/dist/commands/portfolios.js +434 -55
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/vendor/core/capabilities/index.d.ts +0 -1
- package/dist/vendor/core/capabilities/index.d.ts.map +1 -1
- package/dist/vendor/core/capabilities/index.js +0 -1
- package/dist/vendor/core/capabilities/portfolios.d.ts +401 -56
- package/dist/vendor/core/capabilities/portfolios.d.ts.map +1 -1
- package/dist/vendor/core/capabilities/portfolios.js +383 -115
- package/dist/vendor/core/capabilities/registry.d.ts +586 -266
- package/dist/vendor/core/capabilities/registry.d.ts.map +1 -1
- package/dist/vendor/core/capabilities/registry.js +0 -2
- package/dist/vendor/core/capabilities/types.d.ts +1 -1
- package/dist/vendor/core/capabilities/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/quantbrasil/SKILL.md +13 -5
- package/skills/quantbrasil/references/cli.md +22 -25
- package/skills/quantbrasil/references/costs.md +4 -4
- package/skills/quantbrasil/references/errors.md +16 -5
- package/skills/quantbrasil/references/portfolios.md +92 -0
- package/skills/quantbrasil/references/unsupported.md +2 -2
- package/skills/quantbrasil/references/workflows.md +41 -22
- package/dist/commands/analytics.d.ts +0 -131
- package/dist/commands/analytics.d.ts.map +0 -1
- package/dist/commands/analytics.js +0 -291
- package/dist/vendor/core/capabilities/analytics.d.ts +0 -187
- package/dist/vendor/core/capabilities/analytics.d.ts.map +0 -1
- package/dist/vendor/core/capabilities/analytics.js +0 -214
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { invokeCliCapability } from "../cli/client.js";
|
|
2
|
-
import { createCliValidationError } from "../cli/errors.js";
|
|
3
|
-
import { createTerminalTheme } from "../cli/terminal.js";
|
|
4
|
-
export function registerAnalyticsCommands(program, context = {}) {
|
|
5
|
-
const analyticsCommand = program
|
|
6
|
-
.command("analytics")
|
|
7
|
-
.description("Read portfolio analytics operations");
|
|
8
|
-
analyticsCommand
|
|
9
|
-
.command("historical-return")
|
|
10
|
-
.description("Calculate historical return for a saved portfolio or basket")
|
|
11
|
-
.option("--portfolio <id>", "Saved portfolio id", parsePositiveIntegerOption)
|
|
12
|
-
.option("--asset <asset>", "Repeatable asset input in TICKER[:WEIGHT_PCT] form", collectStringOption, [])
|
|
13
|
-
.requiredOption("--from <date>", "Inclusive start date in ISO format")
|
|
14
|
-
.requiredOption("--to <date>", "Inclusive end date in ISO format")
|
|
15
|
-
.option("--json", "Show JSON output")
|
|
16
|
-
.action(async (options) => {
|
|
17
|
-
await runHistoricalReturnCommand(options, context);
|
|
18
|
-
});
|
|
19
|
-
analyticsCommand
|
|
20
|
-
.command("beta")
|
|
21
|
-
.description("Calculate portfolio beta against IBOV")
|
|
22
|
-
.option("--portfolio <id>", "Saved portfolio id", parsePositiveIntegerOption)
|
|
23
|
-
.option("--asset <asset>", "Repeatable asset input in TICKER[:WEIGHT_PCT] form", collectStringOption, [])
|
|
24
|
-
.option("--years <years>", "Lookback window in years", "1")
|
|
25
|
-
.option("--json", "Show JSON output")
|
|
26
|
-
.action(async (options) => {
|
|
27
|
-
await runBetaCommand(options, context);
|
|
28
|
-
});
|
|
29
|
-
analyticsCommand
|
|
30
|
-
.command("var")
|
|
31
|
-
.description("Calculate one-day Value-at-Risk for a portfolio or basket")
|
|
32
|
-
.option("--portfolio <id>", "Saved portfolio id", parsePositiveIntegerOption)
|
|
33
|
-
.option("--asset <asset>", "Repeatable asset input in TICKER[:WEIGHT_PCT] form", collectStringOption, [])
|
|
34
|
-
.option("--years <years>", "Lookback window in years", "1")
|
|
35
|
-
.option("--confidence <confidence>", "Confidence level in percent", "95")
|
|
36
|
-
.option("--json", "Show JSON output")
|
|
37
|
-
.action(async (options) => {
|
|
38
|
-
await runVarCommand(options, context);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
export async function runHistoricalReturnCommand(options, context = {}) {
|
|
42
|
-
const stdout = context.io?.stdout ?? process.stdout;
|
|
43
|
-
const theme = createTerminalTheme(stdout, context.env ?? process.env);
|
|
44
|
-
const response = await invokeCliCapability({
|
|
45
|
-
capability: "analytics.historical-return",
|
|
46
|
-
input: buildHistoricalReturnInput(options),
|
|
47
|
-
env: context.env,
|
|
48
|
-
fetch: context.fetch,
|
|
49
|
-
});
|
|
50
|
-
if (options.json) {
|
|
51
|
-
stdout.write(`${JSON.stringify(response.data, null, 2)}\n`);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
stdout.write(`${formatHistoricalReturnHuman(response.data, theme)}\n`);
|
|
55
|
-
}
|
|
56
|
-
export async function runBetaCommand(options, context = {}) {
|
|
57
|
-
const stdout = context.io?.stdout ?? process.stdout;
|
|
58
|
-
const theme = createTerminalTheme(stdout, context.env ?? process.env);
|
|
59
|
-
const response = await invokeCliCapability({
|
|
60
|
-
capability: "analytics.beta",
|
|
61
|
-
input: buildBetaInput(options),
|
|
62
|
-
env: context.env,
|
|
63
|
-
fetch: context.fetch,
|
|
64
|
-
});
|
|
65
|
-
if (options.json) {
|
|
66
|
-
stdout.write(`${JSON.stringify(response.data, null, 2)}\n`);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
stdout.write(`${formatBetaHuman(response.data, theme)}\n`);
|
|
70
|
-
}
|
|
71
|
-
export async function runVarCommand(options, context = {}) {
|
|
72
|
-
const stdout = context.io?.stdout ?? process.stdout;
|
|
73
|
-
const theme = createTerminalTheme(stdout, context.env ?? process.env);
|
|
74
|
-
const response = await invokeCliCapability({
|
|
75
|
-
capability: "analytics.var",
|
|
76
|
-
input: buildVarInput(options),
|
|
77
|
-
env: context.env,
|
|
78
|
-
fetch: context.fetch,
|
|
79
|
-
});
|
|
80
|
-
if (options.json) {
|
|
81
|
-
stdout.write(`${JSON.stringify(response.data, null, 2)}\n`);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
stdout.write(`${formatVarHuman(response.data, theme)}\n`);
|
|
85
|
-
}
|
|
86
|
-
export function buildHistoricalReturnInput(options) {
|
|
87
|
-
const source = resolveAnalyticsSource(options.portfolio, options.asset ?? []);
|
|
88
|
-
return {
|
|
89
|
-
...source,
|
|
90
|
-
start_date: options.from,
|
|
91
|
-
end_date: options.to,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
export function buildBetaInput(options) {
|
|
95
|
-
const source = resolveAnalyticsSource(options.portfolio, options.asset ?? []);
|
|
96
|
-
return {
|
|
97
|
-
...source,
|
|
98
|
-
years: parseYearsOption(options.years ?? "1"),
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
export function buildVarInput(options) {
|
|
102
|
-
const source = resolveAnalyticsSource(options.portfolio, options.asset ?? []);
|
|
103
|
-
return {
|
|
104
|
-
...source,
|
|
105
|
-
years: parsePositiveIntegerOption(options.years ?? "1"),
|
|
106
|
-
confidence_pct: parseNumberOption(options.confidence ?? "95", "confidence"),
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
export function formatHistoricalReturnHuman(data, theme = createTerminalTheme(process.stdout)) {
|
|
110
|
-
const lines = [
|
|
111
|
-
theme.label("Historical return"),
|
|
112
|
-
"",
|
|
113
|
-
formatSourceLabel(data, theme),
|
|
114
|
-
`${theme.label("Period:")} ${data.effective_start_date} → ${data.effective_end_date}`,
|
|
115
|
-
`${theme.label("Requested:")} ${data.requested_start_date} → ${data.requested_end_date}`,
|
|
116
|
-
"",
|
|
117
|
-
`${theme.label("Portfolio return:")} ${formatPercentValue(data.total_return)}`,
|
|
118
|
-
`${theme.label("Annualized return:")} ${formatPercentValue(data.annualized_return)}`,
|
|
119
|
-
`${theme.label("Max drawdown:")} ${formatPercentValue(data.max_drawdown)}`,
|
|
120
|
-
`${theme.label("Daily volatility:")} ${formatPercentValue(data.daily_volatility)}`,
|
|
121
|
-
`${theme.label("Annualized volatility:")} ${formatPercentValue(data.annualized_volatility)}`,
|
|
122
|
-
`${theme.label("Sharpe ratio:")} ${formatNumber(data.sharpe_ratio)}`,
|
|
123
|
-
"",
|
|
124
|
-
theme.label("Benchmarks"),
|
|
125
|
-
` IBOV: ${formatPercentValue(data.ibov_return)}`,
|
|
126
|
-
` CDI: ${formatPercentValue(data.cdi_return)}`,
|
|
127
|
-
` IPCA: ${formatPercentValue(data.ipca_return)}`,
|
|
128
|
-
"",
|
|
129
|
-
theme.label("Holdings"),
|
|
130
|
-
...data.holdings.map(item => ` - ${item.ticker}: weight=${formatPercentDirect(item.weight_pct)}, return=${formatPercentValue(item.total_return)}, contribution=${formatPercentValue(item.contribution)}`),
|
|
131
|
-
];
|
|
132
|
-
pushNotes(lines, "Assumptions", data.assumptions, theme);
|
|
133
|
-
pushNotes(lines, "Warnings", data.warnings, theme);
|
|
134
|
-
return lines.join("\n");
|
|
135
|
-
}
|
|
136
|
-
export function formatBetaHuman(data, theme = createTerminalTheme(process.stdout)) {
|
|
137
|
-
const lines = [
|
|
138
|
-
theme.label("Portfolio beta"),
|
|
139
|
-
"",
|
|
140
|
-
formatSourceLabel(data, theme),
|
|
141
|
-
`${theme.label("Benchmark:")} ${data.benchmark}`,
|
|
142
|
-
`${theme.label("Lookback:")} ${data.lookback_years}Y`,
|
|
143
|
-
"",
|
|
144
|
-
`${theme.label("Beta:")} ${formatNumber(data.beta)}`,
|
|
145
|
-
`${theme.label("Correlation:")} ${formatNumber(data.correlation)}`,
|
|
146
|
-
`${theme.label("Daily volatility:")} ${formatPercentValue(data.daily_volatility)}`,
|
|
147
|
-
`${theme.label("Annualized volatility:")} ${formatPercentValue(data.annualized_volatility)}`,
|
|
148
|
-
`${theme.label("Long exposure:")} ${formatPercentDirect(data.long_exposure_pct)}`,
|
|
149
|
-
`${theme.label("Short exposure:")} ${formatPercentDirect(data.short_exposure_pct)}`,
|
|
150
|
-
`${theme.label("Net exposure:")} ${formatPercentDirect(data.total_weight_pct)}`,
|
|
151
|
-
"",
|
|
152
|
-
theme.label("Holdings"),
|
|
153
|
-
...data.holdings.map(item => ` - ${item.ticker}: weight=${formatPercentDirect(item.weight_pct)}, beta=${formatNullableNumber(item.beta)}, weighted=${formatNullableNumber(item.weighted_beta)}, corr=${formatNullableNumber(item.correlation)}`),
|
|
154
|
-
];
|
|
155
|
-
pushNotes(lines, "Assumptions", data.assumptions, theme);
|
|
156
|
-
pushNotes(lines, "Warnings", data.warnings, theme);
|
|
157
|
-
return lines.join("\n");
|
|
158
|
-
}
|
|
159
|
-
export function formatVarHuman(data, theme = createTerminalTheme(process.stdout)) {
|
|
160
|
-
const lines = [
|
|
161
|
-
theme.label("Portfolio VaR"),
|
|
162
|
-
"",
|
|
163
|
-
formatSourceLabel(data, theme),
|
|
164
|
-
`${theme.label("Lookback:")} ${data.lookback_years}Y`,
|
|
165
|
-
`${theme.label("Confidence:")} ${formatPercentDirect(data.confidence_pct)}`,
|
|
166
|
-
`${theme.label("Horizon:")} ${data.time_horizon}`,
|
|
167
|
-
"",
|
|
168
|
-
`${theme.label("VaR:")} ${formatPercentValue(data.var)}`,
|
|
169
|
-
`${theme.label("Long exposure:")} ${formatPercentDirect(data.long_exposure_pct)}`,
|
|
170
|
-
`${theme.label("Short exposure:")} ${formatPercentDirect(data.short_exposure_pct)}`,
|
|
171
|
-
`${theme.label("Net exposure:")} ${formatPercentDirect(data.total_weight_pct)}`,
|
|
172
|
-
"",
|
|
173
|
-
theme.label("Holdings"),
|
|
174
|
-
...data.holdings.map(item => ` - ${item.ticker}: weight=${formatPercentDirect(item.weight_pct)}`),
|
|
175
|
-
"",
|
|
176
|
-
`${theme.label("Histogram bins:")} ${formatInteger(data.histogram_data.length)}`,
|
|
177
|
-
];
|
|
178
|
-
pushNotes(lines, "Assumptions", data.assumptions, theme);
|
|
179
|
-
pushNotes(lines, "Warnings", data.warnings, theme);
|
|
180
|
-
return lines.join("\n");
|
|
181
|
-
}
|
|
182
|
-
export function parseAssetSpec(rawAsset) {
|
|
183
|
-
const normalized = rawAsset.trim();
|
|
184
|
-
if (!normalized) {
|
|
185
|
-
throw createCliValidationError("Asset input cannot be empty.");
|
|
186
|
-
}
|
|
187
|
-
const parts = normalized.split(":");
|
|
188
|
-
if (parts.length > 2) {
|
|
189
|
-
throw createCliValidationError(`Invalid asset input "${rawAsset}". Use TICKER[:WEIGHT_PCT].`);
|
|
190
|
-
}
|
|
191
|
-
const [rawTicker, rawWeight] = parts;
|
|
192
|
-
const ticker = rawTicker?.trim().toUpperCase();
|
|
193
|
-
if (!ticker) {
|
|
194
|
-
throw createCliValidationError(`Invalid asset input "${rawAsset}". Use TICKER[:WEIGHT_PCT].`);
|
|
195
|
-
}
|
|
196
|
-
if (rawWeight === undefined) {
|
|
197
|
-
return { ticker, weight_pct: null };
|
|
198
|
-
}
|
|
199
|
-
const weight_pct = Number(rawWeight.trim());
|
|
200
|
-
if (!Number.isFinite(weight_pct)) {
|
|
201
|
-
throw createCliValidationError(`Invalid asset weight in "${rawAsset}". Use TICKER[:WEIGHT_PCT].`);
|
|
202
|
-
}
|
|
203
|
-
return { ticker, weight_pct };
|
|
204
|
-
}
|
|
205
|
-
function resolveAnalyticsSource(portfolioId, assets) {
|
|
206
|
-
const hasPortfolio = portfolioId !== undefined;
|
|
207
|
-
const hasAssets = assets.length > 0;
|
|
208
|
-
if (hasPortfolio === hasAssets) {
|
|
209
|
-
throw createCliValidationError("Use exactly one source: --portfolio <id> or one or more --asset TICKER[:WEIGHT_PCT].");
|
|
210
|
-
}
|
|
211
|
-
if (hasPortfolio) {
|
|
212
|
-
return { portfolio_id: portfolioId };
|
|
213
|
-
}
|
|
214
|
-
return {
|
|
215
|
-
assets: assets.map(parseAssetSpec),
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
function collectStringOption(value, previous) {
|
|
219
|
-
previous.push(value);
|
|
220
|
-
return previous;
|
|
221
|
-
}
|
|
222
|
-
function parsePositiveIntegerOption(value) {
|
|
223
|
-
const normalized = value.trim();
|
|
224
|
-
if (!/^\d+$/.test(normalized)) {
|
|
225
|
-
throw createCliValidationError("Value must be a positive integer.");
|
|
226
|
-
}
|
|
227
|
-
const parsed = Number(normalized);
|
|
228
|
-
if (!Number.isSafeInteger(parsed) || parsed <= 0) {
|
|
229
|
-
throw createCliValidationError("Value must be a positive integer.");
|
|
230
|
-
}
|
|
231
|
-
return parsed;
|
|
232
|
-
}
|
|
233
|
-
function parseYearsOption(value) {
|
|
234
|
-
const parsed = parsePositiveIntegerOption(value);
|
|
235
|
-
if (![1, 3, 5].includes(parsed)) {
|
|
236
|
-
throw createCliValidationError("Years must be one of: 1, 3, 5.");
|
|
237
|
-
}
|
|
238
|
-
return parsed;
|
|
239
|
-
}
|
|
240
|
-
function parseNumberOption(value, fieldName) {
|
|
241
|
-
const parsed = Number(value.trim());
|
|
242
|
-
if (!Number.isFinite(parsed)) {
|
|
243
|
-
throw createCliValidationError(`${fieldName} must be a number.`);
|
|
244
|
-
}
|
|
245
|
-
return parsed;
|
|
246
|
-
}
|
|
247
|
-
function formatSourceLabel(data, theme) {
|
|
248
|
-
if (data.source_type === "saved_portfolio" && data.portfolio_id !== null) {
|
|
249
|
-
const name = data.portfolio_name ? ` · ${data.portfolio_name}` : "";
|
|
250
|
-
return `${theme.bold(String(data.portfolio_id))}${theme.dim(name)}`;
|
|
251
|
-
}
|
|
252
|
-
return theme.bold("Ad-hoc basket");
|
|
253
|
-
}
|
|
254
|
-
function pushNotes(lines, title, items, theme) {
|
|
255
|
-
if (items.length === 0) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
lines.push("");
|
|
259
|
-
lines.push(theme.label(title));
|
|
260
|
-
for (const item of items) {
|
|
261
|
-
lines.push(` - ${item}`);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
function formatNumber(value) {
|
|
265
|
-
return new Intl.NumberFormat("en-US", {
|
|
266
|
-
maximumFractionDigits: 4,
|
|
267
|
-
}).format(value);
|
|
268
|
-
}
|
|
269
|
-
function formatInteger(value) {
|
|
270
|
-
return new Intl.NumberFormat("en-US", {
|
|
271
|
-
maximumFractionDigits: 0,
|
|
272
|
-
}).format(value);
|
|
273
|
-
}
|
|
274
|
-
function formatNullableNumber(value) {
|
|
275
|
-
if (value === null) {
|
|
276
|
-
return "n/a";
|
|
277
|
-
}
|
|
278
|
-
return formatNumber(value);
|
|
279
|
-
}
|
|
280
|
-
function formatPercentValue(value) {
|
|
281
|
-
return `${new Intl.NumberFormat("en-US", {
|
|
282
|
-
maximumFractionDigits: 2,
|
|
283
|
-
minimumFractionDigits: 2,
|
|
284
|
-
}).format(value * 100)}%`;
|
|
285
|
-
}
|
|
286
|
-
function formatPercentDirect(value) {
|
|
287
|
-
return `${new Intl.NumberFormat("en-US", {
|
|
288
|
-
maximumFractionDigits: 2,
|
|
289
|
-
minimumFractionDigits: 2,
|
|
290
|
-
}).format(value)}%`;
|
|
291
|
-
}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
export declare const analyticsCapabilities: readonly [{
|
|
2
|
-
readonly id: "analytics.historical-return";
|
|
3
|
-
readonly kind: "read";
|
|
4
|
-
readonly visibility: readonly ["cli", "opencode"];
|
|
5
|
-
readonly description: "Calculate historical return for a saved portfolio or an ad-hoc weighted basket.";
|
|
6
|
-
readonly http: {
|
|
7
|
-
readonly method: "POST";
|
|
8
|
-
readonly path: "/api/desk/tools/portfolio/historical_return";
|
|
9
|
-
readonly inputMode: "json_body";
|
|
10
|
-
readonly schemas: {
|
|
11
|
-
readonly request: "PortfolioHistoricalReturnRequest";
|
|
12
|
-
readonly response: "HistoricalReturnResponse";
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
readonly cli: {
|
|
16
|
-
readonly group: "analytics";
|
|
17
|
-
readonly command: "historical-return";
|
|
18
|
-
readonly summary: "Calculate historical return for a saved portfolio or repeated --asset inputs.";
|
|
19
|
-
readonly positional: readonly [];
|
|
20
|
-
readonly options: readonly [{
|
|
21
|
-
readonly kind: "option";
|
|
22
|
-
readonly flag: "--portfolio";
|
|
23
|
-
readonly name: "portfolio_id";
|
|
24
|
-
readonly type: "integer";
|
|
25
|
-
readonly required: false;
|
|
26
|
-
readonly placeholder: "ID";
|
|
27
|
-
readonly exclusiveGroup: "source";
|
|
28
|
-
readonly description: "Saved portfolio id. Use exactly one source: --portfolio or repeated --asset.";
|
|
29
|
-
}, {
|
|
30
|
-
readonly kind: "option";
|
|
31
|
-
readonly flag: "--asset";
|
|
32
|
-
readonly name: "assets";
|
|
33
|
-
readonly type: "string_array";
|
|
34
|
-
readonly required: false;
|
|
35
|
-
readonly placeholder: "TICKER[:PESO]";
|
|
36
|
-
readonly multiple: true;
|
|
37
|
-
readonly collectionFormat: "repeatable";
|
|
38
|
-
readonly exclusiveGroup: "source";
|
|
39
|
-
readonly description: "Repeatable ad-hoc asset input using TICKER[:WEIGHT_PCT], for example PRIO3:50.";
|
|
40
|
-
}, {
|
|
41
|
-
readonly kind: "option";
|
|
42
|
-
readonly flag: "--from";
|
|
43
|
-
readonly name: "start_date";
|
|
44
|
-
readonly type: "string";
|
|
45
|
-
readonly required: true;
|
|
46
|
-
readonly placeholder: "AAAA-MM-DD";
|
|
47
|
-
readonly description: "Inclusive start date in ISO format.";
|
|
48
|
-
}, {
|
|
49
|
-
readonly kind: "option";
|
|
50
|
-
readonly flag: "--to";
|
|
51
|
-
readonly name: "end_date";
|
|
52
|
-
readonly type: "string";
|
|
53
|
-
readonly required: true;
|
|
54
|
-
readonly placeholder: "AAAA-MM-DD";
|
|
55
|
-
readonly description: "Inclusive end date in ISO format.";
|
|
56
|
-
}];
|
|
57
|
-
readonly examples: readonly ["quantbrasil analytics historical-return --portfolio 123 --from 2024-01-01 --to 2025-01-01", "quantbrasil analytics historical-return --asset PRIO3:50 --asset VALE3:50 --from 2021-01-01 --to 2025-01-01"];
|
|
58
|
-
};
|
|
59
|
-
readonly tool: {
|
|
60
|
-
readonly name: "qb_historical_return";
|
|
61
|
-
readonly title: "Calculate historical return";
|
|
62
|
-
};
|
|
63
|
-
readonly outputModes: readonly ["json", "human"];
|
|
64
|
-
}, {
|
|
65
|
-
readonly id: "analytics.beta";
|
|
66
|
-
readonly kind: "read";
|
|
67
|
-
readonly visibility: readonly ["cli", "opencode"];
|
|
68
|
-
readonly description: "Calculate portfolio beta against IBOV for a saved portfolio or an ad-hoc basket.";
|
|
69
|
-
readonly http: {
|
|
70
|
-
readonly method: "POST";
|
|
71
|
-
readonly path: "/api/desk/tools/portfolio/beta";
|
|
72
|
-
readonly inputMode: "json_body";
|
|
73
|
-
readonly schemas: {
|
|
74
|
-
readonly request: "PortfolioBetaRequest";
|
|
75
|
-
readonly response: "PortfolioBetaResponse";
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
readonly cli: {
|
|
79
|
-
readonly group: "analytics";
|
|
80
|
-
readonly command: "beta";
|
|
81
|
-
readonly summary: "Calculate portfolio beta against IBOV.";
|
|
82
|
-
readonly positional: readonly [];
|
|
83
|
-
readonly options: readonly [{
|
|
84
|
-
readonly kind: "option";
|
|
85
|
-
readonly flag: "--portfolio";
|
|
86
|
-
readonly name: "portfolio_id";
|
|
87
|
-
readonly type: "integer";
|
|
88
|
-
readonly required: false;
|
|
89
|
-
readonly placeholder: "ID";
|
|
90
|
-
readonly exclusiveGroup: "source";
|
|
91
|
-
readonly description: "Saved portfolio id. Use exactly one source: --portfolio or repeated --asset.";
|
|
92
|
-
}, {
|
|
93
|
-
readonly kind: "option";
|
|
94
|
-
readonly flag: "--asset";
|
|
95
|
-
readonly name: "assets";
|
|
96
|
-
readonly type: "string_array";
|
|
97
|
-
readonly required: false;
|
|
98
|
-
readonly placeholder: "TICKER[:PESO]";
|
|
99
|
-
readonly multiple: true;
|
|
100
|
-
readonly collectionFormat: "repeatable";
|
|
101
|
-
readonly exclusiveGroup: "source";
|
|
102
|
-
readonly description: "Repeatable ad-hoc asset input using TICKER[:WEIGHT_PCT], for example PETR4:120 or WINFUT:-20.";
|
|
103
|
-
}, {
|
|
104
|
-
readonly kind: "option";
|
|
105
|
-
readonly flag: "--years";
|
|
106
|
-
readonly name: "years";
|
|
107
|
-
readonly type: "enum";
|
|
108
|
-
readonly required: false;
|
|
109
|
-
readonly placeholder: "ANOS";
|
|
110
|
-
readonly defaultValue: 1;
|
|
111
|
-
readonly enumValues: readonly ["1", "3", "5"];
|
|
112
|
-
readonly description: "Historical lookback window in years. Accepted values: 1, 3, or 5.";
|
|
113
|
-
}];
|
|
114
|
-
readonly examples: readonly ["quantbrasil analytics beta --portfolio 123 --years 3", "quantbrasil analytics beta --asset PRIO3:120 --asset WINFUT:-20 --years 1"];
|
|
115
|
-
};
|
|
116
|
-
readonly tool: {
|
|
117
|
-
readonly name: "qb_portfolio_beta";
|
|
118
|
-
readonly title: "Calculate portfolio beta";
|
|
119
|
-
};
|
|
120
|
-
readonly outputModes: readonly ["json", "human"];
|
|
121
|
-
}, {
|
|
122
|
-
readonly id: "analytics.var";
|
|
123
|
-
readonly kind: "read";
|
|
124
|
-
readonly visibility: readonly ["cli", "opencode"];
|
|
125
|
-
readonly description: "Calculate one-day Value-at-Risk for a saved portfolio or an ad-hoc basket.";
|
|
126
|
-
readonly http: {
|
|
127
|
-
readonly method: "POST";
|
|
128
|
-
readonly path: "/api/desk/tools/portfolio/var";
|
|
129
|
-
readonly inputMode: "json_body";
|
|
130
|
-
readonly schemas: {
|
|
131
|
-
readonly request: "PortfolioVaRRequest";
|
|
132
|
-
readonly response: "PortfolioVaRResponse";
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
readonly cli: {
|
|
136
|
-
readonly group: "analytics";
|
|
137
|
-
readonly command: "var";
|
|
138
|
-
readonly summary: "Calculate one-day Value-at-Risk for a portfolio or basket.";
|
|
139
|
-
readonly positional: readonly [];
|
|
140
|
-
readonly options: readonly [{
|
|
141
|
-
readonly kind: "option";
|
|
142
|
-
readonly flag: "--portfolio";
|
|
143
|
-
readonly name: "portfolio_id";
|
|
144
|
-
readonly type: "integer";
|
|
145
|
-
readonly required: false;
|
|
146
|
-
readonly placeholder: "ID";
|
|
147
|
-
readonly exclusiveGroup: "source";
|
|
148
|
-
readonly description: "Saved portfolio id. Use exactly one source: --portfolio or repeated --asset.";
|
|
149
|
-
}, {
|
|
150
|
-
readonly kind: "option";
|
|
151
|
-
readonly flag: "--asset";
|
|
152
|
-
readonly name: "assets";
|
|
153
|
-
readonly type: "string_array";
|
|
154
|
-
readonly required: false;
|
|
155
|
-
readonly placeholder: "TICKER[:PESO]";
|
|
156
|
-
readonly multiple: true;
|
|
157
|
-
readonly collectionFormat: "repeatable";
|
|
158
|
-
readonly exclusiveGroup: "source";
|
|
159
|
-
readonly description: "Repeatable ad-hoc asset input using TICKER[:WEIGHT_PCT], for example PRIO3:120 or WINFUT:-20.";
|
|
160
|
-
}, {
|
|
161
|
-
readonly kind: "option";
|
|
162
|
-
readonly flag: "--years";
|
|
163
|
-
readonly name: "years";
|
|
164
|
-
readonly type: "integer";
|
|
165
|
-
readonly required: false;
|
|
166
|
-
readonly placeholder: "ANOS";
|
|
167
|
-
readonly defaultValue: 1;
|
|
168
|
-
readonly description: "Historical lookback window in years. The VaR horizon remains one day.";
|
|
169
|
-
}, {
|
|
170
|
-
readonly kind: "option";
|
|
171
|
-
readonly flag: "--confidence";
|
|
172
|
-
readonly name: "confidence_pct";
|
|
173
|
-
readonly type: "number";
|
|
174
|
-
readonly required: false;
|
|
175
|
-
readonly placeholder: "PERCENTUAL";
|
|
176
|
-
readonly defaultValue: 95;
|
|
177
|
-
readonly description: "Confidence level in percent, for example 95 or 99.";
|
|
178
|
-
}];
|
|
179
|
-
readonly examples: readonly ["quantbrasil analytics var --portfolio 123 --years 1 --confidence 95", "quantbrasil analytics var --asset PRIO3:50 --asset VALE3:50 --years 3 --confidence 99"];
|
|
180
|
-
};
|
|
181
|
-
readonly tool: {
|
|
182
|
-
readonly name: "qb_portfolio_var";
|
|
183
|
-
readonly title: "Calculate portfolio VaR";
|
|
184
|
-
};
|
|
185
|
-
readonly outputModes: readonly ["json", "human"];
|
|
186
|
-
}];
|
|
187
|
-
//# sourceMappingURL=analytics.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/capabilities/analytics.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgOkB,CAAC"}
|