feat: queue-aware paper fills, kill switch, systemd services, WQI+FundingArb in paper trader

- live/paper_trader.py: replaced random 5% fill probability in simulate_avellaneda()
  with QueueAwareFillModel — fills only when aggressor volume exceeds depth ahead,
  regime-adaptive quote placement (tight in LOW_VOL, wide in HIGH_VOL). Integrated
  WQI Predictor and Funding Rate Arb as new strategies with signal generation.
  Dashboard metrics now include WQI summaries, funding arb status, and fill model
  throughput stats (fill rate, fills vs skips). 14 strategies total.
- scripts/kill_switch.py: emergency kill switch — flattens all positions, cancels
  all open orders, verifies account is flat. Supports --dry-run, --mainnet, retry
  logic, L1 action signing. Reads private key from HL_PRIVATE_KEY env or ~/.hl/key.
- infrastructure/systemd/: three service unit files for production deployment:
  ftdt-collector (data collection), ftdt-paper (trading node v2), ftdt-dashboard
  (FastAPI backend). Includes memory/cpu limits, auto-restart, log rotation.

321 tests passing.
This commit is contained in:
ramseshk
2026-08-11 11:28:01 +08:00
parent 3073415d33
commit 09cb0d42b5
5 changed files with 526 additions and 55 deletions
@@ -0,0 +1,26 @@
# FTDT Quant Lab — Data Collector
# Install: sudo cp ftdt-collector.service /etc/systemd/system/
# sudo systemctl enable ftdt-collector
# sudo systemctl start ftdt-collector
[Unit]
Description=FTDT Quant Lab — Hyperliquid Data Collector
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=satoshi
WorkingDirectory=/home/satoshi/ftdt-quant-lab
Environment=PYTHONUNBUFFERED=1
Environment=PATH=/home/satoshi/ftdt-quant-lab/.venv/bin:/usr/local/bin:/usr/bin:/bin
ExecStart=/home/satoshi/ftdt-quant-lab/.venv/bin/python -m cli collect --mainnet --coins BTC,ETH,SOL,HYPE --data-dir data/raw --poll-interval 60 --flush-interval 5
Restart=always
RestartSec=10
StandardOutput=append:/home/satoshi/ftdt-quant-lab/logs/collector.log
StandardError=append:/home/satoshi/ftdt-quant-lab/logs/collector.log
MemoryMax=512M
CPUQuota=50%
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,26 @@
# FTDT Quant Lab — Dashboard Server
# Install: sudo cp ftdt-dashboard.service /etc/systemd/system/
# sudo systemctl enable ftdt-dashboard
# sudo systemctl start ftdt-dashboard
[Unit]
Description=FTDT Quant Lab — FastAPI Dashboard Backend
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=satoshi
WorkingDirectory=/home/satoshi/ftdt-quant-lab
Environment=PYTHONUNBUFFERED=1
Environment=PATH=/home/satoshi/ftdt-quant-lab/.venv/bin:/usr/local/bin:/usr/bin:/bin
ExecStart=/home/satoshi/ftdt-quant-lab/.venv/bin/python dashboard/server.py --port 9175
Restart=always
RestartSec=5
StandardOutput=append:/home/satoshi/ftdt-quant-lab/logs/dashboard.log
StandardError=append:/home/satoshi/ftdt-quant-lab/logs/dashboard.log
MemoryMax=256M
CPUQuota=25%
[Install]
WantedBy=multi-user.target
+27
View File
@@ -0,0 +1,27 @@
# FTDT Quant Lab — Paper Trading Node
# Install: sudo cp ftdt-paper.service /etc/systemd/system/
# sudo systemctl enable ftdt-paper
# sudo systemctl start ftdt-paper
[Unit]
Description=FTDT Quant Lab — Paper Trading Node (v2)
After=network-online.target ftdt-collector.service
Wants=network-online.target
Requires=ftdt-collector.service
[Service]
Type=simple
User=satoshi
WorkingDirectory=/home/satoshi/ftdt-quant-lab
Environment=PYTHONUNBUFFERED=1
Environment=PATH=/home/satoshi/ftdt-quant-lab/.venv/bin:/usr/local/bin:/usr/bin:/bin
ExecStart=/home/satoshi/ftdt-quant-lab/.venv/bin/python -m live.node_v2 --testnet --coins BTC,ETH --mode paper --equity 100000 --metrics-file /tmp/ftdt-metrics-v2.json
Restart=always
RestartSec=15
StandardOutput=append:/home/satoshi/ftdt-quant-lab/logs/paper-node.log
StandardError=append:/home/satoshi/ftdt-quant-lab/logs/paper-node.log
MemoryMax=512M
CPUQuota=50%
[Install]
WantedBy=multi-user.target