cadlag-pro 0.1.0a1__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Cadlag contributors
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,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: cadlag-pro
3
+ Version: 0.1.0a1
4
+ Summary: Basic drawdown and volatility statistics for the Cadlag Mini educational toolkit
5
+ Author: Cadlag contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://cadlag.pro
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Education
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Dynamic: license-file
17
+
18
+ # cadlag-pro — Cadlag Mini
19
+
20
+ **Version 0.1.0a1 is an educational miniature written independently from scratch.**
21
+ It provides the small functionality described below. It does not provide the full
22
+ Cadlag platform and is not API-compatible with previous Cadlag distributions.
23
+ It is an alpha release for learning and experimentation, not live trading.
24
+
25
+ Basic drawdown and volatility statistics for the Cadlag Mini educational toolkit.
26
+
27
+ ## Usage
28
+
29
+ ```python
30
+ from cadlag_pro import max_drawdown, annualized_volatility
31
+ print(max_drawdown([100, 120, 90, 110])) # 0.25
32
+ print(annualized_volatility([100, 110, 99], periods_per_year=2)) # about 0.2
33
+ ```
34
+
35
+ Drawdown is a nonnegative fraction. Volatility uses the sample standard deviation
36
+ of simple returns and square-root annualization. Inputs must be positive and
37
+ finite, with evenly spaced observations for annualization. Fewer than two returns
38
+ produce zero volatility. The Mini edition contains only these basic statistics;
39
+ it does not include commercial platform features or a licensing system.
40
+
41
+
42
+ ## Package family
43
+
44
+ - `cadlag-sdk`: price records and CSV validation.
45
+ - `cadlag-ce`: a prior-close moving-average strategy and equity curve.
46
+ - `cadlag-starter`: synthetic sample prices and a runnable example.
47
+ - `cadlag-pro`: basic drawdown and volatility calculations.
48
+ - `cadlag-quant`: command-line bundle, with optional analytics extra.
49
+
50
+ All Mini components use version `0.1.0a1` and are MIT licensed. Only Python's
51
+ standard library is used beyond dependencies on other Mini components.
@@ -0,0 +1,34 @@
1
+ # cadlag-pro — Cadlag Mini
2
+
3
+ **Version 0.1.0a1 is an educational miniature written independently from scratch.**
4
+ It provides the small functionality described below. It does not provide the full
5
+ Cadlag platform and is not API-compatible with previous Cadlag distributions.
6
+ It is an alpha release for learning and experimentation, not live trading.
7
+
8
+ Basic drawdown and volatility statistics for the Cadlag Mini educational toolkit.
9
+
10
+ ## Usage
11
+
12
+ ```python
13
+ from cadlag_pro import max_drawdown, annualized_volatility
14
+ print(max_drawdown([100, 120, 90, 110])) # 0.25
15
+ print(annualized_volatility([100, 110, 99], periods_per_year=2)) # about 0.2
16
+ ```
17
+
18
+ Drawdown is a nonnegative fraction. Volatility uses the sample standard deviation
19
+ of simple returns and square-root annualization. Inputs must be positive and
20
+ finite, with evenly spaced observations for annualization. Fewer than two returns
21
+ produce zero volatility. The Mini edition contains only these basic statistics;
22
+ it does not include commercial platform features or a licensing system.
23
+
24
+
25
+ ## Package family
26
+
27
+ - `cadlag-sdk`: price records and CSV validation.
28
+ - `cadlag-ce`: a prior-close moving-average strategy and equity curve.
29
+ - `cadlag-starter`: synthetic sample prices and a runnable example.
30
+ - `cadlag-pro`: basic drawdown and volatility calculations.
31
+ - `cadlag-quant`: command-line bundle, with optional analytics extra.
32
+
33
+ All Mini components use version `0.1.0a1` and are MIT licensed. Only Python's
34
+ standard library is used beyond dependencies on other Mini components.
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "cadlag-pro"
7
+ version = "0.1.0a1"
8
+ description = "Basic drawdown and volatility statistics for the Cadlag Mini educational toolkit"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{name = "Cadlag contributors"}]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Education",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3 :: Only",
19
+ "Operating System :: OS Independent",
20
+ ]
21
+ dependencies = []
22
+
23
+ [project.urls]
24
+ Homepage = "https://cadlag.pro"
25
+
26
+ [tool.setuptools.packages.find]
27
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,47 @@
1
+ """Cadlag Mini analytics: ordinary drawdown and historical volatility."""
2
+ from __future__ import annotations
3
+
4
+ import math
5
+ from statistics import stdev
6
+ from typing import Iterable
7
+
8
+ __version__ = "0.1.0a1"
9
+
10
+
11
+ def _values(equity: Iterable[float]) -> tuple[float, ...]:
12
+ values = tuple(float(x) for x in equity)
13
+ if not values or any(not math.isfinite(x) or x <= 0 for x in values):
14
+ raise ValueError("equity must contain finite positive values")
15
+ return values
16
+
17
+
18
+ def max_drawdown(equity: Iterable[float]) -> float:
19
+ """Largest peak-to-trough loss as a nonnegative fraction (0.2 means 20%)."""
20
+ values = _values(equity)
21
+ peak, worst = values[0], 0.0
22
+ for value in values:
23
+ peak = max(peak, value)
24
+ worst = max(worst, 1.0 - value / peak)
25
+ return worst
26
+
27
+
28
+ def annualized_volatility(equity: Iterable[float], *, periods_per_year: int = 252) -> float:
29
+ """Sample standard deviation of simple returns times sqrt(periods_per_year).
30
+
31
+ Returns zero when there are fewer than two returns. Observations must be
32
+ evenly spaced; choose periods_per_year for that spacing (252 for trading days).
33
+ """
34
+ values = _values(equity)
35
+ if isinstance(periods_per_year, bool) or not isinstance(periods_per_year, int) or periods_per_year <= 0:
36
+ raise ValueError("periods_per_year must be a positive integer")
37
+ returns = [b / a - 1.0 for a, b in zip(values, values[1:])]
38
+ if any(not math.isfinite(x) for x in returns):
39
+ raise ValueError("equity range exceeds finite return arithmetic")
40
+ result = stdev(returns) * math.sqrt(periods_per_year) if len(returns) >= 2 else 0.0
41
+ if not math.isfinite(result):
42
+ raise ValueError("volatility exceeds finite arithmetic")
43
+ return result
44
+
45
+
46
+ __all__ = ["max_drawdown", "annualized_volatility"]
47
+
@@ -0,0 +1,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: cadlag-pro
3
+ Version: 0.1.0a1
4
+ Summary: Basic drawdown and volatility statistics for the Cadlag Mini educational toolkit
5
+ Author: Cadlag contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://cadlag.pro
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Education
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Dynamic: license-file
17
+
18
+ # cadlag-pro — Cadlag Mini
19
+
20
+ **Version 0.1.0a1 is an educational miniature written independently from scratch.**
21
+ It provides the small functionality described below. It does not provide the full
22
+ Cadlag platform and is not API-compatible with previous Cadlag distributions.
23
+ It is an alpha release for learning and experimentation, not live trading.
24
+
25
+ Basic drawdown and volatility statistics for the Cadlag Mini educational toolkit.
26
+
27
+ ## Usage
28
+
29
+ ```python
30
+ from cadlag_pro import max_drawdown, annualized_volatility
31
+ print(max_drawdown([100, 120, 90, 110])) # 0.25
32
+ print(annualized_volatility([100, 110, 99], periods_per_year=2)) # about 0.2
33
+ ```
34
+
35
+ Drawdown is a nonnegative fraction. Volatility uses the sample standard deviation
36
+ of simple returns and square-root annualization. Inputs must be positive and
37
+ finite, with evenly spaced observations for annualization. Fewer than two returns
38
+ produce zero volatility. The Mini edition contains only these basic statistics;
39
+ it does not include commercial platform features or a licensing system.
40
+
41
+
42
+ ## Package family
43
+
44
+ - `cadlag-sdk`: price records and CSV validation.
45
+ - `cadlag-ce`: a prior-close moving-average strategy and equity curve.
46
+ - `cadlag-starter`: synthetic sample prices and a runnable example.
47
+ - `cadlag-pro`: basic drawdown and volatility calculations.
48
+ - `cadlag-quant`: command-line bundle, with optional analytics extra.
49
+
50
+ All Mini components use version `0.1.0a1` and are MIT licensed. Only Python's
51
+ standard library is used beyond dependencies on other Mini components.
@@ -0,0 +1,8 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/cadlag_pro/__init__.py
5
+ src/cadlag_pro.egg-info/PKG-INFO
6
+ src/cadlag_pro.egg-info/SOURCES.txt
7
+ src/cadlag_pro.egg-info/dependency_links.txt
8
+ src/cadlag_pro.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ cadlag_pro