@drico2008/fincli 0.1.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.
- package/README.md +644 -0
- package/fincli/__init__.py +3 -0
- package/fincli/app/__init__.py +1 -0
- package/fincli/app/analysis/__init__.py +1 -0
- package/fincli/app/analysis/ai_prompts.py +33 -0
- package/fincli/app/analysis/analyzer.py +119 -0
- package/fincli/app/analysis/assistant_context.py +161 -0
- package/fincli/app/analysis/indicators.py +143 -0
- package/fincli/app/analysis/market_structure.py +106 -0
- package/fincli/app/analysis/technical_debate.py +251 -0
- package/fincli/app/analysis/technical_signal.py +203 -0
- package/fincli/app/cli/__init__.py +1 -0
- package/fincli/app/cli/autocomplete.py +17 -0
- package/fincli/app/cli/commands.py +82 -0
- package/fincli/app/cli/router.py +1257 -0
- package/fincli/app/main.py +16 -0
- package/fincli/app/modules/__init__.py +1 -0
- package/fincli/app/modules/economic_calendar.py +139 -0
- package/fincli/app/modules/exporter.py +51 -0
- package/fincli/app/modules/journal.py +65 -0
- package/fincli/app/modules/journal_analytics.py +70 -0
- package/fincli/app/modules/portfolio.py +34 -0
- package/fincli/app/modules/scanner.py +105 -0
- package/fincli/app/modules/transactions.py +84 -0
- package/fincli/app/modules/watchlist.py +25 -0
- package/fincli/app/providers/__init__.py +1 -0
- package/fincli/app/providers/ai/__init__.py +1 -0
- package/fincli/app/providers/ai/anthropic_provider.py +11 -0
- package/fincli/app/providers/ai/base.py +29 -0
- package/fincli/app/providers/ai/gemini_provider.py +11 -0
- package/fincli/app/providers/ai/groq_provider.py +11 -0
- package/fincli/app/providers/ai/http_provider.py +145 -0
- package/fincli/app/providers/ai/huggingface_provider.py +11 -0
- package/fincli/app/providers/ai/manager.py +60 -0
- package/fincli/app/providers/ai/openai_provider.py +11 -0
- package/fincli/app/providers/ai/openrouter_provider.py +11 -0
- package/fincli/app/providers/ai/together_provider.py +11 -0
- package/fincli/app/providers/market/__init__.py +1 -0
- package/fincli/app/providers/market/base.py +77 -0
- package/fincli/app/providers/market/custom_provider.py +169 -0
- package/fincli/app/providers/market/finnhub_provider.py +187 -0
- package/fincli/app/providers/market/manager.py +123 -0
- package/fincli/app/providers/market/news_provider.py +28 -0
- package/fincli/app/providers/market/symbols.py +182 -0
- package/fincli/app/providers/market/twelvedata_provider.py +167 -0
- package/fincli/app/providers/market/yfinance_provider.py +447 -0
- package/fincli/app/services/__init__.py +1 -0
- package/fincli/app/services/market_data.py +203 -0
- package/fincli/app/services/market_overview.py +111 -0
- package/fincli/app/storage/__init__.py +1 -0
- package/fincli/app/storage/cache.py +38 -0
- package/fincli/app/storage/config.py +114 -0
- package/fincli/app/storage/database.py +101 -0
- package/fincli/app/storage/market_cache.py +92 -0
- package/fincli/app/tui/__init__.py +1 -0
- package/fincli/app/tui/components.py +55 -0
- package/fincli/app/tui/layout.py +261 -0
- package/fincli/app/tui/market_provider_selector.py +267 -0
- package/fincli/app/tui/model_selector.py +412 -0
- package/fincli/app/tui/theme.py +157 -0
- package/fincli/app/utils/__init__.py +1 -0
- package/fincli/app/utils/errors.py +33 -0
- package/fincli/app/utils/formatting.py +17 -0
- package/fincli/app/utils/logger.py +19 -0
- package/npm/bin/fincli.js +35 -0
- package/npm/postinstall.js +72 -0
- package/package.json +23 -0
- package/pyproject.toml +31 -0
- package/requirements.txt +9 -0
package/README.md
ADDED
|
@@ -0,0 +1,644 @@
|
|
|
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: Phase 23 MVP sudah aktif di atas fondasi Phase 1 sampai Phase 22.
|
|
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.
|
|
36
|
+
|
|
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
|
+
```
|
|
50
|
+
|
|
51
|
+
## Global Install
|
|
52
|
+
|
|
53
|
+
Rekomendasi untuk Python CLI adalah `pipx`, karena dependency FinCLI dipasang di environment terisolasi tetapi command `fincli` tersedia global:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install pipx
|
|
57
|
+
pipx ensurepath
|
|
58
|
+
pipx install .
|
|
59
|
+
fincli
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Jika sudah dipublish ke PyPI:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pipx install fincli
|
|
66
|
+
fincli
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
FinCLI juga punya npm wrapper agar bisa mengikuti pola “install once, run anywhere” seperti CLI Node:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm install -g .
|
|
73
|
+
fincli
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Setelah package npm dipublish:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm install -g @drico2008/fincli
|
|
80
|
+
fincli
|
|
81
|
+
```
|
|
82
|
+
|
|
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`.
|
|
84
|
+
|
|
85
|
+
## Setup `.env`
|
|
86
|
+
|
|
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
|
+
## Run
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
fincli
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Atau:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
python -m fincli.app.main
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Command Utama
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
/help
|
|
109
|
+
/dashboard
|
|
110
|
+
/config
|
|
111
|
+
/ai_model
|
|
112
|
+
/ai_model openrouter openai/gpt-4o-mini
|
|
113
|
+
/news_model
|
|
114
|
+
/market AAPL 1d
|
|
115
|
+
/provider status
|
|
116
|
+
/provider list
|
|
117
|
+
/provider test AAPL
|
|
118
|
+
/provider key status
|
|
119
|
+
/watchlist
|
|
120
|
+
/watchlist add AAPL
|
|
121
|
+
/watchlist remove AAPL
|
|
122
|
+
/portfolio
|
|
123
|
+
/portfolio add BTC-USD 0.05 65000
|
|
124
|
+
/portfolio remove BTC-USD
|
|
125
|
+
/portfolio performance
|
|
126
|
+
/tx add buy AAPL 10 185
|
|
127
|
+
/tx add sell AAPL 5 195
|
|
128
|
+
/tx list
|
|
129
|
+
/journal
|
|
130
|
+
/journal add BTC-USD bullish "Breakout gagal, tunggu konfirmasi"
|
|
131
|
+
/journal stats
|
|
132
|
+
/journal review
|
|
133
|
+
/price AAPL
|
|
134
|
+
/technical BTC-USD 1d
|
|
135
|
+
/technical XAUUSD 1d
|
|
136
|
+
/technical EURUSD 1d
|
|
137
|
+
/structure BTC-USD 1d
|
|
138
|
+
/news AAPL
|
|
139
|
+
/funda MSFT
|
|
140
|
+
/yahoo BBRI history 6mo 1d
|
|
141
|
+
/yahoo BBRI statistics
|
|
142
|
+
/yahoo BBRI profile
|
|
143
|
+
/yahoo BBRI financials
|
|
144
|
+
/yahoo BBRI analysis
|
|
145
|
+
/yahoo BBRI holders
|
|
146
|
+
/ai jelaskan risiko market hari ini
|
|
147
|
+
/analyze ETH-USD 4h
|
|
148
|
+
/scan watchlist rsi<30
|
|
149
|
+
/scan watchlist trend=bullish
|
|
150
|
+
/scan watchlist rsi>60 trend=bullish
|
|
151
|
+
/calendar
|
|
152
|
+
/calendar today
|
|
153
|
+
/calendar 2026-06-05 2026-06-12 country=US impact=high
|
|
154
|
+
/export portfolio json C:\Users\MSI\Desktop\portfolio.json
|
|
155
|
+
/export journal csv C:\Users\MSI\Desktop\journal.csv
|
|
156
|
+
/cache stats
|
|
157
|
+
/cache clear
|
|
158
|
+
/clear
|
|
159
|
+
/exit
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Command `/market`, `/price`, `/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`.
|
|
163
|
+
|
|
164
|
+
## AI Chat UX
|
|
165
|
+
|
|
166
|
+
Di TUI, input biasa tanpa slash sekarang diperlakukan sebagai chat ke AI assistant aktif:
|
|
167
|
+
|
|
168
|
+
```text
|
|
169
|
+
hello
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Output ditampilkan dengan format terminal chat:
|
|
173
|
+
|
|
174
|
+
```text
|
|
175
|
+
> hello
|
|
176
|
+
▸ Thinking: routing prompt to active AI provider...
|
|
177
|
+
* Provider: ...
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Command eksplisit tetap bisa dipakai:
|
|
181
|
+
|
|
182
|
+
```text
|
|
183
|
+
/ai jelaskan risiko market hari ini
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
AI assistant di dalam FinCLI dipersonalisasi untuk market workflow:
|
|
187
|
+
|
|
188
|
+
- Mengenali FinCLI sebagai terminal financial dashboard.
|
|
189
|
+
- Boleh free chat untuk pertanyaan umum, market, portfolio, journal, provider, dan risk workflow.
|
|
190
|
+
- Menolak coding/debugging/refactor/pembuatan software di dalam assistant FinCLI agar fokus app tetap jelas.
|
|
191
|
+
- Jika prompt berisi symbol eksplisit, FinCLI menyisipkan market context dari provider chain aktif sebelum memanggil AI provider.
|
|
192
|
+
- Tidak membocorkan API key dan tidak mengklaim realtime jika provider aktif hanya delayed/fallback.
|
|
193
|
+
|
|
194
|
+
## Interactive AI Model Selector
|
|
195
|
+
|
|
196
|
+
```text
|
|
197
|
+
/ai_model
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Di TUI, command ini membuka selector seperti modern CLI:
|
|
201
|
+
|
|
202
|
+
- Select Provider
|
|
203
|
+
- Status provider current/configured
|
|
204
|
+
- Use existing configuration / configure again
|
|
205
|
+
- Select Model
|
|
206
|
+
- Search model/provider
|
|
207
|
+
- Navigasi `up/down`, `Enter`, `Tab`, dan `Esc`
|
|
208
|
+
|
|
209
|
+
Untuk set langsung tanpa selector:
|
|
210
|
+
|
|
211
|
+
```text
|
|
212
|
+
/ai_model openrouter openai/gpt-4o-mini
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Interactive Market/News Provider Selector
|
|
216
|
+
|
|
217
|
+
```text
|
|
218
|
+
/news_model
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Di TUI, command ini membuka selector untuk provider market/news dan fallback priority:
|
|
222
|
+
|
|
223
|
+
- Select Market/News Provider
|
|
224
|
+
- Pilih `Twelve Data`, `Finnhub`, `Custom API`, atau `Yahoo Finance`
|
|
225
|
+
- Pilih preset fallback: recommended, primary + yfinance, data API priority, atau yfinance only
|
|
226
|
+
- Search provider/preset
|
|
227
|
+
- Navigasi `up/down`, `Enter`, `Tab`, dan `Esc`
|
|
228
|
+
|
|
229
|
+
Rekomendasi praktis:
|
|
230
|
+
|
|
231
|
+
```text
|
|
232
|
+
Primary: twelvedata
|
|
233
|
+
Fallback: twelvedata -> finnhub -> custom -> yfinance
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
`yfinance` tetap fallback gratis/delayed. Provider API seperti Twelve Data dan Finnhub tetap bergantung pada API key, plan, entitlement exchange, dan batas rate-limit.
|
|
237
|
+
|
|
238
|
+
## Economic Calendar
|
|
239
|
+
|
|
240
|
+
```text
|
|
241
|
+
/calendar
|
|
242
|
+
/calendar today
|
|
243
|
+
/calendar week US high
|
|
244
|
+
/calendar 2026-06-05 2026-06-12 country=US impact=high
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
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.
|
|
248
|
+
|
|
249
|
+
## Market Cache
|
|
250
|
+
|
|
251
|
+
FinCLI memakai dua lapis cache:
|
|
252
|
+
|
|
253
|
+
- Runtime cache di memori untuk command yang dipanggil berulang dalam sesi TUI.
|
|
254
|
+
- Persistent SQLite cache di `~/.fincli/fincli.db` untuk quote, OHLCV history, news, dan fundamentals.
|
|
255
|
+
|
|
256
|
+
Cache mengikuti `cache_ttl_seconds` dari config. Ini penting untuk mengurangi rate-limit, mempercepat scanner/watchlist, dan membuat provider chain lebih efisien.
|
|
257
|
+
|
|
258
|
+
Command:
|
|
259
|
+
|
|
260
|
+
```text
|
|
261
|
+
/cache stats
|
|
262
|
+
/cache clear
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
`/cache clear` menghapus runtime cache dan persistent market cache. API key tetap aman karena cache hanya menyimpan respons market data, bukan secret.
|
|
266
|
+
|
|
267
|
+
## Dashboard Compact
|
|
268
|
+
|
|
269
|
+
```text
|
|
270
|
+
/dashboard
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Dashboard dibuat sebagai layar awal TUI yang tidak stacked dan tidak ramai. Ringkasannya mencakup:
|
|
274
|
+
|
|
275
|
+
- Provider chain
|
|
276
|
+
- Watchlist price snapshot
|
|
277
|
+
- Portfolio market value dan PnL
|
|
278
|
+
- Journal win rate
|
|
279
|
+
- Command hint untuk langkah berikutnya
|
|
280
|
+
|
|
281
|
+
## Market Overview
|
|
282
|
+
|
|
283
|
+
Command utama untuk melihat instrumen secara profesional:
|
|
284
|
+
|
|
285
|
+
```text
|
|
286
|
+
/market AAPL 1d
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Output berisi:
|
|
290
|
+
|
|
291
|
+
- Data Quality score
|
|
292
|
+
- Quote dan provider status
|
|
293
|
+
- RSI, trend, MACD, ATR
|
|
294
|
+
- Support/resistance
|
|
295
|
+
- Market structure
|
|
296
|
+
- Fundamental snapshot
|
|
297
|
+
- Latest news
|
|
298
|
+
- Disclaimer
|
|
299
|
+
|
|
300
|
+
Gunakan `/market` sebagai entry point sebelum masuk ke `/technical`, `/structure`, atau `/analyze`.
|
|
301
|
+
|
|
302
|
+
## Coverage Instrumen
|
|
303
|
+
|
|
304
|
+
Coverage tergantung provider dan format symbol:
|
|
305
|
+
|
|
306
|
+
- `yfinance`: stocks, ETFs, indices, forex, crypto, commodities, dan mutual funds selama symbol Yahoo valid.
|
|
307
|
+
- `custom`: instrumen apa pun selama API kamu menyediakan endpoint FinCLI.
|
|
308
|
+
- `finnhub`: quote/candle saham, forex candle, crypto candle, company news, company profile, dan economic calendar sesuai plan API.
|
|
309
|
+
- `twelvedata`: multi-asset stocks, forex, ETFs, indices, commodities, dan crypto dengan format symbol yang lebih konsisten untuk market global.
|
|
310
|
+
|
|
311
|
+
Rekomendasi provider priority untuk multi-asset:
|
|
312
|
+
|
|
313
|
+
```text
|
|
314
|
+
/provider priority twelvedata,finnhub,yfinance
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Dengan konfigurasi ini:
|
|
318
|
+
|
|
319
|
+
- `twelvedata` dicoba dulu untuk forex/indices/commodities/global stocks.
|
|
320
|
+
- `finnhub` menjadi fallback untuk saham dan news/fundamental tertentu.
|
|
321
|
+
- `yfinance` tetap fallback gratis/delayed jika provider API gagal.
|
|
322
|
+
|
|
323
|
+
Contoh symbol yfinance:
|
|
324
|
+
|
|
325
|
+
```text
|
|
326
|
+
AAPL
|
|
327
|
+
MSFT
|
|
328
|
+
SPY
|
|
329
|
+
^GSPC
|
|
330
|
+
BTC-USD
|
|
331
|
+
ETH-USD
|
|
332
|
+
EURUSD=X
|
|
333
|
+
GC=F
|
|
334
|
+
CL=F
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
FinCLI juga menerima alias umum dan mengubahnya ke format provider:
|
|
338
|
+
|
|
339
|
+
```text
|
|
340
|
+
EURUSD -> EURUSD=X untuk yfinance, EUR/USD untuk Twelve Data, OANDA:EUR_USD untuk Finnhub forex candle
|
|
341
|
+
XAUUSD -> XAUUSD=X untuk yfinance, XAU/USD untuk Twelve Data
|
|
342
|
+
SPX -> ^GSPC untuk yfinance
|
|
343
|
+
NASDAQ -> ^IXIC untuk yfinance
|
|
344
|
+
DAX -> ^GDAXI untuk yfinance
|
|
345
|
+
NIKKEI -> ^N225 untuk yfinance
|
|
346
|
+
WTI -> CL=F untuk yfinance
|
|
347
|
+
BRENT -> BZ=F untuk yfinance
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Technical AI Summary
|
|
351
|
+
|
|
352
|
+
`/technical` sekarang menyertakan ringkasan khusus untuk AI assistance:
|
|
353
|
+
|
|
354
|
+
```text
|
|
355
|
+
/technical EURUSD 1d
|
|
356
|
+
/technical XAUUSD 1d
|
|
357
|
+
/technical SPX 1d
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Output mencakup trend bias, RSI, MACD, support/resistance, ATR, market structure ringkas, signal, dan risk notes. Signal bersifat rule-based dan transparan:
|
|
361
|
+
|
|
362
|
+
```text
|
|
363
|
+
Signal: BEST TO BUY | BEST TO SELL | CAUTION
|
|
364
|
+
Signal Score
|
|
365
|
+
Confidence
|
|
366
|
+
Signal Reasoning
|
|
367
|
+
Signal Risk Notes
|
|
368
|
+
Invalidation / Caution Level
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
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:
|
|
372
|
+
|
|
373
|
+
Selain signal langsung, `/technical` sekarang memakai `Technical Debate`:
|
|
374
|
+
|
|
375
|
+
- `Bull Chooser`: mencari argumen buy candidate.
|
|
376
|
+
- `Bear Chooser`: mencari argumen sell candidate.
|
|
377
|
+
- `Caution Chooser`: mencari konflik, overextension, volatilitas, dan kualitas konfirmasi.
|
|
378
|
+
- `Judge`: menentukan final `BEST TO BUY`, `BEST TO SELL`, atau `CAUTION`.
|
|
379
|
+
|
|
380
|
+
Debate ini juga dimasukkan ke prompt AI agar AI assistance tidak hanya membaca satu sisi argumen.
|
|
381
|
+
|
|
382
|
+
```text
|
|
383
|
+
/analyze EURUSD 1d
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
## Scanner
|
|
387
|
+
|
|
388
|
+
Contoh:
|
|
389
|
+
|
|
390
|
+
```text
|
|
391
|
+
/scan watchlist
|
|
392
|
+
/scan watchlist rsi<30
|
|
393
|
+
/scan watchlist rsi>70
|
|
394
|
+
/scan watchlist trend=bullish
|
|
395
|
+
/scan watchlist trend=bearish 1d
|
|
396
|
+
/scan watchlist rsi>60 trend=bullish
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Scanner mengambil data history secara async dalam batch terbatas, menghitung indikator, lalu hanya menampilkan symbol yang match filter.
|
|
400
|
+
|
|
401
|
+
## Portfolio Transaction Ledger
|
|
402
|
+
|
|
403
|
+
Gunakan transaction ledger untuk portfolio yang lebih serius:
|
|
404
|
+
|
|
405
|
+
```text
|
|
406
|
+
/tx add buy AAPL 10 185
|
|
407
|
+
/tx add sell AAPL 5 195
|
|
408
|
+
/tx list
|
|
409
|
+
/portfolio performance
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
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.
|
|
413
|
+
|
|
414
|
+
## Journal Analytics
|
|
415
|
+
|
|
416
|
+
```text
|
|
417
|
+
/journal stats
|
|
418
|
+
/journal review
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
`/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.
|
|
422
|
+
|
|
423
|
+
## AI Provider
|
|
424
|
+
|
|
425
|
+
Provider yang disiapkan:
|
|
426
|
+
|
|
427
|
+
- `openrouter`: `OPENROUTER_API_KEY`
|
|
428
|
+
- `openai`: `OPENAI_API_KEY`
|
|
429
|
+
- `groq`: `GROQ_API_KEY`
|
|
430
|
+
- `together`: `TOGETHER_API_KEY`
|
|
431
|
+
- `huggingface`: `HUGGINGFACE_API_KEY`
|
|
432
|
+
- `gemini`: `GEMINI_API_KEY`
|
|
433
|
+
- `anthropic`: `ANTHROPIC_API_KEY`
|
|
434
|
+
|
|
435
|
+
Contoh:
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
/ai_model openrouter openai/gpt-4o-mini
|
|
439
|
+
/ai jelaskan risiko market NVDA secara singkat
|
|
440
|
+
/analyze AAPL 1d
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
API key tidak pernah dicetak penuh di output terminal.
|
|
444
|
+
|
|
445
|
+
## Data Realtime / Delayed
|
|
446
|
+
|
|
447
|
+
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.
|
|
448
|
+
|
|
449
|
+
## Yahoo Finance Tables
|
|
450
|
+
|
|
451
|
+
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`.
|
|
452
|
+
|
|
453
|
+
Command:
|
|
454
|
+
|
|
455
|
+
```text
|
|
456
|
+
/price BBRI
|
|
457
|
+
/technical BBRI 1d
|
|
458
|
+
/analyze BBRI 1d
|
|
459
|
+
/yahoo BBRI history 6mo 1d
|
|
460
|
+
/yahoo BBRI news
|
|
461
|
+
/yahoo BBRI statistics
|
|
462
|
+
/yahoo BBRI profile
|
|
463
|
+
/yahoo BBRI financials
|
|
464
|
+
/yahoo BBRI balance
|
|
465
|
+
/yahoo BBRI cashflow
|
|
466
|
+
/yahoo BBRI analysis
|
|
467
|
+
/yahoo BBRI holders
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
Source URL yang dipakai mengikuti format Yahoo Finance, misalnya:
|
|
471
|
+
|
|
472
|
+
```text
|
|
473
|
+
https://finance.yahoo.com/quote/BBRI.JK/
|
|
474
|
+
https://finance.yahoo.com/quote/BBRI.JK/news/
|
|
475
|
+
https://finance.yahoo.com/quote/BBRI.JK/key-statistics/
|
|
476
|
+
https://finance.yahoo.com/quote/BBRI.JK/history/
|
|
477
|
+
https://finance.yahoo.com/quote/BBRI.JK/profile/
|
|
478
|
+
https://finance.yahoo.com/quote/BBRI.JK/financials/
|
|
479
|
+
https://finance.yahoo.com/quote/BBRI.JK/analysis/
|
|
480
|
+
https://finance.yahoo.com/quote/BBRI.JK/holders/
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
Catatan: availability news, analysis, holders, dan beberapa financial table bergantung coverage Yahoo untuk exchange/ticker tersebut.
|
|
484
|
+
|
|
485
|
+
## Finnhub Provider
|
|
486
|
+
|
|
487
|
+
Aktifkan lewat selector TUI:
|
|
488
|
+
|
|
489
|
+
```text
|
|
490
|
+
/news_model
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
Environment variable:
|
|
494
|
+
|
|
495
|
+
```env
|
|
496
|
+
FINNHUB_API_KEY=your-finnhub-key
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
Endpoint Finnhub yang dipakai:
|
|
500
|
+
|
|
501
|
+
```text
|
|
502
|
+
GET /quote
|
|
503
|
+
GET /stock/candle
|
|
504
|
+
GET /forex/candle
|
|
505
|
+
GET /crypto/candle
|
|
506
|
+
GET /company-news
|
|
507
|
+
GET /stock/profile2
|
|
508
|
+
GET /calendar/economic
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
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.
|
|
512
|
+
|
|
513
|
+
## Twelve Data Provider
|
|
514
|
+
|
|
515
|
+
Aktifkan lewat selector TUI:
|
|
516
|
+
|
|
517
|
+
```text
|
|
518
|
+
/news_model
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
Environment variable:
|
|
522
|
+
|
|
523
|
+
```env
|
|
524
|
+
TWELVE_DATA_API_KEY=your-twelve-data-key
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
Endpoint Twelve Data yang dipakai:
|
|
528
|
+
|
|
529
|
+
```text
|
|
530
|
+
GET /quote
|
|
531
|
+
GET /time_series
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
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.
|
|
535
|
+
|
|
536
|
+
## Provider Commands
|
|
537
|
+
|
|
538
|
+
```text
|
|
539
|
+
/news_model
|
|
540
|
+
/provider list
|
|
541
|
+
/provider status
|
|
542
|
+
/provider test AAPL
|
|
543
|
+
/provider test finnhub AAPL
|
|
544
|
+
/provider key status
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
`/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.
|
|
548
|
+
|
|
549
|
+
Command manual `/provider use ...` dan `/provider priority ...` masih tersedia sebagai advanced CLI fallback, tetapi tidak lagi ditampilkan sebagai flow utama di command palette.
|
|
550
|
+
|
|
551
|
+
Contoh fallback chain yang disimpan selector:
|
|
552
|
+
|
|
553
|
+
```text
|
|
554
|
+
twelvedata -> finnhub -> custom -> yfinance
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
Dengan contoh di atas, FinCLI mencoba Twelve Data lebih dulu. Jika gagal, FinCLI mencoba provider berikutnya dan memakai yfinance delayed sebagai fallback terakhir.
|
|
558
|
+
|
|
559
|
+
## Custom Market Provider
|
|
560
|
+
|
|
561
|
+
Aktifkan lewat selector TUI:
|
|
562
|
+
|
|
563
|
+
```text
|
|
564
|
+
/news_model
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
Environment variable:
|
|
568
|
+
|
|
569
|
+
```env
|
|
570
|
+
MARKET_DATA_API_KEY=your-key
|
|
571
|
+
MARKET_DATA_BASE_URL=https://your-market-api.example.com
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
FinCLI akan memanggil endpoint:
|
|
575
|
+
|
|
576
|
+
```text
|
|
577
|
+
GET /quote/{symbol}
|
|
578
|
+
GET /history/{symbol}?period=6mo&interval=1d
|
|
579
|
+
GET /news/{symbol}?limit=5
|
|
580
|
+
GET /fundamentals/{symbol}
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
Header dikirim sebagai `X-API-Key` dan `Authorization: Bearer <key>`. API key tidak ditampilkan di terminal.
|
|
584
|
+
|
|
585
|
+
Contoh payload quote:
|
|
586
|
+
|
|
587
|
+
```json
|
|
588
|
+
{
|
|
589
|
+
"symbol": "AAPL",
|
|
590
|
+
"price": 123.45,
|
|
591
|
+
"currency": "USD",
|
|
592
|
+
"timestamp": "2026-06-04T12:00:00",
|
|
593
|
+
"status": "realtime"
|
|
594
|
+
}
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
## Local Storage
|
|
598
|
+
|
|
599
|
+
FinCLI menyimpan data lokal di:
|
|
600
|
+
|
|
601
|
+
```text
|
|
602
|
+
~/.fincli/config.json
|
|
603
|
+
~/.fincli/fincli.db
|
|
604
|
+
~/.fincli/fincli.log
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
API key tidak disimpan di output terminal dan sebaiknya tetap berada di `.env` atau environment variable.
|
|
608
|
+
|
|
609
|
+
## Test
|
|
610
|
+
|
|
611
|
+
```bash
|
|
612
|
+
pytest
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
Hasil terakhir di environment ini:
|
|
616
|
+
|
|
617
|
+
```text
|
|
618
|
+
97 passed
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
## Troubleshooting
|
|
622
|
+
|
|
623
|
+
- `fincli` tidak dikenali: jalankan `pip install -e .` dari root project.
|
|
624
|
+
- TUI tidak tampil rapi: perbesar terminal desktop.
|
|
625
|
+
- API key tidak terbaca: pastikan file `.env` ada di root project atau export environment variable.
|
|
626
|
+
- `/price` gagal karena yfinance belum ada: jalankan `pip install -e ".[dev]"` atau `pip install -r requirements.txt`.
|
|
627
|
+
- Config rusak: hapus `~/.fincli/config.json` untuk kembali ke default.
|
|
628
|
+
|
|
629
|
+
## Roadmap Lanjutan
|
|
630
|
+
|
|
631
|
+
- Scanner export dan filter expression parser yang lebih lengkap.
|
|
632
|
+
- Market structure lebih lanjut: pivot strength, multi-timeframe structure, liquidity sweep detection.
|
|
633
|
+
- AI market analysis dengan ranking data quality dan confidence scoring.
|
|
634
|
+
- Custom provider schema validation yang lebih ketat dan adapter untuk provider populer.
|
|
635
|
+
- Provider adapter lanjutan untuk entitlement exchange, symbol search, dan realtime streaming.
|
|
636
|
+
- Economic calendar lanjutan, screener, alert dasar, dan multi-timeframe analysis.
|
|
637
|
+
|
|
638
|
+
## Roadmap v0.3
|
|
639
|
+
|
|
640
|
+
- Plugin system.
|
|
641
|
+
- Strategy builder.
|
|
642
|
+
- Advanced portfolio analytics.
|
|
643
|
+
- Notification integration.
|
|
644
|
+
- Optional cloud sync.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Application package for FinCLI."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Analysis modules."""
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Prompt templates for AI market analysis."""
|
|
2
|
+
|
|
3
|
+
MARKET_ANALYSIS_PROMPT = """
|
|
4
|
+
You are FinCLI's market analysis assistant.
|
|
5
|
+
|
|
6
|
+
Rules:
|
|
7
|
+
- Analyze only from the provided OHLCV, indicators, market structure, and news/fundamental context.
|
|
8
|
+
- Treat the provided Signal Assessment as a rule-based candidate signal, not a guaranteed trade instruction.
|
|
9
|
+
- Do not invent prices, news, fundamentals, or certainty.
|
|
10
|
+
- If data is missing, state that data quality is insufficient.
|
|
11
|
+
- Use probabilistic scenario language, not guaranteed entry signals.
|
|
12
|
+
- If discussing buy/sell, phrase it as candidate bias with confirmation and invalidation conditions.
|
|
13
|
+
- Do not promise profit.
|
|
14
|
+
- Keep the output structured and concise.
|
|
15
|
+
- Add a short non-financial-advice disclaimer.
|
|
16
|
+
|
|
17
|
+
Required output:
|
|
18
|
+
Instrument:
|
|
19
|
+
Timeframe:
|
|
20
|
+
Data Quality:
|
|
21
|
+
Market Summary:
|
|
22
|
+
Trend Bias:
|
|
23
|
+
Key Levels:
|
|
24
|
+
Technical Indicators:
|
|
25
|
+
Market Structure:
|
|
26
|
+
Signal Assessment:
|
|
27
|
+
News/Fundamental Context:
|
|
28
|
+
Bullish Scenario:
|
|
29
|
+
Bearish Scenario:
|
|
30
|
+
Risk Notes:
|
|
31
|
+
Conclusion:
|
|
32
|
+
Disclaimer:
|
|
33
|
+
"""
|