quantstats-pro 0.4.1__tar.gz → 0.4.3__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 (48) hide show
  1. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/CHANGELOG.md +34 -10
  2. quantstats_pro-0.4.3/PKG-INFO +397 -0
  3. quantstats_pro-0.4.3/README.md +345 -0
  4. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/pyproject.toml +1 -1
  5. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/__init__.py +1 -1
  6. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/_montecarlo.py +5 -5
  7. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/_plotting/core.py +7 -7
  8. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/_plotting/wrappers.py +7 -7
  9. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/__init__.py +2 -2
  10. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/base.py +2 -2
  11. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/models/gbm.py +1 -1
  12. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/models/jump_diffusion.py +1 -1
  13. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/plotting.py +1 -1
  14. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/registry.py +2 -2
  15. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/report_montecarlo.html +3 -3
  16. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/reports.py +6 -6
  17. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/stats.py +8 -8
  18. quantstats_pro-0.4.3/quantstats/version.py +1 -0
  19. quantstats_pro-0.4.1/PKG-INFO +0 -509
  20. quantstats_pro-0.4.1/README.md +0 -457
  21. quantstats_pro-0.4.1/quantstats/version.py +0 -1
  22. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/.gitignore +0 -0
  23. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/LICENSE.txt +0 -0
  24. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/_compat.py +0 -0
  25. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/_numpy_compat.py +0 -0
  26. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/_plotting/__init__.py +0 -0
  27. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/_reporting/__init__.py +0 -0
  28. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/_reporting/engine.py +0 -0
  29. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/_reporting/sections.py +0 -0
  30. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/alphadecay/__init__.py +0 -0
  31. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/alphadecay/core.py +0 -0
  32. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/alphadecay/plotting.py +0 -0
  33. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/analytics.py +0 -0
  34. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/core.py +0 -0
  35. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/models/__init__.py +0 -0
  36. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/models/bayesian.py +0 -0
  37. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/models/block_bootstrap.py +0 -0
  38. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/models/bootstrap.py +0 -0
  39. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/models/garch.py +0 -0
  40. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/models/heston.py +0 -0
  41. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/models/shuffle.py +0 -0
  42. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/montecarlo/models/trimmed.py +0 -0
  43. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/plots.py +0 -0
  44. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/py.typed +0 -0
  45. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/report.html +0 -0
  46. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/report_alpha_decay.html +0 -0
  47. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/report_simple.html +0 -0
  48. {quantstats_pro-0.4.1 → quantstats_pro-0.4.3}/quantstats/utils.py +0 -0
@@ -1,15 +1,39 @@
1
1
  Changelog
2
2
  ===========
3
3
 
4
+ 0.4.3
5
+ -----
6
+
7
+ **README / Docs**
8
+
9
+ - Restored shields.io badges (PyPI, Python, CI, License) at the top of README.
10
+ - Restored tearsheet screenshots for `html_simple`, `html_montecarlo`, `html_alpha_decay`, and classic `html` using PyPI-compatible absolute image URLs.
11
+ - Fixed interactive classic sample link to render via HTMLPreview instead of raw HTML source on GitHub.
12
+ - Converted relative doc links (`CHANGELOG`, `CONTRIBUTING`, `LICENSE`, `docs/*.md`) to absolute GitHub URLs so they work on PyPI.
13
+
14
+ 0.4.2
15
+ -----
16
+
17
+ **README / Docs**
18
+
19
+ - README landing refresh: tearsheet screenshots (`html_simple`, `html_montecarlo`, `html_alpha_decay`, classic), restructured funnel, audience positioning, and updated interactive sample (`docs/tearsheet.html`).
20
+ - PyPI project description aligned with README positioning.
21
+
22
+ **Montecarlo / Reports**
23
+
24
+ - Standardised user-facing naming to **Montecarlo** (one word) in HTML tearsheets, docs, and plot titles.
25
+
4
26
  0.4.1
5
27
  -----
6
28
 
7
- **Monte Carlo / Reports**
29
+ **Montecarlo / Reports**
30
+
31
+ - Standardised user-facing naming to **Montecarlo** (one word) in HTML tearsheets, docs, and plot titles.
8
32
 
9
33
  - Redesigned `reports.html_montecarlo()` for institutional, informational use:
10
34
  - Removed PASS/CAUTION/FAIL verdict and tolerance thresholds (`max_acceptable_dd`,
11
35
  `bust_tolerance`); replaced with neutral **Risk Summary** KPI cards (median
12
- across Monte Carlo models) and a **Stress Tests** section with the conservative
36
+ across Montecarlo models) and a **Stress Tests** section with the conservative
13
37
  envelope and attribution table.
14
38
  - Risk Summary KPI cards use a 3-column grid with risk/upside colour accents and
15
39
  per-metric hints.
@@ -40,7 +64,7 @@ Changelog
40
64
  - Added `docs/alphadecay.md`.
41
65
  - `MANIFEST.in` now includes all HTML report templates.
42
66
 
43
- **Monte Carlo engine**
67
+ **Montecarlo engine**
44
68
 
45
69
  - Fixed Heston double variance-drag bug (simulated drift now matches sample mean).
46
70
  - Fixed GARCH drift inflation (simulations anchored to sample mean, not MLE `mu`).
@@ -71,11 +95,11 @@ Changelog
71
95
  `alphadecay.analyze()` run in milliseconds on multi-year daily series.
72
96
  - Redesigned `reports.html_montecarlo()` tearsheet with actionable, conservative
73
97
  metrics and clearer structure:
74
- - **Strategy Assessment** — conservative envelope across Monte Carlo models
98
+ - **Strategy Assessment** — conservative envelope across Montecarlo models
75
99
  (worst-case CAGR p5, MaxDD p95 sizing figure, P(loss), CVaR 5%, P(bust))
76
100
  with automatic PASS / CAUTION / FAIL verdict and configurable thresholds
77
101
  (`max_acceptable_dd`, `bust_tolerance`).
78
- - **Monte Carlo Models** — comparison table with risk-quantile columns
102
+ - **Montecarlo Models** — comparison table with risk-quantile columns
79
103
  highlighted; redundant mean/terminal columns removed.
80
104
  - **Stress Tests** — trimmed bootstrap models separated from neutral
81
105
  simulations; drift `"zero"` / `"rf"` flagged as stress scenarios in the header.
@@ -83,7 +107,7 @@ Changelog
83
107
  ranges; per-model fan charts and terminal histograms moved to a collapsible
84
108
  appendix.
85
109
  - Reproducibility footer (sims, seed, horizon, drift, models).
86
- - Default embedded figure format for the Monte Carlo tearsheet is now `svg`.
110
+ - Default embedded figure format for the Montecarlo tearsheet is now `svg`.
87
111
 
88
112
  **Alpha Decay**
89
113
 
@@ -92,7 +116,7 @@ Changelog
92
116
  - `alphadecay.analyze()` returns a structured `DecayResult` with per-metric,
93
117
  per-window observations, health score, and SOTA diagnostics.
94
118
 
95
- **Monte Carlo**
119
+ **Montecarlo**
96
120
 
97
121
  - Redesigned `analytics.summarize()` metrics: `cagr_p5/median/p95`, `maxdd_median/p95`,
98
122
  `terminal_median`, `prob_loss`, `cvar_5` (plus optional `bust_prob` / `goal_prob`).
@@ -117,13 +141,13 @@ Changelog
117
141
  x-axis tick labels, and the metrics-table group separators render as a
118
142
  subtle gray rule. Fixed a daily histogram artefact where calendar-day
119
143
  resample invented 0% returns on weekends/holidays, spiking the centre bin.
120
- - New `reports.html_montecarlo()` — a multi-model Monte Carlo tearsheet for a
144
+ - New `reports.html_montecarlo()` — a multi-model Montecarlo tearsheet for a
121
145
  single asset. Characterises the asset with several models and simulates
122
146
  forward paths, producing a cross-model comparison table plus per-model fan
123
147
  charts and terminal-return distributions.
124
148
  - The existing `reports.html()` is unchanged (full backwards compatibility).
125
149
 
126
- **Monte Carlo**
150
+ **Montecarlo**
127
151
 
128
152
  - New `quantstats.montecarlo` engine with a common `SimulationModel` interface
129
153
  (`calibrate` + `simulate`) and a model registry. Built-in models: GBM,
@@ -227,7 +251,7 @@ QuantStats Pro is an enhanced, actively maintained drop-in replacement:
227
251
  - Added terminal output parameters table for `reports.full()` and `reports.basic()`
228
252
 
229
253
  - Added comprehensive test suite (125 tests):
230
- - Tests for stats, reports, utils, plots, compat, extend_pandas, and Monte Carlo
254
+ - Tests for stats, reports, utils, plots, compat, extend_pandas, and Montecarlo
231
255
 
232
256
  0.0.78
233
257
  ------
@@ -0,0 +1,397 @@
1
+ Metadata-Version: 2.4
2
+ Name: quantstats-pro
3
+ Version: 0.4.3
4
+ Summary: Drop-in replacement for QuantStats — advanced risk engines, institutional HTML tearsheets, and actionable portfolio analytics for quants
5
+ Project-URL: Homepage, https://github.com/diegoalvarezmgl/quantstats-pro
6
+ Project-URL: Documentation, https://github.com/diegoalvarezmgl/quantstats-pro
7
+ Project-URL: Repository, https://github.com/diegoalvarezmgl/quantstats-pro
8
+ Project-URL: Changelog, https://github.com/diegoalvarezmgl/quantstats-pro/blob/main/CHANGELOG.md
9
+ Project-URL: Upstream, https://github.com/ranaroussi/quantstats
10
+ Author-email: Diego Alvarez <diegoalvarezmiguel@gmail.com>, Ran Aroussi <ran@aroussi.com>
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE.txt
13
+ Keywords: algo-trading,algorithmic-trading,algotrading,finance,plotting,portfolio,quant,quantitative-analysis,quantitative-trading,visualization
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Financial and Insurance Industry
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: License :: OSI Approved :: Apache Software License
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Topic :: Office/Business :: Financial
26
+ Classifier: Topic :: Office/Business :: Financial :: Investment
27
+ Classifier: Topic :: Scientific/Engineering
28
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
29
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
30
+ Classifier: Topic :: Software Development :: Libraries
31
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
32
+ Requires-Python: >=3.10
33
+ Requires-Dist: arch>=6.0
34
+ Requires-Dist: matplotlib>=3.7.0
35
+ Requires-Dist: numpy>=1.24.0
36
+ Requires-Dist: pandas>=1.5.0
37
+ Requires-Dist: python-dateutil>=2.8.0
38
+ Requires-Dist: scipy>=1.11.0
39
+ Requires-Dist: seaborn>=0.13.0
40
+ Requires-Dist: tabulate>=0.9.0
41
+ Requires-Dist: yfinance>=0.2.40
42
+ Provides-Extra: dev
43
+ Requires-Dist: ipython>=8.0.0; extra == 'dev'
44
+ Requires-Dist: pandas-stubs>=2.0.0; extra == 'dev'
45
+ Requires-Dist: pyright>=1.1.0; extra == 'dev'
46
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
47
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
48
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
49
+ Provides-Extra: plotly
50
+ Requires-Dist: plotly>=5.0.0; extra == 'plotly'
51
+ Description-Content-Type: text/markdown
52
+
53
+ [![PyPI version](https://img.shields.io/pypi/v/quantstats-pro.svg)](https://pypi.org/project/quantstats-pro/)
54
+ [![Python version](https://img.shields.io/badge/python-3.10+-blue.svg?style=flat)](https://pypi.org/project/quantstats-pro/)
55
+ [![CI](https://github.com/diegoalvarezmgl/quantstats-pro/actions/workflows/ci.yml/badge.svg)](https://github.com/diegoalvarezmgl/quantstats-pro/actions/workflows/ci.yml)
56
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/diegoalvarezmgl/quantstats-pro/blob/main/LICENSE.txt)
57
+
58
+ # QuantStats Pro: Advanced portfolio analytics for quants
59
+
60
+ **QuantStats Pro** is an actively maintained **drop-in replacement** for [QuantStats](https://github.com/ranaroussi/quantstats) — same `import quantstats as qs`, hardened metrics, and a product roadmap that goes well beyond the original scope.
61
+
62
+ Where original quantstats stops at classic performance stats and a single HTML tearsheet, Pro is built to become a **definitive quantitative analytics stack**: advanced risk engines, new metrics, institutional-grade reports, and outputs designed to drive **actionable decisions**, not just describe the past.
63
+
64
+ Built for systematic traders, portfolio managers, and quant researchers who need production-grade tearsheets from a returns series.
65
+
66
+ ```bash
67
+ pip install quantstats-pro # replaces: pip install quantstats
68
+ ```
69
+
70
+ ```python
71
+ import quantstats as qs # import unchanged
72
+ ```
73
+
74
+ > **Note:** QuantStats Pro **cannot coexist** with the original `quantstats`
75
+ > package in the same environment — both provide the `quantstats` import
76
+ > namespace. Uninstall `quantstats` before installing `quantstats-pro`
77
+ > (`pip uninstall quantstats`).
78
+
79
+ [Changelog »](https://github.com/diegoalvarezmgl/quantstats-pro/blob/main/CHANGELOG.md) · [Upstream »](https://github.com/ranaroussi/quantstats) · [Contributing »](https://github.com/diegoalvarezmgl/quantstats-pro/blob/main/CONTRIBUTING.md)
80
+
81
+ ### Why QuantStats Pro?
82
+
83
+ Same API surface, stronger foundation — bugfixes, reliability, and a growing analytics layer that upstream does not aim to provide.
84
+
85
+ **Headline additions (v0.3.0+):**
86
+
87
+
88
+ | Capability | What you get |
89
+ | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
90
+ | `html_simple` | Lean equity-curve tearsheet — fast read on performance vs benchmark |
91
+ | `html_montecarlo` | Multi-model forward risk report (GBM, GARCH, Heston, bootstraps, Bayesian, …) with bust/goal probabilities and cross-model consensus |
92
+ | `html_alpha_decay` | Rolling alpha-decay monitor — z-score traffic lights, CUSUM, time-underwater, per-metric distribution charts |
93
+ | `quantstats.montecarlo` | Programmatic multi-model simulation engine behind the Montecarlo tearsheet |
94
+ | `quantstats.alphadecay` | Short-horizon rolling diagnostics engine behind the Alpha Decay tearsheet |
95
+ | Classic `html` | Full tearsheet — metrics + all charts, visually redesigned (v0.2.0+) |
96
+
97
+
98
+ ### Package modules
99
+
100
+
101
+ | Module | Purpose |
102
+ | ----------------------- | -------------------------------------------------------------------------- |
103
+ | `quantstats.stats` | 50+ performance metrics (Sharpe, Sortino, drawdown, VaR, …) |
104
+ | `quantstats.plots` | Performance visualizations (returns, drawdown, heatmaps, rolling stats, …) |
105
+ | `quantstats.reports` | HTML tearsheets and metrics tables |
106
+ | `quantstats.montecarlo` | Multi-model forward simulation engine and analytics |
107
+ | `quantstats.alphadecay` | Short-horizon rolling risk analysis and decay detection |
108
+ | `quantstats.utils` | Data prep, `download_returns`, pandas helpers |
109
+
110
+
111
+ Legacy shuffle-based Montecarlo remains at `qs.stats.montecarlo()` for backward compatibility. The new engine lives under `quantstats.montecarlo` and powers `qs.reports.html_montecarlo()`.
112
+
113
+ ---
114
+
115
+ ## HTML Tearsheets
116
+
117
+ The main product surface in QuantStats Pro is its **reporting layer**: four HTML tearsheet types that turn a returns series into shareable, browser-ready analytics. All open in the browser by default, or save to disk with `output="path.html"`.
118
+
119
+
120
+ | Function | Use case |
121
+ | ---------------------------------- | ------------------------------------------------------------------------ |
122
+ | `qs.reports.html(...)` | Full classic tearsheet (metrics + all charts) |
123
+ | `qs.reports.html_simple(...)` | **Pro-only** — lean equity-curve tearsheet for quick strategy review |
124
+ | `qs.reports.html_montecarlo(...)` | **Pro-only** — multi-model forward risk analysis (1y horizon by default) |
125
+ | `qs.reports.html_alpha_decay(...)` | **Pro-only** — short-window alpha-decay health monitor (7/15/30d) |
126
+
127
+
128
+ ### Simple tearsheet — `html_simple`
129
+
130
+ Focused equity-curve view with core metrics and charts. Ideal when you need a clean performance read without the full classic layout.
131
+
132
+ ```python
133
+ qs.reports.html_simple(returns, benchmark="SPY", output="qqq_simple.html")
134
+ ```
135
+
136
+ ![Simple tearsheet — QQQ vs SPY](https://raw.githubusercontent.com/diegoalvarezmgl/quantstats-pro/main/docs/report_simple.webp)
137
+
138
+ ### Montecarlo tearsheet — `html_montecarlo`
139
+
140
+ Runs multiple stochastic models in parallel, surfaces bust/goal probabilities, cross-model consensus, and a stress envelope — forward-looking risk in one report.
141
+
142
+ ```python
143
+ qs.reports.html_montecarlo(
144
+ returns,
145
+ bust=-0.25, # P(Bust): drawdown threshold
146
+ goal=0.50, # P(Goal): terminal return target
147
+ sims=500,
148
+ seed=42,
149
+ output="qqq_montecarlo.html",
150
+ )
151
+ ```
152
+
153
+ ![Montecarlo tearsheet — QQQ](https://raw.githubusercontent.com/diegoalvarezmgl/quantstats-pro/main/docs/report_montecarlo.webp)
154
+
155
+ ### Alpha Decay tearsheet — `html_alpha_decay`
156
+
157
+ Rolling-window monitor for short-horizon drift: 10 metrics × 7/15/30-day windows, z-score traffic lights, CUSUM decay detection, and time-underwater analysis.
158
+
159
+ ```python
160
+ qs.reports.html_alpha_decay(
161
+ returns,
162
+ windows=(7, 15, 30),
163
+ output="qqq_alpha_decay.html",
164
+ )
165
+ ```
166
+
167
+ ![Alpha Decay tearsheet — QQQ](https://raw.githubusercontent.com/diegoalvarezmgl/quantstats-pro/main/docs/report_alpha_decay.webp)
168
+
169
+ ### Classic full tearsheet — `html`
170
+
171
+ The original QuantStats report — all metrics and charts, visually redesigned in v0.2.0+.
172
+
173
+ ```python
174
+ qs.reports.html(returns, benchmark="SPY", output="qqq_full.html")
175
+ ```
176
+
177
+ ![Classic HTML tearsheet — QQQ vs SPY](https://raw.githubusercontent.com/diegoalvarezmgl/quantstats-pro/main/docs/report.webp)
178
+
179
+ [View interactive classic sample](https://htmlpreview.github.io/?https://github.com/diegoalvarezmgl/quantstats-pro/blob/main/docs/tearsheet.html) · [Montecarlo docs](https://github.com/diegoalvarezmgl/quantstats-pro/blob/main/docs/montecarlo.md) · [Alpha Decay docs](https://github.com/diegoalvarezmgl/quantstats-pro/blob/main/docs/alphadecay.md)
180
+
181
+ ---
182
+
183
+ ## Quick Start
184
+
185
+ ```python
186
+ import quantstats as qs
187
+
188
+ qs.extend_pandas()
189
+ returns = qs.utils.download_returns("QQQ")
190
+
191
+ # Single metric
192
+ qs.stats.sharpe(returns)
193
+ returns.sharpe() # via extend_pandas()
194
+
195
+ # Snapshot plot
196
+ qs.plots.snapshot(returns, title="QQQ Performance", show=True)
197
+
198
+ # HTML tearsheet vs benchmark
199
+ qs.reports.html(returns, "SPY", output="qqq_report.html")
200
+ qs.reports.html_simple(returns, "SPY", output="qqq_simple.html")
201
+ qs.reports.html_montecarlo(returns, output="qqq_montecarlo.html")
202
+ qs.reports.html_alpha_decay(returns, output="qqq_alpha_decay.html")
203
+ ```
204
+
205
+ See [HTML Tearsheets](#html-tearsheets) above for screenshots and parameter details.
206
+
207
+ ### Crypto and 24/7 markets
208
+
209
+ For daily crypto data, pass `periods_per_year=365` to reports and stats that annualize:
210
+
211
+ ```python
212
+ returns = qs.utils.download_returns("BTC-USD")
213
+ qs.reports.html(returns, periods_per_year=365, output="btc_report.html")
214
+ qs.stats.sharpe(returns, periods=365)
215
+ ```
216
+
217
+ ---
218
+
219
+ ## Montecarlo Engine
220
+
221
+ `quantstats.montecarlo` characterises an asset with several stochastic models, simulates forward paths from each, and compares the distribution of outcomes (CAGR, max drawdown, bust/goal probabilities, CVaR).
222
+
223
+ ### Built-in models
224
+
225
+
226
+ | Model | Name | Category |
227
+ | -------------------------- | -------------------- | ---------- |
228
+ | GBM | `gbm` | Montecarlo |
229
+ | Shuffle (legacy) | `shuffle` | Montecarlo |
230
+ | Bootstrap | `bootstrap` | Montecarlo |
231
+ | Block Bootstrap | `block_bootstrap` | Montecarlo |
232
+ | Jump Diffusion (Merton) | `jump_diffusion` | Montecarlo |
233
+ | GARCH(1,1)-t | `garch` | Montecarlo |
234
+ | Heston (SV) | `heston` | Montecarlo |
235
+ | Bayesian (NIG) | `bayesian` | Montecarlo |
236
+ | Bayesian Bootstrap | `bayesian_bootstrap` | Montecarlo |
237
+ | Trimmed Bootstrap (top 1%) | `trimmed_1pct` | Stress |
238
+
239
+
240
+ ### Programmatic API
241
+
242
+ ```python
243
+ from quantstats.montecarlo import run_models, available_models
244
+ from quantstats.montecarlo import analytics as mca
245
+
246
+ print(available_models())
247
+ # ['bayesian', 'bayesian_bootstrap', 'block_bootstrap', 'bootstrap', ...]
248
+
249
+ results = run_models(
250
+ returns,
251
+ models=["gbm", "garch", "bootstrap"],
252
+ horizon=252, # 1 year (default: periods_per_year)
253
+ sims=1000,
254
+ bust=-0.25,
255
+ goal=0.50,
256
+ seed=42,
257
+ )
258
+
259
+ # Per-model summary row
260
+ gbm = results["gbm"]
261
+ print(gbm.summary) # cagr_p5, cagr_median, maxdd_p95, prob_loss, cvar_5, …
262
+ print(gbm.sim_returns.shape) # (horizon, sims)
263
+
264
+ # Cross-model consensus and stress envelope
265
+ median = mca.model_median_summary(results)
266
+ envelope = mca.conservative_envelope(results)
267
+ hist = mca.historical_summary(returns, horizon=252)
268
+ ```
269
+
270
+ ### Legacy shuffle Montecarlo
271
+
272
+ The original upstream API still works — random permutation of historical returns:
273
+
274
+ ```python
275
+ mc = qs.stats.montecarlo(returns, sims=1000, bust=-0.20, goal=0.50, seed=42)
276
+ print(f"Bust probability: {mc.bust_probability:.1%}")
277
+ print(f"Goal probability: {mc.goal_probability:.1%}")
278
+ mc.plot()
279
+ ```
280
+
281
+ [Full Montecarlo documentation »](https://github.com/diegoalvarezmgl/quantstats-pro/blob/main/docs/montecarlo.md)
282
+
283
+ ---
284
+
285
+ ## Alpha Decay Monitor
286
+
287
+ `quantstats.alphadecay` tracks whether a strategy's short-term risk profile is drifting from its historical norm. It computes **10 rolling metrics** over configurable windows (default 7/15/30 days):
288
+
289
+ CAGR · Volatility · Downside Vol · Max Drawdown · Mean Drawdown · Win Rate · VaR 95% · Expected Shortfall 95% · Payoff Ratio · Skew
290
+
291
+ Each metric-window cell gets a **traffic-light status** (Excellent / Good / Warning / Critical) based on z-scores computed on a per-metric analysis scale (log transforms for skewed metrics). The tearsheet also includes:
292
+
293
+ - **Health score** — count of Good/Excellent cells
294
+ - **CUSUM** return-decay detector
295
+ - **Time underwater** duration analysis
296
+ - Per-metric distribution charts with current observation vs historical mean
297
+
298
+ ### Programmatic API
299
+
300
+ ```python
301
+ from quantstats.alphadecay import analyze, available_metrics
302
+
303
+ print(available_metrics())
304
+ # ['cagr', 'volatility', 'downside_vol', 'max_drawdown', ...]
305
+
306
+ result = analyze(
307
+ returns,
308
+ windows=(7, 15, 30),
309
+ rf=0.0,
310
+ periods=252,
311
+ )
312
+
313
+ print(f"Health: {result.score}/{result.total} ({result.score_pct:.0f}%)")
314
+
315
+ for metric in result.metrics:
316
+ wr = metric.windows[30] # latest 30-day window
317
+ print(f"{metric.spec.label}: z={wr.z_score:+.2f} → {wr.status}")
318
+ ```
319
+
320
+ Generate the full HTML tearsheet with `qs.reports.html_alpha_decay(returns)`.
321
+
322
+ [Alpha Decay documentation »](https://github.com/diegoalvarezmgl/quantstats-pro/blob/main/docs/alphadecay.md)
323
+
324
+ ---
325
+
326
+ ## API reference
327
+
328
+ QuantStats Pro exposes **50+ stats**, **15+ plot types**, and **4 HTML report generators**. Explore the full API interactively:
329
+
330
+ ```python
331
+ [f for f in dir(qs.stats) if not f.startswith("_")]
332
+ [f for f in dir(qs.plots) if not f.startswith("_")]
333
+ help(qs.stats.sharpe)
334
+ ```
335
+
336
+ Notebook / console helpers:
337
+
338
+ ```python
339
+ qs.reports.metrics(returns, mode="full") # metrics table
340
+ qs.reports.plots(returns, mode="full") # all plots
341
+ qs.reports.basic(returns) # basic metrics + plots
342
+ qs.reports.full(returns) # full metrics + plots
343
+ ```
344
+
345
+ See [Montecarlo documentation](https://github.com/diegoalvarezmgl/quantstats-pro/blob/main/docs/montecarlo.md) and `help(qs.stats.<method>)` for parameter details.
346
+
347
+ ### Period-based vs trade-based metrics
348
+
349
+ QuantStats analyzes **return series** (daily, weekly, monthly returns), not discrete trade data. This means:
350
+
351
+ - **Win Rate** = percentage of periods with positive returns
352
+ - **Consecutive Wins/Losses** = consecutive positive/negative return periods
353
+ - **Payoff Ratio** = average winning period return / average losing period return
354
+ - **Profit Factor** = sum of positive returns / sum of negative returns
355
+
356
+ These metrics are **valid and useful** for systematic strategies, return-series analysis, and period-by-period comparison. For discretionary traders with multi-day trades, period-based stats may differ from trade-level statistics — consistent with how Sharpe, Sortino, and drawdown metrics operate on return periods.
357
+
358
+ ---
359
+
360
+ ## Installation
361
+
362
+ ```bash
363
+ pip install quantstats-pro --upgrade
364
+ ```
365
+
366
+ ## Requirements
367
+
368
+ - [Python](https://www.python.org) >= 3.10
369
+ - [pandas](https://github.com/pydata/pandas) >= 1.5.0
370
+ - [numpy](http://www.numpy.org) >= 1.24.0
371
+ - [scipy](https://www.scipy.org) >= 1.11.0
372
+ - [matplotlib](https://matplotlib.org) >= 3.7.0
373
+ - [seaborn](https://seaborn.pydata.org) >= 0.13.0
374
+ - [tabulate](https://bitbucket.org/astanin/python-tabulate) >= 0.9.0
375
+ - [yfinance](https://github.com/ranaroussi/yfinance) >= 0.2.40
376
+ - [arch](https://github.com/bashtage/arch) >= 6.0 (GARCH calibration for Montecarlo)
377
+ - [plotly](https://plot.ly/) >= 5.0.0 (optional, for using `plots.to_plotly()`)
378
+
379
+ ## Questions?
380
+
381
+ If you find a bug, please [open an issue](https://github.com/diegoalvarezmgl/quantstats-pro/issues).
382
+
383
+ Contributions welcome — check [open issues](https://github.com/diegoalvarezmgl/quantstats-pro/issues) or upstream [QuantStats issues](https://github.com/ranaroussi/quantstats/issues) for bugs we're tracking.
384
+
385
+ ## Known limitations
386
+
387
+ When saving the monthly returns heatmap via `savefig={...}`, the figure may still be displayed in addition to being written to disk. Pass `show=False` explicitly where supported.
388
+
389
+ ## Legal Stuff
390
+
391
+ **QuantStats Pro** is a fork of **QuantStats** by Ran Aroussi, distributed under the **Apache Software License**. See [LICENSE.txt](https://github.com/diegoalvarezmgl/quantstats-pro/blob/main/LICENSE.txt) for details.
392
+
393
+ ## Credits
394
+
395
+ **QuantStats Pro** — maintained by [Diego Alvarez](https://github.com/diegoalvarezmgl)
396
+
397
+ **QuantStats** (original) — [Ran Aroussi](https://github.com/ranaroussi)