A fully automated financial markets trading system with event detection, Bayesian signal scoring, and risk-managed execution.
Newton is a multi-stage trading system built with:
- Data Pipeline (Stage 1): Oanda + Binance data fetchers, TimescaleDB storage, technical indicators
- Event Detection (Stage 2): Configurable event detection, token generation, Bayesian scoring
- ML Pipeline (Stage 3): Feature engineering, XGBoost training, model evaluation
- UAT & Admin UI (Stage 4): React client, UAT test runner, admin panels (Feature Explorer, Signal Inspector, Regime Monitor, Model Dashboard)
- Trading Engine (Stage 5): Risk management, broker adapters, circuit breakers
- Backtesting (Stage 6): Historical simulation, performance metrics
- Paper/Live Trading (Stage 7-8): Deployment stages
Current status: Stage 6 complete (v0.6.12) — Backtesting. Stage 7 queued (Client Web UI). → See TASKS and CHANGELOG
┌─────────────────────────────────────────────────────────────┐
│ Client │
│ (Health panel → Data viewer → Signal display → ...) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ API Layer │
│ (FastAPI: /api/v1/health, /ohlcv, /features, /signal) │
└─────────────────────────────────────────────────────────────┘
│
┌──────────┬──────────┬──────────┬──────────┬──────────┐
▼ ▼ ▼ ▼ ▼
┌──────────┐┌──────────┐┌──────────┐┌──────────┐┌──────────┐
│ Data ││ Event ││ ML ││ Trading ││ Backtest │
│ Pipeline ││ Detection││ Pipeline ││ Engine ││ │
│ ││ ││ ││ ││- Simulator│
│- Fetchers││- Events ││- Features││- Risk ││- Engine │
│- Indicate││- Tokens ││- XGBoost ││- Executor││- Metrics │
│- Verifier││- Bayesian││- Ensemble││- Brokers ││- Reports │
└──────────┘└──────────┘└──────────┘└──────────┘└──────────┘
│
▼
┌────────────────────────────────────────────────┐
│ TimescaleDB (PostgreSQL) │
│ - ohlcv, features, events, tokens, config │
└────────────────────────────────────────────────┘
- Python 3.11+
- PostgreSQL 15+ with TimescaleDB extension
- Node.js 18+ (for client)
- Docker & Docker Compose (for database)
git clone https://github.com/rusty-oc/newton.git
cd newton
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtNotes on TA-Lib dependency:
ta-libis included inrequirements.txtas the canonical technical indicator engine.- Most Linux/macOS/Windows Python 3.11 environments receive prebuilt wheels.
- If wheel install is unavailable in your environment, install system TA-Lib C library first, then rerun
pip install -r requirements.txt.
docker compose up -dThis starts TimescaleDB on localhost:5432. Configure DATABASE_URL in your environment.
python scripts/db_bootstrap.py
python scripts/db_status.py./scripts/run_api.sh
# or: uvicorn src.app:app --reload --port 8000API available at http://localhost:8000 (docs at /api/docs).
Build static assets:
cd client
npm install
npm run buildRun options:
-
Dev mode (recommended for development):
cd client npm run devOpens on
http://localhost:4173with hot reload. Proxies/apicalls tohttp://127.0.0.1:8000(API server must be running). -
Integrated mode: run API via
./scripts/run_api.shand openhttp://localhost:8000/(serves built client fromclient/dist/).
The client provides:
- Health Dashboard — system status, broker connectivity, candle freshness with auto-refresh
- UAT Runner — run 28 behavioral tests across 7 suites with pass/fail results
- Admin Panels — Feature Explorer, Signal Inspector, Regime Monitor, Model Dashboard
- Backtest Runner — run backtests per instrument with equity curve, metrics, gate evaluation, regime breakdown, trade list, comparison view
Configuration files in config/ directory:
| File | Purpose |
|---|---|
system.json |
Global system settings |
risk.json |
Risk parameters (position limits, stops) |
instruments/*.json |
Instrument definitions |
strategies/*.json |
Strategy configurations |
feature_providers.json |
Indicator definitions |
classifications/*.json |
Token classification rules per instrument |
Environment variables (see .env.example):
DATABASE_URL— PostgreSQL connection stringOANDA_API_KEY— Oanda account keyBINANCE_API_KEY/BINANCE_API_SECRET— Binance credentials
ruff check . # Linting
mypy src # Type checking (strict)
pytest -q # Tests (includes coverage via addopts)
pytest --cov=src -q # Tests with explicit coverage reportpytest -q # all tests
pytest -q tests/unit # unit only
pytest -q tests/integration # integration onlygit checkout -b stage/{N}-{name}
# e.g., git checkout -b stage/2-event-detection- Database: Use managed TimescaleDB (Timescale Cloud, AWS RDS, etc.)
- API: Run behind reverse proxy (nginx, Caddy) with TLS
- Secrets: Never commit
.env— use secret management (HashiCorp Vault, AWS Secrets Manager) - Monitoring: Enable health endpoint monitoring (
/api/v1/health) - Backups: Configure TimescaleDB automated backups
Note: Dockerfile is a scaffold placeholder — containerized deployment is deferred to Stage 7 (DEC-012).
- SPEC — Standalone consolidated build specification (implementation-agnostic)
- SPEC_DRAFT — Canonical full specification draft
- DECISIONS — Accepted architecture/product decisions
- docs/dev — Developer documentation
- docs/ops — Operations runbooks
- docs/user — User guides
Newton uses 0.{STAGE}.{TASK} versioning:
0.1.5= Stage 1 complete0.2.8= Stage 2 complete0.3.10= Stage 3 complete0.4.8= Stage 4 complete0.5.12= Stage 5 complete0.6.12= Stage 6 complete- Fix releases:
0.4.6= Stage 4, fix tasks shipped
See CHANGELOG for release history.
Private — All rights reserved.