263470786d
Aggiunge la persistenza SQLite, l'audit log a hash chain, il kill switch coordinato e i CLI di gestione documentati in docs/05-data-model.md e docs/07-risk-controls.md. 197 test pass, 1 skipped (sqlite3 CLI mancante), copertura totale 97%. State (`state/`): - 0001_init.sql con positions, instructions, decisions, dvol_history, manual_actions, system_state. - db.py: connect con WAL + foreign_keys + transaction ctx, runner forward-only basato su PRAGMA user_version. - models.py: record Pydantic, Decimal preservato come TEXT. - repository.py: CRUD typed con singola connessione passata, cache aware, posizioni concorrenti. Safety (`safety/`): - audit_log.py: AuditLog append-only con SHA-256 chain e fsync, verify_chain riconosce ogni manomissione (payload, prev_hash, hash, JSON, separatori). - kill_switch.py: arm/disarm transazionali, idempotenti, accoppiati all'audit chain. Config (`config/loader.py` + `strategy.yaml`): - Loader YAML con deep-merge di strategy.local.yaml. - Verifica config_hash SHA-256 (riga config_hash esclusa). - File golden strategy.yaml + esempio override. Scripts: - dead_man.sh: watchdog shell indipendente da Python. - backup.py: VACUUM INTO orario con retention 30 giorni. CLI: - audit verify (exit 2 su tampering). - kill-switch arm/disarm/status su SQLite reale. - state inspect con tabella posizioni aperte. - config hash, config validate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
54 lines
1.0 KiB
Python
54 lines
1.0 KiB
Python
"""Strategy configuration: schema, loader, validation."""
|
|
|
|
from cerbero_bite.config.loader import (
|
|
ConfigHashError,
|
|
LoadedConfig,
|
|
compute_config_hash,
|
|
load_strategy,
|
|
)
|
|
from cerbero_bite.config.schema import (
|
|
AssetConfig,
|
|
DvolAdjustmentBand,
|
|
EntryConfig,
|
|
ExecutionConfig,
|
|
ExitConfig,
|
|
KellyConfig,
|
|
LiquidityConfig,
|
|
McpConfig,
|
|
MonitoringConfig,
|
|
ShortStrikeSpec,
|
|
SizingConfig,
|
|
SpreadType,
|
|
SpreadWidthSpec,
|
|
StorageConfig,
|
|
StrategyConfig,
|
|
StructureConfig,
|
|
TelegramConfig,
|
|
golden_config,
|
|
)
|
|
|
|
__all__ = [
|
|
"AssetConfig",
|
|
"ConfigHashError",
|
|
"DvolAdjustmentBand",
|
|
"EntryConfig",
|
|
"ExecutionConfig",
|
|
"ExitConfig",
|
|
"KellyConfig",
|
|
"LiquidityConfig",
|
|
"LoadedConfig",
|
|
"McpConfig",
|
|
"MonitoringConfig",
|
|
"ShortStrikeSpec",
|
|
"SizingConfig",
|
|
"SpreadType",
|
|
"SpreadWidthSpec",
|
|
"StorageConfig",
|
|
"StrategyConfig",
|
|
"StructureConfig",
|
|
"TelegramConfig",
|
|
"compute_config_hash",
|
|
"golden_config",
|
|
"load_strategy",
|
|
]
|