statera 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.
Files changed (77) hide show
  1. statera-1.0.0/CHANGELOG.md +34 -0
  2. statera-1.0.0/LICENSE +21 -0
  3. statera-1.0.0/MANIFEST.in +7 -0
  4. statera-1.0.0/PKG-INFO +184 -0
  5. statera-1.0.0/README.md +151 -0
  6. statera-1.0.0/README.tr.md +161 -0
  7. statera-1.0.0/config/research_2026-11-29.yaml +2 -0
  8. statera-1.0.0/docs/en/architecture.md +86 -0
  9. statera-1.0.0/docs/en/configuration.md +111 -0
  10. statera-1.0.0/docs/en/execution.md +91 -0
  11. statera-1.0.0/docs/en/getting-started.md +115 -0
  12. statera-1.0.0/docs/en/integrations.md +81 -0
  13. statera-1.0.0/docs/en/limitations.md +35 -0
  14. statera-1.0.0/docs/en/python-api.md +137 -0
  15. statera-1.0.0/docs/en/research-and-optimization.md +96 -0
  16. statera-1.0.0/docs/en/risk-management.md +68 -0
  17. statera-1.0.0/docs/en/strategy-development.md +127 -0
  18. statera-1.0.0/docs/reference-run/README.md +29 -0
  19. statera-1.0.0/docs/tr/architecture.md +87 -0
  20. statera-1.0.0/docs/tr/configuration.md +111 -0
  21. statera-1.0.0/docs/tr/execution.md +94 -0
  22. statera-1.0.0/docs/tr/getting-started.md +117 -0
  23. statera-1.0.0/docs/tr/integrations.md +88 -0
  24. statera-1.0.0/docs/tr/limitations.md +40 -0
  25. statera-1.0.0/docs/tr/python-api.md +143 -0
  26. statera-1.0.0/docs/tr/research-and-optimization.md +99 -0
  27. statera-1.0.0/docs/tr/risk-management.md +72 -0
  28. statera-1.0.0/docs/tr/strategy-development.md +130 -0
  29. statera-1.0.0/examples/README.md +25 -0
  30. statera-1.0.0/examples/a_strategy_research.py +70 -0
  31. statera-1.0.0/examples/b_external_backtest.py +57 -0
  32. statera-1.0.0/examples/c_web_backend.py +118 -0
  33. statera-1.0.0/examples/d_llm_strategy_spec.py +173 -0
  34. statera-1.0.0/examples/synthetic_data.py +25 -0
  35. statera-1.0.0/main.py +8 -0
  36. statera-1.0.0/pyproject.toml +58 -0
  37. statera-1.0.0/requirements-lock.txt +46 -0
  38. statera-1.0.0/requirements.txt +8 -0
  39. statera-1.0.0/setup.cfg +10 -0
  40. statera-1.0.0/statera/__init__.py +10 -0
  41. statera-1.0.0/statera/api.py +499 -0
  42. statera-1.0.0/statera/approval.py +71 -0
  43. statera-1.0.0/statera/cli.py +229 -0
  44. statera-1.0.0/statera/config.py +122 -0
  45. statera-1.0.0/statera/data.py +263 -0
  46. statera-1.0.0/statera/default.yaml +94 -0
  47. statera-1.0.0/statera/engine.py +333 -0
  48. statera-1.0.0/statera/execution/__init__.py +1 -0
  49. statera-1.0.0/statera/execution/adapter.py +53 -0
  50. statera-1.0.0/statera/execution/feeds.py +69 -0
  51. statera-1.0.0/statera/execution/trader.py +249 -0
  52. statera-1.0.0/statera/indicators.py +49 -0
  53. statera-1.0.0/statera/metrics.py +184 -0
  54. statera-1.0.0/statera/pipeline.py +539 -0
  55. statera-1.0.0/statera/plan.py +107 -0
  56. statera-1.0.0/statera/reports.py +56 -0
  57. statera-1.0.0/statera/risk.py +137 -0
  58. statera-1.0.0/statera/store.py +182 -0
  59. statera-1.0.0/statera/strategies/__init__.py +148 -0
  60. statera-1.0.0/statera/strategies/base.py +103 -0
  61. statera-1.0.0/statera/strategies/ema_crossover.py +41 -0
  62. statera-1.0.0/statera.egg-info/PKG-INFO +184 -0
  63. statera-1.0.0/statera.egg-info/SOURCES.txt +76 -0
  64. statera-1.0.0/statera.egg-info/dependency_links.txt +1 -0
  65. statera-1.0.0/statera.egg-info/entry_points.txt +2 -0
  66. statera-1.0.0/statera.egg-info/requires.txt +11 -0
  67. statera-1.0.0/statera.egg-info/top_level.txt +1 -0
  68. statera-1.0.0/strategies/template_strategy.py +48 -0
  69. statera-1.0.0/tests/__init__.py +0 -0
  70. statera-1.0.0/tests/conftest.py +56 -0
  71. statera-1.0.0/tests/test_api.py +187 -0
  72. statera-1.0.0/tests/test_data_metrics.py +90 -0
  73. statera-1.0.0/tests/test_engine.py +279 -0
  74. statera-1.0.0/tests/test_examples.py +34 -0
  75. statera-1.0.0/tests/test_execution.py +259 -0
  76. statera-1.0.0/tests/test_research.py +172 -0
  77. statera-1.0.0/tests/test_strategy_leakage.py +44 -0
@@ -0,0 +1,34 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 — 2026-11-29 (initial release, not published)
4
+
5
+ ### Framework
6
+ - MIT-licensed `statera` distribution with editable, Git and wheel/sdist installs, a `statera`
7
+ console script and Python ≥ 3.12 support (verified on 3.12 and 3.14).
8
+ - GitHub Actions builds, validates and smoke-tests the distribution before OIDC publishing to PyPI or TestPyPI.
9
+ - Public API in `statera` (`statera.__all__`): `load_config`, `market_data_from_frame`, `backtest`,
10
+ `research`, `analyze_risk`, `position_size`, `activate_plan`, `run_replay`, `run_paper`, strategy
11
+ registration/discovery, typed `BacktestResult` / `ResearchResult` / `PositionSize`.
12
+ - Default configuration ships inside the package (`statera/default.yaml`); all paths resolve against a
13
+ configurable base directory (`--base-dir`, `load_config(base_dir=...)`), not the repository.
14
+ - Strategy resolution: instances, in-process registry, `strategies_dir`, `statera.strategies` entry points,
15
+ built-ins.
16
+ - Internal research orchestration module renamed `statera.research` → `statera.pipeline`; CLI moved to
17
+ `statera/cli.py` (`main.py` remains as a checkout shim).
18
+
19
+ ### Research, risk, execution (V1 core)
20
+ - Shared bar engine (next-bar fills, fees, slippage, gaps, stop-first ambiguity, exchange precision, MTM equity).
21
+ - Bounded grid/TPE optimisation with all trials recorded, purged walk-forward, sensitivity, cost/delay stress,
22
+ block-bootstrap CI, Monte Carlo risk sizing under hard limits, single frozen holdout test with a cross-run
23
+ holdout-usage registry, fail-closed approval.
24
+ - Versioned, hashed, expiring trading plans; replay and paper trading with SQLite persistence, idempotent
25
+ bar processing, restart recovery and kill switches. No real-money order path.
26
+ - Paper sessions now persist their start anchor immediately (restart before the first bar keeps it).
27
+
28
+ ### Documentation and examples
29
+ - English and Turkish README and developer docs (`docs/en`, `docs/tr`); runnable integration examples
30
+ (`examples/`): custom-strategy research, external backtest, web job backend, LLM strategy-spec adapter.
31
+ - Curated reference report of the real 2026-11-29 research run (`docs/reference-run/`, REJECTED).
32
+
33
+ ### Verification
34
+ - 83 tests pass (Python 3.14.7 and 3.12.15).
statera-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ccakirr
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,7 @@
1
+ include README.md README.tr.md CHANGELOG.md requirements.txt requirements-lock.txt main.py
2
+ recursive-include tests *.py
3
+ recursive-include examples *.py *.md
4
+ recursive-include docs *.md
5
+ recursive-include strategies *.py
6
+ recursive-include config *.yaml
7
+ global-exclude __pycache__ *.py[cod]
statera-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,184 @@
1
+ Metadata-Version: 2.4
2
+ Name: statera
3
+ Version: 1.0.0
4
+ Summary: Research, validation and simulated (paper/replay) execution framework for rule-based crypto spot strategies
5
+ Author: ccakirr
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ccakirr/statera
8
+ Project-URL: Repository, https://github.com/ccakirr/statera
9
+ Project-URL: Issues, https://github.com/ccakirr/statera/issues
10
+ Keywords: quantitative-finance,backtesting,walk-forward,monte-carlo,paper-trading,crypto
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Financial and Insurance Industry
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: Office/Business :: Financial :: Investment
19
+ Requires-Python: >=3.12
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: numpy<3,>=2.5.5
23
+ Requires-Dist: pandas<4,>=3.1.1
24
+ Requires-Dist: ccxt<5,>=4.5.94
25
+ Requires-Dist: optuna<6,>=5.1.0
26
+ Requires-Dist: matplotlib<4,>=3.11.2
27
+ Requires-Dist: PyYAML<7,>=6.0.4
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest<10,>=9.2.0; extra == "dev"
30
+ Requires-Dist: build>=1.2; extra == "dev"
31
+ Requires-Dist: twine>=6.1; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ # Statera
35
+
36
+ **English** · [Türkçe](https://github.com/ccakirr/statera/blob/main/README.tr.md)
37
+
38
+ Statera is a Python framework for **researching, validating and paper-trading rule-based crypto spot strategies**
39
+ (long-only, no leverage). It answers one question with auditable evidence: *does this strategy show a robust,
40
+ cost-adjusted edge on data it was never tuned on?* "No" is a normal, valid answer.
41
+
42
+ Statera is **not a profitable trading bot** and places **no real-money orders**. `APPROVED_FOR_PAPER` authorises
43
+ simulated execution only. Passing validation does not prove future profitability.
44
+
45
+ ## Who it is for
46
+ - Quant developers who want a realistic backtester plus walk-forward, holdout, stress and Monte Carlo risk checks.
47
+ - Application developers embedding strategy evaluation in their own products (Python API, CLI, structured results).
48
+ - Teams that need reproducible, fail-closed research records rather than optimistic equity curves.
49
+
50
+ ## What problems it solves
51
+ | Problem | Statera's answer |
52
+ |---|---|
53
+ | Backtests that ignore fees, slippage, gaps, cash limits and exchange minimums | One shared engine with next-bar fills, conservative intrabar ordering and exchange precision |
54
+ | Overfitting through unlimited parameter search | Bounded global trial budget; every attempted configuration is recorded |
55
+ | Holdout data silently reused until something passes | Untouched chronological holdout, tested once per frozen config; inspections recorded across runs |
56
+ | Position sizing chosen from optimistic curves | Monte Carlo sizing on development data only, with hard user risk limits |
57
+ | Backtest/live rule drift | Backtest, replay and paper trading share the same engine |
58
+
59
+ ## Key capabilities
60
+ - Public Binance OHLCV via CCXT (no API keys), local cache, validation; gaps reported, never forward-filled.
61
+ - Python strategy plugins with explicit, bounded parameter spaces; register in-process, by directory or entry point.
62
+ - Realistic engine: next-bar open entries, fees and slippage on every fill, gap fills, stop-first on ambiguous bars,
63
+ cash and quantity constraints, net R = net PnL / initial monetary risk, marked-to-market drawdown.
64
+ - Research pipeline: grid/Optuna search → purged walk-forward → sensitivity, cost and delay stress → Monte Carlo
65
+ risk sizing → freeze → single holdout test → `APPROVED_FOR_PAPER` / `REJECTED` / `INSUFFICIENT_DATA`.
66
+ - Versioned, hashed, expiring trading plans; replay and paper trading with SQLite persistence, duplicate-order
67
+ prevention, restart recovery and kill switches.
68
+
69
+ ## Architecture (high level)
70
+ ```mermaid
71
+ flowchart LR
72
+ D[data: CCXT / your OHLCV] --> S[strategy plugin: signals]
73
+ S --> E[engine: fills, costs, sizing, MTM]
74
+ E --> P[pipeline: optimise, walk-forward, gates]
75
+ P --> R[risk: Monte Carlo sizing]
76
+ R --> H[single holdout test]
77
+ H --> A[approval]
78
+ A --> PL[trading_plan.json]
79
+ PL --> T[trader: replay / paper]
80
+ T --> E
81
+ ```
82
+ See the [architecture guide](https://github.com/ccakirr/statera/blob/main/docs/en/architecture.md).
83
+
84
+ ## Installation
85
+ Requires Python 3.12 or later. Use `import statera` in Python and `statera` at the command line.
86
+
87
+ Install from PyPI once the first release is published.
88
+
89
+ ```bash
90
+ python -m pip install statera
91
+ ```
92
+
93
+ Install from Git once the desired revision is pushed. Replace `REF` with a tag or commit.
94
+
95
+ ```bash
96
+ python -m pip install "git+https://github.com/ccakirr/statera.git@REF"
97
+ ```
98
+
99
+ For a TestPyPI release, use a fresh virtual environment in a checkout of the matching version. Install
100
+ the pinned dependencies from PyPI, then install the Statera wheel from TestPyPI.
101
+
102
+ ```bash
103
+ python -m pip install --index-url https://pypi.org/simple/ -r requirements.txt
104
+ python -m pip install --index-url https://test.pypi.org/simple/ --no-deps --only-binary=:all: "statera==1.0.0"
105
+ python -m pip check
106
+ ```
107
+
108
+ For local development and distribution builds, run the following from a checkout.
109
+
110
+ ```bash
111
+ python -m pip install -e ".[dev]"
112
+ python -m build
113
+ python -m twine check --strict dist/*
114
+ ```
115
+
116
+ Use `python -m pip install -r requirements-lock.txt` for the full verified dependency set.
117
+
118
+ ### Publishing
119
+
120
+ Configure a pending GitHub Actions Trusted Publisher on each index before the first upload. Set the
121
+ project to `statera`, enter the actual GitHub repository owner and name, and set the workflow
122
+ filename to `publish.yml`. Use the GitHub environment `pypi` for PyPI and `testpypi` for TestPyPI.
123
+ See [PyPI's Trusted Publishing setup guide](https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/).
124
+
125
+ To publish to TestPyPI, run **Publish Python distribution** manually from GitHub Actions on the branch
126
+ or tag you want to test. To publish to PyPI, push a version tag such as `v1.0.0` or publish a GitHub
127
+ Release for that tag. Match the tag to the version in `pyproject.toml` and `statera.__version__`.
128
+
129
+ ## Quick start
130
+ CLI (installed as `statera`; `python main.py` also works in a checkout):
131
+ ```bash
132
+ statera data # download/validate BTC/USDT, ETH/USDT 15m (~2 years)
133
+ statera backtest --strategy ema_crossover --offline
134
+ statera research --strategy ema_crossover --offline
135
+ statera report
136
+ ```
137
+ Python:
138
+ ```python
139
+ import statera
140
+
141
+ cfg = statera.load_config(base_dir="./my_statera") # state, data, reports live under this directory
142
+ bt = statera.backtest("ema_crossover", cfg=cfg, symbol="BTC/USDT", timeframe="15m", offline=True)
143
+ print(bt.metrics["expectancy_R"], bt.equity_metrics["max_drawdown"])
144
+
145
+ res = statera.research("ema_crossover", cfg=cfg, offline=True)
146
+ print(res.decision, res.reasons[:3]) # APPROVED_FOR_PAPER | REJECTED | INSUFFICIENT_DATA
147
+ ```
148
+ (`offline=True` needs a cache in that `base_dir`; run `statera --base-dir ./my_statera data` first or omit it.)
149
+
150
+ ## Documentation
151
+ | Topic | English | Türkçe |
152
+ |---|---|---|
153
+ | Getting started | [getting-started](https://github.com/ccakirr/statera/blob/main/docs/en/getting-started.md) | [başlangıç](https://github.com/ccakirr/statera/blob/main/docs/tr/getting-started.md) |
154
+ | Architecture | [architecture](https://github.com/ccakirr/statera/blob/main/docs/en/architecture.md) | [mimari](https://github.com/ccakirr/statera/blob/main/docs/tr/architecture.md) |
155
+ | Configuration | [configuration](https://github.com/ccakirr/statera/blob/main/docs/en/configuration.md) | [yapılandırma](https://github.com/ccakirr/statera/blob/main/docs/tr/configuration.md) |
156
+ | Strategy development | [strategy-development](https://github.com/ccakirr/statera/blob/main/docs/en/strategy-development.md) | [strateji geliştirme](https://github.com/ccakirr/statera/blob/main/docs/tr/strategy-development.md) |
157
+ | Research & optimisation | [research-and-optimization](https://github.com/ccakirr/statera/blob/main/docs/en/research-and-optimization.md) | [araştırma ve optimizasyon](https://github.com/ccakirr/statera/blob/main/docs/tr/research-and-optimization.md) |
158
+ | Risk management | [risk-management](https://github.com/ccakirr/statera/blob/main/docs/en/risk-management.md) | [risk yönetimi](https://github.com/ccakirr/statera/blob/main/docs/tr/risk-management.md) |
159
+ | Execution | [execution](https://github.com/ccakirr/statera/blob/main/docs/en/execution.md) | [yürütme](https://github.com/ccakirr/statera/blob/main/docs/tr/execution.md) |
160
+ | Python API reference | [python-api](https://github.com/ccakirr/statera/blob/main/docs/en/python-api.md) | [Python API](https://github.com/ccakirr/statera/blob/main/docs/tr/python-api.md) |
161
+ | Integrations | [integrations](https://github.com/ccakirr/statera/blob/main/docs/en/integrations.md) | [entegrasyonlar](https://github.com/ccakirr/statera/blob/main/docs/tr/integrations.md) |
162
+ | Limitations | [limitations](https://github.com/ccakirr/statera/blob/main/docs/en/limitations.md) | [sınırlamalar](https://github.com/ccakirr/statera/blob/main/docs/tr/limitations.md) |
163
+
164
+ See the [runnable integration examples](https://github.com/ccakirr/statera/blob/main/examples/README.md).
165
+
166
+ ## Maturity
167
+ Version 1.0.0 is the initial beta release. An automated test suite and one real end-to-end research run
168
+ verify this single-developer project. The supported Python API is listed in `statera.__all__`.
169
+
170
+ ## Verified results (2026-11-29)
171
+ - Test suite: `pytest` → **83 passed** (deterministic synthetic fixtures; see [getting started](https://github.com/ccakirr/statera/blob/main/docs/en/getting-started.md)).
172
+ - Real research run `20261129T104233Z_018709` (`ema_crossover`, BTC/USDT and ETH/USDT 15m, 70,080 bars each,
173
+ 2024-11-29 → 2026-11-29, 0 missing bars): **REJECTED**. 60/60 optimisation trials had negative development
174
+ expectancy (best E[R]: BTC −0.062, ETH −0.086); walk-forward out-of-sample E[R]: BTC −0.120 (161 trades),
175
+ ETH −0.218 (373 trades). The top 3 candidates failed every development gate; the holdout (from 2026-07-06)
176
+ was never inspected and no plan was approved. See the [reference run reports](https://github.com/ccakirr/statera/blob/main/docs/reference-run/README.md).
177
+
178
+ ## Limitations
179
+ Bar-level simulation (unknown intrabar path, no order book or partial fills), single long-only spot position, no
180
+ live trading, statistical limits of walk-forward selection and bootstrap resampling. See the
181
+ [full list of limitations](https://github.com/ccakirr/statera/blob/main/docs/en/limitations.md).
182
+
183
+ ## License
184
+ Statera is distributed under the [MIT License](https://github.com/ccakirr/statera/blob/main/LICENSE).
@@ -0,0 +1,151 @@
1
+ # Statera
2
+
3
+ **English** · [Türkçe](https://github.com/ccakirr/statera/blob/main/README.tr.md)
4
+
5
+ Statera is a Python framework for **researching, validating and paper-trading rule-based crypto spot strategies**
6
+ (long-only, no leverage). It answers one question with auditable evidence: *does this strategy show a robust,
7
+ cost-adjusted edge on data it was never tuned on?* "No" is a normal, valid answer.
8
+
9
+ Statera is **not a profitable trading bot** and places **no real-money orders**. `APPROVED_FOR_PAPER` authorises
10
+ simulated execution only. Passing validation does not prove future profitability.
11
+
12
+ ## Who it is for
13
+ - Quant developers who want a realistic backtester plus walk-forward, holdout, stress and Monte Carlo risk checks.
14
+ - Application developers embedding strategy evaluation in their own products (Python API, CLI, structured results).
15
+ - Teams that need reproducible, fail-closed research records rather than optimistic equity curves.
16
+
17
+ ## What problems it solves
18
+ | Problem | Statera's answer |
19
+ |---|---|
20
+ | Backtests that ignore fees, slippage, gaps, cash limits and exchange minimums | One shared engine with next-bar fills, conservative intrabar ordering and exchange precision |
21
+ | Overfitting through unlimited parameter search | Bounded global trial budget; every attempted configuration is recorded |
22
+ | Holdout data silently reused until something passes | Untouched chronological holdout, tested once per frozen config; inspections recorded across runs |
23
+ | Position sizing chosen from optimistic curves | Monte Carlo sizing on development data only, with hard user risk limits |
24
+ | Backtest/live rule drift | Backtest, replay and paper trading share the same engine |
25
+
26
+ ## Key capabilities
27
+ - Public Binance OHLCV via CCXT (no API keys), local cache, validation; gaps reported, never forward-filled.
28
+ - Python strategy plugins with explicit, bounded parameter spaces; register in-process, by directory or entry point.
29
+ - Realistic engine: next-bar open entries, fees and slippage on every fill, gap fills, stop-first on ambiguous bars,
30
+ cash and quantity constraints, net R = net PnL / initial monetary risk, marked-to-market drawdown.
31
+ - Research pipeline: grid/Optuna search → purged walk-forward → sensitivity, cost and delay stress → Monte Carlo
32
+ risk sizing → freeze → single holdout test → `APPROVED_FOR_PAPER` / `REJECTED` / `INSUFFICIENT_DATA`.
33
+ - Versioned, hashed, expiring trading plans; replay and paper trading with SQLite persistence, duplicate-order
34
+ prevention, restart recovery and kill switches.
35
+
36
+ ## Architecture (high level)
37
+ ```mermaid
38
+ flowchart LR
39
+ D[data: CCXT / your OHLCV] --> S[strategy plugin: signals]
40
+ S --> E[engine: fills, costs, sizing, MTM]
41
+ E --> P[pipeline: optimise, walk-forward, gates]
42
+ P --> R[risk: Monte Carlo sizing]
43
+ R --> H[single holdout test]
44
+ H --> A[approval]
45
+ A --> PL[trading_plan.json]
46
+ PL --> T[trader: replay / paper]
47
+ T --> E
48
+ ```
49
+ See the [architecture guide](https://github.com/ccakirr/statera/blob/main/docs/en/architecture.md).
50
+
51
+ ## Installation
52
+ Requires Python 3.12 or later. Use `import statera` in Python and `statera` at the command line.
53
+
54
+ Install from PyPI once the first release is published.
55
+
56
+ ```bash
57
+ python -m pip install statera
58
+ ```
59
+
60
+ Install from Git once the desired revision is pushed. Replace `REF` with a tag or commit.
61
+
62
+ ```bash
63
+ python -m pip install "git+https://github.com/ccakirr/statera.git@REF"
64
+ ```
65
+
66
+ For a TestPyPI release, use a fresh virtual environment in a checkout of the matching version. Install
67
+ the pinned dependencies from PyPI, then install the Statera wheel from TestPyPI.
68
+
69
+ ```bash
70
+ python -m pip install --index-url https://pypi.org/simple/ -r requirements.txt
71
+ python -m pip install --index-url https://test.pypi.org/simple/ --no-deps --only-binary=:all: "statera==1.0.0"
72
+ python -m pip check
73
+ ```
74
+
75
+ For local development and distribution builds, run the following from a checkout.
76
+
77
+ ```bash
78
+ python -m pip install -e ".[dev]"
79
+ python -m build
80
+ python -m twine check --strict dist/*
81
+ ```
82
+
83
+ Use `python -m pip install -r requirements-lock.txt` for the full verified dependency set.
84
+
85
+ ### Publishing
86
+
87
+ Configure a pending GitHub Actions Trusted Publisher on each index before the first upload. Set the
88
+ project to `statera`, enter the actual GitHub repository owner and name, and set the workflow
89
+ filename to `publish.yml`. Use the GitHub environment `pypi` for PyPI and `testpypi` for TestPyPI.
90
+ See [PyPI's Trusted Publishing setup guide](https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/).
91
+
92
+ To publish to TestPyPI, run **Publish Python distribution** manually from GitHub Actions on the branch
93
+ or tag you want to test. To publish to PyPI, push a version tag such as `v1.0.0` or publish a GitHub
94
+ Release for that tag. Match the tag to the version in `pyproject.toml` and `statera.__version__`.
95
+
96
+ ## Quick start
97
+ CLI (installed as `statera`; `python main.py` also works in a checkout):
98
+ ```bash
99
+ statera data # download/validate BTC/USDT, ETH/USDT 15m (~2 years)
100
+ statera backtest --strategy ema_crossover --offline
101
+ statera research --strategy ema_crossover --offline
102
+ statera report
103
+ ```
104
+ Python:
105
+ ```python
106
+ import statera
107
+
108
+ cfg = statera.load_config(base_dir="./my_statera") # state, data, reports live under this directory
109
+ bt = statera.backtest("ema_crossover", cfg=cfg, symbol="BTC/USDT", timeframe="15m", offline=True)
110
+ print(bt.metrics["expectancy_R"], bt.equity_metrics["max_drawdown"])
111
+
112
+ res = statera.research("ema_crossover", cfg=cfg, offline=True)
113
+ print(res.decision, res.reasons[:3]) # APPROVED_FOR_PAPER | REJECTED | INSUFFICIENT_DATA
114
+ ```
115
+ (`offline=True` needs a cache in that `base_dir`; run `statera --base-dir ./my_statera data` first or omit it.)
116
+
117
+ ## Documentation
118
+ | Topic | English | Türkçe |
119
+ |---|---|---|
120
+ | Getting started | [getting-started](https://github.com/ccakirr/statera/blob/main/docs/en/getting-started.md) | [başlangıç](https://github.com/ccakirr/statera/blob/main/docs/tr/getting-started.md) |
121
+ | Architecture | [architecture](https://github.com/ccakirr/statera/blob/main/docs/en/architecture.md) | [mimari](https://github.com/ccakirr/statera/blob/main/docs/tr/architecture.md) |
122
+ | Configuration | [configuration](https://github.com/ccakirr/statera/blob/main/docs/en/configuration.md) | [yapılandırma](https://github.com/ccakirr/statera/blob/main/docs/tr/configuration.md) |
123
+ | Strategy development | [strategy-development](https://github.com/ccakirr/statera/blob/main/docs/en/strategy-development.md) | [strateji geliştirme](https://github.com/ccakirr/statera/blob/main/docs/tr/strategy-development.md) |
124
+ | Research & optimisation | [research-and-optimization](https://github.com/ccakirr/statera/blob/main/docs/en/research-and-optimization.md) | [araştırma ve optimizasyon](https://github.com/ccakirr/statera/blob/main/docs/tr/research-and-optimization.md) |
125
+ | Risk management | [risk-management](https://github.com/ccakirr/statera/blob/main/docs/en/risk-management.md) | [risk yönetimi](https://github.com/ccakirr/statera/blob/main/docs/tr/risk-management.md) |
126
+ | Execution | [execution](https://github.com/ccakirr/statera/blob/main/docs/en/execution.md) | [yürütme](https://github.com/ccakirr/statera/blob/main/docs/tr/execution.md) |
127
+ | Python API reference | [python-api](https://github.com/ccakirr/statera/blob/main/docs/en/python-api.md) | [Python API](https://github.com/ccakirr/statera/blob/main/docs/tr/python-api.md) |
128
+ | Integrations | [integrations](https://github.com/ccakirr/statera/blob/main/docs/en/integrations.md) | [entegrasyonlar](https://github.com/ccakirr/statera/blob/main/docs/tr/integrations.md) |
129
+ | Limitations | [limitations](https://github.com/ccakirr/statera/blob/main/docs/en/limitations.md) | [sınırlamalar](https://github.com/ccakirr/statera/blob/main/docs/tr/limitations.md) |
130
+
131
+ See the [runnable integration examples](https://github.com/ccakirr/statera/blob/main/examples/README.md).
132
+
133
+ ## Maturity
134
+ Version 1.0.0 is the initial beta release. An automated test suite and one real end-to-end research run
135
+ verify this single-developer project. The supported Python API is listed in `statera.__all__`.
136
+
137
+ ## Verified results (2026-11-29)
138
+ - Test suite: `pytest` → **83 passed** (deterministic synthetic fixtures; see [getting started](https://github.com/ccakirr/statera/blob/main/docs/en/getting-started.md)).
139
+ - Real research run `20261129T104233Z_018709` (`ema_crossover`, BTC/USDT and ETH/USDT 15m, 70,080 bars each,
140
+ 2024-11-29 → 2026-11-29, 0 missing bars): **REJECTED**. 60/60 optimisation trials had negative development
141
+ expectancy (best E[R]: BTC −0.062, ETH −0.086); walk-forward out-of-sample E[R]: BTC −0.120 (161 trades),
142
+ ETH −0.218 (373 trades). The top 3 candidates failed every development gate; the holdout (from 2026-07-06)
143
+ was never inspected and no plan was approved. See the [reference run reports](https://github.com/ccakirr/statera/blob/main/docs/reference-run/README.md).
144
+
145
+ ## Limitations
146
+ Bar-level simulation (unknown intrabar path, no order book or partial fills), single long-only spot position, no
147
+ live trading, statistical limits of walk-forward selection and bootstrap resampling. See the
148
+ [full list of limitations](https://github.com/ccakirr/statera/blob/main/docs/en/limitations.md).
149
+
150
+ ## License
151
+ Statera is distributed under the [MIT License](https://github.com/ccakirr/statera/blob/main/LICENSE).
@@ -0,0 +1,161 @@
1
+ # Statera
2
+
3
+ [English](README.md) · **Türkçe**
4
+
5
+ Statera; kural tabanlı kripto spot stratejilerini (yalnızca long, kaldıraçsız) **araştırmak, doğrulamak ve kâğıt
6
+ üzerinde (paper) işletmek** için bir Python çerçevesidir. Tek bir soruyu denetlenebilir kanıtlarla yanıtlar:
7
+ *Bu strateji, hiç ayarlanmadığı veride maliyetler düşüldükten sonra sağlam bir üstünlük (edge) gösteriyor mu?*
8
+ "Hayır" normal ve geçerli bir yanıttır.
9
+
10
+ Statera **kârlı bir alım-satım botu değildir** ve **gerçek parayla emir göndermez**. `APPROVED_FOR_PAPER`
11
+ yalnızca simülasyon ortamında işlem yapmaya izin verir. Doğrulamayı geçmek gelecekte kâr edileceğini kanıtlamaz.
12
+
13
+ ## Kimler için
14
+ - Gerçekçi bir backtest motoruna ek olarak walk-forward, holdout, stres ve Monte Carlo risk kontrolleri isteyen
15
+ kantitatif geliştiriciler.
16
+ - Strateji değerlendirmesini kendi ürünlerine gömmek isteyen uygulama geliştiricileri (Python API, CLI,
17
+ yapılandırılmış sonuçlar).
18
+ - İyimser sermaye eğrileri yerine tekrarlanabilir, ihtiyatlı (fail-closed) araştırma kayıtlarına ihtiyaç duyan ekipler.
19
+
20
+ ## Hangi sorunları çözer
21
+ | Sorun | Statera'nın yanıtı |
22
+ |---|---|
23
+ | Komisyon, kayma (slippage), fiyat boşlukları, nakit sınırları ve borsa minimumlarını yok sayan backtestler | Sonraki bar dolumları, ihtiyatlı bar içi sıralama ve borsa hassasiyeti uygulayan ortak motor |
24
+ | Sınırsız parametre aramasıyla aşırı uyum (overfitting) | Sınırlı genel deneme bütçesi; denenen her yapılandırma kaydedilir |
25
+ | Bir şey geçene kadar holdout verisinin sessizce yeniden kullanılması | Dokunulmamış kronolojik holdout; dondurulmuş her yapılandırma için tek test; incelemeler çalışmalar arasında kaydedilir |
26
+ | İyimser eğrilerden seçilen pozisyon büyüklüğü | Yalnızca geliştirme verisiyle, kullanıcının katı risk limitleri altında Monte Carlo ile boyutlandırma |
27
+ | Backtest ile canlı kurallar arasında sapma | Backtest, replay ve paper trading aynı motoru kullanır |
28
+
29
+ ## Temel yetenekler
30
+ - CCXT üzerinden herkese açık Binance OHLCV verisi (API anahtarı gerekmez), yerel önbellek ve doğrulama;
31
+ eksik mumlar raporlanır, asla ileri doldurulmaz.
32
+ - Açık ve sınırlı parametre uzaylarına sahip Python strateji eklentileri; süreç içinde, dizin üzerinden veya
33
+ entry point ile kaydedilebilir.
34
+ - Gerçekçi motor: sonraki barın açılışında giriş, her dolumda komisyon ve kayma, boşluk dolumları, belirsiz
35
+ barlarda önce stop, nakit ve miktar kısıtları, net R = net kâr-zarar / başlangıç parasal riski, piyasa
36
+ değerine göre (MTM) drawdown.
37
+ - Araştırma hattı: grid/Optuna araması → arındırılmış (purged) walk-forward → duyarlılık, maliyet ve gecikme
38
+ stresi → Monte Carlo ile risk boyutlandırma → dondurma → tek holdout testi →
39
+ `APPROVED_FOR_PAPER` / `REJECTED` / `INSUFFICIENT_DATA`.
40
+ - Sürümlü, hash'li ve süresi dolan işlem planları; SQLite kalıcılığı, mükerrer emir önleme, yeniden başlatma
41
+ sonrası kurtarma ve acil durdurma (kill switch) ile replay ve paper trading.
42
+
43
+ ## Mimari (üst düzey)
44
+ ```mermaid
45
+ flowchart LR
46
+ D[data: CCXT / your OHLCV] --> S[strategy plugin: signals]
47
+ S --> E[engine: fills, costs, sizing, MTM]
48
+ E --> P[pipeline: optimise, walk-forward, gates]
49
+ P --> R[risk: Monte Carlo sizing]
50
+ R --> H[single holdout test]
51
+ H --> A[approval]
52
+ A --> PL[trading_plan.json]
53
+ PL --> T[trader: replay / paper]
54
+ T --> E
55
+ ```
56
+ Ayrıntılar: [docs/tr/architecture.md](docs/tr/architecture.md).
57
+
58
+ ## Kurulum
59
+ Python 3.12 veya üzeri gerekir. Python'da `import statera`, komut satırında `statera` kullanılır.
60
+
61
+ İlk sürüm yayımlandıktan sonra PyPI üzerinden kurabilirsiniz.
62
+
63
+ ```bash
64
+ python -m pip install statera
65
+ ```
66
+
67
+ İstediğiniz sürüm depoya gönderildikten sonra doğrudan Git üzerinden kurabilirsiniz. `REF` yerine
68
+ etiketi veya commit kimliğini yazın.
69
+
70
+ ```bash
71
+ python -m pip install "git+https://github.com/ccakirr/statera.git@REF"
72
+ ```
73
+
74
+ TestPyPI sürümü için aynı sürümün kaynak kopyasında temiz bir sanal ortam kullanın. Önce sabitlenmiş
75
+ bağımlılıkları PyPI'dan, ardından Statera wheel paketini TestPyPI'dan kurun.
76
+
77
+ ```bash
78
+ python -m pip install --index-url https://pypi.org/simple/ -r requirements.txt
79
+ python -m pip install --index-url https://test.pypi.org/simple/ --no-deps --only-binary=:all: "statera==1.0.0"
80
+ python -m pip check
81
+ ```
82
+
83
+ Yerel geliştirme ve dağıtım dosyalarını üretmek için aşağıdaki komutları kaynak dizininde çalıştırın.
84
+
85
+ ```bash
86
+ python -m pip install -e ".[dev]"
87
+ python -m build
88
+ python -m twine check --strict dist/*
89
+ ```
90
+
91
+ Doğrulanmış tüm bağımlılıkları kurmak için `python -m pip install -r requirements-lock.txt` kullanın.
92
+
93
+ ### Yayınlama
94
+
95
+ İlk yüklemeden önce her iki dizinde de bekleyen bir GitHub Actions Trusted Publisher tanımlayın. Proje
96
+ adını `statera`, iş akışı dosyasını `publish.yml` olarak girin ve GitHub deponuzun gerçek
97
+ sahip ve depo adını kullanın. GitHub ortam adı PyPI için `pypi`, TestPyPI için `testpypi` olmalıdır.
98
+ Adımlar [PyPI Trusted Publishing rehberinde](https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/) yer alır.
99
+
100
+ TestPyPI'ya yüklemek için GitHub Actions'ta **Publish Python distribution** iş akışını sınayacağınız dal
101
+ veya etiket üzerinde elle çalıştırın. PyPI'ya yüklemek için `v1.0.0` gibi bir sürüm etiketini gönderin veya
102
+ o etiket için GitHub Release yayımlayın. Etiketteki sürümü `pyproject.toml` ve `statera.__version__` ile eşleştirin.
103
+
104
+ ## Hızlı başlangıç
105
+ CLI (`statera` olarak kurulur; kaynak dizininde `python main.py` de çalışır):
106
+ ```bash
107
+ statera data # download/validate BTC/USDT, ETH/USDT 15m (~2 years)
108
+ statera backtest --strategy ema_crossover --offline
109
+ statera research --strategy ema_crossover --offline
110
+ statera report
111
+ ```
112
+ Python:
113
+ ```python
114
+ import statera
115
+
116
+ cfg = statera.load_config(base_dir="./my_statera") # state, data, reports live under this directory
117
+ bt = statera.backtest("ema_crossover", cfg=cfg, symbol="BTC/USDT", timeframe="15m", offline=True)
118
+ print(bt.metrics["expectancy_R"], bt.equity_metrics["max_drawdown"])
119
+
120
+ res = statera.research("ema_crossover", cfg=cfg, offline=True)
121
+ print(res.decision, res.reasons[:3]) # APPROVED_FOR_PAPER | REJECTED | INSUFFICIENT_DATA
122
+ ```
123
+ (`offline=True` için o `base_dir` altında bir önbellek gerekir; önce `statera --base-dir ./my_statera data`
124
+ komutunu çalıştırın ya da bu bayrağı kullanmayın.)
125
+
126
+ ## Dokümantasyon
127
+ | Konu | English | Türkçe |
128
+ |---|---|---|
129
+ | Başlangıç | [getting-started](docs/en/getting-started.md) | [başlangıç](docs/tr/getting-started.md) |
130
+ | Mimari | [architecture](docs/en/architecture.md) | [mimari](docs/tr/architecture.md) |
131
+ | Yapılandırma | [configuration](docs/en/configuration.md) | [yapılandırma](docs/tr/configuration.md) |
132
+ | Strateji geliştirme | [strategy-development](docs/en/strategy-development.md) | [strateji geliştirme](docs/tr/strategy-development.md) |
133
+ | Araştırma ve optimizasyon | [research-and-optimization](docs/en/research-and-optimization.md) | [araştırma ve optimizasyon](docs/tr/research-and-optimization.md) |
134
+ | Risk yönetimi | [risk-management](docs/en/risk-management.md) | [risk yönetimi](docs/tr/risk-management.md) |
135
+ | Yürütme | [execution](docs/en/execution.md) | [yürütme](docs/tr/execution.md) |
136
+ | Python API başvurusu | [python-api](docs/en/python-api.md) | [Python API](docs/tr/python-api.md) |
137
+ | Entegrasyonlar | [integrations](docs/en/integrations.md) | [entegrasyonlar](docs/tr/integrations.md) |
138
+ | Sınırlamalar | [limitations](docs/en/limitations.md) | [sınırlamalar](docs/tr/limitations.md) |
139
+
140
+ Çalıştırılabilir entegrasyon örnekleri: [examples/](examples/README.md).
141
+
142
+ ## Olgunluk düzeyi
143
+ 1.0.0 ilk beta sürümüdür. Tek geliştiricili proje, otomatik test paketi ve bir gerçek uçtan uca araştırma
144
+ çalışmasıyla doğrulandı. Desteklenen Python API'si `statera.__all__` içinde listelenir.
145
+
146
+ ## Doğrulanmış sonuçlar (2026-11-29)
147
+ - Test paketi: `pytest` → **83 test geçti** (deterministik sentetik veri; bkz. [başlangıç](docs/tr/getting-started.md)).
148
+ - Gerçek araştırma çalışması `20261129T104233Z_018709` (`ema_crossover`, BTC/USDT ve ETH/USDT 15 dk, her biri
149
+ 70.080 bar, 2024-11-29 → 2026-11-29, eksik bar yok): **REJECTED**. 60 optimizasyon denemesinin tamamının
150
+ geliştirme beklenen değeri negatifti (en iyi E[R]: BTC −0,062, ETH −0,086). Walk-forward örneklem dışı E[R]:
151
+ BTC −0,120 (161 işlem), ETH −0,218 (373 işlem). İlk 3 aday tüm geliştirme kapılarında başarısız oldu; holdout
152
+ (2026-07-06'dan itibaren) hiç incelenmedi ve hiçbir plan onaylanmadı. Raporlar:
153
+ [docs/reference-run/](docs/reference-run/README.md).
154
+
155
+ ## Sınırlamalar
156
+ Bar düzeyinde simülasyon (bar içi fiyat yolu bilinmez, emir defteri veya kısmi dolum yoktur), tek bir long spot
157
+ pozisyonu, canlı işlem yok; walk-forward seçimi ve bootstrap yeniden örneklemenin istatistiksel sınırları
158
+ geçerlidir. Tam liste: [docs/tr/limitations.md](docs/tr/limitations.md).
159
+
160
+ ## Lisans
161
+ Statera [MIT Lisansı](LICENSE) altında dağıtılır.
@@ -0,0 +1,2 @@
1
+ data:
2
+ end: "2026-11-29T10:30:00Z" # pinned (exclusive) for the 2026-11-29 research run