@drico2008/fincli 0.3.1 → 0.4.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 +217 -217
- package/fincli/__init__.py +1 -1
- package/fincli/app/analysis/ai_prompts.py +29 -27
- package/fincli/app/analysis/analyzer.py +34 -34
- package/fincli/app/analysis/assistant_context.py +3 -3
- package/fincli/app/cli/commands.py +33 -27
- package/fincli/app/cli/router.py +1633 -1105
- package/fincli/app/diagnostics/__init__.py +2 -0
- package/fincli/app/diagnostics/capabilities.py +44 -0
- package/fincli/app/diagnostics/runtime.py +106 -0
- package/fincli/app/main.py +6 -1
- package/fincli/app/modules/economic_calendar.py +512 -512
- package/fincli/app/modules/portfolio_risk.py +305 -305
- package/fincli/app/modules/trading.py +142 -0
- package/fincli/app/plugins/loader.py +72 -72
- package/fincli/app/providers/market/finnhub_provider.py +51 -2
- package/fincli/app/providers/market/symbols.py +95 -2
- package/fincli/app/providers/reliability.py +82 -65
- package/fincli/app/research/__init__.py +8 -8
- package/fincli/app/research/engine.py +119 -112
- package/fincli/app/research/exporter.py +91 -91
- package/fincli/app/research/formatter.py +25 -24
- package/fincli/app/research/models.py +22 -21
- package/fincli/app/research/prompt_builder.py +53 -51
- package/fincli/app/services/data_quality.py +27 -0
- package/fincli/app/services/data_trust.py +117 -0
- package/fincli/app/services/macro_data.py +158 -50
- package/fincli/app/services/market_data.py +183 -79
- package/fincli/app/services/market_overview.py +131 -142
- package/fincli/app/services/news_aggregator.py +95 -95
- package/fincli/app/storage/config.py +6 -3
- package/fincli/app/storage/database.py +130 -117
- package/fincli/app/storage/provider_metrics.py +61 -61
- package/fincli/app/storage/secrets.py +128 -128
- package/npm/bin/fincli.js +65 -65
- package/package.json +7 -7
- package/pyproject.toml +1 -1
package/README.md
CHANGED
|
@@ -1,217 +1,217 @@
|
|
|
1
|
-
# FinCLI v0.
|
|
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
|
|
1
|
+
# FinCLI v0.4.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
|
package/fincli/__init__.py
CHANGED
|
@@ -5,41 +5,43 @@ You are FinCLI's market analysis assistant.
|
|
|
5
5
|
|
|
6
6
|
Rules:
|
|
7
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
|
-
- Treat the provided User Gameplay Profile as a risk constraint for SL/TP sizing and scenario wording.
|
|
8
|
+
- Treat the provided Signal Assessment as a rule-based candidate signal, not a guaranteed trade instruction.
|
|
9
|
+
- Treat the provided User Gameplay Profile as a risk constraint for SL/TP sizing and scenario wording.
|
|
10
10
|
- Do not invent prices, news, fundamentals, or certainty.
|
|
11
|
-
- If data is missing, state that data quality is insufficient.
|
|
11
|
+
- If data is missing, state that data quality is insufficient.
|
|
12
12
|
- Use the AI Grounding Guard before conclusions: check data_quality, provider reliability, missing data, and provider metrics.
|
|
13
|
+
- Obey the Data Trust Gate exactly. If Trust Level is blocked or limited, Signal must be CAUTION/WAIT, SL/TP must be conditional or "not valid until data is verified".
|
|
13
14
|
- If reliability is not ok, missing data exists, or provider metrics show weak success/error performance, reduce confidence and say what must be verified.
|
|
14
|
-
- Use probabilistic scenario language, not guaranteed entry signals.
|
|
15
|
+
- Use probabilistic scenario language, not guaranteed entry signals.
|
|
15
16
|
- If discussing buy/sell, phrase it as candidate bias with confirmation and invalidation conditions.
|
|
16
17
|
- Do not promise profit.
|
|
17
18
|
- Keep the output structured and concise.
|
|
18
19
|
- Add a short non-financial-advice disclaimer.
|
|
19
20
|
|
|
20
|
-
Required output:
|
|
21
|
-
Instrument:
|
|
22
|
-
Timeframe:
|
|
23
|
-
Data Quality:
|
|
24
|
-
Provider Reliability:
|
|
25
|
-
Missing Data:
|
|
21
|
+
Required output:
|
|
22
|
+
Instrument:
|
|
23
|
+
Timeframe:
|
|
24
|
+
Data Quality:
|
|
25
|
+
Provider Reliability:
|
|
26
|
+
Missing Data:
|
|
26
27
|
Provider Metrics:
|
|
28
|
+
Data Trust Gate:
|
|
27
29
|
Market Summary:
|
|
28
|
-
Trend Bias:
|
|
29
|
-
Key Levels:
|
|
30
|
-
Technical Indicators:
|
|
31
|
-
Market Structure:
|
|
32
|
-
Signal Assessment:
|
|
33
|
-
Signal:
|
|
34
|
-
SL:
|
|
35
|
-
TP1:
|
|
36
|
-
TP2:
|
|
37
|
-
TP3:
|
|
38
|
-
Reason:
|
|
39
|
-
News/Fundamental Context:
|
|
40
|
-
Bullish Scenario:
|
|
41
|
-
Bearish Scenario:
|
|
42
|
-
Risk Notes:
|
|
43
|
-
Conclusion:
|
|
44
|
-
Disclaimer:
|
|
30
|
+
Trend Bias:
|
|
31
|
+
Key Levels:
|
|
32
|
+
Technical Indicators:
|
|
33
|
+
Market Structure:
|
|
34
|
+
Signal Assessment:
|
|
35
|
+
Signal:
|
|
36
|
+
SL:
|
|
37
|
+
TP1:
|
|
38
|
+
TP2:
|
|
39
|
+
TP3:
|
|
40
|
+
Reason:
|
|
41
|
+
News/Fundamental Context:
|
|
42
|
+
Bullish Scenario:
|
|
43
|
+
Bearish Scenario:
|
|
44
|
+
Risk Notes:
|
|
45
|
+
Conclusion:
|
|
46
|
+
Disclaimer:
|
|
45
47
|
"""
|
|
@@ -4,11 +4,11 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from fincli.app.analysis.ai_prompts import MARKET_ANALYSIS_PROMPT
|
|
6
6
|
from fincli.app.analysis.indicators import TechnicalSummary
|
|
7
|
-
from fincli.app.analysis.market_structure import MarketStructureSummary
|
|
8
|
-
from fincli.app.analysis.technical_debate import format_debate, run_technical_debate
|
|
9
|
-
from fincli.app.analysis.technical_signal import format_signal
|
|
10
|
-
from fincli.app.analysis.trading_methods import analyze_trading_methods, format_trading_methods_context
|
|
11
|
-
from fincli.app.providers.market.base import Candle
|
|
7
|
+
from fincli.app.analysis.market_structure import MarketStructureSummary
|
|
8
|
+
from fincli.app.analysis.technical_debate import format_debate, run_technical_debate
|
|
9
|
+
from fincli.app.analysis.technical_signal import format_signal
|
|
10
|
+
from fincli.app.analysis.trading_methods import analyze_trading_methods, format_trading_methods_context
|
|
11
|
+
from fincli.app.providers.market.base import Candle
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def market_analysis_prompt() -> str:
|
|
@@ -16,17 +16,17 @@ def market_analysis_prompt() -> str:
|
|
|
16
16
|
return MARKET_ANALYSIS_PROMPT.strip()
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
def build_market_analysis_prompt(
|
|
20
|
-
symbol: str,
|
|
21
|
-
timeframe: str,
|
|
22
|
-
candles: list[Candle],
|
|
23
|
-
technical: TechnicalSummary,
|
|
24
|
-
structure: MarketStructureSummary | None = None,
|
|
25
|
-
news_context: str = "No news/fundamental context provided.",
|
|
26
|
-
user_gameplay_context: str = "User Gameplay Profile: not configured.",
|
|
27
|
-
trading_methods_context: str = "",
|
|
28
|
-
grounding_context: str = "",
|
|
29
|
-
) -> str:
|
|
19
|
+
def build_market_analysis_prompt(
|
|
20
|
+
symbol: str,
|
|
21
|
+
timeframe: str,
|
|
22
|
+
candles: list[Candle],
|
|
23
|
+
technical: TechnicalSummary,
|
|
24
|
+
structure: MarketStructureSummary | None = None,
|
|
25
|
+
news_context: str = "No news/fundamental context provided.",
|
|
26
|
+
user_gameplay_context: str = "User Gameplay Profile: not configured.",
|
|
27
|
+
trading_methods_context: str = "",
|
|
28
|
+
grounding_context: str = "",
|
|
29
|
+
) -> str:
|
|
30
30
|
"""Build a structured AI prompt from market data and computed indicators."""
|
|
31
31
|
recent = candles[-10:]
|
|
32
32
|
ohlcv_lines = [
|
|
@@ -55,29 +55,29 @@ def build_market_analysis_prompt(
|
|
|
55
55
|
debate = run_technical_debate(technical, structure, candles) if structure is not None else None
|
|
56
56
|
return (
|
|
57
57
|
f"{market_analysis_prompt()}\n\n"
|
|
58
|
-
f"Instrument: {symbol}\n"
|
|
59
|
-
f"Timeframe: {timeframe}\n"
|
|
60
|
-
f"Data Quality: {len(candles)} candles available from provider.\n\n"
|
|
61
|
-
"AI Grounding Guard:\n"
|
|
62
|
-
f"{grounding_context or 'Data Quality: unknown; Provider Reliability: unknown; Missing Data: unknown; Provider Metrics: unavailable.'}\n"
|
|
63
|
-
"Instruction: If reliability is not ok, missing data exists, or provider metrics are weak, reduce confidence before conclusion.\n\n"
|
|
64
|
-
"Recent OHLCV:\n"
|
|
58
|
+
f"Instrument: {symbol}\n"
|
|
59
|
+
f"Timeframe: {timeframe}\n"
|
|
60
|
+
f"Data Quality: {len(candles)} candles available from provider.\n\n"
|
|
61
|
+
"AI Grounding Guard:\n"
|
|
62
|
+
f"{grounding_context or 'Data Quality: unknown; Provider Reliability: unknown; Missing Data: unknown; Provider Metrics: unavailable.'}\n"
|
|
63
|
+
"Instruction: If reliability is not ok, missing data exists, or provider metrics are weak, reduce confidence before conclusion.\n\n"
|
|
64
|
+
"Recent OHLCV:\n"
|
|
65
65
|
f"{chr(10).join(ohlcv_lines)}\n\n"
|
|
66
66
|
"Computed Indicators:\n"
|
|
67
67
|
f"{chr(10).join(indicator_lines)}\n\n"
|
|
68
68
|
"Market Structure:\n"
|
|
69
69
|
f"{_format_structure(structure)}\n\n"
|
|
70
|
-
"Signal Assessment:\n"
|
|
71
|
-
f"{format_signal(debate.judge_signal) if debate is not None else 'No signal assessment available.'}\n\n"
|
|
72
|
-
"Technical Debate:\n"
|
|
73
|
-
f"{format_debate(debate) if debate is not None else 'No technical debate available.'}\n\n"
|
|
74
|
-
"Trading Method Context:\n"
|
|
75
|
-
f"{trading_methods_context or format_trading_methods_context(analyze_trading_methods(candles))}\n\n"
|
|
76
|
-
"User Gameplay Context:\n"
|
|
77
|
-
f"{user_gameplay_context}\n\n"
|
|
78
|
-
"News/Fundamental Context:\n"
|
|
79
|
-
f"{news_context}\n"
|
|
80
|
-
)
|
|
70
|
+
"Signal Assessment:\n"
|
|
71
|
+
f"{format_signal(debate.judge_signal) if debate is not None else 'No signal assessment available.'}\n\n"
|
|
72
|
+
"Technical Debate:\n"
|
|
73
|
+
f"{format_debate(debate) if debate is not None else 'No technical debate available.'}\n\n"
|
|
74
|
+
"Trading Method Context:\n"
|
|
75
|
+
f"{trading_methods_context or format_trading_methods_context(analyze_trading_methods(candles))}\n\n"
|
|
76
|
+
"User Gameplay Context:\n"
|
|
77
|
+
f"{user_gameplay_context}\n\n"
|
|
78
|
+
"News/Fundamental Context:\n"
|
|
79
|
+
f"{news_context}\n"
|
|
80
|
+
)
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
def build_technical_ai_summary(symbol: str, timeframe: str, candles: list[Candle]) -> str:
|
|
@@ -6,11 +6,11 @@ import re
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
FINCLI_ASSISTANT_SYSTEM_PROMPT = """
|
|
9
|
-
You are FinCLI AI Assistance, the embedded assistant inside FinCLI v0.
|
|
9
|
+
You are FinCLI AI Assistance, the embedded assistant inside FinCLI v0.4.0.
|
|
10
10
|
|
|
11
11
|
Identity and scope:
|
|
12
|
-
- FinCLI is a terminal-first financial dashboard for market data, news/fundamentals, technical analysis, watchlists, portfolios, journals, and provider configuration.
|
|
13
|
-
- FinCLI commands start with slash commands inside the TUI, for example /help, /research AAPL --quick, /macro US, /profile, /technical AAPL, and /analyze XAUUSD.
|
|
12
|
+
- FinCLI is a terminal-first financial dashboard for market data, news/fundamentals, technical analysis, watchlists, portfolios, journals, and provider configuration.
|
|
13
|
+
- FinCLI commands start with slash commands inside the TUI, for example /help, /research AAPL --quick, /macro US, /profile, /technical AAPL, and /analyze XAUUSD.
|
|
14
14
|
- Your role is to help users understand markets, risk, portfolio context, trading journal patterns, FinCLI commands, and general non-coding questions.
|
|
15
15
|
- Free chat is allowed, but you must keep your identity as FinCLI's assistant and be clear when market data is unavailable or delayed.
|
|
16
16
|
|