Database Schema & Models
Relevant source files
The following files were used as context for generating this wiki page:
The Rabid Raccoon database system is a PostgreSQL-backed persistence layer managed via Prisma ORM. It is architected to handle high-frequency market data, diverse economic indicators (FRED), and algorithmic trading signals. The schema prioritizes data integrity through strict typing (using Decimal for financial values) and structured metadata for auditing ingestion runs.
The system is divided into four primary domains: Market Data, Economic Indicators, Signal/Setup tracking, and Administrative Registry/Logging.
Sources: prisma/schema.prisma:1-12, README.md:95-98
Core Data Architecture
The architecture uses a star-like schema where central registries (Symbol, EconomicSeries) act as parents to time-series observation tables. A significant refactor consolidated various economic tables into domain-specific buckets to align with high-performance analysis requirements.
Entity Relationship Overview
The following diagram illustrates the relationships between the core market symbols, economic series, and their respective observation data points.
The schema utilizes PostgreSQL enums to enforce domain constraints across timeframes, signal directions, and ingestion statuses.
Sources: prisma/schema.prisma:14-88, prisma/migrations/20260213110000_comprehensive_schema_refactor/migration.sql:20-33
Market Data Models
Market data is categorized by instrument type and granularity. The primary focus is on MES (Micro E-mini S&P 500) futures, which are stored in dedicated tables for 1-minute, 15-minute, hourly, and daily intervals.
Symbol Registry
The Symbol model is the master record for any tradable instrument.
| Field | Type | Description |
|---|---|---|
code | String (PK) | Unique identifier (e.g., "MES") |
tickSize | Decimal | Minimum price increment (Precision: 18,6) |
dataSource | Enum | Primary provider (DATABENTO, FRED, YAHOO, etc.) |
isActive | Boolean | Toggles ingestion for the symbol |
Sources: prisma/schema.prisma:90-107, prisma/migrations/20260213110000_comprehensive_schema_refactor/migration.sql:38-39
Time-Series Price Tables
Price data is stored with Decimal(18,6) precision to prevent floating-point rounding errors during financial calculations.
model MktFuturesMes1h {
id BigInt @id @default(autoincrement())
eventTime DateTime @db.Timestamptz(6)
open Decimal @db.Decimal(18, 6)
high Decimal @db.Decimal(18, 6)
low Decimal @db.Decimal(18, 6)
close Decimal @db.Decimal(18, 6)
volume BigInt?
source DataSource @default(DATABENTO)
rowHash String? @db.VarChar(64)
}
Sources: prisma/schema.prisma:125-142, prisma/migrations/20260213110000_comprehensive_schema_refactor/migration.sql:47-51
Economic & Macro Models
The economic domain is highly normalized, splitting indicators into specialized tables to improve query performance for specific asset classes.
Economic Series & Observations
Every observation is tied to a seriesId defined in the EconomicSeries registry. Observations use a knowledgeTime field to support point-in-time analysis and prevent look-ahead bias in backtesting.
| Table Name | Category | Example Series |
|---|---|---|
EconRates1d | RATES | Fed Funds Rate (DFF), SOFR |
EconYields1d | YIELDS | 10Y Treasury (DGS10), 2Y Treasury |
EconVolIndices1d | VOLATILITY | VIX, VVIX, High Yield OAS |
EconInflation1d | INFLATION | CPI, PCE, TIPS Breakevens |
EconLabor1d | LABOR | Nonfarm Payrolls, Unemployment |
Sources: prisma/schema.prisma:194-320, scripts/ingest-fred-complete.ts:40-100
News & Reports
The schema includes models for qualitative data, such as EconNews1d and PolicyNews1d, which store headlines and summaries from institutional sources like the Federal Reserve or SEC.
Sources: prisma/schema.prisma:350-410, scripts/ingest-alt-news-feeds.ts:60-120
Trading Signals & Machine Learning
The database tracks algorithmic setups and machine learning model versions to facilitate performance auditing.
Measured Move & BHG Setups
MeasuredMoveSignal and BhgSetup (Break-Hook-Go) store the geometric coordinates of technical patterns.
- BhgSetup: Tracks specific phases (
TOUCHED,HOOKED,GO_FIRED) and outcomes liketp1HitorslHit. - MeasuredMoveSignal: Records Fibonacci projection targets (100%, 123.6%) and retracement ratios.
Sources: prisma/schema.prisma:500-580, prisma/migrations/20260213110000_comprehensive_schema_refactor/migration.sql:160-200
Model Registry
The MesModelRegistry stores metadata for AutoGluon or other ML models, including training rows, feature sets (JSON), and out-of-fold (OOF) metrics like Brier score and AUC.
Sources: prisma/schema.prisma:597-615, prisma/migrations/20260213110000_comprehensive_schema_refactor/migration.sql:237-245
System Administration
Ingestion Logging
The IngestionRun model provides a comprehensive audit log of all data synchronization tasks.
| Field | Description |
|---|---|
job | The name of the script or task (e.g., "fred-complete") |
status | Enum: RUNNING, COMPLETED, FAILED |
rowsInserted | Count of new records added to the DB |
details | JSON blob containing error messages or performance stats |
Sources: prisma/schema.prisma:513-524, prisma/migrations/20260213110000_comprehensive_schema_refactor/migration.sql:220-235
Conclusion
The Rabid Raccoon database schema is a robust, time-series optimized structure that emphasizes financial precision and traceability. By utilizing specialized tables for market and economic data while maintaining central registries for symbols and models, the system ensures high performance for both real-time trading and long-term machine learning dataset construction.