quantlite 1.11.0__tar.gz → 1.13.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 (268) hide show
  1. {quantlite-1.11.0/src/quantlite.egg-info → quantlite-1.13.0}/PKG-INFO +30 -19
  2. {quantlite-1.11.0 → quantlite-1.13.0}/README.md +27 -12
  3. {quantlite-1.11.0 → quantlite-1.13.0}/pyproject.toml +13 -4
  4. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/__init__.py +17 -2
  5. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/_doctor.py +21 -4
  6. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/accessor.py +14 -0
  7. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/alerts/__init__.py +36 -8
  8. quantlite-1.13.0/src/quantlite/antifragile/__init__.py +468 -0
  9. quantlite-1.13.0/src/quantlite/backtesting/analysis.py +375 -0
  10. quantlite-1.13.0/src/quantlite/backtesting/engine.py +566 -0
  11. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/backtesting/legacy.py +16 -1
  12. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/backtesting/signals.py +26 -21
  13. quantlite-1.13.0/src/quantlite/benchmark/compare.py +594 -0
  14. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/benchmark/runner.py +61 -19
  15. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/benchmark/speed.py +53 -15
  16. quantlite-1.13.0/src/quantlite/benchmark/tail_events.py +691 -0
  17. quantlite-1.13.0/src/quantlite/contagion/__init__.py +444 -0
  18. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/core/types.py +76 -4
  19. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/crypto/exchange.py +45 -8
  20. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/crypto/funding.py +16 -3
  21. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/crypto/onchain.py +86 -33
  22. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/crypto/stablecoin.py +82 -21
  23. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/data/__init__.py +23 -6
  24. quantlite-1.13.0/src/quantlite/data/base.py +307 -0
  25. quantlite-1.13.0/src/quantlite/data/cache.py +368 -0
  26. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/data/crypto.py +55 -3
  27. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/data/fred.py +22 -3
  28. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/data/funding.py +4 -1
  29. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/data/local.py +42 -8
  30. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/data/registry.py +26 -2
  31. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/data/stream.py +37 -7
  32. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/data_generation.py +23 -2
  33. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/datasets/__init__.py +50 -17
  34. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/dependency/clustering.py +44 -6
  35. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/dependency/copulas.py +155 -70
  36. quantlite-1.13.0/src/quantlite/dependency/correlation.py +296 -0
  37. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/distributions/fat_tails.py +51 -11
  38. quantlite-1.13.0/src/quantlite/diversification/__init__.py +284 -0
  39. quantlite-1.13.0/src/quantlite/ergodicity/__init__.py +293 -0
  40. quantlite-1.13.0/src/quantlite/ergodicity/ruin.py +369 -0
  41. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/explain/attribution.py +46 -27
  42. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/explain/audit.py +25 -12
  43. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/explain/narratives.py +30 -5
  44. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/explain/whatif.py +105 -54
  45. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/factors/classical.py +6 -4
  46. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/factors/custom.py +11 -0
  47. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/factors/tail_risk.py +66 -44
  48. quantlite-1.13.0/src/quantlite/forensics/__init__.py +604 -0
  49. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/honesty.py +73 -9
  50. quantlite-1.13.0/src/quantlite/instruments/bond_pricing.py +169 -0
  51. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/instruments/exotic_options.py +54 -8
  52. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/instruments/option_pricing.py +33 -6
  53. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/metrics.py +28 -9
  54. quantlite-1.13.0/src/quantlite/monte_carlo.py +140 -0
  55. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/network/__init__.py +75 -20
  56. quantlite-1.13.0/src/quantlite/overfit/__init__.py +530 -0
  57. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/pipeline.py +172 -61
  58. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/portfolio/dynamic_kelly.py +43 -18
  59. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/portfolio/ensemble.py +58 -8
  60. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/portfolio/optimisation.py +210 -33
  61. quantlite-1.13.0/src/quantlite/portfolio/rebalancing.py +373 -0
  62. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/portfolio/regime_bl.py +17 -3
  63. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/portfolio/walkforward.py +44 -18
  64. quantlite-1.13.0/src/quantlite/reference.py +309 -0
  65. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/regime_integration/portfolio.py +128 -57
  66. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/regime_integration/reporting.py +42 -13
  67. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/regime_integration/risk.py +92 -34
  68. quantlite-1.13.0/src/quantlite/regimes/changepoint.py +421 -0
  69. quantlite-1.13.0/src/quantlite/regimes/conditional.py +261 -0
  70. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/regimes/hmm.py +81 -19
  71. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/regimes/online.py +60 -18
  72. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/report/__init__.py +1 -2
  73. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/report/html_renderer.py +11 -2
  74. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/report/pdf_renderer.py +26 -9
  75. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/report/sections.py +184 -37
  76. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/report/tearsheet.py +28 -7
  77. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/resample/__init__.py +112 -25
  78. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/risk/evt.py +44 -6
  79. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/risk/gaussian.py +6 -3
  80. quantlite-1.13.0/src/quantlite/risk/metrics.py +402 -0
  81. quantlite-1.13.0/src/quantlite/scenarios/__init__.py +359 -0
  82. quantlite-1.13.0/src/quantlite/scenarios/historical.py +862 -0
  83. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/score/__init__.py +6 -3
  84. quantlite-1.13.0/src/quantlite/score/_methodology.py +55 -0
  85. quantlite-1.13.0/src/quantlite/score/_qls1.py +80 -0
  86. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/score/artifact.py +7 -5
  87. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/score/engine.py +186 -39
  88. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/score/integrity.py +92 -12
  89. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/score/monitoring.py +207 -36
  90. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/score/provenance.py +5 -3
  91. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/simulation/copula_mc.py +47 -12
  92. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/simulation/evt_simulation.py +129 -56
  93. quantlite-1.13.0/src/quantlite/simulation/regime_mc.py +489 -0
  94. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/visualisation.py +47 -9
  95. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/viz/alerts.py +15 -4
  96. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/viz/allocation.py +85 -13
  97. quantlite-1.13.0/src/quantlite/viz/benchmark.py +927 -0
  98. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/viz/dependency.py +37 -31
  99. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/viz/explain.py +60 -7
  100. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/viz/gaussian.py +6 -1
  101. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/viz/online_regimes.py +5 -5
  102. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/viz/portfolio.py +183 -25
  103. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/viz/regimes.py +78 -18
  104. quantlite-1.13.0/src/quantlite/viz/risk.py +625 -0
  105. quantlite-1.13.0/src/quantlite/viz/scenarios.py +127 -0
  106. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/viz/streaming.py +10 -6
  107. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/viz/theme.py +40 -3
  108. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/viz/volatility.py +83 -4
  109. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/volatility/__init__.py +3 -0
  110. quantlite-1.13.0/src/quantlite/volatility/dcc.py +471 -0
  111. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/volatility/garch.py +158 -13
  112. {quantlite-1.11.0 → quantlite-1.13.0/src/quantlite.egg-info}/PKG-INFO +30 -19
  113. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite.egg-info/SOURCES.txt +31 -7
  114. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite.egg-info/requires.txt +2 -6
  115. quantlite-1.13.0/tests/test_analysis.py +174 -0
  116. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_antifragile.py +25 -2
  117. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_backtesting.py +2 -1
  118. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_benchmarks.py +40 -21
  119. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_changepoint.py +3 -1
  120. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_correlation.py +63 -0
  121. quantlite-1.13.0/tests/test_data_connectors.py +598 -0
  122. quantlite-1.13.0/tests/test_definition_ledger.py +131 -0
  123. quantlite-1.13.0/tests/test_definitions_backtesting_overfit.py +2029 -0
  124. quantlite-1.13.0/tests/test_definitions_charts_a.py +1833 -0
  125. quantlite-1.13.0/tests/test_definitions_charts_b.py +2092 -0
  126. quantlite-1.13.0/tests/test_definitions_crypto.py +1058 -0
  127. quantlite-1.13.0/tests/test_definitions_data_core_score.py +2918 -0
  128. quantlite-1.13.0/tests/test_definitions_factors_explain_benchmark.py +2329 -0
  129. quantlite-1.13.0/tests/test_definitions_known_six.py +623 -0
  130. quantlite-1.13.0/tests/test_definitions_portfolio.py +1699 -0
  131. quantlite-1.13.0/tests/test_definitions_regimes.py +1383 -0
  132. quantlite-1.13.0/tests/test_definitions_review_fixes.py +383 -0
  133. quantlite-1.13.0/tests/test_definitions_risk_and_processes.py +1652 -0
  134. quantlite-1.13.0/tests/test_definitions_simulation_scenarios.py +1672 -0
  135. quantlite-1.13.0/tests/test_definitions_volatility_dependence.py +2617 -0
  136. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_doctor.py +1 -1
  137. quantlite-1.13.0/tests/test_drawdown_from_the_start.py +58 -0
  138. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_ergodicity.py +16 -1
  139. quantlite-1.13.0/tests/test_ergodicity_ruin.py +211 -0
  140. quantlite-1.13.0/tests/test_forensics.py +247 -0
  141. quantlite-1.13.0/tests/test_front_door.py +27 -0
  142. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_honesty.py +26 -0
  143. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_monitoring.py +20 -2
  144. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_overfit.py +85 -3
  145. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_pipeline.py +48 -0
  146. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_rebalancing.py +2 -1
  147. quantlite-1.13.0/tests/test_reference.py +195 -0
  148. quantlite-1.13.0/tests/test_regime_integration_risk_first_passage.py +67 -0
  149. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_report.py +26 -6
  150. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_scenarios.py +6 -1
  151. quantlite-1.13.0/tests/test_scenarios_historical.py +520 -0
  152. quantlite-1.13.0/tests/test_viz_ported_from_plotly.py +262 -0
  153. quantlite-1.13.0/tests/test_viz_untested_modules.py +396 -0
  154. quantlite-1.13.0/tests/test_volatility_arch_crosscheck.py +106 -0
  155. quantlite-1.13.0/tests/test_volatility_dcc.py +341 -0
  156. quantlite-1.11.0/src/quantlite/antifragile/__init__.py +0 -347
  157. quantlite-1.11.0/src/quantlite/backtesting/analysis.py +0 -226
  158. quantlite-1.11.0/src/quantlite/backtesting/engine.py +0 -401
  159. quantlite-1.11.0/src/quantlite/benchmark/compare.py +0 -483
  160. quantlite-1.11.0/src/quantlite/benchmark/tail_events.py +0 -314
  161. quantlite-1.11.0/src/quantlite/contagion/__init__.py +0 -295
  162. quantlite-1.11.0/src/quantlite/data/base.py +0 -106
  163. quantlite-1.11.0/src/quantlite/data/cache.py +0 -155
  164. quantlite-1.11.0/src/quantlite/dependency/correlation.py +0 -192
  165. quantlite-1.11.0/src/quantlite/diversification/__init__.py +0 -222
  166. quantlite-1.11.0/src/quantlite/ergodicity/__init__.py +0 -220
  167. quantlite-1.11.0/src/quantlite/forensics/__init__.py +0 -380
  168. quantlite-1.11.0/src/quantlite/instruments/bond_pricing.py +0 -108
  169. quantlite-1.11.0/src/quantlite/monte_carlo.py +0 -88
  170. quantlite-1.11.0/src/quantlite/overfit/__init__.py +0 -403
  171. quantlite-1.11.0/src/quantlite/portfolio/rebalancing.py +0 -246
  172. quantlite-1.11.0/src/quantlite/regimes/changepoint.py +0 -248
  173. quantlite-1.11.0/src/quantlite/regimes/conditional.py +0 -170
  174. quantlite-1.11.0/src/quantlite/risk/metrics.py +0 -310
  175. quantlite-1.11.0/src/quantlite/scenarios/__init__.py +0 -261
  176. quantlite-1.11.0/src/quantlite/simulation/regime_mc.py +0 -328
  177. quantlite-1.11.0/src/quantlite/viz/benchmark.py +0 -615
  178. quantlite-1.11.0/src/quantlite/viz/plotly_backend/__init__.py +0 -84
  179. quantlite-1.11.0/src/quantlite/viz/plotly_backend/dependency.py +0 -284
  180. quantlite-1.11.0/src/quantlite/viz/plotly_backend/portfolio.py +0 -274
  181. quantlite-1.11.0/src/quantlite/viz/plotly_backend/regimes.py +0 -262
  182. quantlite-1.11.0/src/quantlite/viz/plotly_backend/risk.py +0 -487
  183. quantlite-1.11.0/src/quantlite/viz/plotly_backend/theme.py +0 -129
  184. quantlite-1.11.0/src/quantlite/viz/risk.py +0 -299
  185. quantlite-1.11.0/tests/test_analysis.py +0 -112
  186. quantlite-1.11.0/tests/test_data_connectors.py +0 -343
  187. quantlite-1.11.0/tests/test_forensics.py +0 -163
  188. quantlite-1.11.0/tests/test_plotly_viz.py +0 -283
  189. {quantlite-1.11.0 → quantlite-1.13.0}/LICENSE +0 -0
  190. {quantlite-1.11.0 → quantlite-1.13.0}/setup.cfg +0 -0
  191. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/backtesting/__init__.py +0 -0
  192. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/benchmark/__init__.py +0 -0
  193. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/core/__init__.py +0 -0
  194. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/crypto/__init__.py +0 -0
  195. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/data/yahoo.py +0 -0
  196. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/datasets/data/dff.csv +0 -0
  197. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/datasets/data/dgs10.csv +0 -0
  198. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/datasets/data/dgs2.csv +0 -0
  199. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/datasets/data/dtwexbgs.csv +0 -0
  200. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/datasets/data/four_assets_prices.csv +0 -0
  201. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/dependency/__init__.py +0 -0
  202. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/distributions/__init__.py +0 -0
  203. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/explain/__init__.py +0 -0
  204. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/factors/__init__.py +0 -0
  205. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/instruments/__init__.py +0 -0
  206. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/portfolio/__init__.py +0 -0
  207. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/portfolio/tail_risk_parity.py +0 -0
  208. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/py.typed +0 -0
  209. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/regime_integration/__init__.py +0 -0
  210. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/regimes/__init__.py +0 -0
  211. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/risk/__init__.py +0 -0
  212. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/simulation/__init__.py +0 -0
  213. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/viz/__init__.py +0 -0
  214. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/viz/funding.py +0 -0
  215. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite/volatility/realised.py +0 -0
  216. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite.egg-info/dependency_links.txt +0 -0
  217. {quantlite-1.11.0 → quantlite-1.13.0}/src/quantlite.egg-info/top_level.txt +0 -0
  218. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_accessor.py +0 -0
  219. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_alerts.py +0 -0
  220. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_allocation_engine.py +0 -0
  221. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_clustering.py +0 -0
  222. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_conditional.py +0 -0
  223. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_contagion.py +0 -0
  224. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_copulas.py +0 -0
  225. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_crypto_exchange.py +0 -0
  226. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_crypto_funding.py +0 -0
  227. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_crypto_onchain.py +0 -0
  228. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_crypto_stablecoin.py +0 -0
  229. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_data_funding.py +0 -0
  230. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_data_generation.py +0 -0
  231. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_datasets.py +0 -0
  232. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_diversification.py +0 -0
  233. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_engine.py +0 -0
  234. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_evt.py +0 -0
  235. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_explainability.py +0 -0
  236. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_explainable_html.py +0 -0
  237. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_factors_classical.py +0 -0
  238. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_factors_custom.py +0 -0
  239. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_factors_tail_risk.py +0 -0
  240. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_fat_tails.py +0 -0
  241. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_hmm.py +0 -0
  242. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_instruments.py +0 -0
  243. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_metrics.py +0 -0
  244. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_monte_carlo.py +0 -0
  245. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_network.py +0 -0
  246. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_online_regime.py +0 -0
  247. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_optimisation.py +0 -0
  248. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_provenance.py +0 -0
  249. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_regime_integration.py +0 -0
  250. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_resample.py +0 -0
  251. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_risk_gaussian.py +0 -0
  252. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_risk_metrics.py +0 -0
  253. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_score.py +0 -0
  254. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_signals.py +0 -0
  255. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_sim_copula.py +0 -0
  256. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_sim_evt.py +0 -0
  257. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_sim_regime.py +0 -0
  258. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_stream.py +0 -0
  259. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_visualisation.py +0 -0
  260. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_viz.py +0 -0
  261. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_viz_dependency.py +0 -0
  262. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_viz_funding.py +0 -0
  263. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_viz_gaussian.py +0 -0
  264. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_viz_portfolio.py +0 -0
  265. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_viz_regimes.py +0 -0
  266. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_viz_volatility.py +0 -0
  267. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_volatility_garch.py +0 -0
  268. {quantlite-1.11.0 → quantlite-1.13.0}/tests/test_volatility_realised.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantlite
3
- Version: 1.11.0
3
+ Version: 1.13.0
4
4
  Summary: A fat-tail-native quantitative finance toolkit: EVT, risk metrics, and honest modelling for markets that bite.
5
5
  Author-email: Prasant Sudhakaran <code@prasant.net>
6
6
  License-Expression: MIT
@@ -27,6 +27,7 @@ Requires-Dist: pandas>=2.0
27
27
  Requires-Dist: scipy>=1.10
28
28
  Requires-Dist: matplotlib>=3.7
29
29
  Requires-Dist: mplfinance
30
+ Requires-Dist: six
30
31
  Provides-Extra: yahoo
31
32
  Requires-Dist: yfinance>=0.2; extra == "yahoo"
32
33
  Provides-Extra: crypto
@@ -36,19 +37,13 @@ Requires-Dist: ccxt>=4.0; extra == "stream"
36
37
  Provides-Extra: fred
37
38
  Requires-Dist: fredapi>=0.5; extra == "fred"
38
39
  Provides-Extra: plotly
39
- Requires-Dist: plotly>=5.0; extra == "plotly"
40
- Requires-Dist: kaleido>=0.2; extra == "plotly"
41
40
  Provides-Extra: report
42
- Requires-Dist: plotly>=5.0; extra == "report"
43
- Requires-Dist: kaleido>=0.2; extra == "report"
44
41
  Provides-Extra: pdf
45
42
  Requires-Dist: weasyprint>=60; extra == "pdf"
46
43
  Provides-Extra: all
47
44
  Requires-Dist: yfinance>=0.2; extra == "all"
48
45
  Requires-Dist: ccxt>=4.0; extra == "all"
49
46
  Requires-Dist: fredapi>=0.5; extra == "all"
50
- Requires-Dist: plotly>=5.0; extra == "all"
51
- Requires-Dist: kaleido>=0.2; extra == "all"
52
47
  Requires-Dist: weasyprint>=60; extra == "all"
53
48
  Requires-Dist: hmmlearn>=0.3; extra == "all"
54
49
  Provides-Extra: docs
@@ -63,6 +58,7 @@ Requires-Dist: ruff>=0.4; extra == "dev"
63
58
  Requires-Dist: mypy>=1.8; extra == "dev"
64
59
  Requires-Dist: pandas-stubs; extra == "dev"
65
60
  Requires-Dist: hmmlearn>=0.3; extra == "dev"
61
+ Requires-Dist: arch>=7.0; extra == "dev"
66
62
  Requires-Dist: mkdocs>=1.5; extra == "dev"
67
63
  Requires-Dist: mkdocs-material>=9.5; extra == "dev"
68
64
  Requires-Dist: mkdocstrings[python]>=0.24; extra == "dev"
@@ -93,6 +89,17 @@ ql.tearsheet(result, regimes=regimes, save="portfolio.html")
93
89
 
94
90
  Five lines. Fetch data, detect market regimes, build a regime-aware portfolio, backtest it, and generate a full tearsheet. That is the Dream API.
95
91
 
92
+ Then four questions, one call each, every answer in plain English:
93
+
94
+ ```python
95
+ ql.honesty_check(returns, n_trials=20).explain() # is this Sharpe ratio real, or the best of twenty tries?
96
+ ql.versus_gaussian(returns).explain() # the tail your data shows, beside what a normal model says
97
+ ql.ruin_check(returns, leverage=3).explain() # what leverage does to the path you actually live
98
+ ql.replay_all(prices, weights, prices=True).explain() # every historical crisis your data covers, replayed
99
+ ```
100
+
101
+ And one to check the library itself: `ql.reference_check()` reproduces 29 published results, from the deflated Sharpe ratio to the Kelly fraction, and shows any difference.
102
+
96
103
  ---
97
104
 
98
105
  ## Why QuantLite
@@ -100,13 +107,14 @@ Five lines. Fetch data, detect market regimes, build a regime-aware portfolio, b
100
107
  - **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.
101
108
  - **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.
102
109
  - **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.
110
+ - **Results explain themselves.** The headline tools return results whose `explain()` says what the number means and what it does not, with the caveats the computation raised. Underneath they are still the dicts and dataclasses they were, so existing code is unaffected.
103
111
  - **Every chart follows Stephen Few's principles.** Maximum data-ink ratio, muted palette, direct labels, no chartjunk. Publication-ready by default.
104
112
 
105
113
  ---
106
114
 
107
115
  ## The QuantLite Score
108
116
 
109
- An open, versioned, verifiable rating for trading track records. Raw Sharpe ratios are trivially gamed: test fifty variants and publish the winner, start the chart at the bottom of a drawdown, sell tail risk and post a 92% win rate. The QuantLite Score rates a track record on the statistics that are hard to game — deflated Sharpe, bootstrap robustness, tail risk, consistency — and flags the classic manipulation patterns.
117
+ An open, versioned, verifiable rating for trading track records. Raw Sharpe ratios are trivially gamed: test fifty variants and publish the winner, start the chart at the bottom of a drawdown, sell tail risk and post a 92% win rate. The QuantLite Score rates a track record on the statistics that are hard to game (deflated Sharpe, bootstrap robustness, tail risk, consistency) and flags the classic manipulation patterns.
110
118
 
111
119
  ```python
112
120
  from quantlite.score import compute_score, verify_artifact
@@ -118,7 +126,7 @@ payload = result.artifact.to_json() # publish or store this
118
126
  assert verify_artifact(payload, returns) # anyone can reproduce it bit for bit
119
127
  ```
120
128
 
121
- Every score ships as a portable artifact with a SHA-256 content hash. Same returns, same parameters, same library version: same score, bit for bit. The methodology (QLS-1.0) is open and frozen per version — see [the specification](docs/score.md).
129
+ Every score ships as a portable artifact with a SHA-256 content hash. Same returns, same parameters, same methodology version: same score, bit for bit, in every library version. The methodology (QLS-1.1 is current; QLS-1.0 scores still verify) is open and frozen per version; see [the specification](docs/score.md).
122
130
 
123
131
  ---
124
132
 
@@ -144,7 +152,7 @@ The ensemble average says you are making money. The time average says you are go
144
152
 
145
153
  ### Fourth Quadrant Map
146
154
 
147
- Taleb's Fourth Quadrant: where payoffs are extreme and distributions are unknown. Know which quadrant your portfolio lives in before the market tells you.
155
+ Taleb's Fourth Quadrant: where fat tails meet complex payoffs, and models fail. Returns can show the fat tails; the complexity of the payoff lives in the positions, options and leverage behind them.
148
156
 
149
157
  ![Fourth Quadrant Map](https://raw.githubusercontent.com/prasants/QuantLite/main/docs/images/fourth_quadrant_map.png)
150
158
 
@@ -154,11 +162,11 @@ You tested 50 strategies and picked the best. The Deflated Sharpe Ratio tells yo
154
162
 
155
163
  ![Deflated Sharpe](https://raw.githubusercontent.com/prasants/QuantLite/main/docs/images/deflated_sharpe.png)
156
164
 
157
- ### Scenario Stress Heatmap
165
+ ### Historical Crises
158
166
 
159
- How does your portfolio fare under the GFC, COVID, the taper tantrum, and a dozen other crises? One glance.
167
+ A 60/40 portfolio of SPY and TLT, replayed on real prices through every crisis since 2007. Its worst was not 2008 but 2022, when stocks and bonds fell together and the hedge failed.
160
168
 
161
- ![Scenario Heatmap](https://raw.githubusercontent.com/prasants/QuantLite/main/examples/scenario_heatmap.png)
169
+ ![Historical Crises](https://raw.githubusercontent.com/prasants/QuantLite/main/docs/images/replay_summary.png)
162
170
 
163
171
  ### Copula Contours
164
172
 
@@ -186,7 +194,6 @@ Install only the data sources you need:
186
194
  pip install quantlite[yahoo] # Yahoo Finance
187
195
  pip install quantlite[crypto] # Cryptocurrency exchanges (CCXT)
188
196
  pip install quantlite[fred] # FRED macroeconomic data
189
- pip install quantlite[plotly] # Interactive Plotly charts
190
197
  pip install quantlite[all] # Everything
191
198
  ```
192
199
 
@@ -242,10 +249,10 @@ print(f"1-in-100 loss: {summary.return_level_100:.4f}")
242
249
  from quantlite.forensics import deflated_sharpe_ratio
243
250
  from quantlite.resample import bootstrap_sharpe_distribution
244
251
 
245
- # You tried 50 strategies and the best had Sharpe 1.8.
246
- # Is it real?
247
- dsr = deflated_sharpe_ratio(observed_sharpe=1.8, n_trials=50, n_obs=252)
248
- print(f"Probability Sharpe is genuine: {dsr:.2%}")
252
+ # You tried 50 strategies and the best had an annualised Sharpe of 1.8
253
+ # over a year of daily data. Is it real?
254
+ dsr = deflated_sharpe_ratio(observed_sharpe=1.8, n_trials=50, n_obs=252, periods_per_year=252)
255
+ print(f"Probability Sharpe is genuine: {dsr:.2%}") # 31.62%: more likely luck than skill
249
256
 
250
257
  # Bootstrap confidence interval on the Sharpe ratio
251
258
  result = bootstrap_sharpe_distribution(returns, n_samples=2000, seed=42)
@@ -265,6 +272,7 @@ print(f"95% CI: [{result['ci_lower']:.2f}, {result['ci_upper']:.2f}]")
265
272
  | `quantlite.risk.gaussian` | `versus_gaussian`: your tail number beside what a normal model would have said, with the ratio and a plain-English `explain()` |
266
273
  | `quantlite.risk.evt` | GPD, GEV, Hill estimator, Peaks Over Threshold, return levels |
267
274
  | `quantlite.volatility` | Realised volatility (Parkinson, Garman-Klass, Rogers-Satchell, Yang-Zhang), GARCH, GJR-GARCH, and EGARCH with Student-t innovations by default |
275
+ | `quantlite.volatility.fit_dcc` | Dynamic conditional correlation (Engle 2002) on Student-t GARCH marginals: correlation paths, crisis versus average correlation, portfolio volatility with today's correlations, and a test of whether correlations move at all |
268
276
  | `quantlite.distributions.fat_tails` | Student-t, Lévy stable, regime-switching GBM, Kou jump-diffusion |
269
277
  | `quantlite.metrics` | Annualised return, volatility, Sharpe, max drawdown |
270
278
 
@@ -301,8 +309,10 @@ print(f"95% CI: [{result['ci_lower']:.2f}, {result['ci_upper']:.2f}]")
301
309
  | Module | Description |
302
310
  |--------|-------------|
303
311
  | `quantlite.ergodicity` | Time-average vs ensemble-average growth, Kelly fraction, leverage effect |
312
+ | `quantlite.ruin_check` | What leverage does to the path an investor lives: time-average growth, growth-optimal and zero-growth leverage, and the chance of ruin from a block bootstrap of your own returns, beside a normal model's answer |
304
313
  | `quantlite.antifragile` | Antifragility score, convexity, Fourth Quadrant, barbell allocation, Lindy |
305
314
  | `quantlite.scenarios` | Composable scenario engine, pre-built crisis library, shock propagation |
315
+ | `quantlite.scenarios.replay` | Twelve historical crises with verified dates, replayed on your own data: return, worst fall, worst day, recovery, correlation before and during, across markets and time zones |
306
316
 
307
317
  ### Honest Backtesting
308
318
 
@@ -310,6 +320,7 @@ print(f"95% CI: [{result['ci_lower']:.2f}, {result['ci_upper']:.2f}]")
310
320
  |--------|-------------|
311
321
  | `quantlite.forensics` | Deflated Sharpe Ratio, Probabilistic Sharpe, haircut adjustments, minimum track record |
312
322
  | `quantlite.honesty_check` | One call, one verdict: PSR, deflated Sharpe with the luck benchmark, minimum track record, bootstrap interval, and PBO when the trials are supplied |
323
+ | `quantlite.reference_check` | Reproduces 29 published results (deflated and probabilistic Sharpe, minimum track record, normal tail constants, Kelly, Parkinson, Sharpe and Sortino, Black-Scholes, effective bets, copula tail dependence) and shows the differences; `python -m quantlite.reference` for CI |
313
324
  | `quantlite.overfit` | CSCV/PBO, TrialTracker, multiple testing correction, walk-forward validation |
314
325
  | `quantlite.resample` | Block and stationary bootstrap, confidence intervals for Sharpe and drawdown |
315
326
 
@@ -389,10 +400,10 @@ Full documentation lives in the [`docs/`](docs/) directory:
389
400
  | [portfolio.md](docs/portfolio.md) | Portfolio optimisation and rebalancing |
390
401
  | [data.md](docs/data.md) | Data connectors |
391
402
  | [visualisation.md](docs/visualisation.md) | Stephen Few-themed charts |
392
- | [interactive_viz.md](docs/interactive_viz.md) | Plotly interactive charts |
393
403
  | [ergodicity.md](docs/ergodicity.md) | Ergodicity economics |
394
404
  | [antifragility.md](docs/antifragility.md) | Antifragility measurement |
395
405
  | [scenarios.md](docs/scenarios.md) | Scenario stress testing |
406
+ | [historical_scenarios.md](docs/historical_scenarios.md) | Historical crises replayed on your data |
396
407
  | [forensics.md](docs/forensics.md) | Deflated Sharpe and strategy forensics |
397
408
  | [overfitting.md](docs/overfitting.md) | Overfitting detection |
398
409
  | [resampling.md](docs/resampling.md) | Bootstrap resampling |
@@ -23,6 +23,17 @@ ql.tearsheet(result, regimes=regimes, save="portfolio.html")
23
23
 
24
24
  Five lines. Fetch data, detect market regimes, build a regime-aware portfolio, backtest it, and generate a full tearsheet. That is the Dream API.
25
25
 
26
+ Then four questions, one call each, every answer in plain English:
27
+
28
+ ```python
29
+ ql.honesty_check(returns, n_trials=20).explain() # is this Sharpe ratio real, or the best of twenty tries?
30
+ ql.versus_gaussian(returns).explain() # the tail your data shows, beside what a normal model says
31
+ ql.ruin_check(returns, leverage=3).explain() # what leverage does to the path you actually live
32
+ ql.replay_all(prices, weights, prices=True).explain() # every historical crisis your data covers, replayed
33
+ ```
34
+
35
+ And one to check the library itself: `ql.reference_check()` reproduces 29 published results, from the deflated Sharpe ratio to the Kelly fraction, and shows any difference.
36
+
26
37
  ---
27
38
 
28
39
  ## Why QuantLite
@@ -30,13 +41,14 @@ Five lines. Fetch data, detect market regimes, build a regime-aware portfolio, b
30
41
  - **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.
31
42
  - **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.
32
43
  - **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.
44
+ - **Results explain themselves.** The headline tools return results whose `explain()` says what the number means and what it does not, with the caveats the computation raised. Underneath they are still the dicts and dataclasses they were, so existing code is unaffected.
33
45
  - **Every chart follows Stephen Few's principles.** Maximum data-ink ratio, muted palette, direct labels, no chartjunk. Publication-ready by default.
34
46
 
35
47
  ---
36
48
 
37
49
  ## The QuantLite Score
38
50
 
39
- An open, versioned, verifiable rating for trading track records. Raw Sharpe ratios are trivially gamed: test fifty variants and publish the winner, start the chart at the bottom of a drawdown, sell tail risk and post a 92% win rate. The QuantLite Score rates a track record on the statistics that are hard to game — deflated Sharpe, bootstrap robustness, tail risk, consistency — and flags the classic manipulation patterns.
51
+ An open, versioned, verifiable rating for trading track records. Raw Sharpe ratios are trivially gamed: test fifty variants and publish the winner, start the chart at the bottom of a drawdown, sell tail risk and post a 92% win rate. The QuantLite Score rates a track record on the statistics that are hard to game (deflated Sharpe, bootstrap robustness, tail risk, consistency) and flags the classic manipulation patterns.
40
52
 
41
53
  ```python
42
54
  from quantlite.score import compute_score, verify_artifact
@@ -48,7 +60,7 @@ payload = result.artifact.to_json() # publish or store this
48
60
  assert verify_artifact(payload, returns) # anyone can reproduce it bit for bit
49
61
  ```
50
62
 
51
- Every score ships as a portable artifact with a SHA-256 content hash. Same returns, same parameters, same library version: same score, bit for bit. The methodology (QLS-1.0) is open and frozen per version — see [the specification](docs/score.md).
63
+ Every score ships as a portable artifact with a SHA-256 content hash. Same returns, same parameters, same methodology version: same score, bit for bit, in every library version. The methodology (QLS-1.1 is current; QLS-1.0 scores still verify) is open and frozen per version; see [the specification](docs/score.md).
52
64
 
53
65
  ---
54
66
 
@@ -74,7 +86,7 @@ The ensemble average says you are making money. The time average says you are go
74
86
 
75
87
  ### Fourth Quadrant Map
76
88
 
77
- Taleb's Fourth Quadrant: where payoffs are extreme and distributions are unknown. Know which quadrant your portfolio lives in before the market tells you.
89
+ Taleb's Fourth Quadrant: where fat tails meet complex payoffs, and models fail. Returns can show the fat tails; the complexity of the payoff lives in the positions, options and leverage behind them.
78
90
 
79
91
  ![Fourth Quadrant Map](https://raw.githubusercontent.com/prasants/QuantLite/main/docs/images/fourth_quadrant_map.png)
80
92
 
@@ -84,11 +96,11 @@ You tested 50 strategies and picked the best. The Deflated Sharpe Ratio tells yo
84
96
 
85
97
  ![Deflated Sharpe](https://raw.githubusercontent.com/prasants/QuantLite/main/docs/images/deflated_sharpe.png)
86
98
 
87
- ### Scenario Stress Heatmap
99
+ ### Historical Crises
88
100
 
89
- How does your portfolio fare under the GFC, COVID, the taper tantrum, and a dozen other crises? One glance.
101
+ A 60/40 portfolio of SPY and TLT, replayed on real prices through every crisis since 2007. Its worst was not 2008 but 2022, when stocks and bonds fell together and the hedge failed.
90
102
 
91
- ![Scenario Heatmap](https://raw.githubusercontent.com/prasants/QuantLite/main/examples/scenario_heatmap.png)
103
+ ![Historical Crises](https://raw.githubusercontent.com/prasants/QuantLite/main/docs/images/replay_summary.png)
92
104
 
93
105
  ### Copula Contours
94
106
 
@@ -116,7 +128,6 @@ Install only the data sources you need:
116
128
  pip install quantlite[yahoo] # Yahoo Finance
117
129
  pip install quantlite[crypto] # Cryptocurrency exchanges (CCXT)
118
130
  pip install quantlite[fred] # FRED macroeconomic data
119
- pip install quantlite[plotly] # Interactive Plotly charts
120
131
  pip install quantlite[all] # Everything
121
132
  ```
122
133
 
@@ -172,10 +183,10 @@ print(f"1-in-100 loss: {summary.return_level_100:.4f}")
172
183
  from quantlite.forensics import deflated_sharpe_ratio
173
184
  from quantlite.resample import bootstrap_sharpe_distribution
174
185
 
175
- # You tried 50 strategies and the best had Sharpe 1.8.
176
- # Is it real?
177
- dsr = deflated_sharpe_ratio(observed_sharpe=1.8, n_trials=50, n_obs=252)
178
- print(f"Probability Sharpe is genuine: {dsr:.2%}")
186
+ # You tried 50 strategies and the best had an annualised Sharpe of 1.8
187
+ # over a year of daily data. Is it real?
188
+ dsr = deflated_sharpe_ratio(observed_sharpe=1.8, n_trials=50, n_obs=252, periods_per_year=252)
189
+ print(f"Probability Sharpe is genuine: {dsr:.2%}") # 31.62%: more likely luck than skill
179
190
 
180
191
  # Bootstrap confidence interval on the Sharpe ratio
181
192
  result = bootstrap_sharpe_distribution(returns, n_samples=2000, seed=42)
@@ -195,6 +206,7 @@ print(f"95% CI: [{result['ci_lower']:.2f}, {result['ci_upper']:.2f}]")
195
206
  | `quantlite.risk.gaussian` | `versus_gaussian`: your tail number beside what a normal model would have said, with the ratio and a plain-English `explain()` |
196
207
  | `quantlite.risk.evt` | GPD, GEV, Hill estimator, Peaks Over Threshold, return levels |
197
208
  | `quantlite.volatility` | Realised volatility (Parkinson, Garman-Klass, Rogers-Satchell, Yang-Zhang), GARCH, GJR-GARCH, and EGARCH with Student-t innovations by default |
209
+ | `quantlite.volatility.fit_dcc` | Dynamic conditional correlation (Engle 2002) on Student-t GARCH marginals: correlation paths, crisis versus average correlation, portfolio volatility with today's correlations, and a test of whether correlations move at all |
198
210
  | `quantlite.distributions.fat_tails` | Student-t, Lévy stable, regime-switching GBM, Kou jump-diffusion |
199
211
  | `quantlite.metrics` | Annualised return, volatility, Sharpe, max drawdown |
200
212
 
@@ -231,8 +243,10 @@ print(f"95% CI: [{result['ci_lower']:.2f}, {result['ci_upper']:.2f}]")
231
243
  | Module | Description |
232
244
  |--------|-------------|
233
245
  | `quantlite.ergodicity` | Time-average vs ensemble-average growth, Kelly fraction, leverage effect |
246
+ | `quantlite.ruin_check` | What leverage does to the path an investor lives: time-average growth, growth-optimal and zero-growth leverage, and the chance of ruin from a block bootstrap of your own returns, beside a normal model's answer |
234
247
  | `quantlite.antifragile` | Antifragility score, convexity, Fourth Quadrant, barbell allocation, Lindy |
235
248
  | `quantlite.scenarios` | Composable scenario engine, pre-built crisis library, shock propagation |
249
+ | `quantlite.scenarios.replay` | Twelve historical crises with verified dates, replayed on your own data: return, worst fall, worst day, recovery, correlation before and during, across markets and time zones |
236
250
 
237
251
  ### Honest Backtesting
238
252
 
@@ -240,6 +254,7 @@ print(f"95% CI: [{result['ci_lower']:.2f}, {result['ci_upper']:.2f}]")
240
254
  |--------|-------------|
241
255
  | `quantlite.forensics` | Deflated Sharpe Ratio, Probabilistic Sharpe, haircut adjustments, minimum track record |
242
256
  | `quantlite.honesty_check` | One call, one verdict: PSR, deflated Sharpe with the luck benchmark, minimum track record, bootstrap interval, and PBO when the trials are supplied |
257
+ | `quantlite.reference_check` | Reproduces 29 published results (deflated and probabilistic Sharpe, minimum track record, normal tail constants, Kelly, Parkinson, Sharpe and Sortino, Black-Scholes, effective bets, copula tail dependence) and shows the differences; `python -m quantlite.reference` for CI |
243
258
  | `quantlite.overfit` | CSCV/PBO, TrialTracker, multiple testing correction, walk-forward validation |
244
259
  | `quantlite.resample` | Block and stationary bootstrap, confidence intervals for Sharpe and drawdown |
245
260
 
@@ -319,10 +334,10 @@ Full documentation lives in the [`docs/`](docs/) directory:
319
334
  | [portfolio.md](docs/portfolio.md) | Portfolio optimisation and rebalancing |
320
335
  | [data.md](docs/data.md) | Data connectors |
321
336
  | [visualisation.md](docs/visualisation.md) | Stephen Few-themed charts |
322
- | [interactive_viz.md](docs/interactive_viz.md) | Plotly interactive charts |
323
337
  | [ergodicity.md](docs/ergodicity.md) | Ergodicity economics |
324
338
  | [antifragility.md](docs/antifragility.md) | Antifragility measurement |
325
339
  | [scenarios.md](docs/scenarios.md) | Scenario stress testing |
340
+ | [historical_scenarios.md](docs/historical_scenarios.md) | Historical crises replayed on your data |
326
341
  | [forensics.md](docs/forensics.md) | Deflated Sharpe and strategy forensics |
327
342
  | [overfitting.md](docs/overfitting.md) | Overfitting detection |
328
343
  | [resampling.md](docs/resampling.md) | Bootstrap resampling |
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "quantlite"
7
- version = "1.11.0"
7
+ version = "1.13.0"
8
8
  description = "A fat-tail-native quantitative finance toolkit: EVT, risk metrics, and honest modelling for markets that bite."
9
9
  requires-python = ">=3.10"
10
10
  license = "MIT"
@@ -43,6 +43,9 @@ dependencies = [
43
43
  "scipy>=1.10",
44
44
  "matplotlib>=3.7",
45
45
  "mplfinance",
46
+ # mplfinance imports six without declaring it. It used to arrive with
47
+ # python-dateutil, which dropped it in 4.0.
48
+ "six",
46
49
  ]
47
50
 
48
51
  [project.optional-dependencies]
@@ -50,10 +53,12 @@ yahoo = ["yfinance>=0.2"]
50
53
  crypto = ["ccxt>=4.0"]
51
54
  stream = ["ccxt>=4.0"]
52
55
  fred = ["fredapi>=0.5"]
53
- plotly = ["plotly>=5.0", "kaleido>=0.2"]
54
- report = ["plotly>=5.0", "kaleido>=0.2"]
56
+ # The Plotly backend was removed in 1.12; these extras stay, empty, so
57
+ # existing install commands keep working.
58
+ plotly = []
59
+ report = []
55
60
  pdf = ["weasyprint>=60"]
56
- all = ["yfinance>=0.2", "ccxt>=4.0", "fredapi>=0.5", "plotly>=5.0", "kaleido>=0.2", "weasyprint>=60", "hmmlearn>=0.3"]
61
+ all = ["yfinance>=0.2", "ccxt>=4.0", "fredapi>=0.5", "weasyprint>=60", "hmmlearn>=0.3"]
57
62
  docs = [
58
63
  "mkdocs>=1.5",
59
64
  "mkdocs-material>=9.5",
@@ -67,6 +72,7 @@ dev = [
67
72
  "mypy>=1.8",
68
73
  "pandas-stubs",
69
74
  "hmmlearn>=0.3",
75
+ "arch>=7.0",
70
76
  "mkdocs>=1.5",
71
77
  "mkdocs-material>=9.5",
72
78
  "mkdocstrings[python]>=0.24",
@@ -95,3 +101,6 @@ disallow_untyped_defs = false
95
101
  [tool.pytest.ini_options]
96
102
  testpaths = ["tests"]
97
103
  asyncio_mode = "auto"
104
+ markers = [
105
+ "checks(name): the public function or method this test checks against its definition",
106
+ ]
@@ -17,7 +17,7 @@ from __future__ import annotations
17
17
  import importlib
18
18
  from typing import Any
19
19
 
20
- __version__ = "1.11.0"
20
+ __version__ = "1.13.0"
21
21
 
22
22
  # Public names mapped to the module that defines them, for lazy loading.
23
23
  _ATTR_SOURCES = {
@@ -67,9 +67,16 @@ _ATTR_SOURCES = {
67
67
  "VersusGaussian": "quantlite.risk.gaussian",
68
68
  "honesty_check": "quantlite.honesty",
69
69
  "HonestyReport": "quantlite.honesty",
70
+ "ruin_check": "quantlite.ergodicity.ruin",
71
+ "RuinReport": "quantlite.ergodicity.ruin",
72
+ "reference_check": "quantlite.reference",
70
73
  # The first five minutes (v1.11)
71
74
  "doctor": "quantlite._doctor",
72
-
75
+ # History and correlation (v1.12)
76
+ "replay": "quantlite.scenarios.historical",
77
+ "replay_all": "quantlite.scenarios.historical",
78
+ "historical_scenarios": "quantlite.scenarios.historical",
79
+ "fit_dcc": "quantlite.volatility.dcc",
73
80
  }
74
81
 
75
82
  # Names whose attribute on the source module differs from the public name.
@@ -152,9 +159,17 @@ __all__ = [
152
159
  "VersusGaussian",
153
160
  "honesty_check",
154
161
  "HonestyReport",
162
+ "ruin_check",
163
+ "RuinReport",
164
+ "reference_check",
155
165
  # The first five minutes (v1.11)
156
166
  "doctor",
157
167
  "datasets",
168
+ # History and correlation (v1.12)
169
+ "replay",
170
+ "replay_all",
171
+ "historical_scenarios",
172
+ "fit_dcc",
158
173
  ]
159
174
 
160
175
 
@@ -21,14 +21,20 @@ import sys
21
21
 
22
22
  __all__ = ["doctor"]
23
23
 
24
+ # The packages of the [all] extra, as listed under ``all`` in pyproject.toml
25
+ # ([project.optional-dependencies]). Keep the two in step.
26
+ _ALL_EXTRA: tuple[str, ...] = ("yfinance", "ccxt", "fredapi", "weasyprint", "hmmlearn")
27
+
24
28
  # extra name -> (packages that must be importable, what it unlocks)
25
29
  _EXTRAS: dict[str, tuple[tuple[str, ...], str]] = {
26
30
  "yahoo": (("yfinance",), "Yahoo Finance connector: fetch(..., source='yahoo')"),
27
31
  "crypto": (("ccxt",), "Exchange OHLCV, order books, funding history: fetch(..., source='ccxt'), data.funding"),
28
32
  "fred": (("fredapi",), "FRED macro series by API key: fetch(..., source='fred')"),
29
- "plotly": (("plotly", "kaleido"), "Interactive charts: backend='plotly' on viz functions"),
30
33
  "pdf": (("weasyprint",), "PDF tearsheets (also needs the pango and cairo system libraries)"),
31
- "all": (("hmmlearn",), "HMM regime detection: detect_regimes(method='hmm'); part of the [all] extra"),
34
+ "all": (
35
+ _ALL_EXTRA,
36
+ "Every optional package above plus hmmlearn (HMM regimes: detect_regimes(method='hmm'))",
37
+ ),
32
38
  }
33
39
 
34
40
  _CORE = ("numpy", "scipy", "pandas", "matplotlib")
@@ -53,7 +59,14 @@ def doctor(*, echo: bool = True) -> dict[str, bool]:
53
59
  -------
54
60
  dict
55
61
  Extra name to installed flag. Bundled datasets and everything in
56
- the core need no extra and are not listed.
62
+ the core need no extra and are not listed. ``"all"`` is true only
63
+ when every package of the ``[all]`` extra is findable.
64
+
65
+ Notes
66
+ -----
67
+ Before QuantLite 1.13 ``"all"`` tested hmmlearn alone, so a machine
68
+ with hmmlearn and none of yfinance, ccxt, fredapi or weasyprint was
69
+ reported as ``all: installed``.
57
70
  """
58
71
  from . import __version__
59
72
 
@@ -74,7 +87,11 @@ def doctor(*, echo: bool = True) -> dict[str, bool]:
74
87
  mark = "installed" if status[name] else "missing "
75
88
  lines.append(f" {name:<{width}} {mark} {unlocks}")
76
89
  if not status[name]:
77
- lines.append(f" {'':<{width}} pip install quantlite[{name}] (needs {', '.join(packages)})")
90
+ absent = [p for p in packages if not _present(p)]
91
+ lines.append(
92
+ f" {'':<{width}} pip install quantlite[{name}]"
93
+ f" (needs {', '.join(absent)})"
94
+ )
78
95
  lines.append("")
79
96
  lines.append("Bundled datasets need no extra: quantlite.datasets.available()")
80
97
  print("\n".join(lines))
@@ -8,10 +8,12 @@ nothing and removes a step from every call::
8
8
  returns.ql.cvar(0.01) # a float, from risk.metrics.cvar
9
9
  returns.ql.versus_gaussian() # VersusGaussian, with explain()
10
10
  returns.ql.honesty_check(n_trials=8) # HonestyReport
11
+ returns.ql.ruin_check(leverage=2) # RuinReport
11
12
  returns.ql.garch(model="gjr") # GARCHFit
12
13
 
13
14
  frame.ql.hrp() # PortfolioWeights
14
15
  frame.ql.regimes(n_regimes=3) # regime labels
16
+ frame.ql.dcc() # DCCFit: correlations over time
15
17
  frame.ql.versus_gaussian() # one VersusGaussian per column
16
18
 
17
19
  Thin delegation only. Every method calls the public function of the
@@ -71,6 +73,12 @@ class SeriesAccessor:
71
73
 
72
74
  return honesty_check(self._values(), **kwargs)
73
75
 
76
+ def ruin_check(self, **kwargs: Any) -> Any:
77
+ """See :func:`quantlite.ergodicity.ruin.ruin_check`."""
78
+ from .ergodicity.ruin import ruin_check
79
+
80
+ return ruin_check(self._values(), **kwargs)
81
+
74
82
  def garch(self, **kwargs: Any) -> Any:
75
83
  """See :func:`quantlite.volatility.fit_garch`."""
76
84
  from .volatility import fit_garch
@@ -106,6 +114,12 @@ class FrameAccessor:
106
114
  for col in self._df.columns
107
115
  }
108
116
 
117
+ def dcc(self, **kwargs: Any) -> Any:
118
+ """Dynamic conditional correlation; see :func:`quantlite.volatility.fit_dcc`."""
119
+ from .volatility import fit_dcc
120
+
121
+ return fit_dcc(self._df, **kwargs)
122
+
109
123
  def honesty_check(self, **kwargs: Any) -> dict[str, Any]:
110
124
  """One :class:`HonestyReport` per column."""
111
125
  from .honesty import honesty_check
@@ -22,6 +22,7 @@ Example::
22
22
  from __future__ import annotations
23
23
 
24
24
  import logging
25
+ import math
25
26
  import time
26
27
  from collections.abc import Callable, Sequence
27
28
  from dataclasses import dataclass, field
@@ -115,10 +116,21 @@ class AlertManager:
115
116
 
116
117
  Args:
117
118
  max_history: Maximum number of alerts to keep in the
118
- history log. Defaults to 1000.
119
+ history log. Defaults to 1000. Zero keeps no history.
120
+
121
+ Raises:
122
+ ValueError: If ``max_history`` is negative.
119
123
  """
120
124
 
125
+ _RULE_CONDITIONS = ("regime_change",)
126
+
121
127
  def __init__(self, max_history: int = 1000) -> None:
128
+ if max_history < 0:
129
+ raise ValueError(
130
+ f"max_history must be zero or more, got {max_history}. "
131
+ "Use 0 to keep no history."
132
+ )
133
+ self._name_counter = 0
122
134
  self._rules: dict[str, AlertRule] = {}
123
135
  self._history: list[Alert] = []
124
136
  self._max_history = max_history
@@ -162,9 +174,17 @@ class AlertManager:
162
174
 
163
175
  Returns:
164
176
  The created ``AlertRule``.
177
+
178
+ Raises:
179
+ ValueError: If ``condition`` is not a supported condition.
165
180
  """
181
+ if condition not in self._RULE_CONDITIONS:
182
+ raise ValueError(
183
+ f"Unknown condition '{condition}'. Supported: {list(self._RULE_CONDITIONS)}. "
184
+ "Use add_threshold() for threshold alerts."
185
+ )
166
186
  if name is None:
167
- name = f"{metric}_{condition}_{len(self._rules)}"
187
+ name = self._next_name(f"{metric}_{condition}")
168
188
 
169
189
  rule = AlertRule(
170
190
  name=name,
@@ -200,7 +220,7 @@ class AlertManager:
200
220
  The created ``AlertRule``.
201
221
  """
202
222
  if name is None:
203
- name = f"{metric}_threshold_{len(self._rules)}"
223
+ name = self._next_name(f"{metric}_threshold")
204
224
 
205
225
  dir_enum = ThresholdDirection(direction.lower())
206
226
 
@@ -216,6 +236,14 @@ class AlertManager:
216
236
  self._rules[name] = rule
217
237
  return rule
218
238
 
239
+ def _next_name(self, prefix: str) -> str:
240
+ """Return an auto-generated rule name that no earlier rule has used."""
241
+ while True:
242
+ name = f"{prefix}_{self._name_counter}"
243
+ self._name_counter += 1
244
+ if name not in self._rules:
245
+ return name
246
+
219
247
  def remove_rule(self, name: str) -> None:
220
248
  """Remove an alert rule by name.
221
249
 
@@ -273,15 +301,14 @@ class AlertManager:
273
301
  continue
274
302
  if rule.metric != metric:
275
303
  continue
276
- if now - rule._last_fired < rule.cooldown_s:
277
- continue
278
304
 
305
+ # Evaluate even during cooldown so a cross rule keeps its previous
306
+ # value up to date; the alert is only dropped, never fired late.
279
307
  alert = self._evaluate_rule(
280
308
  rule, value, regime, previous_regime, metadata
281
309
  )
282
- if alert is not None:
310
+ if alert is not None and now - rule._last_fired >= rule.cooldown_s:
283
311
  rule._last_fired = now
284
- rule._last_value = value
285
312
  self._record_alert(alert)
286
313
  fired.append(alert)
287
314
 
@@ -353,6 +380,7 @@ class AlertManager:
353
380
  elif (
354
381
  rule.condition == "threshold"
355
382
  and value is not None
383
+ and not math.isnan(value)
356
384
  and rule.threshold is not None
357
385
  ):
358
386
  triggered = False
@@ -395,7 +423,7 @@ class AlertManager:
395
423
  """
396
424
  self._history.append(alert)
397
425
  if len(self._history) > self._max_history:
398
- self._history = self._history[-self._max_history:]
426
+ self._history = self._history[len(self._history) - self._max_history:]
399
427
 
400
428
  # Fire rule-specific callback
401
429
  rule = self._rules.get(alert.rule_name)