Stratex is the dedicated 24/7 algorithmic trading, quantitative execution, and live telemetry platform of the FRIDAY Universe. It operates autonomously in continuous execution mode to discover trade opportunities, evaluate multi-timeframe quantitative strategies, manage microstructural friction, enforce portfolio risk limits, and execute orders against Binance Testnet while providing real-time telemetry streaming to the ecosystem.
flowchart TD
subgraph Public["Public Internet (HTTPS)"]
Gateway["Reverse Proxy: https://friday-universe.duckdns.org/stratex/*"]
end
subgraph Mesh["friday_mesh (Private Docker Network)"]
subgraph StratexContainer["Stratex Container (:8000, Non-Root appuser)"]
Supervisor["Process Supervisor: scripts/supervise_services.py"]
WSGI["Gunicorn WSGI: dashboard:app (2 workers, 4 threads, timeout: 0)"]
Bot["Trading Bot Daemon: bot.py (Singleton Socket Lock)"]
Resilience["Resilience Layer: CircuitBreakers, TTLCache, Secret Sanitizer"]
Engine["Testnet Engine: Risk Gates & Execution Funnel"]
Supervisor --> WSGI
Supervisor --> Bot
WSGI <--> Resilience
Bot <--> Resilience
Bot --> Engine
end
subgraph Upstream["Upstream FRIDAY Mesh Microservices"]
Memora["Memora (:8000)"]
Inference["Inference / Cortex (:8000)"]
IntelX["IntelX (:8000)"]
Futuris["Futuris (:8000)"]
end
Resilience -.->|Circuit-Broken Async Requests| Memora
Resilience -.->|Circuit-Broken Async Requests| Inference
Resilience -.->|Circuit-Broken Async Requests| IntelX
Resilience -.->|Circuit-Broken Async Requests| Futuris
end
Gateway -->|Forward /stratex/*| WSGI
Stratex is modernized and deployed on Oracle Cloud Always Free:
| Component | Specification |
|---|---|
| Hardware Target | Oracle Cloud Always Free (2 OCPUs, 12 GB RAM Ampere A1 ARM64 / AMD x86_64 host) |
| Public Gateway URL | https://friday-universe.duckdns.org/stratex/ |
| Internal Mesh URL | http://stratex:8000 (Directly reachable by FRIDAY Core) |
| Internal Container Port | 8000 (Port 5000 is permanently decommissioned) |
| Host Mapped Port | 8008 (8008:8000) |
| Container Mesh Network | friday_mesh (Docker bridge network managed with Caddy HTTPS proxy) |
| Execution WSGI Stack | Multi-threaded Gunicorn (--bind 0.0.0.0:8000 --workers 2 --threads 4 --timeout 0 dashboard:app) |
| Bot Execution Daemon | Singleton process bot.py managed via scripts/supervise_services.py |
Stratex implements strict defense-in-depth safeguards preventing unintended real-money order execution:
- Testnet / Paper Isolation:
LIVE_TRADING_ENABLEDis hardcoded toFalseby default in source.ExecutionPolicy.can_place_order()strictly checksTRADING_MODE,TESTNET_ENABLED, andLIVE_TRADING_ENABLED. Orders are blocked with explicit rejection reasons (LIVE_TRADING_LOCKED,TESTNET_DISABLED).
- Singleton Socket Lock:
bot.pyacquires an exclusive local socket lock (acquire_singleton_lock(port=48888)) withSO_REUSEADDRandatexitcleanup. This guarantees that container restarts or duplicate supervisor triggers cannot run parallel order-dispatching loops.
- Atomic File Persistence:
- Trade ledgers (
testnet_trade_ledger.jsonl), portfolio snapshots (testnet_portfolio.json), and equity records (testnet_equity_history.jsonl) are managed via atomic write-and-rename mechanics to prevent file corruption during abrupt shutdowns.
- Trade ledgers (
- Signal Trapping & Clean Teardown:
scripts/supervise_services.pytrapsSIGTERM,SIGINT, andSIGHUP. It forwards termination signals to both child processes, awaiting exit for up to 5 seconds before forcing termination.
Stratex provides structured JSON and Server-Sent Event (SSE) endpoints:
Returns process liveness status suitable for container orchestrators and reverse proxy healthchecks.
{
"status": "ok",
"dashboard": "online",
"mode": "TESTNET",
"evidence_class": "process_liveness",
"engine": "online",
"engine_healthy": true,
"engine_trading_capable": false,
"capability_reasons": ["NO_VALIDATED_STRATEGIES_LOADED"],
"observed_at": "2026-10-14T21:30:00Z"
}Returns HTTP 200 OK only when the trading engine has a fresh heartbeat and is capable of generating signals, or HTTP 503 Service Unavailable otherwise.
Authoritative system status, portfolio balances, risk utilization, and performance metrics.
{
"status": "ok",
"dashboard": "online",
"evidence_class": "process_liveness",
"mode": "TESTNET",
"overall_health": "OK",
"equity": 10000.0,
"cash": 10000.0,
"crypto_holdings_value": 0.0,
"total_pnl": 0.0,
"realized_pnl": 0.0,
"unrealized_pnl": 0.0,
"win_rate": 0.0,
"open_positions": 0,
"max_drawdown": 0.0,
"observed_at": "2026-10-14T21:30:00Z"
}Server-Sent Events (SSE) telemetry stream for real-time frontend charts and bot state propagation.
- Note: Requires
--timeout 0in Gunicorn WSGI configuration to prevent connection drops.
Returns current open positions, active stop-loss (SL) / take-profit (TP) prices, unrealized PnL, and duration.
Returns the historical executed trades ledger, win/loss breakdown, gross profit/loss, and total net returns.
Real-time diagnostic telemetry on all internal mesh circuit breakers (intelx, futuris, inference_prediction):
{
"status": "OK",
"service": "stratex",
"circuit_breakers": {
"intelx": {
"name": "intelx",
"state": "CLOSED",
"failure_count": 0,
"failure_threshold": 4,
"recovery_timeout": 30.0,
"total_trips": 0,
"seconds_since_state_change": 12.4
}
},
"timestamp": "2026-10-14T21:30:00Z"
}All API routes (/api/*) return clean, predictable, and sanitized JSON error payloads:
{
"error": "BAD_REQUEST",
"message": "Invalid query parameters provided",
"success": false
}Emergency risk control endpoints to immediately halt scanning, disallow new entries, or flatten existing exposures. Protected by require_bot_api_key and scoped authentication tokens.
STRATEX_EXECUTION_MODE=DISABLEDis the default. Set it toDEMOonly after the selected venue's demo credentials and safety configuration have been verified.STRATEX_ALLOWED_EXECUTION_VENUESexplicitly allowlists eligible venues; MT5 is not allowed by default.STRATEX_ORDER_DB=state/stratex_orders.sqlite3stores order intents and idempotency state. The state directory is persistent runtime data and must not be committed.- The new shared OMS package is a foundation for venue routing and duplicate protection; the legacy strategy engine must still be wired to it before this is end-to-end.
Stratex reads environment variables from .env. A complete configuration template is provided in .env.example.
The credential sets for legacy Binance Testnet and the current Demo Trading environment are not interchangeable. When BINANCE_DEMO_TRADING=true, the Binance venue agent requires the fresh BINANCE_API_KEY and BINANCE_API_SECRET values and pins execution to Demo endpoints. It does not fall back to legacy keys. Use GET /api/agents to inspect the safe agent catalog and configuration state.
| Variable | Description | Default | Allowed Values |
|---|---|---|---|
PORT |
WSGI listening port | 8000 |
Any valid TCP port |
TRADING_MODE |
Execution mode | PAPER |
PAPER, TESTNET, FUTURES |
TESTNET_ENABLED |
Allow the existing non-production execution path | False in the sample |
True, False |
LIVE_TRADING_ENABLED |
Live money trading | False |
Must remain False |
BINANCE_DEMO_TRADING |
Select current Binance Demo Trading endpoints | false |
true, false |
BINANCE_API_KEY |
Current Binance Demo Trading API key (when Demo Trading is selected) | Empty | Demo Trading key only |
BINANCE_API_SECRET |
Current Binance Demo Trading API secret | Empty | Demo Trading secret only |
API_KEY / SECRET_KEY |
Legacy Binance Testnet credentials (used only when Demo Trading is false) | Placeholder in sample | Legacy Testnet keys only |
MT5_BRIDGE_ENABLED |
Enable the remote MT5 bridge adapter | false |
true, false |
MT5_BRIDGE_URL |
Private/VPN address for the Windows MT5 bridge | Empty | Private network URL only |
MT5_BRIDGE_TOKEN |
Bearer token for the MT5 bridge | Empty | High-entropy secret |
MAX_TESTNET_EXPOSURE |
Maximum portfolio capital exposure | 0.05 |
Float (e.g. 0.05 = 5%) |
MAX_DAILY_LOSS_PCT |
Maximum daily loss tolerance | 0.02 |
Float (e.g. 0.02 = 2%) |
MAX_TESTNET_DRAWDOWN_PCT |
Maximum drawdown circuit breaker | 0.05 |
Float (e.g. 0.05 = 5%) |
MAX_OPEN_POSITIONS |
Maximum simultaneous open positions | 5 |
Positive integer |
INFERENCE_URL |
FRIDAY Cortex / Inference gateway | https://friday-universe.duckdns.org/cortex |
Mesh route |
MEMORA_URL |
FRIDAY Memora cloud memory gateway | https://friday-universe.duckdns.org/memora |
Mesh route |
INTELX_URL |
FRIDAY IntelX research gateway | https://friday-universe.duckdns.org/intelx |
Mesh route |
FUTURIS_URL |
FRIDAY Futuris predictive forecasting | https://friday-universe.duckdns.org/futuris |
Mesh route |
STRATEX_URL |
Public Stratex gateway route | https://friday-universe.duckdns.org/stratex |
Gateway URL |
Run Stratex directly attached to the friday_mesh Docker bridge:
# 1. Create or ensure friday_mesh exists
docker network create friday_mesh || true
# 2. Build and launch container
docker compose up -d --build
# 3. Check container logs
docker compose logs -f stratexTo execute locally under Python 3.11+:
# 1. Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# 2. Install dependencies
pip install -r requirements.txt
# 3. Launch supervised services
python scripts/supervise_services.pyRun the full automated test suite:
pytest -v --tb=shortThe read-only market-data layer now normalizes broker-native instruments, quotes and OHLCV bars by explicit venue. Use GET /api/v1/market/instruments?venue=all to discover symbols and contract constraints, GET /api/v1/market/quote?venue=mt5&symbol=EURUSD for one broker's quote, and GET /api/v1/market/candles?venue=mt5&symbol=EURUSD&timeframe=15m for that venue's candles. These endpoints require read API scope. MT5 returns the broker's exact symbol names and contract sizing; the market-data layer never assumes an MT5 lot is equivalent to a Binance quantity.
The existing Futures strategy path now has an explicit, disabled-by-default integration point. STRATEX_ORDER_MANAGER_ENABLED=false preserves the legacy executor. When it is explicitly enabled, the Futures entry call requires the current RiskGate and risk context, creates a normalized TradeIntent, and sends it through the shared OMS. The OMS calls the same deterministic RiskGate again immediately before submit, checks the execution policy and kill switch, persists the order ID/status, and refuses blind retries for an ambiguous result. Successful protected fills are mirrored to the legacy active-trade store so the existing Futures monitor/trailing loops can see the protective Algo Order IDs.
This flag is not a production readiness toggle. Keep STRATEX_EXECUTION_MODE=DISABLED and STRATEX_ORDER_MANAGER_ENABLED=false until CI is green, Demo Trading keys are installed privately, a Binance demo integration run verifies fills + both protective Algo orders + sibling-order cancellation, and restart/reconciliation tests have passed. MT5 routing remains allowlisted separately and requires its own demo bridge soak test.
A read-only reconciliation process can be supervised alongside the trading engine. It remains off unless both STRATEX_ORDER_MANAGER_ENABLED=true and STRATEX_RECONCILIATION_ENABLED=true, the runtime is explicitly Demo Futures, the live flag is false, and the selected venues are properly configured. It never creates or cancels orders; ambiguous states remain unresolved until a venue confirms them. Keep both flags disabled until complete demo validation.