terminus-lab 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 (30) hide show
  1. terminus_lab-0.1.0/LICENSE +27 -0
  2. terminus_lab-0.1.0/PKG-INFO +167 -0
  3. terminus_lab-0.1.0/README.md +129 -0
  4. terminus_lab-0.1.0/pyproject.toml +53 -0
  5. terminus_lab-0.1.0/setup.cfg +4 -0
  6. terminus_lab-0.1.0/terminus/__init__.py +44 -0
  7. terminus_lab-0.1.0/terminus/cli.py +404 -0
  8. terminus_lab-0.1.0/terminus/fetch.py +169 -0
  9. terminus_lab-0.1.0/terminus/filter.py +211 -0
  10. terminus_lab-0.1.0/terminus/indicators.py +162 -0
  11. terminus_lab-0.1.0/terminus/ml/__init__.py +16 -0
  12. terminus_lab-0.1.0/terminus/ml/optim.py +248 -0
  13. terminus_lab-0.1.0/terminus/ml/regime.py +395 -0
  14. terminus_lab-0.1.0/terminus/portfolio.py +241 -0
  15. terminus_lab-0.1.0/terminus/registry.py +246 -0
  16. terminus_lab-0.1.0/terminus/risk/__init__.py +0 -0
  17. terminus_lab-0.1.0/terminus/risk/factor_model.py +382 -0
  18. terminus_lab-0.1.0/terminus/risk/metrics.py +216 -0
  19. terminus_lab-0.1.0/terminus/rules.py +395 -0
  20. terminus_lab-0.1.0/terminus/simulate.py +312 -0
  21. terminus_lab-0.1.0/terminus/store.py +516 -0
  22. terminus_lab-0.1.0/terminus/sweep.py +260 -0
  23. terminus_lab-0.1.0/terminus/telemetry.py +407 -0
  24. terminus_lab-0.1.0/terminus/walk_forward.py +251 -0
  25. terminus_lab-0.1.0/terminus_lab.egg-info/PKG-INFO +167 -0
  26. terminus_lab-0.1.0/terminus_lab.egg-info/SOURCES.txt +28 -0
  27. terminus_lab-0.1.0/terminus_lab.egg-info/dependency_links.txt +1 -0
  28. terminus_lab-0.1.0/terminus_lab.egg-info/entry_points.txt +2 -0
  29. terminus_lab-0.1.0/terminus_lab.egg-info/requires.txt +16 -0
  30. terminus_lab-0.1.0/terminus_lab.egg-info/top_level.txt +1 -0
@@ -0,0 +1,27 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Khaled
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.
22
+
23
+ Terminus is a research tool. It does not constitute financial advice. Past
24
+ performance in backtests does not guarantee future results. Trade at your
25
+ own risk. No warranty that strategies surviving Terminus will be profitable
26
+ in live markets. The authors are not responsible for trading losses, missed
27
+ opportunities, or decisions made using this software.
@@ -0,0 +1,167 @@
1
+ Metadata-Version: 2.4
2
+ Name: terminus-lab
3
+ Version: 0.1.0
4
+ Summary: End of All Trades — ruthless backtesting lab for long-only spot strategies.
5
+ Author: Stronex Labs
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Stronex-Labs/terminus
8
+ Project-URL: Documentation, https://github.com/Stronex-Labs/terminus/tree/main/docs
9
+ Project-URL: Issues, https://github.com/Stronex-Labs/terminus/issues
10
+ Keywords: backtest,crypto,trading,walk-forward,spot,halal,shariah,quantitative,strategy
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Financial and Insurance Industry
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Office/Business :: Financial :: Investment
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: numpy>=1.24
24
+ Requires-Dist: pandas>=2.0
25
+ Requires-Dist: pandas-ta>=0.3.14b
26
+ Requires-Dist: pyarrow>=10.0
27
+ Requires-Dist: httpx>=0.25
28
+ Requires-Dist: python-dotenv>=1.0
29
+ Provides-Extra: ml
30
+ Requires-Dist: xgboost>=2.0; extra == "ml"
31
+ Requires-Dist: scikit-learn>=1.3; extra == "ml"
32
+ Requires-Dist: httpx>=0.25; extra == "ml"
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7; extra == "dev"
35
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
36
+ Requires-Dist: ruff>=0.1; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ <p align="center">
40
+ <img src="assets/logo.png" alt="Terminus" width="320"/>
41
+ </p>
42
+
43
+ <h1 align="center">Terminus</h1>
44
+ <p align="center"><em>End of All Trades</em></p>
45
+
46
+ <p align="center">
47
+ <img src="https://img.shields.io/badge/python-3.10%2B-blue?style=flat-square" />
48
+ <img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" />
49
+ <img src="https://img.shields.io/badge/status-alpha-orange?style=flat-square" />
50
+ <img src="https://img.shields.io/badge/halal--first-spot%20only-gold?style=flat-square" />
51
+ <img src="https://img.shields.io/github/stars/Stronex-Labs/terminus?style=flat-square" />
52
+ </p>
53
+
54
+ <p align="center"><strong>Where strategies go to prove themselves — or die.</strong></p>
55
+
56
+ ---
57
+
58
+ Terminus is a pure Python backtesting engine built for one thing: **honest results**.
59
+
60
+ 8 years of market data. Year-by-year walk-forward with frozen parameters. Realistic fees and slippage. A content-hashed simulation store so you never burn compute twice.
61
+
62
+ Most backtesting tools let you cheat. Terminus doesn't.
63
+
64
+ ---
65
+
66
+ ## Why Terminus
67
+
68
+ - **Near-perfect walk-forward required** — frozen parameters tested year by year. At most 2 losing years tolerated, each no worse than −10%.
69
+ - **Bear years count** — 2022 was −64% on BTC. Your strategy survives that or it doesn't ship.
70
+ - **Multi-pair generalization required** — works on one pair? That's a curve fit. Terminus requires success across multiple pairs.
71
+ - **Realistic execution** — fees, entry slippage, stop slippage, TP slippage, timeout slippage, cooldowns, max-hold. Tiered by market cap.
72
+ - **Halal-first** — spot-only, no leverage, no shorts, no interest. Cash (stablecoin) is a valid position in bear regimes.
73
+ - **Content-hashed cache** — every sim keyed by `hash(pair + tf + config + date_range + slippage + fee)`. Same inputs = instant cache hit.
74
+
75
+ ---
76
+
77
+ ## Quickstart
78
+
79
+ ```bash
80
+ pip install terminus-lab
81
+
82
+ # Fetch 8 years of data
83
+ terminus fetch --pairs BTCUSDT,ETHUSDT,SOLUSDT --tfs 1h,4h,1d --days 2920
84
+
85
+ # Run the full sweep
86
+ terminus sweep
87
+
88
+ # Walk-forward the top candidates year-by-year
89
+ terminus walk-forward --top 15
90
+
91
+ # Generate the report
92
+ terminus report --min-calmar 1.5 --min-bear-return -5
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Example Output
98
+
99
+ ```
100
+ === TOP 15 SURVIVORS by ANNUALIZED return ===
101
+ Rank Pair TF Family Yrs TotalRet AnnRet Calmar Bear22
102
+ ----- ---------- ---- ----------------------- ---- -------- ------ ------ ------
103
+ 1 TIAUSDT 2h Ichi-bull+BTCreg 3/3 +90.7% +24.0% 2.77 -
104
+ 2 XRPUSDT 2h Ichi-bull+BTCreg 6/6 +213.5% +21.0% 5.68 +0.0%
105
+ 3 LTCUSDT 12h Ichi-bull+BTCreg 3/3 +70.1% +19.4% 4.28 +0.0%
106
+ 4 BNBUSDT 1h ROC10+BTCreg 5/5 +133.2% +18.4% 4.93 +0.0%
107
+ 5 SOLUSDT 4h ATR-brk 5/5 +130.6% +18.2% 7.86 +13.2%
108
+ ```
109
+
110
+ ---
111
+
112
+ ## What's Inside
113
+
114
+ | Module | What it does |
115
+ |--------|-------------|
116
+ | **Sweep engine** | Runs thousands of configs in parallel, skips cache hits |
117
+ | **Walk-forward** | Frozen / anchored / rolling — calendar-year folds |
118
+ | **Portfolio builder** | Correlation-capped leg selection, blended Sharpe/Calmar |
119
+ | **ML module** | XGBoost regime classifier (BULL/BEAR/CHOP) + WF-aware optimizer |
120
+ | **Community hub** | Contribute sim results, query the global leaderboard |
121
+ | **SQLite store** | Local 6-table schema, travels with your research |
122
+
123
+ **30+ strategy families** — RSI, EMA/MACD crosses, Bollinger, Donchian, ATR breakouts, Ichimoku, Supertrend, Keltner, VWAP reclaim, Heikin Ashi, ROC momentum, and more.
124
+
125
+ ---
126
+
127
+ ## Philosophy
128
+
129
+ Terminus is **pessimistic by default**. It will tell you your strategy doesn't work before it tells you it does. That's the point.
130
+
131
+ Terminus is **reproducible by design**. The content-hash cache means any claim in a report traces back to the exact inputs that produced it. `sims.db` travels with your conclusions.
132
+
133
+ Terminus is **spot-only, halal-first**. Built by someone who can't use futures or margin. If you have those tools, you have more alpha. If you don't — Terminus fits your constraints natively.
134
+
135
+ ---
136
+
137
+ ## Community Hub
138
+
139
+ ```
140
+ https://terminus-hub.shatla-tech.workers.dev/api/v1
141
+ ```
142
+
143
+ Contribute your sim results. Query the global leaderboard. Every user's runs feed the aggregate — rare pairs and exotic timeframes covered by people who care about them.
144
+
145
+ ---
146
+
147
+ ## Status
148
+
149
+ **Alpha.** Used in production on a paper-trading bot running 7 pairs. API may shift. Results format and research data model are stable.
150
+
151
+ ---
152
+
153
+ ## Contributing
154
+
155
+ PRs welcome for:
156
+ - New strategy families (numpy-vectorized signals)
157
+ - Alternative data fetchers (Kraken, Coinbase, OKX, Bybit spot)
158
+ - Portfolio construction methods
159
+ - New walk-forward modes
160
+
161
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
162
+
163
+ ---
164
+
165
+ ## License
166
+
167
+ MIT. Use it, fork it, ship it. If you find something useful, open a PR — the community sim database grows stronger with every contributor.
@@ -0,0 +1,129 @@
1
+ <p align="center">
2
+ <img src="assets/logo.png" alt="Terminus" width="320"/>
3
+ </p>
4
+
5
+ <h1 align="center">Terminus</h1>
6
+ <p align="center"><em>End of All Trades</em></p>
7
+
8
+ <p align="center">
9
+ <img src="https://img.shields.io/badge/python-3.10%2B-blue?style=flat-square" />
10
+ <img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" />
11
+ <img src="https://img.shields.io/badge/status-alpha-orange?style=flat-square" />
12
+ <img src="https://img.shields.io/badge/halal--first-spot%20only-gold?style=flat-square" />
13
+ <img src="https://img.shields.io/github/stars/Stronex-Labs/terminus?style=flat-square" />
14
+ </p>
15
+
16
+ <p align="center"><strong>Where strategies go to prove themselves — or die.</strong></p>
17
+
18
+ ---
19
+
20
+ Terminus is a pure Python backtesting engine built for one thing: **honest results**.
21
+
22
+ 8 years of market data. Year-by-year walk-forward with frozen parameters. Realistic fees and slippage. A content-hashed simulation store so you never burn compute twice.
23
+
24
+ Most backtesting tools let you cheat. Terminus doesn't.
25
+
26
+ ---
27
+
28
+ ## Why Terminus
29
+
30
+ - **Near-perfect walk-forward required** — frozen parameters tested year by year. At most 2 losing years tolerated, each no worse than −10%.
31
+ - **Bear years count** — 2022 was −64% on BTC. Your strategy survives that or it doesn't ship.
32
+ - **Multi-pair generalization required** — works on one pair? That's a curve fit. Terminus requires success across multiple pairs.
33
+ - **Realistic execution** — fees, entry slippage, stop slippage, TP slippage, timeout slippage, cooldowns, max-hold. Tiered by market cap.
34
+ - **Halal-first** — spot-only, no leverage, no shorts, no interest. Cash (stablecoin) is a valid position in bear regimes.
35
+ - **Content-hashed cache** — every sim keyed by `hash(pair + tf + config + date_range + slippage + fee)`. Same inputs = instant cache hit.
36
+
37
+ ---
38
+
39
+ ## Quickstart
40
+
41
+ ```bash
42
+ pip install terminus-lab
43
+
44
+ # Fetch 8 years of data
45
+ terminus fetch --pairs BTCUSDT,ETHUSDT,SOLUSDT --tfs 1h,4h,1d --days 2920
46
+
47
+ # Run the full sweep
48
+ terminus sweep
49
+
50
+ # Walk-forward the top candidates year-by-year
51
+ terminus walk-forward --top 15
52
+
53
+ # Generate the report
54
+ terminus report --min-calmar 1.5 --min-bear-return -5
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Example Output
60
+
61
+ ```
62
+ === TOP 15 SURVIVORS by ANNUALIZED return ===
63
+ Rank Pair TF Family Yrs TotalRet AnnRet Calmar Bear22
64
+ ----- ---------- ---- ----------------------- ---- -------- ------ ------ ------
65
+ 1 TIAUSDT 2h Ichi-bull+BTCreg 3/3 +90.7% +24.0% 2.77 -
66
+ 2 XRPUSDT 2h Ichi-bull+BTCreg 6/6 +213.5% +21.0% 5.68 +0.0%
67
+ 3 LTCUSDT 12h Ichi-bull+BTCreg 3/3 +70.1% +19.4% 4.28 +0.0%
68
+ 4 BNBUSDT 1h ROC10+BTCreg 5/5 +133.2% +18.4% 4.93 +0.0%
69
+ 5 SOLUSDT 4h ATR-brk 5/5 +130.6% +18.2% 7.86 +13.2%
70
+ ```
71
+
72
+ ---
73
+
74
+ ## What's Inside
75
+
76
+ | Module | What it does |
77
+ |--------|-------------|
78
+ | **Sweep engine** | Runs thousands of configs in parallel, skips cache hits |
79
+ | **Walk-forward** | Frozen / anchored / rolling — calendar-year folds |
80
+ | **Portfolio builder** | Correlation-capped leg selection, blended Sharpe/Calmar |
81
+ | **ML module** | XGBoost regime classifier (BULL/BEAR/CHOP) + WF-aware optimizer |
82
+ | **Community hub** | Contribute sim results, query the global leaderboard |
83
+ | **SQLite store** | Local 6-table schema, travels with your research |
84
+
85
+ **30+ strategy families** — RSI, EMA/MACD crosses, Bollinger, Donchian, ATR breakouts, Ichimoku, Supertrend, Keltner, VWAP reclaim, Heikin Ashi, ROC momentum, and more.
86
+
87
+ ---
88
+
89
+ ## Philosophy
90
+
91
+ Terminus is **pessimistic by default**. It will tell you your strategy doesn't work before it tells you it does. That's the point.
92
+
93
+ Terminus is **reproducible by design**. The content-hash cache means any claim in a report traces back to the exact inputs that produced it. `sims.db` travels with your conclusions.
94
+
95
+ Terminus is **spot-only, halal-first**. Built by someone who can't use futures or margin. If you have those tools, you have more alpha. If you don't — Terminus fits your constraints natively.
96
+
97
+ ---
98
+
99
+ ## Community Hub
100
+
101
+ ```
102
+ https://terminus-hub.shatla-tech.workers.dev/api/v1
103
+ ```
104
+
105
+ Contribute your sim results. Query the global leaderboard. Every user's runs feed the aggregate — rare pairs and exotic timeframes covered by people who care about them.
106
+
107
+ ---
108
+
109
+ ## Status
110
+
111
+ **Alpha.** Used in production on a paper-trading bot running 7 pairs. API may shift. Results format and research data model are stable.
112
+
113
+ ---
114
+
115
+ ## Contributing
116
+
117
+ PRs welcome for:
118
+ - New strategy families (numpy-vectorized signals)
119
+ - Alternative data fetchers (Kraken, Coinbase, OKX, Bybit spot)
120
+ - Portfolio construction methods
121
+ - New walk-forward modes
122
+
123
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
124
+
125
+ ---
126
+
127
+ ## License
128
+
129
+ MIT. Use it, fork it, ship it. If you find something useful, open a PR — the community sim database grows stronger with every contributor.
@@ -0,0 +1,53 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "terminus-lab"
7
+ version = "0.1.0"
8
+ description = "End of All Trades — ruthless backtesting lab for long-only spot strategies."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [
12
+ { name = "Stronex Labs" },
13
+ ]
14
+ requires-python = ">=3.10"
15
+ keywords = [
16
+ "backtest", "crypto", "trading", "walk-forward", "spot",
17
+ "halal", "shariah", "quantitative", "strategy",
18
+ ]
19
+ classifiers = [
20
+ "Development Status :: 3 - Alpha",
21
+ "Intended Audience :: Financial and Insurance Industry",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Programming Language :: Python :: 3.13",
28
+ "Topic :: Office/Business :: Financial :: Investment",
29
+ ]
30
+ dependencies = [
31
+ "numpy>=1.24",
32
+ "pandas>=2.0",
33
+ "pandas-ta>=0.3.14b",
34
+ "pyarrow>=10.0",
35
+ "httpx>=0.25",
36
+ "python-dotenv>=1.0",
37
+ ]
38
+
39
+ [project.optional-dependencies]
40
+ ml = ["xgboost>=2.0", "scikit-learn>=1.3", "httpx>=0.25"]
41
+ dev = ["pytest>=7", "pytest-asyncio>=0.21", "ruff>=0.1"]
42
+
43
+ [project.scripts]
44
+ terminus = "terminus.cli:main"
45
+
46
+ [project.urls]
47
+ Homepage = "https://github.com/Stronex-Labs/terminus"
48
+ Documentation = "https://github.com/Stronex-Labs/terminus/tree/main/docs"
49
+ Issues = "https://github.com/Stronex-Labs/terminus/issues"
50
+
51
+ [tool.setuptools.packages.find]
52
+ include = ["terminus*"]
53
+ exclude = ["tests*", "docs*", "examples*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,44 @@
1
+ """Terminus — ruthless backtesting lab for long-only spot strategies.
2
+
3
+ Public API:
4
+ from terminus import (
5
+ ResearchStore, simulate, VRule,
6
+ build_all_configs, run_full_sweep,
7
+ walk_forward_frozen, filter_sims,
8
+ greedy_portfolio,
9
+ )
10
+
11
+ ML (requires pip install terminus-lab[ml]):
12
+ from terminus.ml import RegimeClassifier, optimize_params
13
+ """
14
+ from __future__ import annotations
15
+
16
+ __version__ = "0.1.0"
17
+
18
+ from .store import ResearchStore, SimRecord, get_store, hash_config
19
+ from .simulate import simulate_fast as simulate
20
+ from .rules import VRule
21
+ from .indicators import precompute_all, precompute_v2, build_btc_regime_series
22
+ from .registry import (
23
+ build_v1_configs, build_v2_configs, build_all_configs,
24
+ build_configs_with_regime, all_exit_methods, count_configs,
25
+ )
26
+ from .walk_forward import walk_forward_frozen, walk_forward_reopt_anchored
27
+ from .filter import filter_sims, Survivor, survivor_report
28
+ from .portfolio import greedy_portfolio, reconstruct_legs, correlation
29
+ from .sweep import run_full_sweep
30
+ from . import telemetry
31
+
32
+ __all__ = [
33
+ "__version__",
34
+ "ResearchStore", "SimRecord", "get_store", "hash_config",
35
+ "simulate", "VRule",
36
+ "precompute_all", "precompute_v2", "build_btc_regime_series",
37
+ "build_v1_configs", "build_v2_configs", "build_all_configs",
38
+ "build_configs_with_regime", "all_exit_methods", "count_configs",
39
+ "walk_forward_frozen", "walk_forward_reopt_anchored",
40
+ "filter_sims", "Survivor", "survivor_report",
41
+ "greedy_portfolio", "reconstruct_legs", "correlation",
42
+ "run_full_sweep",
43
+ "telemetry",
44
+ ]