feat(strategy_pythagoras): scaffold workspace member + register in uv

This commit is contained in:
Adriano Dal Pastro
2026-05-19 13:12:23 +00:00
parent 14f476dd09
commit 37558a34f5
11 changed files with 131 additions and 2 deletions
+3
View File
@@ -47,3 +47,6 @@ logs/
build/ build/
dist/ dist/
*.egg *.egg
# Pythagoras source PDFs (local only, not tracked)
src/strategy_pythagoras/Pythagoras/*.pdf
+4 -2
View File
@@ -10,14 +10,16 @@ requires-python = ">=3.13"
dependencies = [ dependencies = [
"multi-swarm-core", "multi-swarm-core",
"strategy-crypto", "strategy-crypto",
"strategy-pythagoras",
] ]
[tool.uv.workspace] [tool.uv.workspace]
members = ["src/multi_swarm_core", "src/strategy_crypto"] members = ["src/multi_swarm_core", "src/strategy_crypto", "src/strategy_pythagoras"]
[tool.uv.sources] [tool.uv.sources]
multi-swarm-core = { workspace = true } multi-swarm-core = { workspace = true }
strategy-crypto = { workspace = true } strategy-crypto = { workspace = true }
strategy-pythagoras = { workspace = true }
[dependency-groups] [dependency-groups]
dev = [ dev = [
@@ -42,7 +44,7 @@ python_version = "3.13"
strict = true strict = true
[tool.pytest.ini_options] [tool.pytest.ini_options]
testpaths = ["src/multi_swarm_core/tests", "src/strategy_crypto/tests"] testpaths = ["src/multi_swarm_core/tests", "src/strategy_crypto/tests", "src/strategy_pythagoras/tests"]
addopts = "-v --tb=short --import-mode=importlib" addopts = "-v --tb=short --import-mode=importlib"
markers = [ markers = [
"integration: tests that require external services (Cerbero, LLM API)", "integration: tests that require external services (Cerbero, LLM API)",
+78
View File
@@ -0,0 +1,78 @@
# strategy_pythagoras
Strategia di trading basata sul framework **Pythagoras-Malanga**
(candle-pattern + geometria frattale), evoluta via GA sul core
`multi_swarm_core`. Workspace member del monorepo `multi_swarm_coevolutive`.
## Scope
Pipeline coevolutiva su candele OHLC: il GA del core esplora combinazioni
di indicatori candle-pattern, geometria pitagorica e ratio frattali, e
produce strategie JSON freezate. Questo member le esegue in
**paper-trading forward-test** ed espone una dashboard NiceGUI per
analisi invarianza scala/tick e candle.
## Layout
```
strategy_pythagoras/
├── backend/ paper trading runner (PaperExecutor, Portfolio, PaperRepository)
│ └── schema.py tabelle paper_trading_* (DB locale dedicato)
├── frontend/ NiceGUI dashboard (tab invariance, candle, equity, ticks)
├── strategies/ JSON freezate input al runner
│ (pythagoras_*.json)
└── prompts.json 7 stili di prompt LLM (candle-pattern, frattale, ratio,
pivot, kagi, renko, hybrid)
```
## Run paper-trading smoke
```bash
uv run python scripts/run_pythagoras_smoke.py \
--name pythagoras-smoke-001 \
--initial-capital 1000 \
--poll-seconds 300
```
Il default `--strategies-dir` punta ai JSON shippati col package via
`importlib.resources.files("strategy_pythagoras") / "strategies"`.
## Dashboard
```bash
uv run python -m strategy_pythagoras.frontend.nicegui_app
```
In produzione: `https://swarm.tielogic.xyz/strategy_pythagoras_gui/`
(root_path configurato via `DASHBOARD_ROOT_PATH=/strategy_pythagoras_gui`).
## DB schema
Schema isolato dal core e dalle altre strategie. Due DB distinti:
- `state/strategy_pythagoras.db` — GA + analisi invarianza
(env `STRATEGY_PYTHAGORAS_DB_PATH`)
- `state/strategy_pythagoras_paper.db` — paper-trading runs
(env `STRATEGY_PYTHAGORAS_PAPER_DB_PATH`)
Tabelle paper-trading:
- `paper_trading_runs` — metadata run (id, name, capital, status)
- `paper_trading_positions` — posizioni aperte (long/short)
- `paper_trading_trades` — trade realized (entry/exit, pnl, fees)
- `paper_trading_equity` — equity curve snapshot
- `paper_trading_ticks` — log signal/action per ogni bar
DDL gestito da `strategy_pythagoras.backend.schema.init_schema()`.
La dashboard legge **anche** il `runs.db` del core GA (env `GA_DB_PATH`)
per correlare paper performance con i genomi di provenienza e con i
risultati di fitness invariance.
## References
- Spec: `docs/superpowers/specs/2026-05-19-strategy-pythagoras-design.md`
- Plan: `docs/superpowers/plans/2026-05-19-strategy-pythagoras.md`
- Summary paper: `Pythagoras/Pythagoras_Trading_Prediction.summary.md`
- Summary frattali: `Pythagoras/Libro_frattali.summary.md`
- Pattern member: vedi `src/strategy_crypto/README.md`
+21
View File
@@ -0,0 +1,21 @@
[project]
name = "strategy-pythagoras"
version = "0.1.0"
description = "Strategy Pythagoras: candle-pattern GA su framework Pythagoras-Malanga, paper-trading runner + NiceGUI dashboard"
authors = [{ name = "Adriano Dal Pastro", email = "adrianodalpastro@tielogic.com" }]
requires-python = ">=3.13"
dependencies = [
"multi-swarm-core",
"nicegui>=3.11.1",
"plotly>=5.24",
"pandas>=2.2",
"pyarrow>=18.0",
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel.force-include]
"strategy_pythagoras/strategies" = "strategy_pythagoras/strategies"
"strategy_pythagoras/prompts.json" = "strategy_pythagoras/prompts.json"
@@ -0,0 +1 @@
{}
Generated
+24
View File
@@ -18,6 +18,7 @@ members = [
"multi-swarm-coevolutive", "multi-swarm-coevolutive",
"multi-swarm-core", "multi-swarm-core",
"strategy-crypto", "strategy-crypto",
"strategy-pythagoras",
] ]
[[package]] [[package]]
@@ -900,6 +901,7 @@ source = { virtual = "." }
dependencies = [ dependencies = [
{ name = "multi-swarm-core" }, { name = "multi-swarm-core" },
{ name = "strategy-crypto" }, { name = "strategy-crypto" },
{ name = "strategy-pythagoras" },
] ]
[package.dev-dependencies] [package.dev-dependencies]
@@ -917,6 +919,7 @@ dev = [
requires-dist = [ requires-dist = [
{ name = "multi-swarm-core", editable = "src/multi_swarm_core" }, { name = "multi-swarm-core", editable = "src/multi_swarm_core" },
{ name = "strategy-crypto", editable = "src/strategy_crypto" }, { name = "strategy-crypto", editable = "src/strategy_crypto" },
{ name = "strategy-pythagoras", editable = "src/strategy_pythagoras" },
] ]
[package.metadata.requires-dev] [package.metadata.requires-dev]
@@ -1980,6 +1983,27 @@ requires-dist = [
{ name = "pyarrow", specifier = ">=18.0" }, { name = "pyarrow", specifier = ">=18.0" },
] ]
[[package]]
name = "strategy-pythagoras"
version = "0.1.0"
source = { editable = "src/strategy_pythagoras" }
dependencies = [
{ name = "multi-swarm-core" },
{ name = "nicegui" },
{ name = "pandas" },
{ name = "plotly" },
{ name = "pyarrow" },
]
[package.metadata]
requires-dist = [
{ name = "multi-swarm-core", editable = "src/multi_swarm_core" },
{ name = "nicegui", specifier = ">=3.11.1" },
{ name = "pandas", specifier = ">=2.2" },
{ name = "plotly", specifier = ">=5.24" },
{ name = "pyarrow", specifier = ">=18.0" },
]
[[package]] [[package]]
name = "tenacity" name = "tenacity"
version = "9.1.4" version = "9.1.4"