VaclavSercl/sniper

Rust

0

2 commits

updated Aug 16, 2026

See the code

README

🐺 Sniper Armada v21.0 Omni-Interface

Sovereign HFT Trading System β€” Pure Rust Hive with Omni-Router and in-process AI inference.

Version Architecture Rust AI Latency


⚑ Key Features

  • Omni-Router (Dual-Exchange) β€” Native Binance and Bitfinex support running concurrently in L0 hot paths.

  • The War Room Dashboard β€” 10Hz HTML5 Canvas SSE live data stream displaying OBI tachometers and VWS (Volume Weighted Spread).

  • 1088B Zero-Copy MMap Architecture (ArmadaStateV2) β€” Ultra-fast IPC telemetry memory mapping avoiding kernel overhead.

  • Sub-millisecond execution β€” Zero-allocation Rust hot paths with fixed-point arithmetic (i64 Γ— 1e8)

  • 5-bot fleet β€” Hydra (MM), Moonshot (flash dip), Grid (grid maker), Trigon (tri-arb), Nexus (cross-venue arb)

  • Dual AI inference β€” In-process Candle Logit Sniping (<20ms) + Gemini 3.1 Pro strategic oracle via ZeroClaw

  • Hexagonal Architecture β€” VenueAdapter trait enables zero-effort exchange integration (Bitfinex, Binance, ...)

  • Cognitive Engineering β€” Few-Shot anchored L1 prompt + Sovereign Constitution L2 with Chain-of-Thought forcing

  • Brain Transplant Protocol β€” Safe hot-swap GGUF models with shadow mode validation, zero downtime

  • Autonomous operation β€” Sovereign Boot Protocol (v20.0 Strategy Pattern) with 5 RiskClass Pillars (HEDGE, ARBITRAGE, MARKET_MAKER, STAT_ARB, POSITIONAL), quota watchdog, Sentinel guardian

  • Lock-free IPC β€” mmap with SeqLock atomics, 64-byte cache-line aligned structs via /dev/shm/beroun/

πŸ”§ V21.0 Omni-Interface Architecture Details

  • The War Room (V2 Omni-Interface Dashboard): A modern HTML5 Canvas-based tactical view streaming live telemetry at 10Hz via Server-Sent Events (SSE). Replaces static port-based views with zero-lag OBI (Order Book Imbalance) tachometers and Volume Weighted Spread depth-charts.
  • ArmadaStateV2 (1088B Zero-Copy MMap): Highly optimized memory mapping protocol for sub-millisecond data sharing. Layout eliminates kernel syscall bottlenecks, enabling lock-free state synchronization between Python orchestrators and Rust HFT threads.
  • Cross-Exchange Arbitrage (VWS): Omni-Router natively integrates Bitfinex and Binance under a Volume Weighted Spread mechanism. Nexus analyzes true depth parity before executing latency-padded atomic cross-venue fills.
  • Autonomous ML Injector & Hot-Swap: Safe, lock-free Candle GGUF tensor weight deployments, allowing zero-downtime model swaps dynamically informed by L2 regime context.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   L0: MUSCLE         β”‚     β”‚   L1: REFLEXES           β”‚     β”‚   L2: GENERAL             β”‚
β”‚   (Rust Execution)   β”‚     β”‚   (Candle + Cortex)      β”‚     β”‚   (ZeroClaw + Gemini)     β”‚
β”‚                     β”‚     β”‚                         β”‚     β”‚                          β”‚
β”‚  Hydra  ──┐         β”‚     β”‚  Candle L1 Brain        β”‚     β”‚  Sovereign Constitution  β”‚
β”‚  Grid   ─── mmap ◀──┼──────  Logit Sniping (<20ms)  β”‚     β”‚  Gemini 3.1 Pro Preview  β”‚
β”‚  Moonshot──         β”‚     β”‚  4-token: BID/ASK/      β”‚     β”‚  <thinking> CoT forcing  β”‚
β”‚  Trigon ───         β”‚     β”‚    HOLD/KILL             β”‚     β”‚  RAG memory (SQLite)     β”‚
β”‚  Nexus  β”€β”€β”˜         β”‚     β”‚  CPU mode (GTX 1060)    β”‚     β”‚  Telegram alerts         β”‚
β”‚                     β”‚     β”‚                         β”‚     β”‚  Quota Watchdog (5min)   β”‚
β”‚  VenueAdapter trait  β”‚     β”‚                         β”‚     β”‚                          β”‚
β”‚  Bitfinex + Binance  β”‚     β”‚                         β”‚     β”‚  Hard Guardrails:        β”‚
β”‚                     β”‚     β”‚  ChatTemplate Resolver   β”‚     β”‚  FAIL-FAST / MAX EXPO /  β”‚
β”‚                     β”‚     β”‚  (Phi3/Llama3/Qwen2/    β”‚     β”‚  ANTI-JITTER             β”‚
β”‚                     β”‚     β”‚   Gemma2/Mistral)       β”‚     β”‚                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        <1ms                        <20ms                          ~5min cycle

πŸš€ Quick Start

# Build all bots + AI
cargo build --release

# Deploy fleet
./deploy_armada.sh --build

# Start ZeroClaw L2 Oracle
export GEMINI_API_KEY=your_key
zeroclaw daemon

# Hot restart via systemd
sudo systemctl restart sniper-armada

# Status
zeroclaw status

πŸ“¦ Repository Structure

sniper/
β”œβ”€β”€ hydra/              # L0 Market Maker (Rust β€” Bitfinex WS)
β”œβ”€β”€ moonshot/           # L0 Flash Crash Dip Buyer (Rust β€” multi-pair)
β”œβ”€β”€ grid/               # L0 Dynamic Grid Maker (Rust β€” L2 warped)
β”œβ”€β”€ trigon/             # L0 Triangular Arbitrage (Rust β€” 14 triangles)
β”œβ”€β”€ nexus/              # L0 Cross-Exchange Arb (Rust β€” Binance↔Bitfinex)
β”œβ”€β”€ shared/             # sniper-shared crate (types, IPC, framework, venues)
β”‚   └── src/exchange/   #   VenueAdapter trait + BitfinexVenue + BinanceVenue
β”œβ”€β”€ candle-brain/       # 🧠 In-process L1 AI inference (Candle + GGUF)
β”‚   β”œβ”€β”€ src/brain.rs    #   CandleL1Brain β€” GGUF model loading + inference
β”‚   β”œβ”€β”€ src/logit_sniper.rs  # Logit Sniping β€” 4-token classifier
β”‚   β”œβ”€β”€ src/chat_template.rs # Model-agnostic template resolver
β”‚   └── src/transplant.rs    # SBP v3.1 Brain Transplant Protocol
β”œβ”€β”€ architect/          # L1 Cortex (Rust) + L2 Oracle + Commander
β”‚   β”œβ”€β”€ cortex/         #   Sovereign Cortex daemon (Sentinel, GPU, UDS)
β”‚   β”œβ”€β”€ l2_oracle.py    #   Legacy L2 brain (replaced by ZeroClaw)
β”‚   └── tg_commander.py #   Telegram interface + bot management
β”œβ”€β”€ zeroclaw/           # 🐝 ZeroClaw L2 Orchestrator
β”‚   β”œβ”€β”€ config.toml     #   Gemini 3.1 Pro, SQLite RAG, Telegram
β”‚   β”œβ”€β”€ system_prompt.md#   Sovereign Constitution (CRO persona)
β”‚   └── tools/          #   mmap tools (read_engine_state, write_risk_param, quota_watchdog)
β”œβ”€β”€ infra/              # systemd service, install/stop scripts
β”œβ”€β”€ state/              # Persistent pre-crash state (armada_state.json)
β”œβ”€β”€ deploy_armada.sh    # Sovereign Boot Script
β”œβ”€β”€ watchdog.sh         # Cron-based process monitor
β”œβ”€β”€ ARCHITECTURE.md     # Full system documentation
└── README.md           # This file

🧠 AI Layers

L1 β€” Logit Sniping (Candle, In-Process)

ROLE: Ultra-low latency HFT Reflex Core.
TASK: Classify L2 microstructure to predict next 100ms price tick.
OUTPUT: EXACTLY ONE TOKEN FROM [BID, ASK, HOLD, KILL].
  • No text generation β€” reads raw logits for 4 tokens in <20ms
  • Model-agnostic β€” ChatTemplate auto-detects Phi-3.5, Llama-3, Qwen2, Gemma2, Mistral
  • Few-Shot anchored β€” 3 in-context examples force deterministic classification
  • KILL action β€” immediate order cancellation on toxic sweep detection

L2 β€” Sovereign Constitution (ZeroClaw + Gemini 3.1 Pro)

  • Chain-of-Thought forcing β€” <thinking> block required before any Tool Call
  • Hard Guardrails β€” FAIL-FAST, MAX EXPOSURE (0.05 BTC), ANTI-JITTER
  • RAG Memory β€” SQLite vector DB recalls past decisions and their outcomes
  • Brain Transplant β€” safe hot-swap of GGUF models with shadow validation

πŸ›‘οΈ Safety Guarantees

LayerMechanismProtection
L0SeqLock + AtomicsData consistency without locks
L1OBI + Sweep + KILLToxic flow protection (<20ms)
L1Sentinel (4-layer)PnL crash, position drift, heartbeat
L1Brain TransplantSafe model swap with rollback
L2Hard GuardrailsFAIL-FAST, MAX EXPO, ANTI-JITTER
L2Quota WatchdogTelegram alert on API quota exhaustion
L2Sovereign Boot ProtocolPaper→Live validation (66min)
OSsystemd Restart=alwaysAuto-restart on failure, OOM protection
OSwatchdog.sh (cron)Last-resort process resurrection

πŸ”§ Production Setup

# Prerequisites
sudo apt install -y nvidia-cuda-toolkit   # For future GPU acceleration

# Install systemd service + kernel tuning
sudo ./infra/install_service.sh

# Configure API keys
cp .env.example .env
# Edit: BITFINEX_API_KEY, BINANCE_API_KEY, TELEGRAM_BOT_TOKEN, GEMINI_API_KEY

# ZeroClaw onboarding
zeroclaw onboard --quick --provider gemini --model gemini-2.5-pro

# Verify
sudo systemctl status sniper-armada
zeroclaw status

πŸ“š Guides

πŸ“„ License

Private. All rights reserved.

Contributors

VaclavSercl

2 commits

VaclavSercl/sniper

Rust

0

2 commits

updated Aug 16, 2026

See the code

README

🐺 Sniper Armada v21.0 Omni-Interface

Sovereign HFT Trading System β€” Pure Rust Hive with Omni-Router and in-process AI inference.

Version Architecture Rust AI Latency


⚑ Key Features

  • Omni-Router (Dual-Exchange) β€” Native Binance and Bitfinex support running concurrently in L0 hot paths.

  • The War Room Dashboard β€” 10Hz HTML5 Canvas SSE live data stream displaying OBI tachometers and VWS (Volume Weighted Spread).

  • 1088B Zero-Copy MMap Architecture (ArmadaStateV2) β€” Ultra-fast IPC telemetry memory mapping avoiding kernel overhead.

  • Sub-millisecond execution β€” Zero-allocation Rust hot paths with fixed-point arithmetic (i64 Γ— 1e8)

  • 5-bot fleet β€” Hydra (MM), Moonshot (flash dip), Grid (grid maker), Trigon (tri-arb), Nexus (cross-venue arb)

  • Dual AI inference β€” In-process Candle Logit Sniping (<20ms) + Gemini 3.1 Pro strategic oracle via ZeroClaw

  • Hexagonal Architecture β€” VenueAdapter trait enables zero-effort exchange integration (Bitfinex, Binance, ...)

  • Cognitive Engineering β€” Few-Shot anchored L1 prompt + Sovereign Constitution L2 with Chain-of-Thought forcing

  • Brain Transplant Protocol β€” Safe hot-swap GGUF models with shadow mode validation, zero downtime

  • Autonomous operation β€” Sovereign Boot Protocol (v20.0 Strategy Pattern) with 5 RiskClass Pillars (HEDGE, ARBITRAGE, MARKET_MAKER, STAT_ARB, POSITIONAL), quota watchdog, Sentinel guardian

  • Lock-free IPC β€” mmap with SeqLock atomics, 64-byte cache-line aligned structs via /dev/shm/beroun/

πŸ”§ V21.0 Omni-Interface Architecture Details

  • The War Room (V2 Omni-Interface Dashboard): A modern HTML5 Canvas-based tactical view streaming live telemetry at 10Hz via Server-Sent Events (SSE). Replaces static port-based views with zero-lag OBI (Order Book Imbalance) tachometers and Volume Weighted Spread depth-charts.
  • ArmadaStateV2 (1088B Zero-Copy MMap): Highly optimized memory mapping protocol for sub-millisecond data sharing. Layout eliminates kernel syscall bottlenecks, enabling lock-free state synchronization between Python orchestrators and Rust HFT threads.
  • Cross-Exchange Arbitrage (VWS): Omni-Router natively integrates Bitfinex and Binance under a Volume Weighted Spread mechanism. Nexus analyzes true depth parity before executing latency-padded atomic cross-venue fills.
  • Autonomous ML Injector & Hot-Swap: Safe, lock-free Candle GGUF tensor weight deployments, allowing zero-downtime model swaps dynamically informed by L2 regime context.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   L0: MUSCLE         β”‚     β”‚   L1: REFLEXES           β”‚     β”‚   L2: GENERAL             β”‚
β”‚   (Rust Execution)   β”‚     β”‚   (Candle + Cortex)      β”‚     β”‚   (ZeroClaw + Gemini)     β”‚
β”‚                     β”‚     β”‚                         β”‚     β”‚                          β”‚
β”‚  Hydra  ──┐         β”‚     β”‚  Candle L1 Brain        β”‚     β”‚  Sovereign Constitution  β”‚
β”‚  Grid   ─── mmap ◀──┼──────  Logit Sniping (<20ms)  β”‚     β”‚  Gemini 3.1 Pro Preview  β”‚
β”‚  Moonshot──         β”‚     β”‚  4-token: BID/ASK/      β”‚     β”‚  <thinking> CoT forcing  β”‚
β”‚  Trigon ───         β”‚     β”‚    HOLD/KILL             β”‚     β”‚  RAG memory (SQLite)     β”‚
β”‚  Nexus  β”€β”€β”˜         β”‚     β”‚  CPU mode (GTX 1060)    β”‚     β”‚  Telegram alerts         β”‚
β”‚                     β”‚     β”‚                         β”‚     β”‚  Quota Watchdog (5min)   β”‚
β”‚  VenueAdapter trait  β”‚     β”‚                         β”‚     β”‚                          β”‚
β”‚  Bitfinex + Binance  β”‚     β”‚                         β”‚     β”‚  Hard Guardrails:        β”‚
β”‚                     β”‚     β”‚  ChatTemplate Resolver   β”‚     β”‚  FAIL-FAST / MAX EXPO /  β”‚
β”‚                     β”‚     β”‚  (Phi3/Llama3/Qwen2/    β”‚     β”‚  ANTI-JITTER             β”‚
β”‚                     β”‚     β”‚   Gemma2/Mistral)       β”‚     β”‚                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        <1ms                        <20ms                          ~5min cycle

πŸš€ Quick Start

# Build all bots + AI
cargo build --release

# Deploy fleet
./deploy_armada.sh --build

# Start ZeroClaw L2 Oracle
export GEMINI_API_KEY=your_key
zeroclaw daemon

# Hot restart via systemd
sudo systemctl restart sniper-armada

# Status
zeroclaw status

πŸ“¦ Repository Structure

sniper/
β”œβ”€β”€ hydra/              # L0 Market Maker (Rust β€” Bitfinex WS)
β”œβ”€β”€ moonshot/           # L0 Flash Crash Dip Buyer (Rust β€” multi-pair)
β”œβ”€β”€ grid/               # L0 Dynamic Grid Maker (Rust β€” L2 warped)
β”œβ”€β”€ trigon/             # L0 Triangular Arbitrage (Rust β€” 14 triangles)
β”œβ”€β”€ nexus/              # L0 Cross-Exchange Arb (Rust β€” Binance↔Bitfinex)
β”œβ”€β”€ shared/             # sniper-shared crate (types, IPC, framework, venues)
β”‚   └── src/exchange/   #   VenueAdapter trait + BitfinexVenue + BinanceVenue
β”œβ”€β”€ candle-brain/       # 🧠 In-process L1 AI inference (Candle + GGUF)
β”‚   β”œβ”€β”€ src/brain.rs    #   CandleL1Brain β€” GGUF model loading + inference
β”‚   β”œβ”€β”€ src/logit_sniper.rs  # Logit Sniping β€” 4-token classifier
β”‚   β”œβ”€β”€ src/chat_template.rs # Model-agnostic template resolver
β”‚   └── src/transplant.rs    # SBP v3.1 Brain Transplant Protocol
β”œβ”€β”€ architect/          # L1 Cortex (Rust) + L2 Oracle + Commander
β”‚   β”œβ”€β”€ cortex/         #   Sovereign Cortex daemon (Sentinel, GPU, UDS)
β”‚   β”œβ”€β”€ l2_oracle.py    #   Legacy L2 brain (replaced by ZeroClaw)
β”‚   └── tg_commander.py #   Telegram interface + bot management
β”œβ”€β”€ zeroclaw/           # 🐝 ZeroClaw L2 Orchestrator
β”‚   β”œβ”€β”€ config.toml     #   Gemini 3.1 Pro, SQLite RAG, Telegram
β”‚   β”œβ”€β”€ system_prompt.md#   Sovereign Constitution (CRO persona)
β”‚   └── tools/          #   mmap tools (read_engine_state, write_risk_param, quota_watchdog)
β”œβ”€β”€ infra/              # systemd service, install/stop scripts
β”œβ”€β”€ state/              # Persistent pre-crash state (armada_state.json)
β”œβ”€β”€ deploy_armada.sh    # Sovereign Boot Script
β”œβ”€β”€ watchdog.sh         # Cron-based process monitor
β”œβ”€β”€ ARCHITECTURE.md     # Full system documentation
└── README.md           # This file

🧠 AI Layers

L1 β€” Logit Sniping (Candle, In-Process)

ROLE: Ultra-low latency HFT Reflex Core.
TASK: Classify L2 microstructure to predict next 100ms price tick.
OUTPUT: EXACTLY ONE TOKEN FROM [BID, ASK, HOLD, KILL].
  • No text generation β€” reads raw logits for 4 tokens in <20ms
  • Model-agnostic β€” ChatTemplate auto-detects Phi-3.5, Llama-3, Qwen2, Gemma2, Mistral
  • Few-Shot anchored β€” 3 in-context examples force deterministic classification
  • KILL action β€” immediate order cancellation on toxic sweep detection

L2 β€” Sovereign Constitution (ZeroClaw + Gemini 3.1 Pro)

  • Chain-of-Thought forcing β€” <thinking> block required before any Tool Call
  • Hard Guardrails β€” FAIL-FAST, MAX EXPOSURE (0.05 BTC), ANTI-JITTER
  • RAG Memory β€” SQLite vector DB recalls past decisions and their outcomes
  • Brain Transplant β€” safe hot-swap of GGUF models with shadow validation

πŸ›‘οΈ Safety Guarantees

LayerMechanismProtection
L0SeqLock + AtomicsData consistency without locks
L1OBI + Sweep + KILLToxic flow protection (<20ms)
L1Sentinel (4-layer)PnL crash, position drift, heartbeat
L1Brain TransplantSafe model swap with rollback
L2Hard GuardrailsFAIL-FAST, MAX EXPO, ANTI-JITTER
L2Quota WatchdogTelegram alert on API quota exhaustion
L2Sovereign Boot ProtocolPaper→Live validation (66min)
OSsystemd Restart=alwaysAuto-restart on failure, OOM protection
OSwatchdog.sh (cron)Last-resort process resurrection

πŸ”§ Production Setup

# Prerequisites
sudo apt install -y nvidia-cuda-toolkit   # For future GPU acceleration

# Install systemd service + kernel tuning
sudo ./infra/install_service.sh

# Configure API keys
cp .env.example .env
# Edit: BITFINEX_API_KEY, BINANCE_API_KEY, TELEGRAM_BOT_TOKEN, GEMINI_API_KEY

# ZeroClaw onboarding
zeroclaw onboard --quick --provider gemini --model gemini-2.5-pro

# Verify
sudo systemctl status sniper-armada
zeroclaw status

πŸ“š Guides

πŸ“„ License

Private. All rights reserved.

Contributors

VaclavSercl

2 commits

Languages

Rust

49.7%

Python

39.0%

HTML

9.5%

Shell

1.8%