quantlite 1.0.0__tar.gz → 1.0.2__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.
- quantlite-1.0.2/PKG-INFO +422 -0
- quantlite-1.0.2/README.md +341 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/pyproject.toml +1 -1
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/__init__.py +1 -1
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/data/base.py +8 -1
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/data/cache.py +5 -2
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/data/yahoo.py +6 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/pipeline.py +17 -4
- quantlite-1.0.2/src/quantlite.egg-info/PKG-INFO +422 -0
- quantlite-1.0.0/PKG-INFO +0 -1191
- quantlite-1.0.0/README.md +0 -1110
- quantlite-1.0.0/src/quantlite.egg-info/PKG-INFO +0 -1191
- {quantlite-1.0.0 → quantlite-1.0.2}/LICENSE +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/setup.cfg +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/antifragile/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/backtesting/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/backtesting/analysis.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/backtesting/engine.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/backtesting/legacy.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/backtesting/signals.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/contagion/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/core/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/core/types.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/crypto/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/crypto/exchange.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/crypto/onchain.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/crypto/stablecoin.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/data/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/data/crypto.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/data/fred.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/data/local.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/data/registry.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/data_generation.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/dependency/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/dependency/clustering.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/dependency/copulas.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/dependency/correlation.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/distributions/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/distributions/fat_tails.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/diversification/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/ergodicity/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/factors/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/factors/classical.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/factors/custom.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/factors/tail_risk.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/forensics/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/instruments/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/instruments/bond_pricing.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/instruments/exotic_options.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/instruments/option_pricing.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/metrics.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/monte_carlo.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/network/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/overfit/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/portfolio/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/portfolio/optimisation.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/portfolio/rebalancing.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/regime_integration/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/regime_integration/portfolio.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/regime_integration/reporting.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/regime_integration/risk.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/regimes/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/regimes/changepoint.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/regimes/conditional.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/regimes/hmm.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/report/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/report/html_renderer.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/report/pdf_renderer.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/report/sections.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/report/tearsheet.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/resample/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/risk/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/risk/evt.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/risk/metrics.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/scenarios/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/simulation/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/simulation/copula_mc.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/simulation/evt_simulation.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/simulation/regime_mc.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/visualisation.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/viz/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/viz/dependency.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/viz/plotly_backend/__init__.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/viz/plotly_backend/dependency.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/viz/plotly_backend/portfolio.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/viz/plotly_backend/regimes.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/viz/plotly_backend/risk.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/viz/plotly_backend/theme.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/viz/portfolio.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/viz/regimes.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/viz/risk.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite/viz/theme.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite.egg-info/SOURCES.txt +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite.egg-info/dependency_links.txt +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite.egg-info/requires.txt +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/src/quantlite.egg-info/top_level.txt +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_analysis.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_antifragile.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_backtesting.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_changepoint.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_clustering.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_conditional.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_contagion.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_copulas.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_correlation.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_crypto_exchange.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_crypto_onchain.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_crypto_stablecoin.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_data_connectors.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_data_generation.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_diversification.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_engine.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_ergodicity.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_evt.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_factors_classical.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_factors_custom.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_factors_tail_risk.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_fat_tails.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_forensics.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_hmm.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_instruments.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_metrics.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_monte_carlo.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_network.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_optimisation.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_overfit.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_pipeline.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_plotly_viz.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_rebalancing.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_regime_integration.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_report.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_resample.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_risk_metrics.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_scenarios.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_signals.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_sim_copula.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_sim_evt.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_sim_regime.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_visualisation.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_viz.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_viz_dependency.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_viz_portfolio.py +0 -0
- {quantlite-1.0.0 → quantlite-1.0.2}/tests/test_viz_regimes.py +0 -0
quantlite-1.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: quantlite
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: A fat-tail-native quantitative finance toolkit: EVT, risk metrics, and honest modelling for markets that bite.
|
|
5
|
+
Author-email: Prasant Sudhakaran <code@prasant.net>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2024 Prasant Sudhakaran
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in
|
|
18
|
+
all copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
26
|
+
THE SOFTWARE.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://github.com/prasants/QuantLite
|
|
30
|
+
Project-URL: Repository, https://github.com/prasants/QuantLite
|
|
31
|
+
Project-URL: Issues, https://github.com/prasants/QuantLite/issues
|
|
32
|
+
Keywords: quant,finance,risk,extreme value theory,monte carlo,fat tails,VaR,CVaR,options
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
35
|
+
Classifier: Intended Audience :: Science/Research
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
43
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
44
|
+
Classifier: Typing :: Typed
|
|
45
|
+
Requires-Python: >=3.9
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
License-File: LICENSE
|
|
48
|
+
Requires-Dist: numpy>=1.24
|
|
49
|
+
Requires-Dist: pandas>=2.0
|
|
50
|
+
Requires-Dist: scipy>=1.10
|
|
51
|
+
Requires-Dist: matplotlib>=3.7
|
|
52
|
+
Requires-Dist: mplfinance
|
|
53
|
+
Provides-Extra: yahoo
|
|
54
|
+
Requires-Dist: yfinance>=0.2; extra == "yahoo"
|
|
55
|
+
Provides-Extra: crypto
|
|
56
|
+
Requires-Dist: ccxt>=4.0; extra == "crypto"
|
|
57
|
+
Provides-Extra: fred
|
|
58
|
+
Requires-Dist: fredapi>=0.5; extra == "fred"
|
|
59
|
+
Provides-Extra: plotly
|
|
60
|
+
Requires-Dist: plotly>=5.0; extra == "plotly"
|
|
61
|
+
Requires-Dist: kaleido>=0.2; extra == "plotly"
|
|
62
|
+
Provides-Extra: report
|
|
63
|
+
Requires-Dist: plotly>=5.0; extra == "report"
|
|
64
|
+
Requires-Dist: kaleido>=0.2; extra == "report"
|
|
65
|
+
Provides-Extra: pdf
|
|
66
|
+
Requires-Dist: weasyprint>=60; extra == "pdf"
|
|
67
|
+
Provides-Extra: all
|
|
68
|
+
Requires-Dist: yfinance>=0.2; extra == "all"
|
|
69
|
+
Requires-Dist: ccxt>=4.0; extra == "all"
|
|
70
|
+
Requires-Dist: fredapi>=0.5; extra == "all"
|
|
71
|
+
Requires-Dist: plotly>=5.0; extra == "all"
|
|
72
|
+
Requires-Dist: kaleido>=0.2; extra == "all"
|
|
73
|
+
Requires-Dist: weasyprint>=60; extra == "all"
|
|
74
|
+
Requires-Dist: hmmlearn>=0.3; extra == "all"
|
|
75
|
+
Provides-Extra: dev
|
|
76
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
77
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
78
|
+
Requires-Dist: mypy>=1.8; extra == "dev"
|
|
79
|
+
Requires-Dist: pandas-stubs; extra == "dev"
|
|
80
|
+
Dynamic: license-file
|
|
81
|
+
|
|
82
|
+
# QuantLite
|
|
83
|
+
|
|
84
|
+
[](https://pypi.org/project/quantlite/)
|
|
85
|
+
[](https://www.python.org/downloads/)
|
|
86
|
+
[](LICENSE)
|
|
87
|
+
|
|
88
|
+
**A fat-tail-native quantitative finance toolkit for Python.**
|
|
89
|
+
|
|
90
|
+
Most quantitative finance libraries bolt fat tails on as an afterthought, if they bother at all. They fit Gaussians, compute VaR with normal assumptions, and hope the tails never bite. The tails always bite.
|
|
91
|
+
|
|
92
|
+
QuantLite starts from the other end. Every distribution is fat-tailed by default. Every risk metric accounts for extremes. Every backtest ships with an honesty check. The result is a toolkit that models markets as they actually behave, not as textbooks wish they would.
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
import quantlite as ql
|
|
96
|
+
|
|
97
|
+
data = ql.fetch(["AAPL", "BTC-USD", "GLD", "TLT"], period="5y")
|
|
98
|
+
regimes = ql.detect_regimes(data, n_regimes=3)
|
|
99
|
+
weights = ql.construct_portfolio(data, regime_aware=True, regimes=regimes)
|
|
100
|
+
result = ql.backtest(data, weights)
|
|
101
|
+
ql.tearsheet(result, regimes=regimes, save="portfolio.html")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Five lines. Fetch data, detect market regimes, build a regime-aware portfolio, backtest it, and generate a full tearsheet. That is the Dream API.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Why QuantLite
|
|
109
|
+
|
|
110
|
+
- **Fat tails are the default, not an afterthought.** Student-t, Lévy stable, GPD, and GEV distributions are first-class citizens. Gaussian is explicitly opt-in, never implicit.
|
|
111
|
+
- **Operationalises Taleb, Peters, and Lopez de Prado.** Ergodicity economics, antifragility scoring, the Fourth Quadrant map, Deflated Sharpe Ratios, and CSCV overfitting detection are built in, not bolted on.
|
|
112
|
+
- **Every backtest comes with an honesty check.** Bootstrap confidence intervals, multiple-testing corrections, and walk-forward validation ensure you know whether your Sharpe ratio is genuine or a statistical artefact.
|
|
113
|
+
- **Every chart follows Stephen Few's principles.** Maximum data-ink ratio, muted palette, direct labels, no chartjunk. Publication-ready by default.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Visual Showcase
|
|
118
|
+
|
|
119
|
+
### Fat Tails vs Gaussian
|
|
120
|
+
|
|
121
|
+
Where the Gaussian underestimates tail risk, EVT and Student-t fitting reveal the true shape of returns. The difference is where fortunes are lost.
|
|
122
|
+
|
|
123
|
+

|
|
124
|
+
|
|
125
|
+
### Regime Timeline
|
|
126
|
+
|
|
127
|
+
Hidden Markov Models automatically identify bull, bear, and crisis regimes. Your portfolio should know which world it is living in.
|
|
128
|
+
|
|
129
|
+

|
|
130
|
+
|
|
131
|
+
### Ergodicity Gap
|
|
132
|
+
|
|
133
|
+
The ensemble average says you are making money. The time average says you are going broke. The gap between them is the most important number in finance that nobody computes.
|
|
134
|
+
|
|
135
|
+

|
|
136
|
+
|
|
137
|
+
### Fourth Quadrant Map
|
|
138
|
+
|
|
139
|
+
Taleb's Fourth Quadrant: where payoffs are extreme and distributions are unknown. Know which quadrant your portfolio lives in before the market tells you.
|
|
140
|
+
|
|
141
|
+

|
|
142
|
+
|
|
143
|
+
### Deflated Sharpe Ratio
|
|
144
|
+
|
|
145
|
+
You tested 50 strategies and picked the best. The Deflated Sharpe Ratio tells you the probability that your winner is genuine, not a multiple-testing artefact.
|
|
146
|
+
|
|
147
|
+

|
|
148
|
+
|
|
149
|
+
### Scenario Stress Heatmap
|
|
150
|
+
|
|
151
|
+
How does your portfolio fare under the GFC, COVID, the taper tantrum, and a dozen other crises? One glance.
|
|
152
|
+
|
|
153
|
+

|
|
154
|
+
|
|
155
|
+
### Copula Contours
|
|
156
|
+
|
|
157
|
+
Five copula families fitted to the same data. Gaussian copula says tail dependence is zero. Student-t and Clayton disagree. They are right.
|
|
158
|
+
|
|
159
|
+

|
|
160
|
+
|
|
161
|
+
### Pipeline Equity Curve
|
|
162
|
+
|
|
163
|
+
The Dream API in action: regime-aware portfolio construction with automatic defensive tilting during crisis periods.
|
|
164
|
+
|
|
165
|
+

|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Installation
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
pip install quantlite
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Install only the data sources you need:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
pip install quantlite[yahoo] # Yahoo Finance
|
|
179
|
+
pip install quantlite[crypto] # Cryptocurrency exchanges (CCXT)
|
|
180
|
+
pip install quantlite[fred] # FRED macroeconomic data
|
|
181
|
+
pip install quantlite[plotly] # Interactive Plotly charts
|
|
182
|
+
pip install quantlite[all] # Everything
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Optional: `hmmlearn` for HMM regime detection.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Quickstart
|
|
190
|
+
|
|
191
|
+
### The Dream API
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
import quantlite as ql
|
|
195
|
+
|
|
196
|
+
# Fetch → detect regimes → build portfolio → backtest → report
|
|
197
|
+
data = ql.fetch(["AAPL", "BTC-USD", "GLD", "TLT"], period="5y")
|
|
198
|
+
regimes = ql.detect_regimes(data, n_regimes=3)
|
|
199
|
+
weights = ql.construct_portfolio(data, regime_aware=True, regimes=regimes)
|
|
200
|
+
result = ql.backtest(data, weights)
|
|
201
|
+
ql.tearsheet(result, regimes=regimes, save="portfolio.html")
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Fat-Tail Risk Analysis
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
from quantlite.distributions.fat_tails import student_t_process
|
|
208
|
+
from quantlite.risk.metrics import value_at_risk, cvar, return_moments
|
|
209
|
+
from quantlite.risk.evt import tail_risk_summary
|
|
210
|
+
|
|
211
|
+
# Generate fat-tailed returns (nu=4 gives realistic equity tail behaviour)
|
|
212
|
+
returns = student_t_process(nu=4.0, mu=0.0003, sigma=0.012, n_steps=2520, rng_seed=42)
|
|
213
|
+
|
|
214
|
+
# Cornish-Fisher VaR accounts for skewness and kurtosis
|
|
215
|
+
var_99 = value_at_risk(returns, alpha=0.01, method="cornish-fisher")
|
|
216
|
+
cvar_99 = cvar(returns, alpha=0.01)
|
|
217
|
+
moments = return_moments(returns)
|
|
218
|
+
|
|
219
|
+
print(f"VaR (99%): {var_99:.4f}")
|
|
220
|
+
print(f"CVaR (99%): {cvar_99:.4f}")
|
|
221
|
+
print(f"Excess kurtosis: {moments.kurtosis:.2f}")
|
|
222
|
+
|
|
223
|
+
# Full EVT tail analysis
|
|
224
|
+
summary = tail_risk_summary(returns)
|
|
225
|
+
print(f"Hill tail index: {summary.hill_estimate.tail_index:.2f}")
|
|
226
|
+
print(f"GPD shape (xi): {summary.gpd_fit.shape:.4f}")
|
|
227
|
+
print(f"1-in-100 loss: {summary.return_level_100:.4f}")
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Backtest Forensics
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
from quantlite.forensics import deflated_sharpe_ratio
|
|
234
|
+
from quantlite.resample import bootstrap_sharpe_distribution
|
|
235
|
+
|
|
236
|
+
# You tried 50 strategies and the best had Sharpe 1.8.
|
|
237
|
+
# Is it real?
|
|
238
|
+
dsr = deflated_sharpe_ratio(observed_sharpe=1.8, n_trials=50, n_obs=252)
|
|
239
|
+
print(f"Probability Sharpe is genuine: {dsr:.2%}")
|
|
240
|
+
|
|
241
|
+
# Bootstrap confidence interval on the Sharpe ratio
|
|
242
|
+
result = bootstrap_sharpe_distribution(returns, n_samples=2000, seed=42)
|
|
243
|
+
print(f"Sharpe: {result['point_estimate']:.2f}")
|
|
244
|
+
print(f"95% CI: [{result['ci_lower']:.2f}, {result['ci_upper']:.2f}]")
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Module Reference
|
|
250
|
+
|
|
251
|
+
### Core Risk
|
|
252
|
+
|
|
253
|
+
| Module | Description |
|
|
254
|
+
|--------|-------------|
|
|
255
|
+
| `quantlite.risk.metrics` | VaR (historical, parametric, Cornish-Fisher), CVaR, Sortino, Calmar, Omega, tail ratio, drawdowns |
|
|
256
|
+
| `quantlite.risk.evt` | GPD, GEV, Hill estimator, Peaks Over Threshold, return levels |
|
|
257
|
+
| `quantlite.distributions.fat_tails` | Student-t, Lévy stable, regime-switching GBM, Kou jump-diffusion |
|
|
258
|
+
| `quantlite.metrics` | Annualised return, volatility, Sharpe, max drawdown |
|
|
259
|
+
|
|
260
|
+
### Dependency and Portfolio
|
|
261
|
+
|
|
262
|
+
| Module | Description |
|
|
263
|
+
|--------|-------------|
|
|
264
|
+
| `quantlite.dependency.copulas` | Gaussian, Student-t, Clayton, Gumbel, Frank copulas with tail dependence |
|
|
265
|
+
| `quantlite.dependency.correlation` | Rolling, EWMA, stress, rank correlation |
|
|
266
|
+
| `quantlite.dependency.clustering` | Hierarchical Risk Parity |
|
|
267
|
+
| `quantlite.portfolio.optimisation` | Mean-variance, CVaR, risk parity, HRP, Black-Litterman, Kelly |
|
|
268
|
+
| `quantlite.portfolio.rebalancing` | Calendar, threshold, and tactical rebalancing |
|
|
269
|
+
|
|
270
|
+
### Backtesting
|
|
271
|
+
|
|
272
|
+
| Module | Description |
|
|
273
|
+
|--------|-------------|
|
|
274
|
+
| `quantlite.backtesting.engine` | Multi-asset backtesting with circuit breakers and slippage |
|
|
275
|
+
| `quantlite.backtesting.signals` | Momentum, mean reversion, trend following, volatility targeting |
|
|
276
|
+
| `quantlite.backtesting.analysis` | Performance summaries, monthly tables, regime attribution |
|
|
277
|
+
|
|
278
|
+
### Data
|
|
279
|
+
|
|
280
|
+
| Module | Description |
|
|
281
|
+
|--------|-------------|
|
|
282
|
+
| `quantlite.data` | Unified connectors: Yahoo Finance, CCXT, FRED, local files, plugin registry |
|
|
283
|
+
| `quantlite.data_generation` | GBM, correlated GBM, Ornstein-Uhlenbeck, Merton jump-diffusion |
|
|
284
|
+
|
|
285
|
+
### Taleb Stack
|
|
286
|
+
|
|
287
|
+
| Module | Description |
|
|
288
|
+
|--------|-------------|
|
|
289
|
+
| `quantlite.ergodicity` | Time-average vs ensemble-average growth, Kelly fraction, leverage effect |
|
|
290
|
+
| `quantlite.antifragile` | Antifragility score, convexity, Fourth Quadrant, barbell allocation, Lindy |
|
|
291
|
+
| `quantlite.scenarios` | Composable scenario engine, pre-built crisis library, shock propagation |
|
|
292
|
+
|
|
293
|
+
### Honest Backtesting
|
|
294
|
+
|
|
295
|
+
| Module | Description |
|
|
296
|
+
|--------|-------------|
|
|
297
|
+
| `quantlite.forensics` | Deflated Sharpe Ratio, Probabilistic Sharpe, haircut adjustments, minimum track record |
|
|
298
|
+
| `quantlite.overfit` | CSCV/PBO, TrialTracker, multiple testing correction, walk-forward validation |
|
|
299
|
+
| `quantlite.resample` | Block and stationary bootstrap, confidence intervals for Sharpe and drawdown |
|
|
300
|
+
|
|
301
|
+
### Systemic Risk
|
|
302
|
+
|
|
303
|
+
| Module | Description |
|
|
304
|
+
|--------|-------------|
|
|
305
|
+
| `quantlite.contagion` | CoVaR, Delta CoVaR, Marginal Expected Shortfall, Granger causality |
|
|
306
|
+
| `quantlite.network` | Correlation networks, eigenvector centrality, cascade simulation, community detection |
|
|
307
|
+
| `quantlite.diversification` | Effective Number of Bets, entropy diversification, tail diversification |
|
|
308
|
+
|
|
309
|
+
### Crypto
|
|
310
|
+
|
|
311
|
+
| Module | Description |
|
|
312
|
+
|--------|-------------|
|
|
313
|
+
| `quantlite.crypto.stablecoin` | Depeg probability, peg deviation tracking, reserve risk scoring |
|
|
314
|
+
| `quantlite.crypto.exchange` | Exchange concentration (HHI), wallet risk, proof of reserves, slippage |
|
|
315
|
+
| `quantlite.crypto.onchain` | Wallet exposure, TVL tracking, DeFi dependency graphs, smart contract risk |
|
|
316
|
+
|
|
317
|
+
### Simulation
|
|
318
|
+
|
|
319
|
+
| Module | Description |
|
|
320
|
+
|--------|-------------|
|
|
321
|
+
| `quantlite.simulation.evt_simulation` | EVT tail simulation, parametric tail simulation, scenario fan |
|
|
322
|
+
| `quantlite.simulation.copula_mc` | Gaussian copula MC, t-copula MC, stress correlation MC |
|
|
323
|
+
| `quantlite.simulation.regime_mc` | Regime-switching simulation, reverse stress test |
|
|
324
|
+
| `quantlite.monte_carlo` | Monte Carlo simulation harness |
|
|
325
|
+
|
|
326
|
+
### Factor Models
|
|
327
|
+
|
|
328
|
+
| Module | Description |
|
|
329
|
+
|--------|-------------|
|
|
330
|
+
| `quantlite.factors.classical` | Fama-French three/five-factor, Carhart four-factor, factor attribution |
|
|
331
|
+
| `quantlite.factors.custom` | Custom factor construction, significance testing, decay analysis |
|
|
332
|
+
| `quantlite.factors.tail_risk` | CVaR decomposition, regime factor exposure, crowding score |
|
|
333
|
+
|
|
334
|
+
### Regime Integration and Pipeline
|
|
335
|
+
|
|
336
|
+
| Module | Description |
|
|
337
|
+
|--------|-------------|
|
|
338
|
+
| `quantlite.regimes.hmm` | Hidden Markov Model regime detection |
|
|
339
|
+
| `quantlite.regimes.changepoint` | CUSUM and Bayesian changepoint detection |
|
|
340
|
+
| `quantlite.regimes.conditional` | Regime-conditional risk metrics and VaR |
|
|
341
|
+
| `quantlite.regime_integration` | Defensive tilting, filtered backtesting, regime tearsheets |
|
|
342
|
+
| `quantlite.pipeline` | Dream API: `fetch`, `detect_regimes`, `construct_portfolio`, `backtest`, `tearsheet` |
|
|
343
|
+
|
|
344
|
+
### Other
|
|
345
|
+
|
|
346
|
+
| Module | Description |
|
|
347
|
+
|--------|-------------|
|
|
348
|
+
| `quantlite.instruments` | Black-Scholes, bonds, barrier and Asian options |
|
|
349
|
+
| `quantlite.viz` | Stephen Few-themed charts: risk dashboards, copula contours, regime timelines |
|
|
350
|
+
| `quantlite.report` | HTML/PDF tearsheet generation |
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## Design Philosophy
|
|
355
|
+
|
|
356
|
+
1. **Fat tails are the default.** Gaussian assumptions are explicitly opt-in, never implicit.
|
|
357
|
+
2. **Explicit return types.** Every function documents its return type precisely: `float`, `dict` with named keys, or a frozen dataclass with clear attributes.
|
|
358
|
+
3. **Composable modules.** Risk metrics feed into portfolio optimisation which feeds into backtesting. Each layer works independently.
|
|
359
|
+
4. **Honest modelling.** If a method has known limitations (e.g., Gaussian copula has zero tail dependence), the docstring says so.
|
|
360
|
+
5. **Reproducible.** Every stochastic function accepts `rng_seed` for deterministic output.
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## Documentation
|
|
365
|
+
|
|
366
|
+
Full documentation lives in the [`docs/`](docs/) directory:
|
|
367
|
+
|
|
368
|
+
| Document | Topic |
|
|
369
|
+
|----------|-------|
|
|
370
|
+
| [risk.md](docs/risk.md) | Risk metrics and EVT |
|
|
371
|
+
| [copulas.md](docs/copulas.md) | Copula dependency structures |
|
|
372
|
+
| [regimes.md](docs/regimes.md) | Regime detection |
|
|
373
|
+
| [portfolio.md](docs/portfolio.md) | Portfolio optimisation and rebalancing |
|
|
374
|
+
| [data.md](docs/data.md) | Data connectors |
|
|
375
|
+
| [visualisation.md](docs/visualisation.md) | Stephen Few-themed charts |
|
|
376
|
+
| [interactive_viz.md](docs/interactive_viz.md) | Plotly interactive charts |
|
|
377
|
+
| [ergodicity.md](docs/ergodicity.md) | Ergodicity economics |
|
|
378
|
+
| [antifragility.md](docs/antifragility.md) | Antifragility measurement |
|
|
379
|
+
| [scenarios.md](docs/scenarios.md) | Scenario stress testing |
|
|
380
|
+
| [forensics.md](docs/forensics.md) | Deflated Sharpe and strategy forensics |
|
|
381
|
+
| [overfitting.md](docs/overfitting.md) | Overfitting detection |
|
|
382
|
+
| [resampling.md](docs/resampling.md) | Bootstrap resampling |
|
|
383
|
+
| [contagion.md](docs/contagion.md) | Systemic risk and contagion |
|
|
384
|
+
| [network.md](docs/network.md) | Financial network analysis |
|
|
385
|
+
| [diversification.md](docs/diversification.md) | Diversification diagnostics |
|
|
386
|
+
| [factors_classical.md](docs/factors_classical.md) | Classical factor models |
|
|
387
|
+
| [factors_custom.md](docs/factors_custom.md) | Custom factor tools |
|
|
388
|
+
| [factors_tail_risk.md](docs/factors_tail_risk.md) | Tail risk factor analysis |
|
|
389
|
+
| [simulation_evt.md](docs/simulation_evt.md) | EVT simulation |
|
|
390
|
+
| [simulation_copula.md](docs/simulation_copula.md) | Copula Monte Carlo |
|
|
391
|
+
| [simulation_regime.md](docs/simulation_regime.md) | Regime-switching simulation |
|
|
392
|
+
| [regime_integration.md](docs/regime_integration.md) | Regime-aware pipelines |
|
|
393
|
+
| [pipeline.md](docs/pipeline.md) | Dream API reference |
|
|
394
|
+
| [reports.md](docs/reports.md) | Tearsheet generation |
|
|
395
|
+
| [stablecoin_risk.md](docs/stablecoin_risk.md) | Stablecoin risk |
|
|
396
|
+
| [exchange_risk.md](docs/exchange_risk.md) | Exchange risk |
|
|
397
|
+
| [onchain_risk.md](docs/onchain_risk.md) | On-chain risk |
|
|
398
|
+
| [architecture.md](docs/architecture.md) | Library architecture |
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## Contributing
|
|
403
|
+
|
|
404
|
+
Contributions are welcome. Please ensure:
|
|
405
|
+
|
|
406
|
+
1. All new functions have type hints and docstrings
|
|
407
|
+
2. Tests pass: `pytest`
|
|
408
|
+
3. Code is formatted: `ruff check` and `ruff format`
|
|
409
|
+
4. British spellings in all documentation
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
## License
|
|
414
|
+
|
|
415
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
|
416
|
+
|
|
417
|
+
## Links
|
|
418
|
+
|
|
419
|
+
- [PyPI](https://pypi.org/project/quantlite/)
|
|
420
|
+
- [GitHub](https://github.com/prasants/QuantLite)
|
|
421
|
+
- [Issue Tracker](https://github.com/prasants/QuantLite/issues)
|
|
422
|
+
- [Changelog](CHANGELOG.md)
|