Add integration tests for execution persistence, metrics, and opportunity writing
CI / lint-test-build (push) Failing after 1m23s
CI / lint-test-build (push) Failing after 1m23s
- Implemented integration tests for the execution writer to ensure trade orders and PnL are persisted correctly. - Created integration tests for the metrics calculator to summarize execution data accurately. - Added integration tests for the opportunity writer to verify event persistence. - Established PostgreSQL schema validation tests to ensure all expected tables, columns, and constraints exist. - Removed outdated unit tests that relied on DuckDB and replaced them with tests using PgStore.
This commit is contained in:
@@ -8,7 +8,7 @@ Primary goals:
|
||||
|
||||
- Detect and execute triangular opportunities on Kraken with fee/slippage-aware math.
|
||||
- Keep hot-path latency low with incremental order-book updates and event-driven scoring.
|
||||
- Persist operational data in DuckDB for dev, test, and prod.
|
||||
- Persist operational data in PostgreSQL for all environments.
|
||||
- Provide operator controls, audit trail, and alerting through a server-rendered dashboard.
|
||||
- Support backtesting, parameter sweeps, and deferred experimental strategy work behind feature flags.
|
||||
|
||||
@@ -17,7 +17,7 @@ Primary goals:
|
||||
- Python 3.12+ runtime.
|
||||
- Native Kraken WebSocket on the hot path.
|
||||
- HTMX + Jinja2 UI, no SPA build step.
|
||||
- DuckDB everywhere.
|
||||
- PostgreSQL everywhere.
|
||||
- Self-hosted Gitea Actions CI and Gitea registry.
|
||||
- Windows development support.
|
||||
- Secrets must stay out of the repository.
|
||||
@@ -32,7 +32,7 @@ The bot consumes Kraken market data, detects opportunities, and executes trades
|
||||
|
||||
- Kraken REST + WebSocket provide market data and execution.
|
||||
- FastAPI serves HTML fragments, JSON endpoints, and SSE streams.
|
||||
- DuckDB stores trades, opportunities, snapshots, audit events, and runtime state.
|
||||
- PostgreSQL stores trades, opportunities, snapshots, audit events, and runtime state.
|
||||
- Coolify can deploy the published image using environment variables and persistent storage.
|
||||
|
||||
## 4. Solution Strategy
|
||||
@@ -55,7 +55,7 @@ The bot consumes Kraken market data, detects opportunities, and executes trades
|
||||
- `execution/` - multi-leg trade sequencing.
|
||||
- `backtesting/` - replay engine, parameter sweep, experiment scaffolds.
|
||||
- `strategy/` - experimental strategy modules such as stat-arb.
|
||||
- `storage/` - DuckDB schema and repositories.
|
||||
- `storage/` - PostgreSQL schema and repositories.
|
||||
- `alerting/` - multi-channel notifications.
|
||||
- `runtime/` - startup recovery and graceful shutdown.
|
||||
|
||||
@@ -64,7 +64,7 @@ The bot consumes Kraken market data, detects opportunities, and executes trades
|
||||
- `fastapi`, `uvicorn`, `jinja2`, `htmx`-driven templates.
|
||||
- `orjson` for low-alloc parsing.
|
||||
- `sortedcontainers` for book state.
|
||||
- `duckdb` for persistence and analytics.
|
||||
- `asyncpg` for PostgreSQL persistence.
|
||||
- `pydantic` / `pydantic-settings` for typed configuration.
|
||||
- `cryptography` / keyring for secret handling.
|
||||
|
||||
@@ -77,7 +77,7 @@ The bot consumes Kraken market data, detects opportunities, and executes trades
|
||||
3. Incremental detector scores impacted cycles.
|
||||
4. Risk manager validates the opportunity.
|
||||
5. Execution sequencer places legs if approved.
|
||||
6. Trades and snapshots persist to DuckDB.
|
||||
7. Trades and snapshots persist to PostgreSQL.
|
||||
7. Dashboard and alerts reflect state changes.
|
||||
|
||||
### 6.2 Dashboard Control Flow
|
||||
@@ -112,7 +112,7 @@ The bot consumes Kraken market data, detects opportunities, and executes trades
|
||||
|
||||
- Deploy from the published image.
|
||||
- Configure runtime via environment variables.
|
||||
- Mount persistent storage at `/app/data` for DuckDB.
|
||||
- Connect to PostgreSQL at configured `PG_HOST`.
|
||||
|
||||
## 8. Cross-Cutting Concepts
|
||||
|
||||
@@ -126,7 +126,7 @@ The bot consumes Kraken market data, detects opportunities, and executes trades
|
||||
## 9. Architecture Decisions
|
||||
|
||||
- Native Kraken WS instead of a generic exchange abstraction on the hot path.
|
||||
- DuckDB as the single database engine.
|
||||
- PostgreSQL as the single database engine.
|
||||
- HTMX + Jinja2 instead of SPA frontend.
|
||||
- Backtesting reuses production detector/risk/execution logic.
|
||||
- Experimental stat-arb stays behind a feature flag.
|
||||
@@ -152,5 +152,5 @@ The bot consumes Kraken market data, detects opportunities, and executes trades
|
||||
- WS: WebSocket.
|
||||
- HTMX: HTML-over-the-wire UI library.
|
||||
- SSE: Server-Sent Events.
|
||||
- DUCKDB: Embedded analytical database used for all environments.
|
||||
- PGSQL: PostgreSQL database used for all environments.
|
||||
- Stat arb: Statistical arbitrage, currently experimental and feature-flagged.
|
||||
|
||||
Reference in New Issue
Block a user