mozyfin-cli 0.2.9 → 0.2.10

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 (2) hide show
  1. package/README.md +61 -180
  2. package/package.json +16 -4
package/README.md CHANGED
@@ -1,37 +1,41 @@
1
1
  # Mozyfin CLI
2
2
 
3
- A Bun-powered command line interface for Vietnamese market data from the Mozyfin/Antofin APIs. It is designed for both humans and AI agents: short ticker-first commands, Markdown tables by default, CSV export for long datasets, and predictable plain-text errors.
3
+ Mozyfin CLI brings Vietnamese market data and Mozyfin research workflows to your terminal. It is built for fast lookup, repeatable analysis, and agent-friendly command usage without exposing product internals.
4
4
 
5
- ## Highlights
5
+ ## Why Mozyfin CLI
6
6
 
7
- - Human-readable Markdown output by default
8
- - CSV export with `--csv <file>` for spreadsheets or agent pipelines
9
- - All commands require an API key `MOZYFIN_API_KEY`, saved config, or `--api-key`
10
- - Client-side 1 request/second rate limit for API friendliness
11
- - Built-in technical indicators and risk metrics from OHLCV candles
12
- - Automatic update check that warns when a newer CLI version is available on npm
13
- - Mocked CLI test suite covering command wiring, auth, config, CSV, validation, and output shape
7
+ - **Fast market lookup** search symbols, view profiles, read news, and inspect company data from one command line.
8
+ - **Agent-friendly** concise commands and predictable text output work well with Claude Code, Codex, GitHub Copilot, and other coding agents.
9
+ - **Research-ready** ask natural-language questions, query documents, and export larger tables to CSV when needed.
10
+ - **Terminal-native** use it manually, inside scripts, or as part of an agent workflow.
14
11
 
15
12
  ## Requirements
16
13
 
17
- - [Bun](https://bun.sh) `>= 1.1.0`
18
- - A Mozyfin API key — required for every command (run `mozyfin login` once before using the CLI)
14
+ - A Mozyfin API key for authenticated features
19
15
 
20
- Create an API key at: https://research.mozyfin.com/settings
16
+ Create or manage your API key at:
21
17
 
22
- ## Install
18
+ ```text
19
+ https://research.mozyfin.com/settings
20
+ ```
21
+
22
+ ## Installation
23
23
 
24
24
  ```bash
25
25
  npm install -g mozyfin-cli
26
+ mozyfin --help
26
27
  ```
27
28
 
28
29
  Or with Bun:
29
30
 
30
31
  ```bash
31
32
  bun install -g mozyfin-cli
33
+ mozyfin --help
32
34
  ```
33
35
 
34
- ### Save API Key
36
+ ## Login
37
+
38
+ Save your API key once:
35
39
 
36
40
  ```bash
37
41
  mozyfin login --api-key mozy_ak_xxx
@@ -55,161 +59,87 @@ mozyfin doc "định giá HPG"
55
59
  mozyfin ask "compare VNM and MSN margin trend"
56
60
  ```
57
61
 
58
- ## Commands
62
+ ## Using With Coding Agents
59
63
 
60
- | Command | Purpose | Example |
61
- | --- | --- | --- |
62
- | `login` | Save API key locally | `mozyfin login --api-key <key>` |
63
- | `logout` | Remove saved API key | `mozyfin logout` |
64
- | `search` | Search ticker/company/entity | `mozyfin search --query VNM` |
65
- | `profile` | Company/entity profile | `mozyfin profile VNM.VN` |
66
- | `news` | Market headlines and article search | `mozyfin news --entities VNM.VN --topics stock,earning` |
67
- | `indices` | List supported market indices | `mozyfin indices` |
68
- | `ohlcv` | Historical candles | `mozyfin ohlcv VNM.VN --timeframe 1d --limit 200` |
69
- | `quote` | Historical quote stats | `mozyfin quote VNM.VN --limit 10` |
70
- | `officers` | Company officers/directors | `mozyfin officers VNM.VN` |
71
- | `subsidiary` | Subsidiaries | `mozyfin subsidiary VNM.VN` |
72
- | `holder` | Major shareholders | `mozyfin holder VNM.VN --is-organization true` |
73
- | `holder-tx` | Shareholder transactions | `mozyfin holder-tx VNM.VN --transaction-type buy --limit 100` |
74
- | `financials` | Financial statements summary | `mozyfin financials VNM.VN --year 2024 --quarter 4` |
75
- | `stats` | Financial statistics/ratios | `mozyfin stats VNM.VN --year 2024` |
76
- | `ta` | Technical indicators | `mozyfin ta VNM.VN --sma 20,50 --rsi 14 --macd` |
77
- | `risk` | Return, volatility, Sharpe, drawdown | `mozyfin risk VNM.VN --limit 252 --risk-free 0.03` |
78
- | `doc` | Query analysis reports (RAG) | `mozyfin doc "định giá HPG"` |
79
- | `ask` | Ask the Mozyfin agent | `mozyfin ask "analyze VNM" --timeout 300` |
80
- | `credits` | Check subscription usage | `mozyfin credits` |
81
- | `doctor` | Runtime/config/API health check | `mozyfin doctor` |
82
- | `update` | Upgrade CLI and refresh installed agent skills | `mozyfin update` |
83
- | `skill` | Install/remove/list agent skill packs | `mozyfin skill claude` |
84
-
85
- ## Command Reference
86
-
87
- ### Auth
64
+ Mozyfin CLI is a good fit for agent workflows because agents can call small terminal commands instead of loading large tool schemas or internal implementation details.
88
65
 
89
- ```bash
90
- mozyfin login --api-key <key>
91
- mozyfin logout
92
- mozyfin credits
66
+ Example prompt for your agent:
67
+
68
+ ```text
69
+ Use mozyfin-cli to research VNM.VN.
70
+ Start with `mozyfin --help`, then gather profile, news, financials, and recent candles.
71
+ Summarize the key risks and catalysts with command outputs as evidence.
93
72
  ```
94
73
 
95
- Auth precedence is:
74
+ For larger tabular results, ask your agent to use CSV export:
75
+
76
+ ```bash
77
+ mozyfin ohlcv VNM.VN --timeframe 1d --limit 200 --csv vnm.csv
78
+ ```
96
79
 
97
- 1. Explicit global `--api-key <key>`
98
- 2. `MOZYFIN_API_KEY` environment variable
99
- 3. Saved config from `mozyfin login`
80
+ ## Commands
100
81
 
101
- Config is stored at:
82
+ ### Account
102
83
 
103
- ```text
104
- ~/.config/mozyfin-cli/config.json
84
+ ```bash
85
+ mozyfin login --api-key <key>
86
+ mozyfin logout
87
+ mozyfin credits
88
+ mozyfin doctor
89
+ mozyfin update
105
90
  ```
106
91
 
107
- ### Search and Profile
92
+ ### Discovery
108
93
 
109
94
  ```bash
110
95
  mozyfin search --query VNM
111
- mozyfin search -q "Vinamilk"
112
- mozyfin search -q "" # broad search/all, depending on API behavior
113
96
  mozyfin profile VNM.VN
97
+ mozyfin indices
114
98
  ```
115
99
 
116
- `search` intentionally only exposes `--query` to keep the CLI simple and aligned with the current product workflow.
117
-
118
- ### News
100
+ ### News And Research
119
101
 
120
102
  ```bash
121
103
  mozyfin news --query "Vinamilk" --limit 10
122
104
  mozyfin news --entities VNM.VN,MSN.VN --topics stock,earning --limit 20
123
- ```
124
-
125
- Allowed topics:
126
-
127
- ```text
128
- stock, crypto, forex, tariff, economic, earning, tech, housing, mergers_and_ipo
105
+ mozyfin doc "định giá HPG"
106
+ mozyfin ask "summarize VNM risks and catalysts"
129
107
  ```
130
108
 
131
109
  ### Market Data
132
110
 
133
111
  ```bash
134
112
  mozyfin ohlcv VNM.VN --timeframe 1d --limit 200
135
- mozyfin ohlcv VNM.VN --timeframe 1w --to 2024-12-31 --limit 52
136
- mozyfin ohlcv VNINDEX.VN --timeframe 1d --limit 100
137
- mozyfin quote VNM.VN --to 2024-12-31 --limit 10
113
+ mozyfin quote VNM.VN --limit 10
138
114
  ```
139
115
 
140
- Allowed OHLCV timeframes:
116
+ Supported candle timeframes:
141
117
 
142
118
  ```text
143
119
  1h, 1d, 1w, 1mo, 1y
144
120
  ```
145
121
 
146
- `ohlcv` works for both equities and market indices. The CLI first calls the entity endpoint, and if no candles come back it automatically falls back to the market-index endpoint (`/api/v1/market/market-index/<id>/ohlcv`). The id is passed through unchanged, so `mozyfin ohlcv VNINDEX.VN`, `VN30.VN`, `VN100.VN`, `HNX30.VN`, `HNXIndex.VN`, etc. all work without special-casing. Run `mozyfin indices` to list every supported index id.
147
-
148
- ### Entity Details
122
+ ### Company Data
149
123
 
150
124
  ```bash
151
125
  mozyfin officers VNM.VN
152
126
  mozyfin subsidiary VNM.VN
153
- mozyfin holder VNM.VN --is-organization true --is-foreigner false
127
+ mozyfin holder VNM.VN --is-organization true
154
128
  mozyfin holder-tx VNM.VN --transaction-type buy --limit 100
155
129
  ```
156
130
 
157
- Note: the upstream endpoint for `officers` is named `/office`, but the returned data is officers/directors, so the CLI command uses `officers` for clarity.
158
-
159
- ### Financials
131
+ ### Financials And Analytics
160
132
 
161
133
  ```bash
162
134
  mozyfin financials VNM.VN --year 2024 --quarter 4
163
- mozyfin financials VNM.VN --year 2024 --quarter 4 --statement-type BALANCE_SHEET
164
135
  mozyfin stats VNM.VN --year 2024
165
- ```
166
-
167
- `financials` summarizes nested statement values into common readable columns such as `net_sales`, `gross_profit`, `profit_after_tax`, `total_assets`, `owner_equity`, and `net_operating_cash_flow`.
168
-
169
- ### Analytics
170
-
171
- ```bash
172
- mozyfin ta VNM.VN --sma 20,50,200 --rsi 14 --macd
136
+ mozyfin ta VNM.VN --sma 20,50 --rsi 14 --macd
173
137
  mozyfin risk VNM.VN --limit 252 --risk-free 0.03
174
138
  ```
175
139
 
176
- `ta` and `risk` compute over chronological candles even when the API returns latest-first data.
177
-
178
- ### Document Query
179
-
180
- ```bash
181
- mozyfin doc "định giá HPG"
182
- mozyfin doc "VNM Q4 2024 earnings analysis"
183
- mozyfin doc "so sánh biên lợi nhuận VNM và MSN"
184
- ```
185
-
186
- Queries analysis reports using natural language via RAG. Returns structured Markdown with sections:
187
-
188
- - **Entities** — knowledge graph entities extracted from reports
189
- - **Relationships** — connections between entities
190
- - **Document Chunks** — retrieved report passages relevant to the query
191
- - **References** — source documents mapped to chunks
192
- - **Context** — grounding instructions from the RAG system
193
-
194
- Requires an API key.
195
-
196
- ### Agent
197
-
198
- ```bash
199
- mozyfin ask "summarize VNM risks and catalysts"
200
- mozyfin ask "what is FPT's revenue growth outlook?" --timeout 600
201
- ```
202
-
203
- The command creates an auto-mode chat, sends the prompt, polls until the message finishes, and prints the final text response.
204
-
205
- Guidance:
206
-
207
- - **Ask one focused question per call.** Don't stuff multiple questions into a single prompt — the agent answers better and faster with a clear, narrow ask. Run `mozyfin ask` again for the next question.
208
- - `--timeout <seconds>` defaults to `300` (5 minutes). Raise it for deeper research prompts.
209
-
210
140
  ## Output
211
141
 
212
- Default output is Markdown table or key-value text:
142
+ Mozyfin CLI prints readable text by default, usually Markdown tables or compact key-value sections.
213
143
 
214
144
  ```bash
215
145
  mozyfin search --query VNM
@@ -221,72 +151,23 @@ mozyfin search --query VNM
221
151
  | VNM | Vietnam Dairy Products Joint Stock Company | HOSE | ... | VNM.VN |
222
152
  ```
223
153
 
224
- Use CSV for long datasets:
154
+ Use CSV when you want to save or process larger datasets:
225
155
 
226
156
  ```bash
227
157
  mozyfin ohlcv VNM.VN --timeframe 1d --limit 200 --csv vnm.csv
228
158
  ```
229
159
 
230
- ## Development
231
-
232
- ```bash
233
- bun install
234
- bun run check
235
- bun test
236
- ```
237
-
238
- Useful scripts:
160
+ ## Tips
239
161
 
240
- | Script | Description |
241
- | --- | --- |
242
- | `bun run dev -- <args>` | Run CLI from source |
243
- | `bun test` | Run unit/CLI tests |
244
- | `bun run lint` | Check formatting/linting |
245
- | `bun run format` | Format files |
246
- | `bun run check` | Format/lint with write fixes |
162
+ - Use `mozyfin search --query <text>` first to find the right entity id.
163
+ - Pass ids like `VNM.VN` into detail commands.
164
+ - Use `doc` for document and report questions.
165
+ - Use `ask` for open-ended research prompts.
166
+ - Keep prompts focused; run multiple commands for multi-part research.
247
167
 
248
- Run from source:
168
+ ## Help
249
169
 
250
170
  ```bash
251
- bun run src/index.ts search --query VNM
252
- ```
253
-
254
- ## Test Coverage
255
-
256
- The test suite uses Bun's test runner plus a mocked local HTTP server. It covers:
257
-
258
- - API URL construction and endpoint mapping
259
- - HTTP response and error parsing
260
- - CLI command output shape
261
- - Query parameter mapping for command options
262
- - Auth precedence and config persistence
263
- - CSV file output
264
- - Empty data rendering
265
- - Validation errors and missing API key errors
266
- - `ask` polling and malformed response handling
267
- - Technical indicator and risk helper behavior
268
-
269
- ## Project Structure
270
-
271
- ```text
272
- src/index.ts CLI command definitions
273
- src/lib/api.ts API client, auth, rate limit, URL construction
274
- src/lib/config.ts Local config load/save/clear
275
- src/lib/format.ts Markdown, key-value, CSV formatting
276
- src/lib/analytics.ts SMA, EMA, RSI, MACD, risk metrics
277
- test/*.test.ts Unit and mocked CLI tests
171
+ mozyfin --help
172
+ mozyfin <command> --help
278
173
  ```
279
-
280
- ## Notes for AI Agents
281
-
282
- - Prefer Markdown output for short responses and `--csv <file>` for large tables.
283
- - Use `search --query <text>` to discover entity ids, then pass ids such as `VNM.VN` into detail commands.
284
- - Do not use removed commands/options such as `markets`, `exchanges`, `events`, or `ask --no-wait`.
285
- - `officers` returns people and roles, not physical office addresses.
286
- - Every command requires an API key — call `mozyfin login --api-key <key>` (or set `MOZYFIN_API_KEY`) before any other command.
287
- - Use `doc` for natural language queries against analysis reports (RAG); use `ask` for open-ended AI research that may call multiple data sources.
288
- - If your CLI version is outdated the CLI prints an `⚠️` warning to stderr at the end of each run; pipe stderr separately if you parse output.
289
-
290
- ## License
291
-
292
- Private/internal unless a license is added.
package/package.json CHANGED
@@ -1,14 +1,26 @@
1
1
  {
2
2
  "name": "mozyfin-cli",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "Human- and agent-friendly CLI for Vietnamese market data via Mozyfin/Antofin APIs.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "mozyfin": "./dist/index.js",
8
8
  "mozyfin-cli": "./dist/index.js"
9
9
  },
10
- "files": ["dist", "agent-skills", "package.json", "README.md"],
11
- "keywords": ["mozyfin", "antofin", "vietnam", "stocks", "market-data", "cli"],
10
+ "files": [
11
+ "dist",
12
+ "agent-skills",
13
+ "package.json",
14
+ "README.md"
15
+ ],
16
+ "keywords": [
17
+ "mozyfin",
18
+ "antofin",
19
+ "vietnam",
20
+ "stocks",
21
+ "market-data",
22
+ "cli"
23
+ ],
12
24
  "scripts": {
13
25
  "dev": "bun run src/index.ts",
14
26
  "build": "bun build ./src/index.ts --target bun --minify --outfile dist/index.js && chmod +x dist/index.js",
@@ -38,5 +50,5 @@
38
50
  "bugs": {
39
51
  "url": "https://github.com/onlyai-team/mozyfin-cli/issues"
40
52
  },
41
- "homepage": "https://github.com/onlyai-team/mozyfin-cli#readme"
53
+ "homepage": "https://cli.mozyfin.com"
42
54
  }