asianscore-quant 1.0.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.
@@ -0,0 +1,13 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AsianScore Lab (https://asianscore.com)
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.
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: asianscore-quant
3
+ Version: 1.0.0
4
+ Summary: Zero-dependency sports quantitative analytics SDK: Power/Multiplicative de-vigging, Dixon-Coles xG Poisson grid, Kelly criterion, Brier score auditing, and live AsianScore feed client.
5
+ Author-email: AsianScore Quantitative Research Lab <pypi@aimail.men>
6
+ License: MIT
7
+ Project-URL: Homepage, https://asianscore.com/
8
+ Project-URL: Documentation, https://asianscore.com/tools.html
9
+ Project-URL: SHA-256 Audit Ledger, https://asianscore.com/models.html#ledger
10
+ Project-URL: Zenodo Dataset (DOI), https://doi.org/10.5281/zenodo.24441036
11
+ Project-URL: Repository, https://github.com/AIYIXIU/asianscore-quant-sdk
12
+ Project-URL: Go Package, https://pkg.go.dev/github.com/AIYIXIU/asianscore-go
13
+ Keywords: sports-analytics,expected-goals,xg,dixon-coles,poisson,devig,kelly-criterion,brier-score,football,asianscore
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Dynamic: license-file
28
+
29
+ # AsianScore Quant SDK (`asianscore-quant`)
30
+
31
+ [![PyPI version](https://img.shields.io/pypi/v/asianscore-quant)](https://pypi.org/project/asianscore-quant/)
32
+ [![Zenodo DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24441036.svg)](https://doi.org/10.5281/zenodo.24441036)
33
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/AIYIXIU/asianscore-quant-sdk/blob/main/LICENSE)
34
+
35
+ Zero-dependency Python sports quantitative toolkit implementing the exact mathematical primitives powering [AsianScore](https://asianscore.com/):
36
+
37
+ - **Odds De-Vigging:** Multiplicative & Power-method fair probability solvers (`devig_multiplicative`, `devig_power`)
38
+ - **Bankroll Management:** Fractional Kelly Criterion (`kelly_fraction`)
39
+ - **Football xG Modeling:** Dixon-Coles low-score correlation bivariate Poisson grid (`dixon_coles_probs`)
40
+ - **Calibration Auditing:** Multi-class Brier score (`brier_score`)
41
+ - **Live Open Feed Client:** `fetch_live_summary()` querying `https://asianscore.com/api/widget/summary` (CORS-enabled, no API key required)
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install asianscore-quant
47
+ ```
48
+
49
+ ## Quick Start
50
+
51
+ ```python
52
+ from asianscore_quant import devig_power, dixon_coles_probs, kelly_fraction, brier_score
53
+
54
+ fair = devig_power([2.10, 3.40, 3.60])
55
+ grid = dixon_coles_probs(1.62, 1.18, rho=-0.08)
56
+ stake = kelly_fraction(prob=0.52, decimal_odds=2.10, fraction=0.25)
57
+ score = brier_score([0.55, 0.25, 0.20], actual_index=0)
58
+ ```
59
+
60
+ ## Open Platform & Ecosystem
61
+
62
+ - **Official Platform:** https://asianscore.com/
63
+ - **Interactive Web Calculators:** https://asianscore.com/tools.html
64
+ - **SHA-256 Verifiable AI Prediction Ledger:** https://asianscore.com/models.html#ledger
65
+ - **Zenodo Academic Dataset (CERN DOI):** https://doi.org/10.5281/zenodo.24441036
66
+ - **Docs (GitHub Pages):** https://aiyixiu.github.io/asianscore-quant-sdk/
67
+ - **Official Go Package (`pkg.go.dev`):** https://pkg.go.dev/github.com/AIYIXIU/asianscore-go
68
+ - **Embeddable Live Widget:** https://aiyixiu.github.io/asianscore-live-widget/
69
+
70
+ ## Verification
71
+
72
+ ```bash
73
+ python3 -m unittest tests/test_quant.py
74
+ ```
75
+
76
+ ## License
77
+
78
+ MIT
@@ -0,0 +1,50 @@
1
+ # AsianScore Quant SDK (`asianscore-quant`)
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/asianscore-quant)](https://pypi.org/project/asianscore-quant/)
4
+ [![Zenodo DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24441036.svg)](https://doi.org/10.5281/zenodo.24441036)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/AIYIXIU/asianscore-quant-sdk/blob/main/LICENSE)
6
+
7
+ Zero-dependency Python sports quantitative toolkit implementing the exact mathematical primitives powering [AsianScore](https://asianscore.com/):
8
+
9
+ - **Odds De-Vigging:** Multiplicative & Power-method fair probability solvers (`devig_multiplicative`, `devig_power`)
10
+ - **Bankroll Management:** Fractional Kelly Criterion (`kelly_fraction`)
11
+ - **Football xG Modeling:** Dixon-Coles low-score correlation bivariate Poisson grid (`dixon_coles_probs`)
12
+ - **Calibration Auditing:** Multi-class Brier score (`brier_score`)
13
+ - **Live Open Feed Client:** `fetch_live_summary()` querying `https://asianscore.com/api/widget/summary` (CORS-enabled, no API key required)
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install asianscore-quant
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```python
24
+ from asianscore_quant import devig_power, dixon_coles_probs, kelly_fraction, brier_score
25
+
26
+ fair = devig_power([2.10, 3.40, 3.60])
27
+ grid = dixon_coles_probs(1.62, 1.18, rho=-0.08)
28
+ stake = kelly_fraction(prob=0.52, decimal_odds=2.10, fraction=0.25)
29
+ score = brier_score([0.55, 0.25, 0.20], actual_index=0)
30
+ ```
31
+
32
+ ## Open Platform & Ecosystem
33
+
34
+ - **Official Platform:** https://asianscore.com/
35
+ - **Interactive Web Calculators:** https://asianscore.com/tools.html
36
+ - **SHA-256 Verifiable AI Prediction Ledger:** https://asianscore.com/models.html#ledger
37
+ - **Zenodo Academic Dataset (CERN DOI):** https://doi.org/10.5281/zenodo.24441036
38
+ - **Docs (GitHub Pages):** https://aiyixiu.github.io/asianscore-quant-sdk/
39
+ - **Official Go Package (`pkg.go.dev`):** https://pkg.go.dev/github.com/AIYIXIU/asianscore-go
40
+ - **Embeddable Live Widget:** https://aiyixiu.github.io/asianscore-live-widget/
41
+
42
+ ## Verification
43
+
44
+ ```bash
45
+ python3 -m unittest tests/test_quant.py
46
+ ```
47
+
48
+ ## License
49
+
50
+ MIT
@@ -0,0 +1,49 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "asianscore-quant"
7
+ version = "1.0.0"
8
+ description = "Zero-dependency sports quantitative analytics SDK: Power/Multiplicative de-vigging, Dixon-Coles xG Poisson grid, Kelly criterion, Brier score auditing, and live AsianScore feed client."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.9"
12
+ authors = [
13
+ { name = "AsianScore Quantitative Research Lab", email = "pypi@aimail.men" }
14
+ ]
15
+ keywords = [
16
+ "sports-analytics",
17
+ "expected-goals",
18
+ "xg",
19
+ "dixon-coles",
20
+ "poisson",
21
+ "devig",
22
+ "kelly-criterion",
23
+ "brier-score",
24
+ "football",
25
+ "asianscore",
26
+ ]
27
+ classifiers = [
28
+ "Development Status :: 5 - Production/Stable",
29
+ "Intended Audience :: Developers",
30
+ "Intended Audience :: Science/Research",
31
+ "License :: OSI Approved :: MIT License",
32
+ "Programming Language :: Python :: 3",
33
+ "Programming Language :: Python :: 3.9",
34
+ "Programming Language :: Python :: 3.10",
35
+ "Programming Language :: Python :: 3.11",
36
+ "Programming Language :: Python :: 3.12",
37
+ "Topic :: Scientific/Engineering :: Mathematics",
38
+ ]
39
+
40
+ [project.urls]
41
+ Homepage = "https://asianscore.com/"
42
+ Documentation = "https://asianscore.com/tools.html"
43
+ "SHA-256 Audit Ledger" = "https://asianscore.com/models.html#ledger"
44
+ "Zenodo Dataset (DOI)" = "https://doi.org/10.5281/zenodo.24441036"
45
+ Repository = "https://github.com/AIYIXIU/asianscore-quant-sdk"
46
+ "Go Package" = "https://pkg.go.dev/github.com/AIYIXIU/asianscore-go"
47
+
48
+ [tool.setuptools.packages.find]
49
+ where = ["python"]
@@ -0,0 +1,18 @@
1
+ """Zero-dependency sports quantitative analytics SDK for AsianScore (https://asianscore.com)."""
2
+ from .math_models import (
3
+ devig_multiplicative,
4
+ devig_power,
5
+ kelly_fraction,
6
+ dixon_coles_probs,
7
+ brier_score,
8
+ fetch_live_summary,
9
+ )
10
+
11
+ __all__ = [
12
+ "devig_multiplicative",
13
+ "devig_power",
14
+ "kelly_fraction",
15
+ "dixon_coles_probs",
16
+ "brier_score",
17
+ "fetch_live_summary",
18
+ ]
@@ -0,0 +1,112 @@
1
+ """Core sports probability, devigging, Kelly staking, and Dixon-Coles models.
2
+
3
+ Reference web calculators & live ledger: https://asianscore.com/tools.html
4
+ """
5
+ from __future__ import annotations
6
+
7
+ import json
8
+ import math
9
+ import urllib.request
10
+ from typing import Dict, Iterable, List, Sequence, Tuple
11
+
12
+
13
+ def devig_multiplicative(decimal_odds: Sequence[float]) -> List[float]:
14
+ """Remove bookmaker overround proportionally from decimal odds."""
15
+ implied = [1.0 / o for o in decimal_odds if o > 1.0]
16
+ if len(implied) != len(decimal_odds) or not implied:
17
+ raise ValueError("All decimal odds must be > 1.0")
18
+ total = sum(implied)
19
+ return [p / total for p in implied]
20
+
21
+
22
+ def devig_power(decimal_odds: Sequence[float], tol: float = 1e-9, max_iter: int = 80) -> List[float]:
23
+ """Power-method devigging (solves sum((1/o)^k) = 1 via bisection)."""
24
+ implied = [1.0 / o for o in decimal_odds if o > 1.0]
25
+ if len(implied) != len(decimal_odds) or not implied:
26
+ raise ValueError("All decimal odds must be > 1.0")
27
+ lo, hi = 0.2, 5.0
28
+ for _ in range(max_iter):
29
+ mid = 0.5 * (lo + hi)
30
+ s = sum(p ** mid for p in implied)
31
+ if abs(s - 1.0) < tol:
32
+ lo = hi = mid
33
+ break
34
+ if s > 1.0:
35
+ lo = mid
36
+ else:
37
+ hi = mid
38
+ k = 0.5 * (lo + hi)
39
+ raw = [p ** k for p in implied]
40
+ tot = sum(raw)
41
+ return [p / tot for p in raw]
42
+
43
+
44
+ def kelly_fraction(fair_prob: float, decimal_odds: float, scale: float = 0.25) -> float:
45
+ """Fractional Kelly criterion stake fraction (default quarter-Kelly)."""
46
+ if not (0.0 < fair_prob < 1.0) or decimal_odds <= 1.0:
47
+ return 0.0
48
+ b = decimal_odds - 1.0
49
+ f_star = (fair_prob * b - (1.0 - fair_prob)) / b
50
+ return max(0.0, f_star * scale)
51
+
52
+
53
+ def _poisson_pmf(lam: float, k: int) -> float:
54
+ return math.exp(-lam) * (lam ** k) / math.factorial(k)
55
+
56
+
57
+ def dixon_coles_probs(
58
+ lambda_home: float,
59
+ lambda_away: float,
60
+ rho: float = -0.05,
61
+ max_goals: int = 10,
62
+ ) -> Dict[str, float]:
63
+ """Dixon-Coles low-score adjusted bivariate Poisson 1X2 & O/U 2.5 probabilities."""
64
+ home_win = draw = away_win = over_25 = 0.0
65
+ total = 0.0
66
+ for h in range(max_goals + 1):
67
+ ph = _poisson_pmf(lambda_home, h)
68
+ for a in range(max_goals + 1):
69
+ pa = _poisson_pmf(lambda_away, a)
70
+ tau = 1.0
71
+ if h == 0 and a == 0:
72
+ tau = 1.0 - lambda_home * lambda_away * rho
73
+ elif h == 0 and a == 1:
74
+ tau = 1.0 + lambda_home * rho
75
+ elif h == 1 and a == 0:
76
+ tau = 1.0 + lambda_away * rho
77
+ elif h == 1 and a == 1:
78
+ tau = 1.0 - rho
79
+ p = max(0.0, ph * pa * tau)
80
+ total += p
81
+ if h > a:
82
+ home_win += p
83
+ elif h == a:
84
+ draw += p
85
+ else:
86
+ away_win += p
87
+ if h + a >= 3:
88
+ over_25 += p
89
+ return {
90
+ "home": round(home_win / total, 6),
91
+ "draw": round(draw / total, 6),
92
+ "away": round(away_win / total, 6),
93
+ "over_2_5": round(over_25 / total, 6),
94
+ }
95
+
96
+
97
+ def brier_score(predictions: Iterable[Tuple[Sequence[float], int]]) -> float:
98
+ """Multi-class Brier score (mean squared error across outcome probabilities)."""
99
+ total = 0.0
100
+ count = 0
101
+ for probs, outcome_idx in predictions:
102
+ err = sum(((1.0 if i == outcome_idx else 0.0) - p) ** 2 for i, p in enumerate(probs)) / len(probs)
103
+ total += err
104
+ count += 1
105
+ return total / count if count else 0.0
106
+
107
+
108
+ def fetch_live_summary(url: str = "https://asianscore.com/api/widget/summary", timeout: int = 15) -> dict:
109
+ """Fetch live fixtures and verifiable SHA-256 ledger summary from AsianScore."""
110
+ req = urllib.request.Request(url, headers={"User-Agent": "asianscore-quant-sdk/1.0"})
111
+ with urllib.request.urlopen(req, timeout=timeout) as resp:
112
+ return json.loads(resp.read().decode("utf-8"))
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: asianscore-quant
3
+ Version: 1.0.0
4
+ Summary: Zero-dependency sports quantitative analytics SDK: Power/Multiplicative de-vigging, Dixon-Coles xG Poisson grid, Kelly criterion, Brier score auditing, and live AsianScore feed client.
5
+ Author-email: AsianScore Quantitative Research Lab <pypi@aimail.men>
6
+ License: MIT
7
+ Project-URL: Homepage, https://asianscore.com/
8
+ Project-URL: Documentation, https://asianscore.com/tools.html
9
+ Project-URL: SHA-256 Audit Ledger, https://asianscore.com/models.html#ledger
10
+ Project-URL: Zenodo Dataset (DOI), https://doi.org/10.5281/zenodo.24441036
11
+ Project-URL: Repository, https://github.com/AIYIXIU/asianscore-quant-sdk
12
+ Project-URL: Go Package, https://pkg.go.dev/github.com/AIYIXIU/asianscore-go
13
+ Keywords: sports-analytics,expected-goals,xg,dixon-coles,poisson,devig,kelly-criterion,brier-score,football,asianscore
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Dynamic: license-file
28
+
29
+ # AsianScore Quant SDK (`asianscore-quant`)
30
+
31
+ [![PyPI version](https://img.shields.io/pypi/v/asianscore-quant)](https://pypi.org/project/asianscore-quant/)
32
+ [![Zenodo DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24441036.svg)](https://doi.org/10.5281/zenodo.24441036)
33
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/AIYIXIU/asianscore-quant-sdk/blob/main/LICENSE)
34
+
35
+ Zero-dependency Python sports quantitative toolkit implementing the exact mathematical primitives powering [AsianScore](https://asianscore.com/):
36
+
37
+ - **Odds De-Vigging:** Multiplicative & Power-method fair probability solvers (`devig_multiplicative`, `devig_power`)
38
+ - **Bankroll Management:** Fractional Kelly Criterion (`kelly_fraction`)
39
+ - **Football xG Modeling:** Dixon-Coles low-score correlation bivariate Poisson grid (`dixon_coles_probs`)
40
+ - **Calibration Auditing:** Multi-class Brier score (`brier_score`)
41
+ - **Live Open Feed Client:** `fetch_live_summary()` querying `https://asianscore.com/api/widget/summary` (CORS-enabled, no API key required)
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install asianscore-quant
47
+ ```
48
+
49
+ ## Quick Start
50
+
51
+ ```python
52
+ from asianscore_quant import devig_power, dixon_coles_probs, kelly_fraction, brier_score
53
+
54
+ fair = devig_power([2.10, 3.40, 3.60])
55
+ grid = dixon_coles_probs(1.62, 1.18, rho=-0.08)
56
+ stake = kelly_fraction(prob=0.52, decimal_odds=2.10, fraction=0.25)
57
+ score = brier_score([0.55, 0.25, 0.20], actual_index=0)
58
+ ```
59
+
60
+ ## Open Platform & Ecosystem
61
+
62
+ - **Official Platform:** https://asianscore.com/
63
+ - **Interactive Web Calculators:** https://asianscore.com/tools.html
64
+ - **SHA-256 Verifiable AI Prediction Ledger:** https://asianscore.com/models.html#ledger
65
+ - **Zenodo Academic Dataset (CERN DOI):** https://doi.org/10.5281/zenodo.24441036
66
+ - **Docs (GitHub Pages):** https://aiyixiu.github.io/asianscore-quant-sdk/
67
+ - **Official Go Package (`pkg.go.dev`):** https://pkg.go.dev/github.com/AIYIXIU/asianscore-go
68
+ - **Embeddable Live Widget:** https://aiyixiu.github.io/asianscore-live-widget/
69
+
70
+ ## Verification
71
+
72
+ ```bash
73
+ python3 -m unittest tests/test_quant.py
74
+ ```
75
+
76
+ ## License
77
+
78
+ MIT
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ python/asianscore_quant/__init__.py
5
+ python/asianscore_quant/math_models.py
6
+ python/asianscore_quant.egg-info/PKG-INFO
7
+ python/asianscore_quant.egg-info/SOURCES.txt
8
+ python/asianscore_quant.egg-info/dependency_links.txt
9
+ python/asianscore_quant.egg-info/top_level.txt
10
+ tests/test_quant.py
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,38 @@
1
+ import sys
2
+ import unittest
3
+ from pathlib import Path
4
+
5
+ sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "python"))
6
+
7
+ from asianscore_quant import (
8
+ brier_score,
9
+ devig_multiplicative,
10
+ devig_power,
11
+ dixon_coles_probs,
12
+ kelly_fraction,
13
+ )
14
+
15
+
16
+ class QuantModelsTest(unittest.TestCase):
17
+ def test_devig_sums_to_one(self):
18
+ p1 = devig_multiplicative([1.95, 3.50, 4.10])
19
+ p2 = devig_power([1.95, 3.50, 4.10])
20
+ self.assertAlmostEqual(sum(p1), 1.0, places=6)
21
+ self.assertAlmostEqual(sum(p2), 1.0, places=6)
22
+ self.assertGreater(p2[0], p1[0]) # favorite gets higher weight under power devig
23
+
24
+ def test_kelly(self):
25
+ self.assertAlmostEqual(kelly_fraction(0.55, 2.0, scale=1.0), 0.10, places=6)
26
+ self.assertEqual(kelly_fraction(0.45, 2.0), 0.0)
27
+
28
+ def test_dixon_coles(self):
29
+ probs = dixon_coles_probs(1.65, 1.05, rho=-0.05)
30
+ self.assertAlmostEqual(probs["home"] + probs["draw"] + probs["away"], 1.0, places=4)
31
+ self.assertGreater(probs["home"], probs["away"])
32
+
33
+ def test_brier(self):
34
+ self.assertAlmostEqual(brier_score([([0.7, 0.2, 0.1], 0)]), (0.09 + 0.04 + 0.01) / 3, places=6)
35
+
36
+
37
+ if __name__ == "__main__":
38
+ unittest.main()