financial-dynamics 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. financial_dynamics-1.0.0/.gitignore +17 -0
  2. financial_dynamics-1.0.0/LICENSE +21 -0
  3. financial_dynamics-1.0.0/PKG-INFO +501 -0
  4. financial_dynamics-1.0.0/README.md +451 -0
  5. financial_dynamics-1.0.0/config/default.yaml +36 -0
  6. financial_dynamics-1.0.0/pyproject.toml +89 -0
  7. financial_dynamics-1.0.0/src/financial_dynamics/__init__.py +29 -0
  8. financial_dynamics-1.0.0/src/financial_dynamics/_utils.py +16 -0
  9. financial_dynamics-1.0.0/src/financial_dynamics/backtesting/__init__.py +15 -0
  10. financial_dynamics-1.0.0/src/financial_dynamics/backtesting/evaluator.py +97 -0
  11. financial_dynamics-1.0.0/src/financial_dynamics/backtesting/metrics.py +99 -0
  12. financial_dynamics-1.0.0/src/financial_dynamics/benchmarks/__init__.py +21 -0
  13. financial_dynamics-1.0.0/src/financial_dynamics/benchmarks/baselines.py +129 -0
  14. financial_dynamics-1.0.0/src/financial_dynamics/benchmarks/runner.py +89 -0
  15. financial_dynamics-1.0.0/src/financial_dynamics/calibration/__init__.py +20 -0
  16. financial_dynamics-1.0.0/src/financial_dynamics/calibration/calibrator.py +76 -0
  17. financial_dynamics-1.0.0/src/financial_dynamics/calibration/centroid_fitter.py +76 -0
  18. financial_dynamics-1.0.0/src/financial_dynamics/calibration/hyperparameter_tuner.py +116 -0
  19. financial_dynamics-1.0.0/src/financial_dynamics/config.py +113 -0
  20. financial_dynamics-1.0.0/src/financial_dynamics/data_loader.py +100 -0
  21. financial_dynamics-1.0.0/src/financial_dynamics/forecasting/__init__.py +99 -0
  22. financial_dynamics-1.0.0/src/financial_dynamics/persistence/__init__.py +5 -0
  23. financial_dynamics-1.0.0/src/financial_dynamics/persistence/state_io.py +180 -0
  24. financial_dynamics-1.0.0/src/financial_dynamics/phase0_features/__init__.py +5 -0
  25. financial_dynamics-1.0.0/src/financial_dynamics/phase0_features/feature_engine.py +171 -0
  26. financial_dynamics-1.0.0/src/financial_dynamics/phase0_features/indicators.py +125 -0
  27. financial_dynamics-1.0.0/src/financial_dynamics/phase0_features/normalizer.py +77 -0
  28. financial_dynamics-1.0.0/src/financial_dynamics/phase1_regimes/__init__.py +6 -0
  29. financial_dynamics-1.0.0/src/financial_dynamics/phase1_regimes/centroid_engine.py +56 -0
  30. financial_dynamics-1.0.0/src/financial_dynamics/phase1_regimes/regime_definitions.py +32 -0
  31. financial_dynamics-1.0.0/src/financial_dynamics/phase2_transitions/__init__.py +17 -0
  32. financial_dynamics-1.0.0/src/financial_dynamics/phase2_transitions/bayesian_update.py +61 -0
  33. financial_dynamics-1.0.0/src/financial_dynamics/phase2_transitions/transition_engine.py +77 -0
  34. financial_dynamics-1.0.0/src/financial_dynamics/phase3_stabilization/__init__.py +5 -0
  35. financial_dynamics-1.0.0/src/financial_dynamics/phase3_stabilization/hysteresis.py +32 -0
  36. financial_dynamics-1.0.0/src/financial_dynamics/phase3_stabilization/majority_vote.py +35 -0
  37. financial_dynamics-1.0.0/src/financial_dynamics/phase3_stabilization/persistence.py +52 -0
  38. financial_dynamics-1.0.0/src/financial_dynamics/phase3_stabilization/stabilizer.py +46 -0
  39. financial_dynamics-1.0.0/src/financial_dynamics/phase4_risk/__init__.py +5 -0
  40. financial_dynamics-1.0.0/src/financial_dynamics/phase4_risk/_utils.py +5 -0
  41. financial_dynamics-1.0.0/src/financial_dynamics/phase4_risk/chop_suppression.py +56 -0
  42. financial_dynamics-1.0.0/src/financial_dynamics/phase4_risk/overextension.py +55 -0
  43. financial_dynamics-1.0.0/src/financial_dynamics/phase4_risk/risk_overlay.py +103 -0
  44. financial_dynamics-1.0.0/src/financial_dynamics/pipeline.py +183 -0
  45. financial_dynamics-1.0.0/src/financial_dynamics/signals/__init__.py +13 -0
  46. financial_dynamics-1.0.0/src/financial_dynamics/signals/detector.py +145 -0
  47. financial_dynamics-1.0.0/src/financial_dynamics/types.py +97 -0
  48. financial_dynamics-1.0.0/src/financial_dynamics/visualization/__init__.py +6 -0
  49. financial_dynamics-1.0.0/src/financial_dynamics/visualization/_utils.py +27 -0
  50. financial_dynamics-1.0.0/src/financial_dynamics/visualization/dashboard.py +173 -0
  51. financial_dynamics-1.0.0/src/financial_dynamics/visualization/phase_space.py +74 -0
  52. financial_dynamics-1.0.0/src/financial_dynamics/visualization/phase_space_3d.py +891 -0
  53. financial_dynamics-1.0.0/src/financial_dynamics/visualization/trajectory.py +73 -0
  54. financial_dynamics-1.0.0/src/financial_dynamics/visualization/vector_field.py +86 -0
@@ -0,0 +1,17 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ .pytest_cache/
5
+ .coverage
6
+ *.egg-info/
7
+ dist/
8
+ build/
9
+ .eggs/
10
+ *.csv
11
+ *.png
12
+ !assets/micap_logo.*
13
+ .env
14
+ config/calibrated.yaml
15
+ .venv/
16
+ venv/
17
+ dist/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Jeff Milam & Micap.AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,501 @@
1
+ Metadata-Version: 2.4
2
+ Name: financial-dynamics
3
+ Version: 1.0.0
4
+ Summary: Bayesian system-dynamics pipeline for market regime classification
5
+ Project-URL: Homepage, https://micap.ai
6
+ Project-URL: Repository, https://github.com/jmiaie/financial-dynamics-model
7
+ Project-URL: Documentation, https://github.com/jmiaie/financial-dynamics-model#readme
8
+ Project-URL: Issues, https://github.com/jmiaie/financial-dynamics-model/issues
9
+ Project-URL: Demo, https://financial-dynamics-model.streamlit.app
10
+ Author: Jeff Milam
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: bayesian,finance,markov-chains,quantitative-trading,regime-detection,risk-management,system-dynamics
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Financial and Insurance Industry
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Office/Business :: Financial :: Investment
25
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.10
28
+ Requires-Dist: matplotlib>=3.7
29
+ Requires-Dist: numpy>=1.24
30
+ Requires-Dist: pandas>=2.0
31
+ Requires-Dist: pyyaml>=6.0
32
+ Requires-Dist: scikit-learn>=1.3
33
+ Requires-Dist: scipy>=1.11
34
+ Provides-Extra: all
35
+ Requires-Dist: plotly>=5.17; extra == 'all'
36
+ Requires-Dist: pytest-cov>=4.0; extra == 'all'
37
+ Requires-Dist: pytest>=7.0; extra == 'all'
38
+ Requires-Dist: streamlit>=1.28; extra == 'all'
39
+ Requires-Dist: yfinance>=0.2.31; extra == 'all'
40
+ Provides-Extra: dashboard
41
+ Requires-Dist: plotly>=5.17; extra == 'dashboard'
42
+ Requires-Dist: streamlit>=1.28; extra == 'dashboard'
43
+ Requires-Dist: yfinance>=0.2.31; extra == 'dashboard'
44
+ Provides-Extra: data
45
+ Requires-Dist: yfinance>=0.2.31; extra == 'data'
46
+ Provides-Extra: dev
47
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
48
+ Requires-Dist: pytest>=7.0; extra == 'dev'
49
+ Description-Content-Type: text/markdown
50
+
51
+ <div align="center">
52
+
53
+ # Financial Dynamics Model
54
+
55
+ ### Bayesian System-Dynamics Pipeline for Market Regime Classification
56
+
57
+ [![PyPI version](https://img.shields.io/pypi/v/financial-dynamics?color=0d7377&style=flat-square)](https://pypi.org/project/financial-dynamics/)
58
+ [![Python](https://img.shields.io/pypi/pyversions/financial-dynamics?style=flat-square)](https://pypi.org/project/financial-dynamics/)
59
+ [![License: MIT](https://img.shields.io/badge/license-MIT-0d7377.svg?style=flat-square)](LICENSE)
60
+ [![Tests](https://img.shields.io/badge/tests-229%20passed-0d7377?style=flat-square)](#testing)
61
+ [![Downloads](https://img.shields.io/pypi/dm/financial-dynamics?color=0d7377&style=flat-square)](https://pypi.org/project/financial-dynamics/)
62
+ [![Streamlit](https://img.shields.io/badge/demo-live-0d7377?style=flat-square&logo=streamlit)](https://financial-dynamics-model.streamlit.app)
63
+
64
+ **Transforms raw OHLCV data into explainable regime probabilities for quantitative trading and risk management.**
65
+
66
+ [Live Demo](https://financial-dynamics-model.streamlit.app) &nbsp;|&nbsp; [Documentation](#documentation) &nbsp;|&nbsp; [Install](#installation) &nbsp;|&nbsp; [API Reference](#python-api)
67
+
68
+ **[English](README.md)** &nbsp;|&nbsp; [中文](docs/README_zh.md) &nbsp;|&nbsp; [日本語](docs/README_ja.md) &nbsp;|&nbsp; [한국어](docs/README_ko.md) &nbsp;|&nbsp; [Español](docs/README_es.md) &nbsp;|&nbsp; [Português](docs/README_pt.md)
69
+
70
+ ---
71
+
72
+ <table>
73
+ <tr>
74
+ <td align="center"><strong>80.6%</strong><br><sub>Accuracy</sub></td>
75
+ <td align="center"><strong>229</strong><br><sub>Unit Tests</sub></td>
76
+ <td align="center"><strong>5</strong><br><sub>Pipeline Phases</sub></td>
77
+ <td align="center"><strong>4</strong><br><sub>Market Regimes</sub></td>
78
+ <td align="center"><strong>12</strong><br><sub>3D Viz Layers</sub></td>
79
+ </tr>
80
+ </table>
81
+
82
+ </div>
83
+
84
+ ---
85
+
86
+ ## Why Financial Dynamics?
87
+
88
+ Most regime detection tools are either black-box neural networks or simplistic threshold rules. Financial Dynamics sits in the sweet spot: **fully transparent Bayesian inference** with **production-grade engineering**.
89
+
90
+ Every probability is traceable. Every transition is explainable. Every signal has a clear mathematical origin.
91
+
92
+ ```
93
+ ┌─────────────────────────────────┐
94
+ │ Financial Dynamics Model │
95
+ └────────────────┬────────────────┘
96
+
97
+ ┌───────────────────────────┼───────────────────────────┐
98
+ │ │ │
99
+ ┌────────▼────────┐ ┌────────▼────────┐ ┌────────▼────────┐
100
+ │ Python API │ │ Streamlit App │ │ CLI Tools │
101
+ │ │ │ │ │ │
102
+ │ pipeline.run() │ │ Interactive 3D │ │ run_pipeline │
103
+ │ pipeline.step() │ │ Live Charts │ │ run_backtest │
104
+ │ pipeline.fore- │ │ Signal Feed │ │ run_calibrate │
105
+ │ cast() │ │ Forecasts │ │ run_benchmark │
106
+ └─────────────────┘ └──────────────────┘ └─────────────────┘
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Installation
112
+
113
+ ```bash
114
+ # Core library
115
+ pip install financial-dynamics
116
+
117
+ # With live data (yfinance)
118
+ pip install financial-dynamics[data]
119
+
120
+ # Full dashboard (Streamlit + Plotly + yfinance)
121
+ pip install financial-dynamics[dashboard]
122
+
123
+ # Everything including dev tools
124
+ pip install financial-dynamics[all]
125
+ ```
126
+
127
+ Or from source:
128
+
129
+ ```bash
130
+ git clone https://github.com/jmiaie/financial-dynamics-model.git
131
+ cd financial-dynamics-model
132
+ pip install -e ".[all]"
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Quick Start
138
+
139
+ ### Interactive Dashboard
140
+
141
+ ```bash
142
+ streamlit run app.py
143
+ ```
144
+
145
+ Load any ticker (SPY, QQQ, AAPL, BTC-USD) and watch regime classification in real-time. Charts update instantly, forecasts auto-compute, signals fire as regimes shift.
146
+
147
+ > **Try it now:** [financial-dynamics-model.streamlit.app](https://financial-dynamics-model.streamlit.app)
148
+
149
+ ### Python API
150
+
151
+ ```python
152
+ from financial_dynamics import FinancialDynamicsPipeline
153
+ from financial_dynamics.data_loader import fetch_ohlcv
154
+
155
+ # Fetch data & run pipeline
156
+ df = fetch_ohlcv("SPY", period="1y", interval="1d")
157
+ pipeline = FinancialDynamicsPipeline()
158
+ results = pipeline.run(df)
159
+
160
+ # Current regime + confidence
161
+ current = results["risk_adjusted_regime"].iloc[-1]
162
+ confidence = results["post_prob_CALM_TREND"].iloc[-1]
163
+ print(f"Regime: {current} ({confidence:.1%} confidence)")
164
+
165
+ # Forecast next 10 bars
166
+ forecast = pipeline.forecast(horizon=10)
167
+ print(f"Expected duration: {forecast.expected_duration:.1f} bars")
168
+ print(f"Path: {' → '.join(r.name for r in forecast.most_likely_path[:5])}")
169
+ ```
170
+
171
+ ### CLI
172
+
173
+ ```bash
174
+ python scripts/run_pipeline.py --symbol SPY --period 1y --interval 1d
175
+ python scripts/run_backtest.py --data historical.csv --labels regimes.csv --rolling
176
+ python scripts/run_calibration.py --output calibrated.yaml
177
+ python scripts/run_benchmark.py --config config/default.yaml
178
+ ```
179
+
180
+ ---
181
+
182
+ ## Pipeline Architecture
183
+
184
+ <div align="center">
185
+
186
+ ```
187
+ ╔══════════════════════════════════════════════════════════════╗
188
+ ║ RAW OHLCV DATA ║
189
+ ╚══════════════════════════╦═══════════════════════════════════╝
190
+
191
+ ┌──────────────────────────────────────────────────────────────┐
192
+ │ PHASE 0 │ Feature Engineering │
193
+ │ │ 5D normalized: vol · trend · drawdown · corr · shock │
194
+ └──────────────────────────┬───────────────────────────────────┘
195
+
196
+ ┌──────────────────────────────────────────────────────────────┐
197
+ │ PHASE 1 │ Centroid Classification │
198
+ │ │ P(Sᵢ|Xₜ) = exp(−‖Xₜ − Cᵢ‖ / τ) / Z │
199
+ └──────────────────────────┬───────────────────────────────────┘
200
+
201
+ ┌──────────────────────────────────────────────────────────────┐
202
+ │ PHASE 2 │ Bayesian Markov Transitions │
203
+ │ │ P_post = P_centroid × T[prev, :] / Z │
204
+ │ │ Dirichlet prior · online learning │
205
+ └──────────────────────────┬───────────────────────────────────┘
206
+
207
+ ┌──────────────────────────────────────────────────────────────┐
208
+ │ PHASE 3 │ Temporal Stabilization │
209
+ │ │ Hysteresis · persistence · majority vote │
210
+ └──────────────────────────┬───────────────────────────────────┘
211
+
212
+ ┌──────────────────────────────────────────────────────────────┐
213
+ │ PHASE 4 │ Risk Conditioning │
214
+ │ │ Risk-Off confirmation · overextension · chop loop │
215
+ └──────────────────────────┬───────────────────────────────────┘
216
+
217
+ ╔══════════════════════════════════════════════════════════════╗
218
+ ║ REGIME + CONFIDENCE + FORECAST ║
219
+ ╚══════════════════════════════════════════════════════════════╝
220
+ ```
221
+
222
+ </div>
223
+
224
+ ---
225
+
226
+ ## Market Regimes
227
+
228
+ <table>
229
+ <tr>
230
+ <th width="180">Regime</th>
231
+ <th>Characteristics</th>
232
+ <th width="60">Feature Signature</th>
233
+ <th width="140">Trading Signal</th>
234
+ </tr>
235
+ <tr>
236
+ <td>
237
+ <strong>Calm Trend</strong><br>
238
+ <sub>Low risk, directional</sub>
239
+ </td>
240
+ <td>Low volatility, strong uptrend, minimal drawdown, stable correlations</td>
241
+ <td><code>[0.1, 0.8, 0.05, 0.1, 0.1]</code></td>
242
+ <td>Long accumulation</td>
243
+ </tr>
244
+ <tr>
245
+ <td>
246
+ <strong>Volatile Trend</strong><br>
247
+ <sub>High energy, directional</sub>
248
+ </td>
249
+ <td>High volatility, directional momentum, recoveries from dips</td>
250
+ <td><code>[0.8, 0.7, 0.3, 0.5, 0.6]</code></td>
251
+ <td>Trend-following</td>
252
+ </tr>
253
+ <tr>
254
+ <td>
255
+ <strong>Chop</strong><br>
256
+ <sub>Low energy, directionless</sub>
257
+ </td>
258
+ <td>Low volatility, weak trend, mean-reverting, range-bound</td>
259
+ <td><code>[0.4, 0.2, 0.15, 0.3, 0.3]</code></td>
260
+ <td>Range trading</td>
261
+ </tr>
262
+ <tr>
263
+ <td>
264
+ <strong>Risk-Off</strong><br>
265
+ <sub>High risk, defensive</sub>
266
+ </td>
267
+ <td>High volatility, deep drawdowns, shock clusters, stress contagion</td>
268
+ <td><code>[0.9, 0.3, 0.8, 0.9, 0.9]</code></td>
269
+ <td>Hedging / defensive</td>
270
+ </tr>
271
+ </table>
272
+
273
+ ---
274
+
275
+ ## 3D Phase-Space Attractor Field
276
+
277
+ The interactive 3D visualization projects the 5D feature space onto 3 principal components, revealing the geometric structure of market regimes:
278
+
279
+ <table>
280
+ <tr>
281
+ <td width="50%">
282
+
283
+ **Structural Layers**
284
+ - Regime basins of attraction (convex hulls)
285
+ - 1.5&sigma; covariance ellipsoids
286
+ - Markov transition flow arrows
287
+ - PCA loading vectors (feature axes)
288
+ - Centroid markers with labels
289
+
290
+ </td>
291
+ <td width="50%">
292
+
293
+ **Dynamic Layers**
294
+ - Velocity-encoded trajectory (teal &rarr; red)
295
+ - Regime shift markers at transition points
296
+ - Stationary-distribution halos
297
+ - Volatility danger-zone isosurface
298
+ - Exponential-decay comet trail
299
+
300
+ </td>
301
+ </tr>
302
+ </table>
303
+
304
+ > **10 interactive toggles** — enable/disable each layer independently. Drag to rotate, scroll to zoom, hover for details.
305
+
306
+ ---
307
+
308
+ ## Configuration
309
+
310
+ All parameters in [`config/default.yaml`](config/default.yaml):
311
+
312
+ ```yaml
313
+ features:
314
+ volatility_span: 20 # EWMA lookback
315
+ trend_window: 14 # Linear regression window
316
+ drawdown_window: 60 # Rolling peak window
317
+ normalization_method: zscore # zscore | minmax
318
+
319
+ regimes:
320
+ temperature: 1.0 # Softmax temperature (lower = sharper)
321
+
322
+ transitions:
323
+ prior_strength: 10.0 # Dirichlet prior concentration
324
+ learning_rate: 0.05 # Bayesian update speed
325
+
326
+ stabilization:
327
+ hysteresis_threshold: 0.15 # Min probability gap to flip
328
+ min_persistence_bars: 5 # Bars before confirming change
329
+ majority_vote_window: 10 # Rolling vote window
330
+
331
+ risk:
332
+ riskoff_confirmation_count: 3 # Stressors needed for Risk-Off
333
+ overextension_decay: 0.02 # Regime fatigue rate
334
+ ```
335
+
336
+ ---
337
+
338
+ ## Testing
339
+
340
+ ```bash
341
+ pytest tests/ -v # All 229 tests
342
+ pytest tests/test_phase0_features.py -v # Feature engineering
343
+ pytest tests/test_pipeline_integration.py # End-to-end
344
+ pytest tests/test_stress.py # Numerical stability
345
+ pytest tests/test_visualization.py # 3D rendering
346
+ ```
347
+
348
+ <details>
349
+ <summary><strong>Test Coverage by Module</strong></summary>
350
+
351
+ | Module | Tests | Coverage |
352
+ |--------|------:|---------|
353
+ | Phase 0 — Features | 35 | Core pipeline |
354
+ | Phase 1 — Regimes | 20 | Core pipeline |
355
+ | Phase 2 — Transitions | 25 | Core pipeline |
356
+ | Phase 3 — Stabilization | 30 | Core pipeline |
357
+ | Phase 4 — Risk | 22 | Core pipeline |
358
+ | Pipeline Integration | 18 | End-to-end |
359
+ | Visualization | 16 | 2D + 3D |
360
+ | Signals | 12 | Detection |
361
+ | Stress / Numerical | 20 | Edge cases |
362
+ | Calibration + Others | 31 | Tooling |
363
+
364
+ </details>
365
+
366
+ ---
367
+
368
+ ## Project Structure
369
+
370
+ ```
371
+ src/financial_dynamics/
372
+ ├── pipeline.py # Orchestrator (batch + streaming)
373
+ ├── types.py # Regime, FeatureVector, BarState
374
+ ├── config.py # Typed config + YAML loader
375
+ ├── phase0_features/ # EWMA vol, trend, drawdown, corr, shock
376
+ ├── phase1_regimes/ # Softmax centroid classification
377
+ ├── phase2_transitions/ # Dirichlet-Bayesian Markov learning
378
+ ├── phase3_stabilization/ # Hysteresis, persistence, majority vote
379
+ ├── phase4_risk/ # Risk-Off confirmation, overextension
380
+ ├── visualization/ # 2D/3D phase-space, dashboard, trajectory
381
+ ├── calibration/ # Centroid fitting, hyperparameter tuning
382
+ ├── backtesting/ # Rolling-window evaluation
383
+ ├── benchmarks/ # Baseline classifiers
384
+ ├── forecasting/ # k-step regime forecasts
385
+ ├── signals/ # Regime change / risk detection
386
+ ├── data_loader.py # yfinance integration
387
+ └── persistence/ # State serialization
388
+
389
+ app.py # Streamlit interactive dashboard
390
+ config/default.yaml # All tunable parameters
391
+ ```
392
+
393
+ ---
394
+
395
+ ## Use Cases
396
+
397
+ <table>
398
+ <tr>
399
+ <td width="50%">
400
+
401
+ **Hedge Funds & Prop Desks**
402
+ - Explainable regime filter for systematic strategies
403
+ - Position sizing by regime (scale vega/delta)
404
+ - Early warning for Risk-Off confirmation
405
+
406
+ **Quant Researchers**
407
+ - Modular, testable regime detection
408
+ - Learned transition matrices
409
+ - Multi-asset backtesting
410
+
411
+ </td>
412
+ <td width="50%">
413
+
414
+ **Risk Management**
415
+ - Transparent regime forecasts for stress tests
416
+ - Multi-asset contagion signals
417
+ - Real-time pre-shift warnings
418
+
419
+ **Fintech & Robo-Advisors**
420
+ - Client-friendly regime labels
421
+ - Explainable allocation shifts
422
+ - Automated defensive rebalancing
423
+
424
+ </td>
425
+ </tr>
426
+ </table>
427
+
428
+ ---
429
+
430
+ ## Deployment
431
+
432
+ <details>
433
+ <summary><strong>Streamlit Cloud (2 minutes)</strong></summary>
434
+
435
+ ```bash
436
+ git push origin main
437
+ ```
438
+ Then: [share.streamlit.io](https://share.streamlit.io) &rarr; Connect repo &rarr; Deploy
439
+
440
+ </details>
441
+
442
+ <details>
443
+ <summary><strong>Docker</strong></summary>
444
+
445
+ ```bash
446
+ docker build -t financial-dynamics .
447
+ docker run -d -p 8501:8501 --restart unless-stopped financial-dynamics
448
+ ```
449
+
450
+ </details>
451
+
452
+ <details>
453
+ <summary><strong>Custom Domain (fdm.micapai.com)</strong></summary>
454
+
455
+ See [DEPLOYMENT_GUIDE.md](DEPLOYMENT_GUIDE.md) for Porkbun DNS + Streamlit Cloud setup.
456
+
457
+ </details>
458
+
459
+ ---
460
+
461
+ ## Documentation
462
+
463
+ | Resource | Description |
464
+ |----------|-------------|
465
+ | [DEPLOYMENT_GUIDE.md](DEPLOYMENT_GUIDE.md) | Streamlit Cloud, Docker, custom domain |
466
+ | [STREAMLIT_QUICK_START.md](STREAMLIT_QUICK_START.md) | Run the dashboard locally |
467
+ | [config/default.yaml](config/default.yaml) | All tunable parameters |
468
+ | `scripts/run_pipeline.py --help` | CLI reference |
469
+
470
+ ---
471
+
472
+ ## Contributing
473
+
474
+ Contributions welcome. Please open an issue first to discuss major changes.
475
+
476
+ ```bash
477
+ git clone https://github.com/jmiaie/financial-dynamics-model.git
478
+ cd financial-dynamics-model
479
+ pip install -e ".[all]"
480
+ pytest tests/ -v
481
+ ```
482
+
483
+ ---
484
+
485
+ ## License
486
+
487
+ [MIT](LICENSE) — Jeff Milam & [Micap.AI](https://micap.ai)
488
+
489
+ ---
490
+
491
+ <div align="center">
492
+
493
+ **Built by [Micap.AI](https://micap.ai)**
494
+
495
+ <sub>Python · NumPy · Pandas · SciPy · scikit-learn · Streamlit · Plotly · yfinance · Bayesian inference · Markov chains</sub>
496
+
497
+ <br>
498
+
499
+ [![GitHub stars](https://img.shields.io/github/stars/jmiaie/financial-dynamics-model?style=social)](https://github.com/jmiaie/financial-dynamics-model)
500
+
501
+ </div>