@quantbrasil/cli 0.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +272 -0
  2. package/bin/quantbrasil.js +4 -0
  3. package/dist/cli/auth.d.ts +20 -0
  4. package/dist/cli/auth.d.ts.map +1 -0
  5. package/dist/cli/auth.js +76 -0
  6. package/dist/cli/client.d.ts +17 -0
  7. package/dist/cli/client.d.ts.map +1 -0
  8. package/dist/cli/client.js +112 -0
  9. package/dist/cli/config.d.ts +33 -0
  10. package/dist/cli/config.d.ts.map +1 -0
  11. package/dist/cli/config.js +148 -0
  12. package/dist/cli/errors.d.ts +40 -0
  13. package/dist/cli/errors.d.ts.map +1 -0
  14. package/dist/cli/errors.js +122 -0
  15. package/dist/cli/index.d.ts +30 -0
  16. package/dist/cli/index.d.ts.map +1 -0
  17. package/dist/cli/index.js +112 -0
  18. package/dist/cli/prompt.d.ts +2 -0
  19. package/dist/cli/prompt.d.ts.map +1 -0
  20. package/dist/cli/prompt.js +40 -0
  21. package/dist/cli/skills.d.ts +26 -0
  22. package/dist/cli/skills.d.ts.map +1 -0
  23. package/dist/cli/skills.js +94 -0
  24. package/dist/cli/terminal.d.ts +18 -0
  25. package/dist/cli/terminal.d.ts.map +1 -0
  26. package/dist/cli/terminal.js +43 -0
  27. package/dist/commands/analytics.d.ts +131 -0
  28. package/dist/commands/analytics.d.ts.map +1 -0
  29. package/dist/commands/analytics.js +291 -0
  30. package/dist/commands/assets.d.ts +69 -0
  31. package/dist/commands/assets.d.ts.map +1 -0
  32. package/dist/commands/assets.js +350 -0
  33. package/dist/commands/auth.d.ts +17 -0
  34. package/dist/commands/auth.d.ts.map +1 -0
  35. package/dist/commands/auth.js +48 -0
  36. package/dist/commands/capabilities.d.ts +25 -0
  37. package/dist/commands/capabilities.d.ts.map +1 -0
  38. package/dist/commands/capabilities.js +61 -0
  39. package/dist/commands/init.d.ts +17 -0
  40. package/dist/commands/init.d.ts.map +1 -0
  41. package/dist/commands/init.js +89 -0
  42. package/dist/commands/market.d.ts +45 -0
  43. package/dist/commands/market.d.ts.map +1 -0
  44. package/dist/commands/market.js +162 -0
  45. package/dist/commands/portfolios.d.ts +60 -0
  46. package/dist/commands/portfolios.d.ts.map +1 -0
  47. package/dist/commands/portfolios.js +298 -0
  48. package/dist/commands/skills.d.ts +17 -0
  49. package/dist/commands/skills.d.ts.map +1 -0
  50. package/dist/commands/skills.js +38 -0
  51. package/dist/commands/status.d.ts +15 -0
  52. package/dist/commands/status.d.ts.map +1 -0
  53. package/dist/commands/status.js +52 -0
  54. package/dist/index.d.ts +14 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +13 -0
  57. package/dist/vendor/core/capabilities/analytics.d.ts +187 -0
  58. package/dist/vendor/core/capabilities/analytics.d.ts.map +1 -0
  59. package/dist/vendor/core/capabilities/analytics.js +214 -0
  60. package/dist/vendor/core/capabilities/assets.d.ts +48 -0
  61. package/dist/vendor/core/capabilities/assets.d.ts.map +1 -0
  62. package/dist/vendor/core/capabilities/assets.js +66 -0
  63. package/dist/vendor/core/capabilities/index.d.ts +8 -0
  64. package/dist/vendor/core/capabilities/index.d.ts.map +1 -0
  65. package/dist/vendor/core/capabilities/index.js +7 -0
  66. package/dist/vendor/core/capabilities/market.d.ts +90 -0
  67. package/dist/vendor/core/capabilities/market.d.ts.map +1 -0
  68. package/dist/vendor/core/capabilities/market.js +114 -0
  69. package/dist/vendor/core/capabilities/portfolios.d.ts +224 -0
  70. package/dist/vendor/core/capabilities/portfolios.d.ts.map +1 -0
  71. package/dist/vendor/core/capabilities/portfolios.js +244 -0
  72. package/dist/vendor/core/capabilities/registry.d.ts +1083 -0
  73. package/dist/vendor/core/capabilities/registry.d.ts.map +1 -0
  74. package/dist/vendor/core/capabilities/registry.js +14 -0
  75. package/dist/vendor/core/capabilities/shared.d.ts +3 -0
  76. package/dist/vendor/core/capabilities/shared.d.ts.map +1 -0
  77. package/dist/vendor/core/capabilities/shared.js +2 -0
  78. package/dist/vendor/core/capabilities/types.d.ts +75 -0
  79. package/dist/vendor/core/capabilities/types.d.ts.map +1 -0
  80. package/dist/vendor/core/capabilities/types.js +1 -0
  81. package/dist/vendor/core/errors.d.ts +22 -0
  82. package/dist/vendor/core/errors.d.ts.map +1 -0
  83. package/dist/vendor/core/errors.js +42 -0
  84. package/dist/vendor/core/http/client.d.ts +45 -0
  85. package/dist/vendor/core/http/client.d.ts.map +1 -0
  86. package/dist/vendor/core/http/client.js +170 -0
  87. package/dist/vendor/core/http/index.d.ts +2 -0
  88. package/dist/vendor/core/http/index.d.ts.map +1 -0
  89. package/dist/vendor/core/http/index.js +1 -0
  90. package/dist/vendor/core/index.d.ts +5 -0
  91. package/dist/vendor/core/index.d.ts.map +1 -0
  92. package/dist/vendor/core/index.js +4 -0
  93. package/dist/vendor/core/invoke.d.ts +17 -0
  94. package/dist/vendor/core/invoke.d.ts.map +1 -0
  95. package/dist/vendor/core/invoke.js +70 -0
  96. package/package.json +57 -0
  97. package/skills/quantbrasil/SKILL.md +29 -0
  98. package/skills/quantbrasil/references/cli.md +77 -0
  99. package/skills/quantbrasil/references/costs.md +30 -0
  100. package/skills/quantbrasil/references/errors.md +128 -0
  101. package/skills/quantbrasil/references/unsupported.md +20 -0
  102. package/skills/quantbrasil/references/workflows.md +99 -0
@@ -0,0 +1,77 @@
1
+ # CLI Reference
2
+
3
+ ## Readiness and auth
4
+
5
+ ```bash
6
+ quantbrasil --status
7
+ quantbrasil auth login --api-key <key>
8
+ quantbrasil auth logout
9
+ quantbrasil capabilities --json
10
+ quantbrasil init
11
+ ```
12
+
13
+ ## Market
14
+
15
+ ```bash
16
+ quantbrasil market assets
17
+ quantbrasil market assets --type B3
18
+ quantbrasil market assets --json
19
+
20
+ quantbrasil market price PETR4
21
+ quantbrasil market price PETR4 --date 2026-04-10
22
+ quantbrasil market price PETR4 --timeframe W1
23
+ quantbrasil market price PETR4 --json
24
+ ```
25
+
26
+ ## Asset analysis
27
+
28
+ ```bash
29
+ quantbrasil assets overview PETR4 --sections price,performance
30
+ quantbrasil assets overview PETR4 --sections price,technicals
31
+ quantbrasil assets overview PETR4 --sections price,fundamentals --json
32
+ ```
33
+
34
+ Valid `--sections`:
35
+
36
+ - `price`
37
+ - `performance`
38
+ - `momentum`
39
+ - `technicals`
40
+ - `risk`
41
+ - `fundamentals`
42
+ - `rankings`
43
+
44
+ ## Portfolios
45
+
46
+ ```bash
47
+ quantbrasil portfolios list
48
+ quantbrasil portfolios list --json
49
+
50
+ quantbrasil portfolios get 93
51
+ quantbrasil portfolios get 93 --json
52
+
53
+ quantbrasil portfolios create "Dividendos"
54
+ quantbrasil portfolios rename 93 "Longo Prazo"
55
+ quantbrasil portfolios add-assets 93 PETR4 VALE3
56
+ quantbrasil portfolios remove-assets 93 PETR4
57
+ ```
58
+
59
+ ## Analytics
60
+
61
+ Saved portfolio:
62
+
63
+ ```bash
64
+ quantbrasil analytics historical-return --portfolio 93 --from 2025-01-01 --to 2026-01-01
65
+ quantbrasil analytics beta --portfolio 93 --years 1
66
+ quantbrasil analytics var --portfolio 93 --years 1 --confidence 95
67
+ ```
68
+
69
+ Ad-hoc basket:
70
+
71
+ ```bash
72
+ quantbrasil analytics historical-return --asset VALE3:50 --asset PRIO3:50 --from 2025-01-01 --to 2026-01-01
73
+ quantbrasil analytics beta --asset VALE3:50 --asset PRIO3:50 --years 3
74
+ quantbrasil analytics var --asset VALE3:120 --asset WINFUT:-20 --years 1 --confidence 99
75
+ ```
76
+
77
+ Use `--json` on any analytics command when machine parsing needed.
@@ -0,0 +1,30 @@
1
+ # Cost-Aware Behavior
2
+
3
+ Exact public credit pricing is not locked yet.
4
+
5
+ Current guidance uses backend qualitative classes only:
6
+
7
+ - `free`
8
+ - `standard`
9
+ - `heavy`
10
+
11
+ ## Current behavior guidance
12
+
13
+ - `market assets` is lowest-cost discovery path
14
+ - `market price` is narrow read path
15
+ - `assets overview` is richer and should use minimal `--sections`
16
+ - portfolio analytics (`historical-return`, `beta`, `var`) are heaviest current public reads
17
+
18
+ ## Agent rules
19
+
20
+ - prefer narrow command that answers question
21
+ - prefer `market price` over `assets overview` for quote-only requests
22
+ - prefer one analytics call targeted to actual question
23
+ - do not chain multiple heavy analytics calls unless user asked for them
24
+ - use `--json` only when structured output needed
25
+
26
+ ## Safe defaults
27
+
28
+ - discover portfolio id once, then reuse it
29
+ - avoid full-report behavior when user asked only one metric
30
+ - keep `assets overview --sections` minimal and relevant
@@ -0,0 +1,128 @@
1
+ # Error Handling
2
+
3
+ ## Auth / readiness
4
+
5
+ Check:
6
+
7
+ ```bash
8
+ quantbrasil --status
9
+ ```
10
+
11
+ If not ready:
12
+
13
+ ```bash
14
+ quantbrasil auth login --api-key <key>
15
+ ```
16
+
17
+ If local backend or staging needed:
18
+
19
+ ```bash
20
+ QB_BACKEND_URL=http://127.0.0.1:8000 quantbrasil --status
21
+ ```
22
+
23
+ ## Validation failures
24
+
25
+ Treat CLI validation as user-input error.
26
+
27
+ Examples:
28
+
29
+ - invalid portfolio id
30
+ - invalid `--sections`
31
+ - invalid `--asset TICKER[:WEIGHT_PCT]`
32
+ - invalid `--years`
33
+
34
+ Fix input. Do not retry same bad command.
35
+
36
+ Stable code:
37
+
38
+ - `validation_error`
39
+
40
+ ## Backend auth failures
41
+
42
+ Typical causes:
43
+
44
+ - bad API key
45
+ - revoked API key
46
+ - wrong backend target
47
+
48
+ Recovery:
49
+
50
+ 1. run `quantbrasil --status`
51
+ 2. re-login if needed
52
+ 3. confirm `QB_BACKEND_URL` target
53
+
54
+ Stable codes:
55
+
56
+ - `auth_required`
57
+ - `auth_failed`
58
+
59
+ ## Not found / empty data
60
+
61
+ Possible causes:
62
+
63
+ - portfolio id does not exist
64
+ - ticker not tracked
65
+ - requested history unavailable for period
66
+
67
+ Recovery:
68
+
69
+ - use `market assets` for discovery
70
+ - use `portfolios list` before `portfolios get`
71
+ - narrow period or pick another ticker
72
+
73
+ Stable code:
74
+
75
+ - `not_found`
76
+
77
+ ## Rate limits
78
+
79
+ Do not retry immediately in a tight loop.
80
+
81
+ Recovery:
82
+
83
+ - wait before retrying
84
+ - reduce repeated calls
85
+ - reuse data already returned by a previous command
86
+
87
+ Stable code:
88
+
89
+ - `rate_limited`
90
+
91
+ ## Mutation failures
92
+
93
+ Mutation commands can fail even when the backend route is reachable, for example
94
+ when a requested ticker is invalid for the operation.
95
+
96
+ Recovery:
97
+
98
+ - read the error message
99
+ - fix the requested portfolio id, name, ticker list, or operation
100
+ - do not retry unchanged mutation input
101
+
102
+ Stable code:
103
+
104
+ - `mutation_failed`
105
+
106
+ ## Machine handling note
107
+
108
+ For commands that expose `--json`, failures are written to stderr as:
109
+
110
+ ```json
111
+ {
112
+ "ok": false,
113
+ "error": {
114
+ "code": "validation_error",
115
+ "message": "Invalid section \"summary\". Use only: price, performance, momentum, technicals, risk, fundamentals, rankings.",
116
+ "category": "validation",
117
+ "exit_code": 1
118
+ }
119
+ }
120
+ ```
121
+
122
+ Human stderr includes the same stable code, for example:
123
+
124
+ ```text
125
+ [validation_error] Invalid section "summary". Use only: price, performance, momentum, technicals, risk, fundamentals, rankings.
126
+ ```
127
+
128
+ Branch on `error.code`, not full message text.
@@ -0,0 +1,20 @@
1
+ # Unsupported
2
+
3
+ Unsupported in the public CLI:
4
+
5
+ - `--output <file>` response export
6
+
7
+ Not a supported pattern:
8
+
9
+ - inventing commands not shown in `quantbrasil --help`
10
+ - assuming hidden flags exist
11
+ - treating backend internals as public CLI contract
12
+
13
+ Use the public surface only:
14
+
15
+ - `auth`
16
+ - `capabilities`
17
+ - `market`
18
+ - `assets`
19
+ - `portfolios`
20
+ - `analytics`
@@ -0,0 +1,99 @@
1
+ # Workflows
2
+
3
+ ## Find supported ticker, then get price
4
+
5
+ Use this when user gives company theme, partial name, or market universe question.
6
+
7
+ ```bash
8
+ quantbrasil market assets --type B3
9
+ quantbrasil market price PETR4
10
+ ```
11
+
12
+ If exact ticker already known, skip discovery and go straight to `market price`.
13
+
14
+ ## Get price on specific date
15
+
16
+ ```bash
17
+ quantbrasil market price PETR4 --date 2026-04-10
18
+ ```
19
+
20
+ Use absolute ISO dates.
21
+
22
+ ## Pick cheapest asset command first
23
+
24
+ - need only current or dated quote → `market price`
25
+ - need tracked universe / supported symbols → `market assets`
26
+ - need richer analysis for one asset → `assets overview`
27
+
28
+ Do not jump to `assets overview` if price-only answer is enough.
29
+
30
+ ## Cost-aware `assets overview` section choice
31
+
32
+ Keep `--sections` minimal.
33
+
34
+ Good:
35
+
36
+ ```bash
37
+ quantbrasil assets overview PETR4 --sections price,performance
38
+ quantbrasil assets overview PETR4 --sections price,technicals
39
+ quantbrasil assets overview PETR4 --sections risk,fundamentals
40
+ ```
41
+
42
+ Guidance:
43
+
44
+ - `price,performance` for quick market context
45
+ - `technicals,momentum` for chart / signal questions
46
+ - `risk` for drawdown / volatility style questions
47
+ - `fundamentals,rankings` for valuation / ranking context
48
+
49
+ Avoid asking for every section unless user clearly wants full report.
50
+
51
+ ## Analyze saved portfolio
52
+
53
+ 1. Discover portfolio id.
54
+ 2. Inspect holdings if needed.
55
+ 3. Run analytics.
56
+
57
+ ```bash
58
+ quantbrasil portfolios list
59
+ quantbrasil portfolios get 93
60
+ quantbrasil analytics historical-return --portfolio 93 --from 2025-01-01 --to 2026-01-01
61
+ quantbrasil analytics beta --portfolio 93 --years 1
62
+ quantbrasil analytics var --portfolio 93 --years 1 --confidence 95
63
+ ```
64
+
65
+ ## Analyze ad-hoc basket
66
+
67
+ Use repeated `--asset TICKER[:WEIGHT_PCT]`.
68
+
69
+ Rules:
70
+
71
+ - if weights omitted, backend may assume equal weights
72
+ - negative weights allowed for hedge / short exposure
73
+ - `beta` only accepts `--years 1|3|5`
74
+ - `var --confidence` takes percent like `95` or `99`
75
+
76
+ Example:
77
+
78
+ ```bash
79
+ quantbrasil analytics historical-return --asset VALE3:50 --asset PRIO3:50 --from 2025-01-01 --to 2026-01-01
80
+ quantbrasil analytics beta --asset VALE3:120 --asset WINFUT:-20 --years 1
81
+ quantbrasil analytics var --asset VALE3:120 --asset WINFUT:-20 --years 1 --confidence 99
82
+ ```
83
+
84
+ ## Modify saved portfolio
85
+
86
+ Use explicit mutation commands. Do not retry failed mutations automatically.
87
+
88
+ ```bash
89
+ quantbrasil portfolios create "Dividendos"
90
+ quantbrasil portfolios rename 93 "Longo Prazo"
91
+ quantbrasil portfolios add-assets 93 PETR4 VALE3
92
+ quantbrasil portfolios remove-assets 93 PETR4
93
+ ```
94
+
95
+ Rules:
96
+
97
+ - use `portfolios list` first if user names a portfolio instead of giving id
98
+ - confirm destructive intent before removing assets when user request is ambiguous
99
+ - use `--json` only when structured output is needed