@drico2008/fincli 0.2.2 → 0.3.1

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
@@ -1,909 +1,217 @@
1
- <<<<<<< HEAD
2
- # FinCLI v0.2.2
3
- =======
4
- # FinCLI v0.1.9
5
- >>>>>>> a26bfe0e03787066d4676c17641647723991f356
6
-
7
- FinCLI is a modern financial CLI/TUI terminal for market monitoring, technical analysis, AI-assisted research, portfolio tracking, watchlists, trading journals, and configurable market/news provider workflows.
8
-
9
- Current status: FinCLI is an active MVP moving into v0.2 with a Textual TUI, provider chain, symbol normalization, AI assistance, web research, portfolio, journal, watchlist, exports, and local session history.
10
-
11
- - Single-column Textual TUI with an inline command palette and scrollable command suggestions. The old sidebar has been removed so market output has more room.
12
- - Slash command router for the core FinCLI v0.1 command system.
13
- - Config system using optional `.env` values for local development, `~/.fincli/config.json` for non-secret preferences, and `~/.fincli/secrets.env` for API keys saved from commands.
14
- - SQLite local storage for watchlist, portfolio, journal, transactions, session history, and persistent market cache.
15
- - yfinance fallback for quote, OHLCV history, news, Yahoo tables, and fundamental snapshots.
16
- - Finnhub provider for quotes, stock candles, company news, company profile, and economic calendar via `FINNHUB_API_KEY`.
17
- - Twelve Data provider for multi-asset market data via `TWELVE_DATA_API_KEY`.
18
- - Alpha Vantage provider for stock/FX quote, daily history, news sentiment, and company overview via `ALPHA_VANTAGE_API_KEY`.
19
- - 100+ news connector catalog for `/news`, including public RSS fallbacks and API-key-ready providers such as Marketaux, NewsAPI, GNews, Alpha Vantage News, Finnhub News, StockNewsAPI, APITube, Benzinga, Polygon, Tiingo, FMP, and EODHD.
20
- - Symbol search and provider-specific normalization with `/symbol`.
21
- - Provider entitlement and realtime/delayed labeling with `/provider entitlement`.
22
- - Economic calendar through Finnhub when an API key is configured, with a local fallback when the provider is unavailable.
23
- - Technical analysis: SMA, EMA, RSI, MACD, Bollinger Bands, ATR, support/resistance, volume, trend bias, and technical signal scoring.
24
- - Market structure analysis: HH/HL, LH/LL, break of structure, change of character, liquidity areas, and risk zones.
25
- - Technical Debate engine for `/technical`: Bull Chooser, Bear Chooser, Caution Chooser, and Judge.
26
- - Watchlist scanner: `/scan watchlist` with filters such as `rsi<30`, `rsi>70`, and `trend=bullish`.
27
- - Persistent market cache for quote, OHLCV history, news, and fundamentals to reduce unnecessary API calls.
28
- - `/ai` and `/analyze` use the active AI provider. `/ai` has a FinCLI-specific persona, anti-coding guardrails, optional market context, and optional web research context.
29
- - AI HTTP clients for OpenAI-compatible APIs, Gemini, and Anthropic. OpenRouter, OpenAI, Together, Groq, and HuggingFace use OpenAI-compatible request flows.
30
- - Portfolio view calculates current price, PnL, PnL percent, allocation, and transaction-ledger performance.
31
- - Portfolio and journal export to CSV or JSON.
32
- - Basic tests for command registry, router, config, storage, market providers, technical analysis, AI commands, TUI selectors, web research, and session history.
33
-
34
- ## Stack
35
-
36
- - Python 3.11+
37
- - Textual + Rich for the terminal UI
38
- - SQLite for local storage
39
- - python-dotenv for optional local `.env` support
40
- - yfinance for fallback market/news/fundamental data
41
- - httpx for provider APIs and lightweight web research
42
- - pandas + numpy for analysis workflows
43
- - pytest for tests
44
- - npm wrapper for global installation through `npm install -g`
45
-
46
- Textual was chosen because FinCLI needs an interactive terminal dashboard instead of a static CLI. Rich is still used for tables, panels, Markdown rendering, and structured output.
47
-
48
- ## Install
49
-
50
- For local development:
51
-
52
- ```bash
53
- python -m venv .venv
54
- .venv\Scripts\activate
55
- pip install -e ".[dev]"
56
- ```
57
-
58
- Alternative:
59
-
60
- ```bash
61
- pip install -r requirements.txt
62
- ```
63
-
64
- ## Global Install
65
-
66
- The recommended Python CLI approach is `pipx`, because FinCLI dependencies are installed in an isolated environment while the `fincli` command remains globally available:
67
-
68
- ```bash
69
- pip install pipx
70
- pipx ensurepath
71
- pipx install .
72
- fincli
73
- ```
74
-
75
- If the Python package is published to PyPI:
76
-
77
- ```bash
78
- pipx install fincli
79
- fincli
80
- ```
81
-
82
- FinCLI also ships with an npm wrapper so users can follow a common "install once, run anywhere" CLI pattern:
83
-
84
- ```bash
85
- npm install -g @drico2008/fincli
86
- fincli
87
- ```
88
-
89
- For local npm testing before publishing:
90
-
91
- ```bash
92
- npm install -g .
93
- fincli
94
- ```
95
-
96
- Note: the npm wrapper still requires Python 3.11+ during installation. The postinstall script creates a local `.npm-python` virtual environment inside the installed package, installs the Python FinCLI package there, and the global `fincli` command runs `python -m fincli.app.main`.
97
-
98
- ## Setup
99
-
100
- For local development, you may copy `.env.example`:
101
-
102
- ```bash
103
- copy .env.example .env
104
- ```
105
-
106
- Only fill API keys for providers you want to use. The yfinance fallback does not require an API key. FinCLI never prints full API keys in the terminal.
107
-
108
- For global npm installs, users do not need to open the installed package folder or edit `.env`. Save API keys directly from FinCLI:
109
-
110
- ```text
111
- /ai_model key groq <api_key>
112
- /ai_model key openrouter <api_key>
113
- /news_model key finnhub <api_key>
114
- /news_model key twelvedata <api_key>
115
- /news_model key custom <api_key> https://your-market-api.example.com
116
- ```
117
-
118
- Keys are saved locally at:
119
-
120
- ```text
121
- ~/.fincli/secrets.env
122
- ```
123
-
124
- The file is not printed in full by FinCLI. `/config` and `/provider key status` only show masked key status and safe source labels.
125
-
126
- ## Run
127
-
128
- ```bash
129
- fincli
130
- ```
131
-
132
- Or:
133
-
134
- ```bash
135
- python -m fincli.app.main
136
- ```
137
-
138
- ## Main Commands
139
-
140
- ```text
141
- /help
142
- /dashboard
143
- /config
144
- /ai_model
145
- /ai_model openrouter openai/gpt-4o-mini
146
- /ai_model key groq <api_key>
147
- /news_model
148
- /news_model list
149
- /news_model search rss
150
- /news_model use google_news_rss
151
- /news_model priority google_news_rss,yfinance,marketaux,newsapi,gnews
152
- /news_model key finnhub <api_key>
153
- /news_model key marketaux <api_key>
154
- /news_model key alphavantage <api_key>
155
- /symbol XAUUSD
156
- /symbol normalize BBRI
157
- /market AAPL 1d
158
- /provider status
159
- /provider list
160
- /provider entitlement
161
- /provider test AAPL
162
- /provider key status
163
- /watchlist
164
- /watchlist add AAPL
165
- /watchlist remove AAPL
166
- /portfolio
167
- /portfolio add BTC-USD 0.05 65000
168
- /portfolio remove BTC-USD
169
- /portfolio performance
170
- /tx add buy AAPL 10 185
171
- /tx add sell AAPL 5 195
172
- /tx list
173
- /journal
174
- /journal add BTC-USD bullish "Failed breakout, wait for confirmation"
175
- /journal stats
176
- /journal review
177
- /alert
178
- /alert add AAPL above 200
179
- /alert check
180
- /history
181
- /history sessions
182
- /history show <session_id>
183
- /history save "Morning market research"
184
- /history delete <session_id>
185
- /quote AAPL
186
- /technical BTC-USD 1d
187
- /technical XAUUSD 1d
188
- /technical EURUSD 1d
189
- /mtf AAPL 1d,1h,15m
190
- /backtest AAPL sma_cross 1d
191
- /backtest EURUSD rsi_reversion 1h
192
- /structure BTC-USD 1d
193
- /news AAPL
194
- /web why is the rupiah weakening today
195
- /web sources why is the rupiah weakening today
196
- /funda MSFT
197
- /yahoo BBRI history 6mo 1d
198
- /yahoo BBRI statistics
199
- /yahoo BBRI profile
200
- /yahoo BBRI financials
201
- /yahoo BBRI analysis
202
- /yahoo BBRI holders
203
- /ai explain today's market risk
204
- /analyze ETH-USD 4h
205
- /scan watchlist rsi<30
206
- /scan watchlist trend=bullish
207
- /scan watchlist rsi>60 trend=bullish
208
- /scan export csv scan.csv rsi<30 1d
209
- /report market AAPL md report.md
210
- /report market AAPL json report.json
211
- /calendar
212
- /calendar today
213
- /calendar 2026-06-05 2026-06-12 country=US impact=high
214
- /calendar export csv calendar.csv week US high
215
- /export portfolio json C:\Users\MSI\Desktop\portfolio.json
216
- /export journal csv C:\Users\MSI\Desktop\journal.csv
217
- /cache stats
218
- /cache clear
219
- /clear
220
- /exit
221
- ```
222
-
223
- `/market`, `/quote`, `/technical`, `/structure`, and `/funda` use the active market provider chain. `/news` uses the active news fallback chain from `/news_model priority`. `/ai` and `/analyze` use the active AI provider from `/ai_model`. `/analyze` sends indicator, market structure, news, and fundamental context to the AI prompt. `/ai` can also attach quote, OHLCV/technical, structure, news, fundamental, and web context when the prompt asks for current information or mentions a clear symbol such as `AAPL`, `EURUSD`, or `XAUUSD`.
224
-
225
- ## AI Chat UX
226
-
227
- Inside the TUI, regular input without a slash is treated as chat to the active AI assistant:
228
-
229
- ```text
230
- hello
231
- ```
232
-
233
- Output is rendered as a terminal chat:
234
-
235
- ```text
236
- > hello
237
- > Thinking: routing prompt to active AI provider...
238
- * Provider: ...
239
- ```
240
-
241
- Explicit command mode is still supported:
242
-
243
- ```text
244
- /ai explain today's market risk
245
- ```
246
-
247
- The FinCLI assistant is customized for market workflows:
248
-
249
- - It understands FinCLI as a financial terminal dashboard.
250
- - It supports free chat for general questions, market research, portfolio workflows, journal review, provider setup, and risk analysis.
251
- - It refuses coding, debugging, refactoring, and software-building requests inside the FinCLI assistant so the in-app assistant remains focused.
252
- - If a prompt includes a clear market symbol, FinCLI attaches market context from the active provider chain before calling the AI provider.
253
- - If a prompt needs recent public information, FinCLI can collect lightweight web context and pass it to the AI prompt.
254
- - It never exposes API keys and never claims realtime data when the active provider is delayed or fallback-only.
255
-
256
- Examples:
257
-
258
- ```text
259
- what caused the rupiah to weaken today
260
- latest BI rate news and possible impact on IHSG
261
- ```
262
-
263
- Web research summarized by AI:
264
-
265
- ```text
266
- /web why is the rupiah weakening today
267
- /web gold price and dollar index update
268
- ```
269
-
270
- Raw web sources without AI synthesis:
271
-
272
- ```text
273
- /web sources why is the rupiah weakening today
274
- ```
275
-
276
- FinCLI uses lightweight HTTP web research, not Chrome automation. This is more stable for global npm installs and does not open a browser in the background. Web-based output should still be verified because source quality can vary.
277
-
278
- ## Interactive AI Model Selector
279
-
280
- ```text
281
- /ai_model
282
- ```
283
-
284
- In the TUI, this opens a modern CLI-style selector:
285
-
286
- - Select Provider
287
- - Show current/configured provider status
288
- - Use existing configuration or configure again
289
- - Enter API key from the popup when the provider has no key
290
- - Select Model
291
- - Search model/provider
292
- - Navigate with `up/down`, `Enter`, `Tab`, and `Esc`
293
-
294
- Set a provider/model directly:
295
-
296
- ```text
297
- /ai_model openrouter openai/gpt-4o-mini
298
- ```
299
-
300
- Save a key directly:
301
-
302
- ```text
303
- /ai_model key openrouter <api_key>
304
- ```
305
-
306
- ## News Connectors and Fallbacks
307
-
308
- ```text
309
- /news_model
310
- ```
311
-
312
- `/news_model` manages the `/news` provider chain. It supports public RSS fallbacks, yfinance news, custom news APIs, and API-key providers.
313
-
314
- Useful commands:
315
-
316
- ```text
317
- /news_model list
318
- /news_model search rss
319
- /news_model use google_news_rss
320
- /news_model priority google_news_rss,yfinance,yahoo_finance_rss,marketaux,newsapi,gnews
321
- /news_model key marketaux <api_key>
322
- /news_model key custom_news <api_key> https://your-news-api.example.com
323
- ```
324
-
325
- Practical free-first default:
326
-
327
- ```text
328
- /news_model priority google_news_rss,yfinance,yahoo_finance_rss
329
- ```
330
-
331
- API-key providers such as Marketaux, NewsAPI, GNews, Finnhub, and Alpha Vantage depend on their free-tier limits, plan, exchange entitlement, and rate limits. Public RSS sources may fail or change without notice, so FinCLI tries the next fallback automatically.
332
-
333
- ## Economic Calendar
334
-
335
- ```text
336
- /calendar
337
- /calendar today
338
- /calendar week US high
339
- /calendar 2026-06-05 2026-06-12 country=US impact=high
340
- /calendar export csv calendar.csv week US high
341
- ```
342
-
343
- When `FINNHUB_API_KEY` is configured, FinCLI pulls actual economic calendar data from Finnhub. If the key is missing or the provider fails, FinCLI shows a local fallback list of important event categories such as central bank decisions, inflation releases, labor data, GDP/PMI, and retail sales. The fallback does not claim actual event dates.
344
-
345
- Calendar output includes impact summary counts. `/calendar export` writes filtered events to CSV or JSON.
346
-
347
- ## Market Cache
348
-
349
- FinCLI uses two cache layers:
350
-
351
- - Runtime memory cache for repeated commands in the same TUI session.
352
- - Persistent SQLite cache in `~/.fincli/fincli.db` for quotes, OHLCV history, news, and fundamentals.
353
-
354
- Cache TTL follows `cache_ttl_seconds` from config. This reduces rate-limit pressure, speeds up watchlist/scanner workflows, and makes provider fallback more efficient.
355
-
356
- Commands:
357
-
358
- ```text
359
- /cache stats
360
- /cache clear
361
- ```
362
-
363
- `/cache clear` removes runtime cache and persistent market cache. API keys stay safe because market cache stores provider responses, not secrets.
364
-
365
- ## Dashboard
366
-
367
- ```text
368
- /dashboard
369
- ```
370
-
371
- The dashboard is designed as a compact first screen, not a stacked wall of panels. It includes:
372
-
373
- - Provider chain
374
- - Watchlist price snapshot
375
- - Portfolio market value and PnL
376
- - Journal win rate
377
- - Command hints for next steps
378
-
379
- ## Market Overview
380
-
381
- Use `/market` as a professional entry point for a symbol:
382
-
383
- ```text
384
- /market AAPL 1d
385
- ```
386
-
387
- Output includes:
388
-
389
- - Data Quality score
390
- - Quote and provider status
391
- - RSI, trend, MACD, ATR
392
- - Support/resistance
393
- - Market structure
394
- - Fundamental snapshot
395
- - Latest news
396
- - Disclaimer
397
-
398
- Use `/market` before moving into `/technical`, `/structure`, or `/analyze`.
399
-
400
- ## Instrument Coverage
401
-
402
- Coverage depends on provider and symbol format:
403
-
404
- - `yfinance`: stocks, ETFs, indices, forex, crypto, commodities, and mutual funds as long as Yahoo supports the symbol.
405
- - `custom`: any instrument your API exposes through the FinCLI custom provider schema.
406
- - `finnhub`: stock quotes/candles, forex candles, crypto candles, company news, company profile, and economic calendar depending on API plan.
407
- - `twelvedata`: multi-asset stocks, forex, ETFs, indices, commodities, and crypto with more consistent global market symbol formatting.
408
- - `alphavantage`: stocks and FX quote/history plus news sentiment and company overview, with strict free-plan rate limits.
409
-
410
- Recommended provider priority for multi-asset usage:
411
-
412
- ```text
413
- /provider priority twelvedata,finnhub,yfinance
414
- ```
415
-
416
- With that setup:
417
-
418
- - `twelvedata` is tried first for forex, indices, commodities, and global stocks.
419
- - `finnhub` is used as fallback for stocks and selected news/fundamental data.
420
- - `yfinance` remains the free delayed fallback if API providers fail.
421
-
422
- Example yfinance symbols:
423
-
424
- ```text
425
- AAPL
426
- MSFT
427
- SPY
428
- ^GSPC
429
- BTC-USD
430
- ETH-USD
431
- EURUSD=X
432
- GC=F
433
- CL=F
434
- ```
435
-
436
- FinCLI accepts common aliases and maps them into provider-specific formats:
437
-
438
- ```text
439
- EURUSD -> EURUSD=X for yfinance, EUR/USD for Twelve Data, OANDA:EUR_USD for Finnhub forex candles
440
- XAUUSD -> XAUUSD=X for yfinance, XAU/USD for Twelve Data
441
- SPX -> ^GSPC for yfinance
442
- NASDAQ -> ^IXIC for yfinance
443
- DAX -> ^GDAXI for yfinance
444
- NIKKEI -> ^N225 for yfinance
445
- WTI -> CL=F for yfinance
446
- BRENT -> BZ=F for yfinance
447
- ```
448
-
449
- ## Technical AI Summary
450
-
451
- `/technical` includes a structured summary designed for AI assistance:
452
-
453
- ```text
454
- /technical EURUSD 1d
455
- /technical XAUUSD 1d
456
- /technical SPX 1d
457
- ```
458
-
459
- Output includes trend bias, RSI, MACD, support/resistance, ATR, market structure summary, signal, and risk notes. The signal is rule-based and transparent:
460
-
461
- ```text
462
- Signal: BEST TO BUY | BEST TO SELL | CAUTION
463
- Signal Score
464
- Confidence
465
- Signal Reasoning
466
- Signal Risk Notes
467
- Invalidation / Caution Level
468
- ```
469
-
470
- The signal is not a guaranteed entry instruction. FinCLI uses scenario language, confirmation, invalidation, and risk notes instead of profit claims.
471
-
472
- `/technical` also uses `Technical Debate`:
473
-
474
- - `Bull Chooser`: finds buy-candidate arguments.
475
- - `Bear Chooser`: finds sell-candidate arguments.
476
- - `Caution Chooser`: finds conflicts, overextension, volatility risk, and weak confirmation.
477
- - `Judge`: decides the final `BEST TO BUY`, `BEST TO SELL`, or `CAUTION`.
478
-
479
- The debate result is also included in AI prompts so the assistant does not reason from only one side.
480
-
481
- ```text
482
- /analyze EURUSD 1d
483
- ```
484
-
485
- ## Multi-Timeframe Analysis
486
-
487
- ```text
488
- /mtf AAPL
489
- /mtf EURUSD 1d,1h,15m
490
- /mtf XAUUSD 1d,4h,1h
491
- ```
492
-
493
- `/mtf` fetches multiple timeframes through the active provider chain, summarizes trend/structure/RSI/MACD/key levels for each timeframe, and returns an alignment label such as `aligned bullish`, `mostly bearish`, or `mixed`. The default timeframe set is `1d,1h,15m` for yfinance compatibility. Use `4h` when the active provider supports it.
494
-
495
- ## Lightweight Backtesting
496
-
497
- ```text
498
- /backtest AAPL sma_cross 1d
499
- /backtest EURUSD rsi_reversion 1h
500
- ```
501
-
502
- The v0.2 lightweight backtester supports educational long-only rule-based strategies:
503
-
504
- - `sma_cross`: enters on fast/slow SMA bullish cross and exits on bearish cross.
505
- - `rsi_reversion`: enters below RSI 30 and exits above RSI 55.
506
-
507
- Output includes candles, trades, total return, win rate, max drawdown, exposure, latest trade, and risk notes. The backtest ignores fees, slippage, spreads, liquidity, and execution constraints.
508
-
509
- ## Scanner
510
-
511
- Examples:
512
-
513
- ```text
514
- /scan watchlist
515
- /scan watchlist rsi<30
516
- /scan watchlist rsi>70
517
- /scan watchlist trend=bullish
518
- /scan watchlist trend=bearish 1d
519
- /scan watchlist rsi>60 trend=bullish
520
- /scan export csv scan.csv rsi<30 1d
521
- /scan export json scan.json trend=bullish 1d
522
- ```
523
-
524
- The scanner fetches history asynchronously in limited batches, calculates indicators, and only displays symbols that match the filter.
525
-
526
- Scanner exports write matched scan rows from the current watchlist to CSV or JSON.
527
-
528
- ## Exportable Market Reports
529
-
530
- ```text
531
- /report market AAPL md report.md
532
- /report market AAPL json report.json
533
- ```
534
-
535
- Market reports reuse the `/market` overview pipeline and export quote, data quality, technicals, market structure, fundamentals, latest news, and disclaimer to Markdown or JSON.
536
-
537
- ## Portfolio Transaction Ledger
538
-
539
- Use the transaction ledger for more serious portfolio tracking:
540
-
541
- ```text
542
- /tx add buy AAPL 10 185
543
- /tx add sell AAPL 5 195
544
- /tx list
545
- /portfolio performance
546
- ```
547
-
548
- Buy transactions update quantity and average price. Sell transactions reduce position size and record realized PnL. `/portfolio performance` shows cost basis, market value, unrealized PnL, realized PnL, and total PnL.
549
-
550
- ## Journal Analytics
551
-
552
- ```text
553
- /journal stats
554
- /journal review
555
- ```
556
-
557
- `/journal stats` calculates total entries, wins/losses, win rate, dominant instrument, dominant emotion, and top tags. `/journal review` sends journal statistics and recent entries to the active AI provider for process review, repeated mistake detection, risk notes, and habit improvement. Output includes a non-financial-advice disclaimer.
558
-
559
- ## Session History
560
-
561
- ```text
562
- /history
563
- /history sessions
564
- /history show <session_id>
565
- /history save "Morning market research"
566
- /history delete <session_id>
567
- /history clear current
568
- ```
569
-
570
- FinCLI stores local session events in SQLite so users can review previous terminal sessions. API key commands are redacted before being saved.
571
-
572
- ## Price Alerts
573
-
574
- ```text
575
- /alert
576
- /alert add AAPL above 200
577
- /alert add EURUSD below 1.0800
578
- /alert check
579
- /alert remove <id>
580
- ```
581
-
582
- Alerts are stored locally in SQLite. v0.2.0 checks alerts manually with `/alert check` using the active quote provider. Triggered alerts are marked inactive. This is not a background notification daemon yet.
583
-
584
- ## AI Providers
585
-
586
- Supported provider keys:
587
-
588
- - `openrouter`: `OPENROUTER_API_KEY`
589
- - `openai`: `OPENAI_API_KEY`
590
- - `groq`: `GROQ_API_KEY`
591
- - `together`: `TOGETHER_API_KEY`
592
- - `huggingface`: `HUGGINGFACE_API_KEY`
593
- - `gemini`: `GEMINI_API_KEY`
594
- - `anthropic`: `ANTHROPIC_API_KEY`
595
-
596
- Examples:
597
-
598
- ```text
599
- /ai_model openrouter openai/gpt-4o-mini
600
- /ai_model key openrouter <api_key>
601
- /ai explain NVDA market risk briefly
602
- /analyze AAPL 1d
603
- ```
604
-
605
- API keys are never printed in full.
606
-
607
- ## Realtime vs Delayed Data
608
-
609
- FinCLI uses yfinance as the default fallback. yfinance data is usually delayed and must not be described as realtime. API providers may provide realtime data only if the provider, subscription plan, and exchange entitlement support it.
610
-
611
- FinCLI displays provider status as realtime, delayed, fallback, or unavailable whenever the provider exposes that status.
612
-
613
- ## Yahoo Finance Tables
614
-
615
- FinCLI uses yfinance for global equities available on Yahoo Finance. For non-US stocks, use the Yahoo exchange suffix when known, such as `BBRI.JK`, `HSBA.L`, `SHOP.TO`, or `0700.HK`. For common IDX tickers such as `BBRI`, `BBCA`, `BMRI`, `TLKM`, and `ASII`, FinCLI automatically maps them to `.JK`.
616
-
617
- Commands:
618
-
619
- ```text
620
- /quote BBRI
621
- /technical BBRI 1d
622
- /analyze BBRI 1d
623
- /yahoo BBRI history 6mo 1d
624
- /yahoo BBRI news
625
- /yahoo BBRI statistics
626
- /yahoo BBRI profile
627
- /yahoo BBRI financials
628
- /yahoo BBRI balance
629
- /yahoo BBRI cashflow
630
- /yahoo BBRI analysis
631
- /yahoo BBRI holders
632
- ```
633
-
634
- Yahoo Finance URL examples:
635
-
636
- ```text
637
- https://finance.yahoo.com/quote/BBRI.JK/
638
- https://finance.yahoo.com/quote/BBRI.JK/news/
639
- https://finance.yahoo.com/quote/BBRI.JK/key-statistics/
640
- https://finance.yahoo.com/quote/BBRI.JK/history/
641
- https://finance.yahoo.com/quote/BBRI.JK/profile/
642
- https://finance.yahoo.com/quote/BBRI.JK/financials/
643
- https://finance.yahoo.com/quote/BBRI.JK/analysis/
644
- https://finance.yahoo.com/quote/BBRI.JK/holders/
645
- ```
646
-
647
- Availability of news, analysis, holders, and financial tables depends on Yahoo coverage for the exchange/ticker.
648
-
649
- ## Finnhub Provider
650
-
651
- Open the provider selector:
652
-
653
- ```text
654
- /news_model
655
- ```
656
-
657
- Environment variable:
658
-
659
- ```env
660
- FINNHUB_API_KEY=your-finnhub-key
661
- ```
662
-
663
- Or save it from FinCLI:
664
-
665
- ```text
666
- /news_model key finnhub <api_key>
667
- ```
668
-
669
- Finnhub endpoints used:
670
-
671
- ```text
672
- GET /quote
673
- GET /stock/candle
674
- GET /forex/candle
675
- GET /crypto/candle
676
- GET /company-news
677
- GET /stock/profile2
678
- GET /calendar/economic
679
- ```
680
-
681
- Finnhub provides REST/WebSocket data for stocks, currencies/forex, and crypto, plus fundamental/news data depending on plan. In FinCLI, news/fundamental support is strongest for equities; forex/crypto are mainly used for candles and technical analysis.
682
-
683
- ## Twelve Data Provider
684
-
685
- Open the provider selector:
686
-
687
- ```text
688
- /news_model
689
- ```
690
-
691
- Environment variable:
692
-
693
- ```env
694
- TWELVE_DATA_API_KEY=your-twelve-data-key
695
- ```
696
-
697
- Or save it from FinCLI:
698
-
699
- ```text
700
- /news_model key twelvedata <api_key>
701
- ```
702
-
703
- Twelve Data endpoints used:
704
-
705
- ```text
706
- GET /quote
707
- GET /time_series
708
- ```
709
-
710
- Twelve Data is useful for multi-asset symbols such as forex (`EURUSD`), metals (`XAUUSD`), global indices, ETFs, crypto, and popular US/Europe/Asia stocks. Always check provider plan and exchange entitlement for realtime vs delayed access.
711
-
712
- ## Alpha Vantage Provider
713
-
714
- Open the provider selector:
715
-
716
- ```text
717
- /news_model
718
- ```
719
-
720
- Environment variable:
721
-
722
- ```env
723
- ALPHA_VANTAGE_API_KEY=your-alpha-vantage-key
724
- ```
725
-
726
- Or save it from FinCLI:
727
-
728
- ```text
729
- /news_model key alphavantage <api_key>
730
- ```
731
-
732
- Alpha Vantage functions used:
733
-
734
- ```text
735
- GLOBAL_QUOTE
736
- TIME_SERIES_DAILY_ADJUSTED
737
- CURRENCY_EXCHANGE_RATE
738
- FX_DAILY
739
- NEWS_SENTIMENT
740
- OVERVIEW
741
- ```
742
-
743
- Alpha Vantage is useful as an additional stocks/FX adapter. Free plans are rate-limited, and realtime/delayed availability depends on provider plan and exchange coverage.
744
-
745
- ## Provider Commands
746
-
747
- ```text
748
- /news_model
749
- /provider list
750
- /provider status
751
- /provider test AAPL
752
- /provider test finnhub AAPL
753
- /provider key status
754
- ```
755
-
756
- `/news_model` is the main TUI flow for selecting market/news providers and fallback priority. `/provider status` shows the active provider, fallback chain, and health message. `/provider test <symbol>` tests the active provider. `/provider test <provider> <symbol>` tests a specific provider without changing the active provider.
757
-
758
- Manual commands such as `/provider use ...` and `/provider priority ...` are still available as advanced CLI fallback commands, but they are not the primary command-palette flow.
759
-
760
- Example fallback chain saved by the selector:
761
-
762
- ```text
763
- twelvedata -> finnhub -> custom -> yfinance
764
- ```
765
-
766
- With this chain, FinCLI tries Twelve Data first. If it fails, it tries the next provider and finally uses delayed yfinance fallback.
767
-
768
- ## Symbol Search and Normalization
769
-
770
- ```text
771
- /symbol apple
772
- /symbol XAUUSD
773
- /symbol normalize EURUSD
774
- /symbol normalize BBRI
775
- ```
776
-
777
- `/symbol` searches the local symbol catalog and displays provider-specific symbol mappings for yfinance, Twelve Data, Finnhub, and custom providers. `/symbol normalize <symbol>` works for any input and shows how FinCLI will normalize the symbol before sending it to each provider.
778
-
779
- Examples:
780
-
781
- ```text
782
- EURUSD -> EURUSD=X for yfinance, EUR/USD for Twelve Data, OANDA:EUR_USD for Finnhub
783
- XAUUSD -> XAUUSD=X for yfinance, XAU/USD for Twelve Data
784
- BBRI -> BBRI.JK for yfinance
785
- ```
786
-
787
- Normalization does not guarantee provider entitlement. Check `/provider entitlement` and your provider plan for realtime/delayed access and supported exchanges.
788
-
789
- ## Custom Market Provider
790
-
791
- Open the provider selector:
792
-
793
- ```text
794
- /news_model
795
- ```
796
-
797
- Environment variables:
798
-
799
- ```env
800
- MARKET_DATA_API_KEY=your-key
801
- MARKET_DATA_BASE_URL=https://your-market-api.example.com
802
- ```
803
-
804
- Or save from FinCLI:
805
-
806
- ```text
807
- /news_model key custom <api_key> https://your-market-api.example.com
808
- ```
809
-
810
- FinCLI calls:
811
-
812
- ```text
813
- GET /quote/{symbol}
814
- GET /history/{symbol}?period=6mo&interval=1d
815
- GET /news/{symbol}?limit=5
816
- GET /fundamentals/{symbol}
817
- ```
818
-
819
- Headers are sent as `X-API-Key` and `Authorization: Bearer <key>`. API keys are not displayed in the terminal.
820
-
821
- Quote payload example:
822
-
823
- ```json
824
- {
825
- "symbol": "AAPL",
826
- "price": 123.45,
827
- "currency": "USD",
828
- "timestamp": "2026-06-04T12:00:00",
829
- "status": "realtime"
830
- }
831
- ```
832
-
833
- ## Local Storage
834
-
835
- FinCLI stores local data at:
836
-
837
- ```text
838
- ~/.fincli/config.json
839
- ~/.fincli/fincli.db
840
- ~/.fincli/fincli.log
841
- ~/.fincli/secrets.env
842
- ```
843
-
844
- API keys are not stored in command output. For global npm installs, the main setup path is:
845
-
846
- ```text
847
- /ai_model key groq <api_key>
848
- /news_model key twelvedata <api_key>
849
- ```
850
-
851
- Keys are stored in `~/.fincli/secrets.env`, automatically loaded for future FinCLI sessions, and do not need to be configured again. If a local `.env` contains an empty value, FinCLI still uses the saved local secret.
852
-
853
- ## Security Notes
854
-
855
- - Do not commit `.env`.
856
- - Do not publish `~/.fincli/secrets.env`.
857
- - FinCLI masks keys in `/config` and `/provider key status`.
858
- - Session history redacts `/ai_model key ...` and `/news_model key ...` commands.
859
- - If an API key was ever exposed in a screenshot, npm package, log, or public repository, revoke and rotate it from the provider dashboard.
860
-
861
- ## Test
862
-
863
- ```bash
864
- pytest
865
- ```
866
-
867
- Latest local verification:
868
-
869
- ```text
870
- 113 passed
871
- ```
872
-
873
- NPM wrapper check:
874
-
875
- ```bash
876
- npm run check
877
- npm pack --dry-run
878
- ```
879
-
880
- ## Troubleshooting
881
-
882
- - `fincli` is not recognized: reinstall with `pip install -e .`, `pipx install .`, or `npm install -g .` from the project root.
883
- - The TUI looks cramped: increase terminal size.
884
- - API key is not detected: use `/ai_model key <provider> <api_key>` or `/news_model key <provider> <api_key>`, then check `/config` or `/provider key status`.
885
- - `/quote` fails because yfinance is missing: run `pip install -e ".[dev]"` or `pip install -r requirements.txt`.
886
- - Config is corrupted: delete `~/.fincli/config.json` to return to defaults.
887
- - Market data fails for a symbol: check the symbol format for the active provider and try `/provider test <symbol>`.
888
-
889
- ## Roadmap v0.2
890
-
891
- - More provider adapters. Alpha Vantage started in v0.2.0.
892
- - Symbol search and provider-specific symbol normalization UI. Started in v0.2.0 through `/symbol`.
893
- - Economic calendar improvements. Summary counts and export started in v0.2.0.
894
- - Screener and scanner export. Scanner export started in v0.2.0 through `/scan export`.
895
- - Lightweight backtesting. Started in v0.2.0 through `/backtest`.
896
- - Alert system. Started in v0.2.0 through local price alerts and `/alert check`.
897
- - Exportable market reports. Started in v0.2.0 through `/report market`.
898
- - Multi-timeframe analysis. Started in v0.2.0 through `/mtf`.
899
- - Stronger custom provider schema validation. Started in v0.2.0.
900
- - Provider entitlement handling and realtime/delayed labeling improvements. Started in v0.2.0 through `/provider entitlement`.
901
-
902
- ## Roadmap v0.3
903
-
904
- - Plugin system.
905
- - Strategy builder.
906
- - Advanced portfolio analytics.
907
- - Notification integrations.
908
- - Optional cloud sync.
909
- - Realtime streaming where supported by provider plans.
1
+ # FinCLI v0.3.0
2
+
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.
4
+
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.
6
+
7
+ ## Highlights
8
+
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.
22
+
23
+ ## Install
24
+
25
+ Local development:
26
+
27
+ ```bash
28
+ python -m venv .venv
29
+ .venv\Scripts\activate
30
+ pip install -e ".[dev]"
31
+ fincli
32
+ ```
33
+
34
+ Global npm wrapper:
35
+
36
+ ```bash
37
+ npm install -g @drico2008/fincli
38
+ fincli
39
+ ```
40
+
41
+ The npm wrapper requires Python 3.11+ on the user machine. It creates an isolated `.npm-python` environment inside the installed package.
42
+
43
+ ## API Key Setup
44
+
45
+ Global users do not need to edit `.env`. Save keys from inside FinCLI:
46
+
47
+ ```text
48
+ /ai_model key groq <api_key>
49
+ /ai_model key openrouter <api_key>
50
+ /news_model key finnhub <api_key>
51
+ /news_model key twelvedata <api_key>
52
+ /news_model key alphavantage <api_key>
53
+ ```
54
+
55
+ Keys are stored locally in:
56
+
57
+ ```text
58
+ ~/.fincli/secrets.env
59
+ ```
60
+
61
+ FinCLI masks keys in terminal output. Use `/secrets status`, `/secrets clear`, `/privacy status`, and `/privacy purge` for local security hygiene.
62
+
63
+ ## Core Commands
64
+
65
+ Research and market:
66
+
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
79
+ ```
80
+
81
+ Providers:
82
+
83
+ ```text
84
+ /news_model
85
+ /news_model list
86
+ /news_model priority google_news_rss,yfinance,yahoo_finance_rss
87
+ /provider status
88
+ /provider metrics
89
+ /provider list
90
+ /provider entitlement
91
+ /provider key status
92
+ /provider test AAPL
93
+ ```
94
+
95
+ Portfolio and risk:
96
+
97
+ ```text
98
+ /portfolio
99
+ /portfolio add AAPL 10 185
100
+ /portfolio performance
101
+ /portfolio risk
102
+ /tx add buy AAPL 10 185
103
+ /tx add sell AAPL 5 195
104
+ ```
105
+
106
+ Workflow:
107
+
108
+ ```text
109
+ /watchlist add AAPL
110
+ /scan watchlist rsi<30
111
+ /journal add AAPL bullish "Breakout failed, wait for confirmation"
112
+ /journal stats
113
+ /journal review
114
+ /alert add AAPL above 200
115
+ /history
116
+ /cache stats
117
+ /cache clear
118
+ ```
119
+
120
+ Security and release:
121
+
122
+ ```text
123
+ /secrets status
124
+ /privacy status
125
+ npm run prepublish:safety
126
+ python scripts/prepublish_check.py
127
+ ```
128
+
129
+ ## Research Engine v2
130
+
131
+ `/research` is the central research command. It returns a compact output:
132
+
133
+ - Snapshot
134
+ - Signal
135
+ - Risk
136
+ - Missing Data
137
+ - Source Quality
138
+ - Decision Points
139
+ - Final Summary
140
+
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.
142
+
143
+ ## Portfolio Risk v3
144
+
145
+ `/portfolio risk` calculates:
146
+
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
157
+
158
+ The health score is a local analytical score, not financial advice. It penalizes high concentration, missing prices, weak diversification, and drawdown.
159
+
160
+ ## Data Notes
161
+
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.
167
+
168
+ ## Local Storage
169
+
170
+ FinCLI stores local data under:
171
+
172
+ ```text
173
+ ~/.fincli/config.json
174
+ ~/.fincli/secrets.env
175
+ ~/.fincli/fincli.db
176
+ ~/.fincli/fincli.log
177
+ ```
178
+
179
+ Do not commit `.env`, local secrets, logs, databases, cache folders, or npm/python virtual environments.
180
+
181
+ ## Prepublish Safety
182
+
183
+ Before publishing to npm or GitHub:
184
+
185
+ ```bash
186
+ python -m pytest -q
187
+ python -m compileall fincli tests scripts
188
+ npm run check
189
+ npm run prepublish:safety
190
+ ```
191
+
192
+ The prepublish checker scans for `.env`, `secrets.env`, logs, SQLite databases, token-like strings, and unsafe `npm pack --dry-run` contents.
193
+
194
+ ## Roadmap
195
+
196
+ ### v0.3.x Hardening
197
+
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.
205
+
206
+ ### v0.4
207
+
208
+ - Strategy builder.
209
+ - Alert daemon and notification integrations.
210
+ - Backtesting with fees, slippage, and position sizing.
211
+ - Optional cloud sync.
212
+ - Plugin marketplace-style connector loading.
213
+ - Realtime streaming where provider plans support it.
214
+
215
+ ## License
216
+
217
+ MIT