Hybrid Stack (JS/Python)
Relevant source files
The following files were used as context for generating this wiki page:
The Rabid Raccoon platform utilizes a hybrid architecture combining a high-performance TypeScript/Next.js web layer with a specialized Python-based High-Frequency Trading (HFT) module. The primary web stack handles real-time market data visualization, persistent storage via Prisma, and AI-driven analysis using Claude and OpenAI. In parallel, the Python "Halsey" module provides standalone intraday scanning and API capabilities, specifically optimized for Micro E-mini S&P 500 (MES) futures.
This dual-stack approach allows the project to leverage modern web technologies for user-facing dashboards and background job orchestration via Inngest, while maintaining a dedicated Python environment for intensive intraday trading logic and HFT simulations.
Sources: README.md:1-20, README.md:120-135, cubic.yaml:5-15
Architecture Overview
The system architecture is divided into a frontend/API layer and a data/trading logic layer. The TypeScript layer manages the data pipeline from sources like Databento and FRED, while the Python layer operates independently for intraday analysis.
System Interaction Flow
The following diagram illustrates how the JS-based web layer and Python-based HFT module interact with shared data sources and the database.
Sources: README.md:105-135, cubic.yaml:10-25
TypeScript/JavaScript Web Layer
The web layer is built on Next.js and deployed via Vercel. It acts as the orchestration hub for data ingestion, AI analysis, and user interaction.
Core Components
- Inngest Orchestration: Handles background jobs with deterministic replay. It is critical that the Inngest client ID is set to
rabid-raccoonto prevent cross-project contamination with other trading systems. - AI Analysis Engines: Integrates with Anthropic (Claude Opus 4.6) for vision-based chart analysis and OpenAI (GPT-5 series) for macro forecasting.
- Data Ingestion Scripts: A suite of TypeScript scripts (using
tsx) is used for backfilling market data, macro indicators, and economic news.
| Component | Technology | Primary File/Directory |
|---|---|---|
| Framework | Next.js 15.5 | src/app/ |
| ORM | Prisma 7.4 | prisma/ |
| Background Jobs | Inngest | src/inngest/ |
| AI Integration | Anthropic / OpenAI SDKs | src/lib/instant-analysis.ts |
| Visualizations | Lightweight Charts | src/components/TechChart.tsx |
Sources: package.json:1-60, cubic.yaml:20-40, README.md:105-115
Data Pipeline and Integrity
Data integrity is enforced through surgical rules in the JS stack to prevent "silent data corruption." OHLCV candles must be validated before insertion (e.g., checking high >= low), and volume must always be handled as BigInt.
Python HFT Halsey Module
Located in the mes_hft_halsey/ directory, this module provides high-frequency trading capabilities independent of the Next.js runtime. It focuses on intraday patterns and swing detection.
Functional Scope
- Standalone Scanner: A Python-based intraday scanner that utilizes Databento, FRED, and Yahoo Finance.
- Swing Detection: Implements swing-order logic for identifying market structure.
- Standalone API: Provides a dedicated Python API for accessing intraday metrics.
Configuration and Execution
The Python module requires its own set of dependencies and is typically executed via CLI for scanning tasks.
# Executing the Halsey Scanner
python mes_hft_halsey/mes_intraday_halsey.py --days-back 90 --swing-order 5 --min-rr 2.0
Sources: README.md:120-135, cubic.yaml:10-15
AI and Machine Learning Integration
The stack leverages both JS and Python for dataset preparation, but the live analysis is primarily handled via JS API routes.
Analysis Pipeline
The project uses vision-based analysis for chart patterns. Screenshots from the LiveMesChart component are sent to the /api/analyse/chart route, which processes them using Anthropic's Claude.
| Feature | Model | Purpose |
|---|---|---|
| Chart Vision | claude-opus-4-6 | Identifies Reversals, Flags, and Triangles from base64 PNGs. |
| Macro Forecast | gpt-5.2-pro | Generates narrative trade plans based on technical and macro data. |
| Deterministic Analysis | Raw Math (TS) | Computes 200+ technical signals across 15M, 1H, 4H. |
Sources: src/app/api/analyse/chart/route.ts:110-150, src/lib/instant-analysis.ts:10-50, src/lib/forecast.ts:20-40
Dataset Generation for ML
The scripts/ directory contains TypeScript-based builders that generate large CSV datasets (e.g., mes_lean_1h.csv) intended for training models like AutoGluon. These datasets merge MES technicals with 19 different FRED macro series.
Conclusion
The hybrid JS/Python stack provides a flexible environment where the TypeScript/Next.js layer handles the complex UI, AI orchestration, and automated data ingestion, while the Python Halsey module offers specialized HFT intraday tools. This separation ensures that high-level analysis and dashboarding do not interfere with the performance-critical trading logic required for MES futures.
Sources: README.md:1-135, cubic.yaml:5-30