API Reference
Relevant source files
The following files were used as context for generating this wiki page:
The Rabid Raccoon API provides a suite of endpoints designed for high-frequency Micro E-mini S&P 500 (MES) futures trading analysis. It encompasses real-time market data retrieval, multi-timeframe technical signal computation, and AI-driven forecasting using large language models like Claude and GPT-5.
The system is architected as a Next.js application with a focus on data integrity, utilizing Prisma ORM for time-series storage and Inngest for background job orchestration. Key features include deterministic technical analysis, cross-asset correlation detection, and visual chart analysis.
Sources: cubic.yaml:5-15, src/lib/instant-analysis.ts:1-10
Analysis Endpoints
These endpoints process market data and technical signals to provide qualitative and quantitative trading insights.
Chart Analysis (POST /api/analyse/chart)
This endpoint performs visual technical analysis on chart screenshots combined with structured OHLCV data. It utilizes the claude-opus-4-6 model to identify patterns and provide bias assessments across 15M, 1H, and 4H timeframes.
Sources: src/app/api/analyse/chart/route.ts:77-85
Request Body
| Parameter | Type | Description |
|---|---|---|
image | string | Base64 encoded PNG screenshot from the trading chart. |
| Sources: src/app/api/analyse/chart/route.ts:13-15 |
Architecture Flow
The diagram below illustrates the flow from receiving a screenshot to returning a structured JSON analysis.
The endpoint retrieves 384 of the most recent 15-minute bars to ensure enough coverage for 4-hour analysis.
Sources: src/app/api/analyse/chart/route.ts:68-75
Instant Analysis Engine
The core logic located in src/lib/instant-analysis.ts computes over 200 technical signals. It operates in two modes: Deterministic (math-only) and AI-Overlay (narrative and levels provided by OpenAI).
Sources: src/lib/instant-analysis.ts:1-12
Signal Categories
| Category | Indicators Included |
|---|---|
| Moving Averages | SMA/EMA (5, 10, 20, 50, 100, 200), Crossovers |
| Oscillators | RSI, Stochastic, Williams %R, CCI, ROC |
| Trend/Volatility | MACD, ATR Expansion, Bollinger Bands, VWAP |
| Structure | Fibonacci Retracements, AB=CD Measured Moves, Swing Highs/Lows |
| Sources: src/lib/instant-analysis.ts:124-215 |
Market Data Endpoints
Market data endpoints handle the retrieval and aggregation of OHLCV data and macro indicators.
Batch Market Data (GET /api/market-data/batch)
Retrieves and processes data for all configured symbols in parallel. It aggregates raw data into 15-minute intervals and computes real-time signals for each symbol.
Sources: src/app/api/market-data/batch/route.ts:40-50
The response includes sparkline data (last 50 close prices) and confluence factors showing signal counts (e.g., "12B/4S/2N").
Sources: src/app/api/market-data/batch/route.ts:88-105
Market Context & Regime Detection
The MarketContext engine (defined in src/lib/market-context.ts) evaluates the broader trading environment by calculating cross-asset correlations and scoring news themes.
Regime Classification
The system classifies the market into three states: RISK-ON, RISK-OFF, or MIXED. This is determined by a scoring algorithm based on factors such as:
- MES Performance: Returns > 0.05% add to the risk-on score.
- VIX Volatility: Compression (< -1%) adds to risk-on; expansion (> 1%) adds to risk-off.
- Yields: Rising 10Y yields (> 1.0%) indicate tightening financial conditions.
- Safe Havens: Bids in Gold (GC) or Bonds (ZN) typically indicate risk-off sentiment.
Sources: src/lib/market-context.ts:167-220
7,000 Breakout Detector
A specialized module monitors the S&P 500 (SPX) for the 7,000 level using a "Strict Two-Close Rule."
- Confirmed Breakout: Requires 2+ consecutive daily closes above 7,000.
- Unconfirmed Breakout: Only one close above the level.
- Rejected: Intraday test of 7,000 but close remains below.
Sources: src/lib/market-context.ts:413-445
Technical Implementation Details
Data Integrity Rules
Per the project's surgical rules in cubic.yaml, the API and ingestion layers must adhere to strict validation:
- Candle Integrity:
open,high,low,closemust be > 0.highmust be >=low,high>=open, andhigh>=close. - Volume Handling: Volume must always be handled as
BigIntto prevent precision loss or overflow. - Timezone: All timestamps must be preserved in UTC to prevent gaps in time-series charting.
Sources: cubic.yaml:58-95
AI Model Failover
The forecasting and analysis modules implement a candidate model chain. If the primary model (e.g., gpt-5.2-pro) fails due to API errors or permissions, the system iterates through fallbacks.
function getAnalysisModelCandidates(): string[] {
const fromEnv = (process.env.OPENAI_ANALYSIS_MODEL || '').trim()
const candidates = [
fromEnv,
'gpt-5.2-pro',
'gpt-5-pro',
'gpt-5.2',
'gpt-5.1',
'gpt-5',
].filter(Boolean)
return [...new Set(candidates)]
}
Sources: src/lib/instant-analysis.ts:37-47
Conclusion
The Rabid Raccoon API Reference provides the framework for a robust futures trading environment. By combining deterministic mathematical signals with advanced AI vision and text analysis, the system offers a multi-layered approach to market interpretation. Strict data integrity rules and a comprehensive market context engine ensure that signals are both technically accurate and macro-aware.