stratstat 0.1.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 (51) hide show
  1. stratstat-0.1.0/LICENSE +21 -0
  2. stratstat-0.1.0/PKG-INFO +439 -0
  3. stratstat-0.1.0/README.md +386 -0
  4. stratstat-0.1.0/pyproject.toml +135 -0
  5. stratstat-0.1.0/setup.cfg +4 -0
  6. stratstat-0.1.0/src/stratstat/__init__.py +536 -0
  7. stratstat-0.1.0/src/stratstat/container.py +466 -0
  8. stratstat-0.1.0/src/stratstat/conventions.py +189 -0
  9. stratstat-0.1.0/src/stratstat/core/__init__.py +6 -0
  10. stratstat-0.1.0/src/stratstat/core/_utils.py +155 -0
  11. stratstat-0.1.0/src/stratstat/core/benchmark.py +934 -0
  12. stratstat-0.1.0/src/stratstat/core/compare.py +1026 -0
  13. stratstat-0.1.0/src/stratstat/core/exposure.py +1120 -0
  14. stratstat-0.1.0/src/stratstat/core/returns/__init__.py +16 -0
  15. stratstat-0.1.0/src/stratstat/core/returns/descriptive.py +1812 -0
  16. stratstat-0.1.0/src/stratstat/core/returns/inference.py +1711 -0
  17. stratstat-0.1.0/src/stratstat/core/returns/risk.py +1971 -0
  18. stratstat-0.1.0/src/stratstat/core/returns/risk_adjusted.py +1644 -0
  19. stratstat-0.1.0/src/stratstat/core/returns/wrappers.py +196 -0
  20. stratstat-0.1.0/src/stratstat/core/trades.py +1587 -0
  21. stratstat-0.1.0/src/stratstat/exceptions.py +36 -0
  22. stratstat-0.1.0/src/stratstat/inputs.py +1349 -0
  23. stratstat-0.1.0/src/stratstat/py.typed +0 -0
  24. stratstat-0.1.0/src/stratstat/registry.py +594 -0
  25. stratstat-0.1.0/src/stratstat/report/__init__.py +64 -0
  26. stratstat-0.1.0/src/stratstat/report/_charts.py +1040 -0
  27. stratstat-0.1.0/src/stratstat/report/_common.py +115 -0
  28. stratstat-0.1.0/src/stratstat/report/_dashboard.py +228 -0
  29. stratstat-0.1.0/src/stratstat/report/_export.py +136 -0
  30. stratstat-0.1.0/src/stratstat/report/_report.py +1169 -0
  31. stratstat-0.1.0/src/stratstat/report/_tearsheet.py +214 -0
  32. stratstat-0.1.0/src/stratstat/results.py +460 -0
  33. stratstat-0.1.0/src/stratstat/schema.py +356 -0
  34. stratstat-0.1.0/src/stratstat.egg-info/PKG-INFO +439 -0
  35. stratstat-0.1.0/src/stratstat.egg-info/SOURCES.txt +49 -0
  36. stratstat-0.1.0/src/stratstat.egg-info/dependency_links.txt +1 -0
  37. stratstat-0.1.0/src/stratstat.egg-info/requires.txt +32 -0
  38. stratstat-0.1.0/src/stratstat.egg-info/top_level.txt +1 -0
  39. stratstat-0.1.0/tests/test_api.py +274 -0
  40. stratstat-0.1.0/tests/test_boundaries.py +59 -0
  41. stratstat-0.1.0/tests/test_container.py +221 -0
  42. stratstat-0.1.0/tests/test_conventions.py +132 -0
  43. stratstat-0.1.0/tests/test_exceptions.py +44 -0
  44. stratstat-0.1.0/tests/test_input_routing.py +147 -0
  45. stratstat-0.1.0/tests/test_inputs.py +126 -0
  46. stratstat-0.1.0/tests/test_kwarg_validation.py +117 -0
  47. stratstat-0.1.0/tests/test_registry.py +83 -0
  48. stratstat-0.1.0/tests/test_results.py +484 -0
  49. stratstat-0.1.0/tests/test_rf_propagation.py +284 -0
  50. stratstat-0.1.0/tests/test_schema.py +292 -0
  51. stratstat-0.1.0/tests/test_utils.py +90 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Syed Qaisar Jalil
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,439 @@
1
+ Metadata-Version: 2.4
2
+ Name: stratstat
3
+ Version: 0.1.0
4
+ Summary: Quantitative strategy evaluation statistics — the modern successor to empyrical, pyfolio, and QuantStats.
5
+ Author: Syed Qaisar Jalil
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/aineurog/stratstat
8
+ Project-URL: Documentation, https://stratstat.readthedocs.io/
9
+ Project-URL: Repository, https://github.com/aineurog/stratstat.git
10
+ Project-URL: Issues, https://github.com/aineurog/stratstat/issues
11
+ Keywords: finance,quantitative,quant,strategy,backtesting,evaluation,statistics,performance,risk,metrics,trading,portfolio,algorithmic trading,risk management,performance metrics,sharpe ratio,sortino ratio,drawdown,time series,alpha,beta,quantstats,empyrical,pyfolio
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Financial and Insurance Industry
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Office/Business :: Financial
22
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Natural Language :: English
25
+ Requires-Python: >=3.10
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: numpy>=1.24
29
+ Requires-Dist: pandas>=1.5
30
+ Provides-Extra: fast
31
+ Requires-Dist: numba>=0.58; extra == "fast"
32
+ Provides-Extra: report
33
+ Requires-Dist: plotly>=5.0; extra == "report"
34
+ Provides-Extra: polars
35
+ Requires-Dist: polars>=0.18; extra == "polars"
36
+ Provides-Extra: image
37
+ Requires-Dist: kaleido>=0.2.1; extra == "image"
38
+ Provides-Extra: pdf
39
+ Requires-Dist: weasyprint; extra == "pdf"
40
+ Provides-Extra: all
41
+ Requires-Dist: stratstat[fast,image,pdf,polars,report]; extra == "all"
42
+ Provides-Extra: docs
43
+ Requires-Dist: sphinx>=7; extra == "docs"
44
+ Requires-Dist: sphinx-rtd-theme>=1; extra == "docs"
45
+ Requires-Dist: myst-parser>=2; extra == "docs"
46
+ Provides-Extra: dev
47
+ Requires-Dist: stratstat[all,docs]; extra == "dev"
48
+ Requires-Dist: pytest>=7.0; extra == "dev"
49
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
50
+ Requires-Dist: ruff>=0.1; extra == "dev"
51
+ Requires-Dist: mypy>=1.0; extra == "dev"
52
+ Dynamic: license-file
53
+
54
+ # StratStat
55
+
56
+ [![CI](https://github.com/aineurog/stratstat/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/aineurog/stratstat/actions/workflows/ci.yml)
57
+ [![PyPI](https://img.shields.io/pypi/v/stratstat.svg)](https://pypi.org/project/stratstat/)
58
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
59
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
60
+
61
+ Strategy evaluation statistics for Python. One library that replaces
62
+ `empyrical`, `pyfolio`, and `QuantStats` with more metrics, a cleaner API, and
63
+ faster computation.
64
+
65
+ StratStat computes 176 statistics across five input tiers. Give it a return
66
+ series, a trade log, positions, a benchmark, or several strategies, and it
67
+ returns typed results with the formula and its citation attached to every
68
+ number.
69
+
70
+ > **Status:** early release, version 0.1.0. The metric and report APIs work
71
+ > today, but several planned features are not implemented yet, including batch
72
+ > strategy computation, resampling of irregular bars, and reconstruction of
73
+ > positions from a trade log. The public API may still change before 1.0.
74
+
75
+ ## Contents
76
+
77
+ - [Why StratStat](#why-stratstat)
78
+ - [Coming from empyrical, pyfolio, or QuantStats?](#coming-from-empyrical-pyfolio-or-quantstats)
79
+ - [Install](#install)
80
+ - [Getting started](#getting-started)
81
+ - [Metrics](#metrics)
82
+ - [Input containers](#input-containers)
83
+ - [Strategy and Comparison containers](#strategy-and-comparison-containers)
84
+ - [Resampling and Monte Carlo](#resampling-and-monte-carlo)
85
+ - [Reports](#reports)
86
+ - [Reference](#reference)
87
+ - [Architecture](#architecture)
88
+ - [Development](#development)
89
+ - [License](#license)
90
+
91
+ ## Why StratStat
92
+
93
+ Three libraries (`empyrical`, `pyfolio`, `QuantStats`) split strategy
94
+ evaluation across three incompatible APIs. StratStat is one library with more
95
+ metrics, one call shape, and the working shown on every number.
96
+
97
+ - **More coverage.** 176 metrics across five input tiers (returns, benchmark,
98
+ exposure, trades, compare). QuantStats exposes roughly 75.
99
+ - **Provenance on every result.** Every `MetricResult` carries its name,
100
+ category, annualization factor, and the citation for its formula, so you can
101
+ reproduce a number and defend it.
102
+ - **No engine lock in.** Pass numpy arrays, pandas objects, polars objects, or
103
+ plain dicts. The core runs on numpy only, no scipy, so it works on a headless
104
+ server.
105
+ - **Built to extend.** Register a metric with one decorator and it works in
106
+ `compute`, `compute_all`, rolling windows, tear sheets, and reports.
107
+
108
+ ## Coming from empyrical, pyfolio, or QuantStats?
109
+
110
+ | You use | The StratStat equivalent |
111
+ |---|---|
112
+ | `empyrical.sharpe_ratio(returns)` | `stratstat.compute(returns, "sharpe_ratio", periods_per_year=252)` |
113
+ | `pyfolio.timeseries.perf_stats(returns)` | `stratstat.compute_returns(returns, periods_per_year=252)` |
114
+ | `quantstats.reports.metrics(mode="full")` | `stratstat.compute_all(returns, periods_per_year=252)` |
115
+
116
+ The quickest tour is `python examples/00_quickstart.py`. For a metric by metric
117
+ comparison against QuantStats see `examples/06_quantstats_comparison.py`, and
118
+ for wall clock timing see `examples/08_timing_benchmark.py`.
119
+
120
+ ## Install
121
+
122
+ ```bash
123
+ pip install stratstat # numpy and pandas
124
+ pip install stratstat[polars] # polars Series and DataFrame input
125
+ pip install stratstat[fast] # numba acceleration for bootstraps
126
+ pip install stratstat[report] # plotly charts, tear sheets, dashboards
127
+ pip install stratstat[image] # static image export (PNG, SVG)
128
+ pip install stratstat[pdf] # PDF report export
129
+ pip install stratstat[all] # everything
130
+ ```
131
+
132
+ Python 3.10 or later.
133
+
134
+ ## Getting started
135
+
136
+ Every tier has one entry point. The snippets below are self contained and
137
+ runnable as they are. They use synthetic data, so nothing has to be
138
+ downloaded. Start with returns, then add the other tiers as your data allows.
139
+
140
+ ### Returns
141
+
142
+ ```python
143
+ import numpy as np
144
+ import stratstat as ss
145
+
146
+ rng = np.random.default_rng(42)
147
+ returns = rng.normal(0.0004, 0.01, size=252) # 252 daily returns
148
+
149
+ # One metric
150
+ result = ss.compute(returns, "sharpe_ratio", periods_per_year=252)
151
+ print(result)
152
+ # MetricResult(name='sharpe_ratio', value=-0.14, category=('risk_adjusted', 'returns'))
153
+
154
+ # Every metric in one category
155
+ risk = ss.compute_all(returns, category="risk", periods_per_year=252)
156
+
157
+ # Every returns tier metric
158
+ all_returns = ss.compute_returns(returns, periods_per_year=252)
159
+
160
+ # Any metric over a rolling window, or per market regime
161
+ ss.rolling(returns, "sharpe_ratio", window=60, periods_per_year=252)
162
+ ss.by_regime(returns, "cagr", np.where(returns > 0, "up", "down"), periods_per_year=252)
163
+
164
+ # Discover what is available
165
+ for m in ss.list_metrics():
166
+ print(m["name"], m["category"], m["requires"])
167
+ ```
168
+
169
+ ### Benchmark
170
+
171
+ ```python
172
+ bench = rng.normal(0.0003, 0.008, size=252)
173
+ bm = ss.compute_benchmark(returns, bench, periods_per_year=252)
174
+ print(bm["alpha"], bm["beta"], bm["information_ratio"])
175
+ ```
176
+
177
+ ### Trades
178
+
179
+ ```python
180
+ trades = {
181
+ "pnl": [0.02, -0.01, 0.03, 0.015, -0.02, 0.01],
182
+ "side": ["long", "short", "long", "long", "short", "long"],
183
+ "duration": [5, 3, 8, 4, 2, 6],
184
+ }
185
+ trade_stats = ss.compute_trades(trades, periods_per_year=252)
186
+ print(trade_stats["win_rate"], trade_stats["profit_factor"])
187
+ ```
188
+
189
+ `pnl` is the only required column. `side` unlocks the long and short
190
+ breakdowns; `duration` unlocks the holding period metrics. See the
191
+ [data contract](docs/usage-guide.md#data-contract) for the rest.
192
+
193
+ ### Exposure
194
+
195
+ ```python
196
+ positions = rng.normal(0.05, 0.30, size=(252, 4)) # 252 periods, 4 assets
197
+ exposure = ss.compute_exposure(positions, periods_per_year=252)
198
+ print(exposure["long_exposure_pct"], exposure["short_exposure_pct"])
199
+ print(exposure["effective_n_positions"], exposure["turnover"])
200
+ ```
201
+
202
+ Metrics that need inputs beyond positions (leverage, long and short beta,
203
+ active share) are skipped here and named in `exposure.meta["skipped"]`. Pass
204
+ `asset_returns`, `benchmark`, and `benchmark_weights` to unlock them.
205
+
206
+ ### Compare
207
+
208
+ ```python
209
+ a = rng.normal(0.0004, 0.01, size=252)
210
+ b = rng.normal(0.0003, 0.012, size=252)
211
+ cmp = ss.compute_compare(np.column_stack([a, b]), periods_per_year=252)
212
+ print(cmp["correlation_matrix"], cmp["diversification_ratio"])
213
+ ```
214
+
215
+ Compare metrics are tagged with the primary category `relative`, so filter
216
+ them with `category="relative"` rather than `"compare"`.
217
+
218
+ ### Everything at once
219
+
220
+ ```python
221
+ everything = ss.compute_all(
222
+ returns,
223
+ trades=trades,
224
+ benchmark=bench,
225
+ exposure=positions,
226
+ periods_per_year=252,
227
+ )
228
+ ```
229
+
230
+ Each tier runs only when its data is present. `everything.meta` records what
231
+ was skipped, excluded, and deduplicated, so nothing is dropped silently.
232
+
233
+ ## Metrics
234
+
235
+ 176 metrics across eight categories. Each returns a `MetricResult` with a
236
+ `meta["ref"]` citation. The full list with formulas is in the
237
+ [formula reference](docs/formula-reference.md).
238
+
239
+ | Category | Count | What it measures | Example metrics |
240
+ |---|---|---|---|
241
+ | Descriptive | 27 | Distribution and summary of returns | `cagr`, `annualized_volatility`, `skewness` |
242
+ | Risk | 24 | Downside, tail, and drawdown risk | `max_drawdown`, `var`, `cvar` |
243
+ | Risk adjusted | 23 | Return per unit of risk | `sharpe_ratio`, `sortino_ratio`, `calmar_ratio` |
244
+ | Inference | 14 | Confidence and significance of performance | `psr`, `sharpe_ci_analytic`, `bias_ratio` |
245
+ | Benchmark | 20 | Performance relative to a benchmark | `alpha`, `beta`, `information_ratio` |
246
+ | Exposure | 24 | Position and book structure | `gross_exposure`, `net_exposure`, `turnover` |
247
+ | Trades | 37 | Round trip and trade log statistics | `win_rate`, `profit_factor`, `expectancy` |
248
+ | Compare | 7 | Several strategies side by side | `correlation_matrix`, `diversification_ratio`, `pbo` |
249
+
250
+ `rolling(metric_name, window)` slides any metric over time, and
251
+ `by_regime(metric_name, labels)` computes any metric per regime. Filter the
252
+ full list with `ss.list_metrics()`, or compute one category with
253
+ `ss.compute_all(returns, category="risk")`.
254
+
255
+ ## Input containers
256
+
257
+ Each tier reads a specific input shape. StratStat normalizes numpy arrays,
258
+ pandas objects, polars objects, and plain dicts into typed containers, so you
259
+ can pass data directly or wrap it yourself.
260
+
261
+ | Container | Tier | What it holds |
262
+ |---|---|---|
263
+ | `ReturnsInput` | returns | One or several return series |
264
+ | `BenchmarkInput` | benchmark | Strategy returns plus a benchmark series |
265
+ | `ExposureInput` | exposure | Position weights, optional asset returns and benchmark weights |
266
+ | `TradeInput` | trades | A trade log with `pnl` and optional columns |
267
+ | `CompareInput` | compare | Several strategy return columns |
268
+
269
+ Both forms work:
270
+
271
+ ```python
272
+ ss.compute(returns_array, "sharpe_ratio", periods_per_year=252)
273
+ ss.compute(ss.ReturnsInput(returns_array, periods_per_year=252), "sharpe_ratio")
274
+ ```
275
+
276
+ Every tier also has its own entry point:
277
+
278
+ ```python
279
+ ss.compute_returns(returns, periods_per_year=252)
280
+ ss.compute_benchmark(returns, bench, periods_per_year=252)
281
+ ss.compute_exposure(positions, asset_returns=asset_returns, periods_per_year=252)
282
+ ss.compute_trades(trades, periods_per_year=252)
283
+ ss.compute_compare(np.column_stack([a, b]), periods_per_year=252)
284
+ ```
285
+
286
+ ## Strategy and Comparison containers
287
+
288
+ A `Strategy` holds one strategy's inputs once and caches the derived quantities
289
+ several metrics share, the equity curve, the running maximum, the drawdown
290
+ series, and the drawdown episodes, so they are computed once, not per metric.
291
+
292
+ ```python
293
+ s = ss.Strategy(
294
+ returns=returns,
295
+ trades=trades,
296
+ benchmark=bench,
297
+ periods_per_year=252,
298
+ )
299
+ s.compute_all() # every metric the inputs support
300
+ s.compute("risk") # one category
301
+ s.report("strategy.html")
302
+ ```
303
+
304
+ When `returns` and `trades` are both present, construction also reconciles the
305
+ trade log against the equity curve and warns if the two do not agree. The
306
+ figures are kept on `s.reconciliation`.
307
+
308
+ A `Comparison` stacks several period aligned return series into one matrix and
309
+ runs the vectorized engine once, then slices per strategy.
310
+
311
+ ```python
312
+ c = ss.Comparison({"a": a, "b": b}, periods_per_year=252)
313
+ c.compute_all()
314
+ c["a"].compute("risk")
315
+ c.labels
316
+ ```
317
+
318
+ ## Resampling and Monte Carlo
319
+
320
+ The inference tier ships resampling metrics with a numba fast path and a numpy
321
+ fallback that agree within floating point tolerance.
322
+
323
+ ```python
324
+ ci = ss.compute(
325
+ returns,
326
+ "block_bootstrap_ci",
327
+ target_metric="sharpe_ratio",
328
+ n_reps=5000,
329
+ random_seed=42,
330
+ )
331
+ print(ci.value) # [lower, upper]
332
+
333
+ dist = ss.compute(returns, "monte_carlo_distribution", target="sharpe", sims=1000)
334
+ print(dist.value) # [min, p05, median, mean, p95, max, std]
335
+
336
+ probs = ss.compute(returns, "monte_carlo_probabilities", bust=-0.20, goal=0.20)
337
+ print(probs.value) # [p_bust, p_goal]
338
+ ```
339
+
340
+ `compute_all` runs the analytic metrics and records the resampling metrics it
341
+ leaves out in `meta["excluded_resampling"]`, so you can run them explicitly with
342
+ `compute` when you want them. Nothing is dropped silently.
343
+
344
+ ## Reports
345
+
346
+ The reporting layer is an optional extra that depends on core, never the other
347
+ way around. Install it with `pip install stratstat[report]`.
348
+
349
+ ```python
350
+ from stratstat.report import tear_sheet, dashboard, generate_report
351
+
352
+ # A single strategy tear sheet
353
+ tear_sheet(returns, benchmark=bench, periods_per_year=252).show()
354
+
355
+ # A multi strategy dashboard
356
+ dashboard(np.column_stack([a, b]), periods_per_year=252).show()
357
+
358
+ # A standalone HTML report on disk
359
+ generate_report(
360
+ returns,
361
+ "report.html",
362
+ benchmark=bench,
363
+ positions=positions,
364
+ trades=trades,
365
+ periods_per_year=252,
366
+ title="My Strategy",
367
+ )
368
+ ```
369
+
370
+ `generate_report` writes one file with tabs for overview, performance,
371
+ exposure, trades, and benchmark. Each tab pulls its numbers from the registry,
372
+ so the methodology section lists the citations for exactly the metrics that were
373
+ computed. Export helpers cover HTML, image, markdown, LaTeX, and JSON.
374
+
375
+ ## Reference
376
+
377
+ The details that rarely change are documented separately so the README stays a
378
+ quick start.
379
+
380
+ - [Formula reference](docs/formula-reference.md) — every metric's formula and
381
+ citation.
382
+ - [Data contract](docs/usage-guide.md#data-contract) — required and optional
383
+ trade log columns, units, and excursion precedence.
384
+ - [Column mapping](docs/usage-guide.md#column-mapping) — mapping your column
385
+ names to the contract with a `Schema`.
386
+ - [Conventions](docs/usage-guide.md#conventions) — the parameters that choose
387
+ between legitimate formula variants.
388
+ - [Custom metrics](docs/usage-guide.md#custom-metrics) — registering your own
389
+ metric.
390
+
391
+ The full documentation builds from `docs/` with Sphinx.
392
+
393
+ ## Architecture
394
+
395
+ ```
396
+ src/stratstat/
397
+ core/ # pure computation, numpy only
398
+ _utils.py # shared helpers
399
+ returns/
400
+ descriptive.py # 27 metrics
401
+ risk.py # 24 metrics
402
+ risk_adjusted.py # 23 metrics
403
+ inference.py # 14 metrics
404
+ wrappers.py # rolling, by_regime
405
+ benchmark.py # 20 metrics
406
+ exposure.py # 24 metrics
407
+ trades.py # 37 metrics
408
+ compare.py # 7 metrics
409
+ report/ # plotly, optional extra
410
+ inputs.py # input containers
411
+ results.py # MetricResult, MetricSet
412
+ registry.py # register_metric, compute
413
+ schema.py # Schema, column mapping
414
+ container.py # Strategy, Comparison
415
+ conventions.py # session defaults
416
+ ```
417
+
418
+ `core` never imports `plotly`, `matplotlib`, or `stratstat.report`. The boundary
419
+ is enforced by a CI test, so you can run StratStat on a headless server with no
420
+ graphics libraries. There is no scipy dependency either: the normal distribution
421
+ functions are implemented in numpy. Every metric has a single implementation in
422
+ `core` that the tear sheet and HTML report call through the registry, so a
423
+ formula is fixed once and fixed everywhere.
424
+
425
+ ## Development
426
+
427
+ ```bash
428
+ git clone https://github.com/aineurog/stratstat.git
429
+ cd stratstat
430
+ pip install -e ".[dev]"
431
+
432
+ pytest tests/ -q
433
+ ruff check src/ tests/
434
+ mypy src/
435
+ ```
436
+
437
+ ## License
438
+
439
+ MIT. See [LICENSE](LICENSE).