@drico2008/fincli 0.1.9 → 0.3.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 (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +124 -625
  3. package/fincli/__init__.py +3 -3
  4. package/fincli/app/agents/__init__.py +5 -0
  5. package/fincli/app/agents/registry.py +76 -0
  6. package/fincli/app/analysis/ai_prompts.py +26 -14
  7. package/fincli/app/analysis/analyzer.py +107 -96
  8. package/fincli/app/analysis/assistant_context.py +187 -186
  9. package/fincli/app/analysis/backtest.py +179 -0
  10. package/fincli/app/analysis/gameplay_plan.py +79 -0
  11. package/fincli/app/analysis/multi_timeframe.py +180 -0
  12. package/fincli/app/analysis/trading_methods.py +144 -0
  13. package/fincli/app/cli/commands.py +108 -81
  14. package/fincli/app/cli/router.py +2327 -1237
  15. package/fincli/app/connectors/__init__.py +5 -0
  16. package/fincli/app/connectors/catalog.py +148 -0
  17. package/fincli/app/connectors/news_connectors.py +412 -0
  18. package/fincli/app/modules/alerts.py +80 -0
  19. package/fincli/app/modules/economic_calendar.py +374 -1
  20. package/fincli/app/modules/portfolio_risk.py +305 -0
  21. package/fincli/app/modules/reports.py +151 -0
  22. package/fincli/app/modules/scanner.py +111 -93
  23. package/fincli/app/modules/transactions.py +84 -84
  24. package/fincli/app/modules/user_profile.py +84 -0
  25. package/fincli/app/plugins/loader.py +72 -0
  26. package/fincli/app/providers/ai/manager.py +60 -60
  27. package/fincli/app/providers/market/alphavantage_provider.py +194 -0
  28. package/fincli/app/providers/market/base.py +98 -77
  29. package/fincli/app/providers/market/custom_provider.py +186 -169
  30. package/fincli/app/providers/market/manager.py +84 -1
  31. package/fincli/app/providers/market/symbols.py +143 -0
  32. package/fincli/app/providers/market/twelvedata_provider.py +167 -167
  33. package/fincli/app/providers/reliability.py +86 -0
  34. package/fincli/app/research/__init__.py +8 -0
  35. package/fincli/app/research/engine.py +137 -0
  36. package/fincli/app/research/exporter.py +91 -0
  37. package/fincli/app/research/formatter.py +27 -0
  38. package/fincli/app/research/models.py +24 -0
  39. package/fincli/app/research/prompt_builder.py +54 -0
  40. package/fincli/app/services/macro_data.py +50 -0
  41. package/fincli/app/services/market_data.py +274 -169
  42. package/fincli/app/services/market_overview.py +42 -1
  43. package/fincli/app/services/news_aggregator.py +95 -0
  44. package/fincli/app/services/web_research.py +267 -267
  45. package/fincli/app/storage/config.py +122 -88
  46. package/fincli/app/storage/database.py +209 -99
  47. package/fincli/app/storage/provider_metrics.py +61 -0
  48. package/fincli/app/storage/secrets.py +26 -2
  49. package/fincli/app/tui/components.py +68 -50
  50. package/fincli/app/tui/layout.py +269 -258
  51. package/fincli/app/tui/market_provider_selector.py +3 -1
  52. package/fincli/app/tui/theme.py +134 -74
  53. package/fincli/app/utils/formatting.py +123 -60
  54. package/package.json +22 -20
  55. package/pyproject.toml +35 -35
package/README.md CHANGED
@@ -1,718 +1,217 @@
1
- # FinCLI v0.1
2
-
3
- FinCLI adalah financial CLI/TUI terminal modern untuk memantau market, mengelola watchlist, portfolio, journal, konfigurasi provider, dan menyiapkan integrasi AI market analysis secara modular.
4
-
5
- Status saat ini: FinCLI MVP aktif dengan TUI, provider chain, AI assistance, web research, portfolio, journal, watchlist, export, dan session history lokal.
6
-
7
- - Textual TUI satu kolom dengan command palette inline yang bisa discroll; sidebar lama sudah dihapus agar output market lebih lega.
8
- - Slash command router dengan command wajib FinCLI v0.1.
9
- - Config system berbasis `.env` untuk secret dan `~/.fincli/config.json` untuk preference non-secret.
10
- - SQLite local storage untuk watchlist, portfolio, dan journal.
11
- - yfinance fallback untuk quote, OHLCV history, news, dan fundamental snapshot.
12
- - Finnhub provider untuk quote, stock candles, company news, dan company profile via `FINNHUB_API_KEY`.
13
- - Twelve Data provider untuk multi-asset market data via `TWELVE_DATA_API_KEY`.
14
- - Economic calendar lewat Finnhub jika API key tersedia, dengan fallback lokal jika provider belum dikonfigurasi.
15
- - Technical analysis dasar: SMA, EMA, RSI, MACD, Bollinger Bands, ATR, support/resistance, volume, trend bias.
16
- - Market structure dasar: HH/HL, LH/LL, break of structure, change of character, liquidity area, risk zone.
17
- - Watchlist scanner: `/scan watchlist` dengan filter `rsi<30`, `rsi>70`, atau `trend=bullish`.
18
- - Persistent SQLite market cache untuk quote, OHLCV history, news, dan fundamental agar provider API tidak dipanggil berulang secara boros.
19
- - `/ai` dan `/analyze` sudah lewat AI provider interface. `/ai` memakai persona FinCLI, guardrail anti-coding, dan market context otomatis jika prompt menyebut symbol eksplisit.
20
- - AI HTTP clients untuk OpenAI-compatible APIs, Gemini, dan Anthropic. OpenRouter, OpenAI, Together, Groq, dan HuggingFace memakai jalur OpenAI-compatible.
21
- - Portfolio view menghitung current price, PnL, dan PnL percent dari quote provider aktif.
22
- - Export portfolio/journal ke CSV atau JSON.
23
- - Basic tests untuk command registry, router, config, storage, market command, technical analysis, dan AI command injection.
24
-
25
- ## Stack
26
-
27
- - Python 3.11+
28
- - Textual + Rich untuk TUI
29
- - SQLite untuk local database
30
- - python-dotenv untuk `.env`
31
- - yfinance untuk fallback market/news/fundamental data
32
- - httpx disiapkan untuk provider API lanjutan
33
- - pytest untuk test
34
-
35
- Textual dipilih karena lebih cocok untuk dashboard terminal interaktif dibanding CLI statis. Rich tetap dipakai untuk table/panel renderable.
1
+ # FinCLI v0.3.0
36
2
 
37
- ## Install
38
-
39
- ```bash
40
- python -m venv .venv
41
- .venv\Scripts\activate
42
- pip install -e ".[dev]"
43
- ```
44
-
45
- Alternatif:
46
-
47
- ```bash
48
- pip install -r requirements.txt
49
- ```
3
+ FinCLI is a modern financial CLI/TUI terminal for market research, technical analysis, AI-assisted analysis, provider management, portfolio risk, journaling, watchlists, and local-first financial workflows.
50
4
 
51
- ## Global Install
5
+ FinCLI is an active MVP. Data quality depends on provider availability, API keys, provider plan entitlement, exchange coverage, and rate limits. yfinance remains the default delayed fallback.
52
6
 
53
- Rekomendasi untuk Python CLI adalah `pipx`, karena dependency FinCLI dipasang di environment terisolasi tetapi command `fincli` tersedia global:
7
+ ## Highlights
54
8
 
55
- ```bash
56
- pip install pipx
57
- pipx ensurepath
58
- pipx install .
59
- fincli
60
- ```
9
+ - Textual + Rich terminal UI with slash commands.
10
+ - Research-first workflow through `/research`.
11
+ - Provider fallback chain with granular reliability labels: `ok`, `auth_failed`, `rate_limited`, `entitlement_missing`, `partial_data`, `schedule_only`, `unavailable`.
12
+ - Provider metrics dashboard with runtime success rate, average latency, fallback count, and error count.
13
+ - Persistent provider metrics in SQLite so `/provider metrics` can show current session and all-time call totals.
14
+ - AI Grounding Guard for `/analyze`: AI prompts must consider data quality, provider reliability, missing data, and provider metrics before conclusions.
15
+ - Market data adapters: yfinance, Finnhub, Twelve Data, Alpha Vantage, and custom provider schema.
16
+ - 100+ news connector catalog with free RSS fallbacks and API-key-ready providers.
17
+ - AI providers: OpenRouter, OpenAI, Groq, Together, HuggingFace, Gemini, Anthropic, and compatible HTTP providers.
18
+ - Technical analysis: RSI, MACD, EMA/SMA, Bollinger Bands, ATR, support/resistance, market structure, and technical debate.
19
+ - Portfolio Risk v3: exposure by asset class/currency, concentration risk, drawdown estimate, risk budget, realized/unrealized PnL, and portfolio health score.
20
+ - Local-first storage: config, secrets, SQLite database, cache, sessions, watchlist, portfolio, journal, alerts.
21
+ - Prepublish safety checks for secrets, runtime artifacts, and npm package manifest.
61
22
 
62
- Jika sudah dipublish ke PyPI:
63
-
64
- ```bash
65
- pipx install fincli
66
- fincli
67
- ```
23
+ ## Install
68
24
 
69
- FinCLI juga punya npm wrapper agar bisa mengikuti pola “install once, run anywhere” seperti CLI Node:
25
+ Local development:
70
26
 
71
27
  ```bash
72
- npm install -g .
28
+ python -m venv .venv
29
+ .venv\Scripts\activate
30
+ pip install -e ".[dev]"
73
31
  fincli
74
32
  ```
75
33
 
76
- Setelah package npm dipublish:
34
+ Global npm wrapper:
77
35
 
78
36
  ```bash
79
37
  npm install -g @drico2008/fincli
80
38
  fincli
81
39
  ```
82
40
 
83
- Catatan: npm wrapper tetap membutuhkan Python 3.11+ saat install. Script npm akan membuat virtualenv `.npm-python`, menginstall package Python FinCLI ke sana, lalu command global `fincli` menjalankan `python -m fincli.app.main`.
41
+ The npm wrapper requires Python 3.11+ on the user machine. It creates an isolated `.npm-python` environment inside the installed package.
84
42
 
85
- ## Setup `.env`
43
+ ## API Key Setup
86
44
 
87
- ```bash
88
- copy .env.example .env
89
- ```
90
-
91
- Isi API key hanya untuk provider yang ingin digunakan. yfinance fallback tidak butuh API key. Config membaca status key tanpa menampilkan secret.
92
-
93
- Untuk install global lewat npm, user tidak perlu membuka folder package atau mengedit `.env`. Simpan API key lewat command FinCLI:
45
+ Global users do not need to edit `.env`. Save keys from inside FinCLI:
94
46
 
95
47
  ```text
96
48
  /ai_model key groq <api_key>
97
49
  /ai_model key openrouter <api_key>
98
50
  /news_model key finnhub <api_key>
99
51
  /news_model key twelvedata <api_key>
100
- /news_model key custom <api_key> https://your-market-api.example.com
52
+ /news_model key alphavantage <api_key>
101
53
  ```
102
54
 
103
- Key disimpan lokal di:
55
+ Keys are stored locally in:
104
56
 
105
57
  ```text
106
58
  ~/.fincli/secrets.env
107
59
  ```
108
60
 
109
- File ini tidak dicetak penuh di output terminal. `/config` dan `/provider key status` hanya menampilkan status/masked key.
61
+ FinCLI masks keys in terminal output. Use `/secrets status`, `/secrets clear`, `/privacy status`, and `/privacy purge` for local security hygiene.
110
62
 
111
- ## Run
63
+ ## Core Commands
112
64
 
113
- ```bash
114
- fincli
115
- ```
65
+ Research and market:
116
66
 
117
- Atau:
118
-
119
- ```bash
120
- python -m fincli.app.main
67
+ ```text
68
+ /research AAPL
69
+ /research AAPL --deep
70
+ /research AAPL --report
71
+ /research AAPL --report --export md report.md
72
+ /research AAPL --report --export json report.json
73
+ /market AAPL 1d
74
+ /news AAPL 7d
75
+ /technical AAPL 1d
76
+ /analyze AAPL 1d
77
+ /mtf AAPL 1d,1h,15m
78
+ /calendar week US high
121
79
  ```
122
80
 
123
- ## Command Utama
81
+ Providers:
124
82
 
125
83
  ```text
126
- /help
127
- /dashboard
128
- /config
129
- /ai_model
130
- /ai_model openrouter openai/gpt-4o-mini
131
84
  /news_model
132
- /market AAPL 1d
85
+ /news_model list
86
+ /news_model priority google_news_rss,yfinance,yahoo_finance_rss
133
87
  /provider status
88
+ /provider metrics
134
89
  /provider list
135
- /provider test AAPL
90
+ /provider entitlement
136
91
  /provider key status
137
- /watchlist
138
- /watchlist add AAPL
139
- /watchlist remove AAPL
140
- /portfolio
141
- /portfolio add BTC-USD 0.05 65000
142
- /portfolio remove BTC-USD
143
- /portfolio performance
144
- /tx add buy AAPL 10 185
145
- /tx add sell AAPL 5 195
146
- /tx list
147
- /journal
148
- /journal add BTC-USD bullish "Breakout gagal, tunggu konfirmasi"
149
- /journal stats
150
- /journal review
151
- /history
152
- /history sessions
153
- /history save "Riset market pagi"
154
- /quote AAPL
155
- /technical BTC-USD 1d
156
- /technical XAUUSD 1d
157
- /technical EURUSD 1d
158
- /structure BTC-USD 1d
159
- /news AAPL
160
- /web penyebab rupiah melemah hari ini
161
- /web sources penyebab rupiah melemah hari ini
162
- /funda MSFT
163
- /yahoo BBRI history 6mo 1d
164
- /yahoo BBRI statistics
165
- /yahoo BBRI profile
166
- /yahoo BBRI financials
167
- /yahoo BBRI analysis
168
- /yahoo BBRI holders
169
- /ai jelaskan risiko market hari ini
170
- /analyze ETH-USD 4h
171
- /scan watchlist rsi<30
172
- /scan watchlist trend=bullish
173
- /scan watchlist rsi>60 trend=bullish
174
- /calendar
175
- /calendar today
176
- /calendar 2026-06-05 2026-06-12 country=US impact=high
177
- /export portfolio json C:\Users\MSI\Desktop\portfolio.json
178
- /export journal csv C:\Users\MSI\Desktop\journal.csv
179
- /cache stats
180
- /cache clear
181
- /clear
182
- /exit
183
- ```
184
-
185
- Command `/market`, `/quote`, `/technical`, `/structure`, `/news`, dan `/funda` sudah memakai provider chain aktif. Command `/ai` dan `/analyze` sudah memakai AI provider aktif dari `/ai_model` dan `.env`. `/analyze` membawa konteks indikator, struktur pasar, news, dan fundamental ringkas ke prompt AI. `/ai` juga mengambil quote, OHLCV/technical, structure, news, dan fundamental saat user menyebut symbol seperti `AAPL`, `EURUSD`, atau `XAUUSD`.
186
-
187
- ## AI Chat UX
188
-
189
- Di TUI, input biasa tanpa slash sekarang diperlakukan sebagai chat ke AI assistant aktif:
190
-
191
- ```text
192
- hello
193
- ```
194
-
195
- Output ditampilkan dengan format terminal chat:
196
-
197
- ```text
198
- > hello
199
- ▸ Thinking: routing prompt to active AI provider...
200
- * Provider: ...
201
- ```
202
-
203
- Command eksplisit tetap bisa dipakai:
204
-
205
- ```text
206
- /ai jelaskan risiko market hari ini
207
- ```
208
-
209
- AI assistant di dalam FinCLI dipersonalisasi untuk market workflow:
210
-
211
- - Mengenali FinCLI sebagai terminal financial dashboard.
212
- - Boleh free chat untuk pertanyaan umum, market, portfolio, journal, provider, dan risk workflow.
213
- - Menolak coding/debugging/refactor/pembuatan software di dalam assistant FinCLI agar fokus app tetap jelas.
214
- - Jika prompt berisi symbol eksplisit, FinCLI menyisipkan market context dari provider chain aktif sebelum memanggil AI provider.
215
- - Jika prompt membutuhkan info terkini, FinCLI dapat mengambil konteks web publik dan memasukkannya ke AI prompt.
216
- - Tidak membocorkan API key dan tidak mengklaim realtime jika provider aktif hanya delayed/fallback.
217
-
218
- Contoh web-aware freechat:
219
-
220
- ```text
221
- apa yang menyebabkan penurunan rupiah terhadap semua mata uang hari ini
222
- berita terbaru BI rate dan dampaknya ke IHSG
223
- ```
224
-
225
- Untuk web search yang dirangkum oleh AI:
226
-
227
- ```text
228
- /web penyebab rupiah melemah hari ini
229
- /web update harga emas dan dollar index
230
- ```
231
-
232
- Untuk melihat sumber mentah tanpa ringkasan AI:
233
-
234
- ```text
235
- /web sources penyebab rupiah melemah hari ini
236
- ```
237
-
238
- FinCLI memakai lightweight HTTP web research, bukan Chrome automation. Ini lebih stabil untuk npm global install dan tidak membuka browser di background. Output tetap harus diverifikasi karena kualitas sumber web bisa berbeda-beda.
239
-
240
- ## Interactive AI Model Selector
241
-
242
- ```text
243
- /ai_model
244
- ```
245
-
246
- Di TUI, command ini membuka selector seperti modern CLI:
247
-
248
- - Select Provider
249
- - Status provider current/configured
250
- - Use existing configuration / configure again
251
- - Configure API key jika provider belum punya key
252
- - Select Model
253
- - Search model/provider
254
- - Navigasi `up/down`, `Enter`, `Tab`, dan `Esc`
255
-
256
- Untuk set langsung tanpa selector:
257
-
258
- ```text
259
- /ai_model openrouter openai/gpt-4o-mini
260
- ```
261
-
262
- ## Interactive Market/News Provider Selector
263
-
264
- ```text
265
- /news_model
266
- ```
267
-
268
- Di TUI, command ini membuka selector untuk provider market/news dan fallback priority:
269
-
270
- - Select Market/News Provider
271
- - Pilih `Twelve Data`, `Finnhub`, `Custom API`, atau `Yahoo Finance`
272
- - Masukkan API key langsung dari popup jika provider belum dikonfigurasi
273
- - Pilih preset fallback: recommended, primary + yfinance, data API priority, atau yfinance only
274
- - Search provider/preset
275
- - Navigasi `up/down`, `Enter`, `Tab`, dan `Esc`
276
-
277
- Rekomendasi praktis:
278
-
279
- ```text
280
- Primary: twelvedata
281
- Fallback: twelvedata -> finnhub -> custom -> yfinance
282
- ```
283
-
284
- `yfinance` tetap fallback gratis/delayed. Provider API seperti Twelve Data dan Finnhub tetap bergantung pada API key, plan, entitlement exchange, dan batas rate-limit.
285
-
286
- ## Economic Calendar
287
-
288
- ```text
289
- /calendar
290
- /calendar today
291
- /calendar week US high
292
- /calendar 2026-06-05 2026-06-12 country=US impact=high
293
- ```
294
-
295
- Jika `FINNHUB_API_KEY` tersedia, FinCLI mengambil economic calendar aktual dari Finnhub. Jika API key kosong atau provider gagal, FinCLI tetap menampilkan fallback kategori event penting seperti central bank decision, inflation release, labor data, GDP/PMI, dan retail sales. Fallback ini tidak mengklaim tanggal aktual.
296
-
297
- ## Market Cache
298
-
299
- FinCLI memakai dua lapis cache:
300
-
301
- - Runtime cache di memori untuk command yang dipanggil berulang dalam sesi TUI.
302
- - Persistent SQLite cache di `~/.fincli/fincli.db` untuk quote, OHLCV history, news, dan fundamentals.
303
-
304
- Cache mengikuti `cache_ttl_seconds` dari config. Ini penting untuk mengurangi rate-limit, mempercepat scanner/watchlist, dan membuat provider chain lebih efisien.
305
-
306
- Command:
307
-
308
- ```text
309
- /cache stats
310
- /cache clear
311
- ```
312
-
313
- `/cache clear` menghapus runtime cache dan persistent market cache. API key tetap aman karena cache hanya menyimpan respons market data, bukan secret.
314
-
315
- ## Dashboard Compact
316
-
317
- ```text
318
- /dashboard
319
- ```
320
-
321
- Dashboard dibuat sebagai layar awal TUI yang tidak stacked dan tidak ramai. Ringkasannya mencakup:
322
-
323
- - Provider chain
324
- - Watchlist price snapshot
325
- - Portfolio market value dan PnL
326
- - Journal win rate
327
- - Command hint untuk langkah berikutnya
328
-
329
- ## Market Overview
330
-
331
- Command utama untuk melihat instrumen secara profesional:
332
-
333
- ```text
334
- /market AAPL 1d
335
- ```
336
-
337
- Output berisi:
338
-
339
- - Data Quality score
340
- - Quote dan provider status
341
- - RSI, trend, MACD, ATR
342
- - Support/resistance
343
- - Market structure
344
- - Fundamental snapshot
345
- - Latest news
346
- - Disclaimer
347
-
348
- Gunakan `/market` sebagai entry point sebelum masuk ke `/technical`, `/structure`, atau `/analyze`.
349
-
350
- ## Coverage Instrumen
351
-
352
- Coverage tergantung provider dan format symbol:
353
-
354
- - `yfinance`: stocks, ETFs, indices, forex, crypto, commodities, dan mutual funds selama symbol Yahoo valid.
355
- - `custom`: instrumen apa pun selama API kamu menyediakan endpoint FinCLI.
356
- - `finnhub`: quote/candle saham, forex candle, crypto candle, company news, company profile, dan economic calendar sesuai plan API.
357
- - `twelvedata`: multi-asset stocks, forex, ETFs, indices, commodities, dan crypto dengan format symbol yang lebih konsisten untuk market global.
358
-
359
- Rekomendasi provider priority untuk multi-asset:
360
-
361
- ```text
362
- /provider priority twelvedata,finnhub,yfinance
363
- ```
364
-
365
- Dengan konfigurasi ini:
366
-
367
- - `twelvedata` dicoba dulu untuk forex/indices/commodities/global stocks.
368
- - `finnhub` menjadi fallback untuk saham dan news/fundamental tertentu.
369
- - `yfinance` tetap fallback gratis/delayed jika provider API gagal.
370
-
371
- Contoh symbol yfinance:
372
-
373
- ```text
374
- AAPL
375
- MSFT
376
- SPY
377
- ^GSPC
378
- BTC-USD
379
- ETH-USD
380
- EURUSD=X
381
- GC=F
382
- CL=F
383
- ```
384
-
385
- FinCLI juga menerima alias umum dan mengubahnya ke format provider:
386
-
387
- ```text
388
- EURUSD -> EURUSD=X untuk yfinance, EUR/USD untuk Twelve Data, OANDA:EUR_USD untuk Finnhub forex candle
389
- XAUUSD -> XAUUSD=X untuk yfinance, XAU/USD untuk Twelve Data
390
- SPX -> ^GSPC untuk yfinance
391
- NASDAQ -> ^IXIC untuk yfinance
392
- DAX -> ^GDAXI untuk yfinance
393
- NIKKEI -> ^N225 untuk yfinance
394
- WTI -> CL=F untuk yfinance
395
- BRENT -> BZ=F untuk yfinance
396
- ```
397
-
398
- ## Technical AI Summary
399
-
400
- `/technical` sekarang menyertakan ringkasan khusus untuk AI assistance:
401
-
402
- ```text
403
- /technical EURUSD 1d
404
- /technical XAUUSD 1d
405
- /technical SPX 1d
406
- ```
407
-
408
- Output mencakup trend bias, RSI, MACD, support/resistance, ATR, market structure ringkas, signal, dan risk notes. Signal bersifat rule-based dan transparan:
409
-
410
- ```text
411
- Signal: BEST TO BUY | BEST TO SELL | CAUTION
412
- Signal Score
413
- Confidence
414
- Signal Reasoning
415
- Signal Risk Notes
416
- Invalidation / Caution Level
417
- ```
418
-
419
- Signal tidak dianggap instruksi entry pasti. FinCLI tetap memakai bahasa skenario, confirmation, invalidation, dan risk notes agar cocok untuk AI assistance serta tidak memberi klaim profit. Ringkasan ini bisa langsung dipakai sebagai konteks sebelum menjalankan:
420
-
421
- Selain signal langsung, `/technical` sekarang memakai `Technical Debate`:
422
-
423
- - `Bull Chooser`: mencari argumen buy candidate.
424
- - `Bear Chooser`: mencari argumen sell candidate.
425
- - `Caution Chooser`: mencari konflik, overextension, volatilitas, dan kualitas konfirmasi.
426
- - `Judge`: menentukan final `BEST TO BUY`, `BEST TO SELL`, atau `CAUTION`.
427
-
428
- Debate ini juga dimasukkan ke prompt AI agar AI assistance tidak hanya membaca satu sisi argumen.
429
-
430
- ```text
431
- /analyze EURUSD 1d
432
- ```
433
-
434
- ## Scanner
435
-
436
- Contoh:
437
-
438
- ```text
439
- /scan watchlist
440
- /scan watchlist rsi<30
441
- /scan watchlist rsi>70
442
- /scan watchlist trend=bullish
443
- /scan watchlist trend=bearish 1d
444
- /scan watchlist rsi>60 trend=bullish
92
+ /provider test AAPL
445
93
  ```
446
94
 
447
- Scanner mengambil data history secara async dalam batch terbatas, menghitung indikator, lalu hanya menampilkan symbol yang match filter.
448
-
449
- ## Portfolio Transaction Ledger
450
-
451
- Gunakan transaction ledger untuk portfolio yang lebih serius:
95
+ Portfolio and risk:
452
96
 
453
97
  ```text
98
+ /portfolio
99
+ /portfolio add AAPL 10 185
100
+ /portfolio performance
101
+ /portfolio risk
454
102
  /tx add buy AAPL 10 185
455
103
  /tx add sell AAPL 5 195
456
- /tx list
457
- /portfolio performance
458
104
  ```
459
105
 
460
- Buy transaction akan memperbarui quantity dan average price. Sell transaction akan mengurangi posisi dan mencatat realized PnL. `/portfolio performance` menampilkan cost basis, market value, unrealized PnL, realized PnL, dan total PnL.
461
-
462
- ## Journal Analytics
106
+ Workflow:
463
107
 
464
108
  ```text
109
+ /watchlist add AAPL
110
+ /scan watchlist rsi<30
111
+ /journal add AAPL bullish "Breakout failed, wait for confirmation"
465
112
  /journal stats
466
113
  /journal review
114
+ /alert add AAPL above 200
115
+ /history
116
+ /cache stats
117
+ /cache clear
467
118
  ```
468
119
 
469
- `/journal stats` menghitung total entry, win/loss, win rate, instrumen dominan, emosi dominan, dan tag teratas. `/journal review` mengirim statistik dan entry journal ke AI provider aktif untuk review proses, pola kesalahan, risk notes, dan perbaikan kebiasaan. Output tetap memakai disclaimer dan bukan nasihat keuangan.
470
-
471
- ## AI Provider
472
-
473
- Provider yang disiapkan:
474
-
475
- - `openrouter`: `OPENROUTER_API_KEY`
476
- - `openai`: `OPENAI_API_KEY`
477
- - `groq`: `GROQ_API_KEY`
478
- - `together`: `TOGETHER_API_KEY`
479
- - `huggingface`: `HUGGINGFACE_API_KEY`
480
- - `gemini`: `GEMINI_API_KEY`
481
- - `anthropic`: `ANTHROPIC_API_KEY`
482
-
483
- Contoh:
484
-
485
- ```bash
486
- /ai_model openrouter openai/gpt-4o-mini
487
- /ai_model key openrouter <api_key>
488
- /ai jelaskan risiko market NVDA secara singkat
489
- /analyze AAPL 1d
490
- ```
491
-
492
- API key tidak pernah dicetak penuh di output terminal.
493
-
494
- ## Data Realtime / Delayed
495
-
496
- FinCLI saat ini memakai yfinance sebagai fallback. Data yfinance umumnya delayed dan tidak boleh diklaim realtime. Provider API key dapat ditambahkan untuk realtime jika provider tersebut mendukungnya.
497
-
498
- ## Yahoo Finance Tables
499
-
500
- FinCLI memakai yfinance untuk akses saham global yang tersedia di Yahoo Finance. Untuk saham di luar US, gunakan suffix Yahoo bila tahu exchange-nya, misalnya `BBRI.JK`, `HSBA.L`, `SHOP.TO`, atau `0700.HK`. Untuk ticker IDX umum seperti `BBRI`, `BBCA`, `BMRI`, `TLKM`, `ASII`, FinCLI otomatis mengarahkannya ke suffix `.JK`.
501
-
502
- Command:
503
-
504
- ```text
505
- /quote BBRI
506
- /technical BBRI 1d
507
- /analyze BBRI 1d
508
- /yahoo BBRI history 6mo 1d
509
- /yahoo BBRI news
510
- /yahoo BBRI statistics
511
- /yahoo BBRI profile
512
- /yahoo BBRI financials
513
- /yahoo BBRI balance
514
- /yahoo BBRI cashflow
515
- /yahoo BBRI analysis
516
- /yahoo BBRI holders
517
- ```
518
-
519
- Source URL yang dipakai mengikuti format Yahoo Finance, misalnya:
520
-
521
- ```text
522
- https://finance.yahoo.com/quote/BBRI.JK/
523
- https://finance.yahoo.com/quote/BBRI.JK/news/
524
- https://finance.yahoo.com/quote/BBRI.JK/key-statistics/
525
- https://finance.yahoo.com/quote/BBRI.JK/history/
526
- https://finance.yahoo.com/quote/BBRI.JK/profile/
527
- https://finance.yahoo.com/quote/BBRI.JK/financials/
528
- https://finance.yahoo.com/quote/BBRI.JK/analysis/
529
- https://finance.yahoo.com/quote/BBRI.JK/holders/
530
- ```
531
-
532
- Catatan: availability news, analysis, holders, dan beberapa financial table bergantung coverage Yahoo untuk exchange/ticker tersebut.
533
-
534
- ## Finnhub Provider
535
-
536
- Aktifkan lewat selector TUI:
537
-
538
- ```text
539
- /news_model
540
- ```
541
-
542
- Environment variable:
543
-
544
- ```env
545
- FINNHUB_API_KEY=your-finnhub-key
546
- ```
547
-
548
- Atau simpan dari FinCLI:
549
-
550
- ```text
551
- /news_model key finnhub <api_key>
552
- ```
553
-
554
- Endpoint Finnhub yang dipakai:
555
-
556
- ```text
557
- GET /quote
558
- GET /stock/candle
559
- GET /forex/candle
560
- GET /crypto/candle
561
- GET /company-news
562
- GET /stock/profile2
563
- GET /calendar/economic
564
- ```
565
-
566
- Catatan: Finnhub menyediakan REST/WebSocket untuk stocks, currencies/forex, dan crypto, plus fundamental/news sesuai plan. Di FinCLI, news/fundamental tetap paling kuat untuk saham; forex/crypto dipakai untuk candle/technical.
567
-
568
- ## Twelve Data Provider
569
-
570
- Aktifkan lewat selector TUI:
571
-
572
- ```text
573
- /news_model
574
- ```
575
-
576
- Environment variable:
577
-
578
- ```env
579
- TWELVE_DATA_API_KEY=your-twelve-data-key
580
- ```
581
-
582
- Atau simpan dari FinCLI:
583
-
584
- ```text
585
- /news_model key twelvedata <api_key>
586
- ```
587
-
588
- Endpoint Twelve Data yang dipakai:
589
-
590
- ```text
591
- GET /quote
592
- GET /time_series
593
- ```
594
-
595
- Twelve Data paling cocok untuk symbol multi-asset seperti forex (`EURUSD`), metals (`XAUUSD`), indices global, ETF, crypto, dan saham populer US/Eropa/Asia. Tetap cek plan dan exchange entitlement provider untuk realtime vs delayed.
596
-
597
- ## Provider Commands
598
-
599
- ```text
600
- /news_model
601
- /provider list
602
- /provider status
603
- /provider test AAPL
604
- /provider test finnhub AAPL
605
- /provider key status
606
- ```
607
-
608
- `/news_model` adalah flow resmi untuk memilih provider market/news dan fallback chain di TUI. `/provider status` menampilkan provider aktif, fallback chain, dan health message dari provider utama. `/provider test <symbol>` melakukan quote test lewat provider aktif. `/provider test <provider> <symbol>` mengetes provider tertentu tanpa mengganti provider aktif.
609
-
610
- Command manual `/provider use ...` dan `/provider priority ...` masih tersedia sebagai advanced CLI fallback, tetapi tidak lagi ditampilkan sebagai flow utama di command palette.
611
-
612
- Contoh fallback chain yang disimpan selector:
120
+ Security and release:
613
121
 
614
122
  ```text
615
- twelvedata -> finnhub -> custom -> yfinance
123
+ /secrets status
124
+ /privacy status
125
+ npm run prepublish:safety
126
+ python scripts/prepublish_check.py
616
127
  ```
617
128
 
618
- Dengan contoh di atas, FinCLI mencoba Twelve Data lebih dulu. Jika gagal, FinCLI mencoba provider berikutnya dan memakai yfinance delayed sebagai fallback terakhir.
619
-
620
- ## Custom Market Provider
621
-
622
- Aktifkan lewat selector TUI:
623
-
624
- ```text
625
- /news_model
626
- ```
129
+ ## Research Engine v2
627
130
 
628
- Environment variable:
131
+ `/research` is the central research command. It returns a compact output:
629
132
 
630
- ```env
631
- MARKET_DATA_API_KEY=your-key
632
- MARKET_DATA_BASE_URL=https://your-market-api.example.com
633
- ```
133
+ - Snapshot
134
+ - Signal
135
+ - Risk
136
+ - Missing Data
137
+ - Source Quality
138
+ - Decision Points
139
+ - Final Summary
634
140
 
635
- Atau simpan dari FinCLI:
141
+ Deep mode sends a concise Research Engine v2 prompt to the active AI provider. Report mode adds report-oriented notes without creating another command surface.
636
142
 
637
- ```text
638
- /news_model key custom <api_key> https://your-market-api.example.com
639
- ```
143
+ ## Portfolio Risk v3
640
144
 
641
- FinCLI akan memanggil endpoint:
145
+ `/portfolio risk` calculates:
642
146
 
643
- ```text
644
- GET /quote/{symbol}
645
- GET /history/{symbol}?period=6mo&interval=1d
646
- GET /news/{symbol}?limit=5
647
- GET /fundamentals/{symbol}
648
- ```
147
+ - Exposure by asset class
148
+ - Currency exposure
149
+ - Concentration risk
150
+ - Drawdown estimate
151
+ - Asset-class cap warning
152
+ - Risk budget from `/profile`
153
+ - Realized PnL
154
+ - Unrealized PnL
155
+ - Total PnL
156
+ - Portfolio health score
649
157
 
650
- Header dikirim sebagai `X-API-Key` dan `Authorization: Bearer <key>`. API key tidak ditampilkan di terminal.
158
+ The health score is a local analytical score, not financial advice. It penalizes high concentration, missing prices, weak diversification, and drawdown.
651
159
 
652
- Contoh payload quote:
160
+ ## Data Notes
653
161
 
654
- ```json
655
- {
656
- "symbol": "AAPL",
657
- "price": 123.45,
658
- "currency": "USD",
659
- "timestamp": "2026-06-04T12:00:00",
660
- "status": "realtime"
661
- }
662
- ```
162
+ - yfinance is a delayed fallback and should not be described as realtime.
163
+ - Finnhub, Twelve Data, Alpha Vantage, and other providers may require API keys, paid plans, and exchange entitlements.
164
+ - Public RSS/news sources can change or fail without notice.
165
+ - Calendar fallback may be `schedule_only` if actual provider data is unavailable.
166
+ - AI output is informational and must not be treated as guaranteed signal or financial advice.
663
167
 
664
168
  ## Local Storage
665
169
 
666
- FinCLI menyimpan data lokal di:
170
+ FinCLI stores local data under:
667
171
 
668
172
  ```text
669
173
  ~/.fincli/config.json
174
+ ~/.fincli/secrets.env
670
175
  ~/.fincli/fincli.db
671
176
  ~/.fincli/fincli.log
672
177
  ```
673
178
 
674
- API key tidak disimpan di output terminal. Untuk install global via npm, jalur utama adalah command FinCLI:
179
+ Do not commit `.env`, local secrets, logs, databases, cache folders, or npm/python virtual environments.
675
180
 
676
- ```text
677
- /ai_model key groq <api_key>
678
- /news_model key twelvedata <api_key>
679
- ```
680
-
681
- Key disimpan lokal di `~/.fincli/secrets.env`, dipakai otomatis untuk semua session FinCLI berikutnya, dan tidak perlu dikonfigurasi ulang. Jika `.env` lokal berisi nilai kosong, FinCLI tetap memakai secret lokal yang sudah tersimpan.
181
+ ## Prepublish Safety
682
182
 
683
- ## Test
183
+ Before publishing to npm or GitHub:
684
184
 
685
185
  ```bash
686
- pytest
687
- ```
688
-
689
- Hasil terakhir di environment ini:
690
-
691
- ```text
692
- 97 passed
186
+ python -m pytest -q
187
+ python -m compileall fincli tests scripts
188
+ npm run check
189
+ npm run prepublish:safety
693
190
  ```
694
191
 
695
- ## Troubleshooting
192
+ The prepublish checker scans for `.env`, `secrets.env`, logs, SQLite databases, token-like strings, and unsafe `npm pack --dry-run` contents.
696
193
 
697
- - `fincli` tidak dikenali: jalankan `pip install -e .` dari root project.
698
- - TUI tidak tampil rapi: perbesar terminal desktop.
699
- - API key tidak terbaca: gunakan `/ai_model key <provider> <api_key>` atau `/news_model key <provider> <api_key>`, lalu cek `/config` atau `/provider key status`.
700
- - `/quote` gagal karena yfinance belum ada: jalankan `pip install -e ".[dev]"` atau `pip install -r requirements.txt`.
701
- - Config rusak: hapus `~/.fincli/config.json` untuk kembali ke default.
194
+ ## Roadmap
702
195
 
703
- ## Roadmap Lanjutan
196
+ ### v0.3.x Hardening
704
197
 
705
- - Scanner export dan filter expression parser yang lebih lengkap.
706
- - Market structure lebih lanjut: pivot strength, multi-timeframe structure, liquidity sweep detection.
707
- - AI market analysis dengan ranking data quality dan confidence scoring.
708
- - Custom provider schema validation yang lebih ketat dan adapter untuk provider populer.
709
- - Provider adapter lanjutan untuk entitlement exchange, symbol search, dan realtime streaming.
710
- - Economic calendar lanjutan, screener, alert dasar, dan multi-timeframe analysis.
198
+ - Provider runtime metrics by provider started in `/provider metrics`.
199
+ - Persistent provider metrics started in v0.3.0.
200
+ - AI Grounding Guard started in `/analyze`.
201
+ - Richer portfolio analytics: drawdown estimate and currency grouping started in Portfolio Risk v3.
202
+ - Better research reports with Markdown/JSON export from `/research --report` started in v0.3.0.
203
+ - Provider-specific schema validation for custom data APIs.
204
+ - Improved AI grounding and citations for web/news-assisted answers.
711
205
 
712
- ## Roadmap v0.3
206
+ ### v0.4
713
207
 
714
- - Plugin system.
715
208
  - Strategy builder.
716
- - Advanced portfolio analytics.
717
- - Notification integration.
209
+ - Alert daemon and notification integrations.
210
+ - Backtesting with fees, slippage, and position sizing.
718
211
  - Optional cloud sync.
212
+ - Plugin marketplace-style connector loading.
213
+ - Realtime streaming where provider plans support it.
214
+
215
+ ## License
216
+
217
+ MIT