Configuration & Environment
Relevant source files
The following files were used as context for generating this wiki page:
The Configuration & Environment of the Rabid Raccoon platform establishes a strict isolation layer for an MES futures trading system. It integrates Next.js on Vercel with a persistent PostgreSQL data layer managed via Prisma ORM, background jobs via Inngest, and external data integrations with Databento and FRED. The environment is designed with a "zero tolerance" policy for data corruption, ensuring that configuration parameters such as Inngest client IDs and UTC timestamps remain immutable to prevent cross-project contamination and signal degradation.
Sources: cubic.yaml:8-16, README.md:120-135
Core Environment Variables
The project relies on a specific set of environment variables for secure communication with AI models, market data providers, and background task orchestrators. All sensitive keys are mandated to come from process.env with no hardcoded literals allowed.
| Variable Name | Purpose | Default / Requirements |
|---|---|---|
DATABASE_URL | PostgreSQL connection string | Must include schema=public |
INNGEST_SIGNING_KEY | Authenticates Inngest background jobs | Required for production |
INNGEST_EVENT_KEY | Signing key for sending Inngest events | Required for production |
OPENAI_API_KEY | Authentication for AI analysis and forecasting | Required for /api/analyse/ai |
ANTHROPIC_API_KEY | Authentication for Claude-based chart analysis | Required for /api/analyse/chart |
FRED_API_KEY | Access to Federal Reserve Economic Data | Required for macro ingestion |
OPENAI_ANALYSIS_MODEL | Specifies the LLM for signal interpretation | Fallback: gpt-5.2-pro |
Sources: cubic.yaml:145-155, README.md:100-115, src/lib/instant-analysis.ts:40-50, src/app/api/analyse/chart/route.ts:58-62
Inngest Background Job Configuration
The Inngest configuration is the most critical part of the production environment. It requires strict isolation to prevent "cross-project contamination" with other Vercel-hosted projects like ZINC-FUSION-V15.
Isolation and Reliability Rules
- Client ID Isolation: The Inngest client ID must always be "rabid-raccoon". Using other values like "fusion-jobs" causes shared concurrency pools and mixed runs.
- Deterministic Replay: All side effects (database writes, API calls) must be wrapped in
step.run(). Code outside this block executes on every retry, which could burn Databento credits or corrupt ingestion logs. - Event Namespacing: To prevent cross-project fan-out, all event names must use the
rr/orbackfill/prefix.
A flowchart showing the required execution path for Inngest background jobs to ensure data integrity and prevent duplicate API costs.
Sources: cubic.yaml:30-60, README.md:144-150
Database and Data Integrity Settings
The environment enforces strict data validation and connection management through Prisma. The data layer is designed as an append-only system for time-series tables.
Data Validation Constraints
The system validates OHLCV (Open, High, Low, Close, Volume) candles before insertion to ensure mathematical integrity:
- Prices must be
> 0. - Relationship integrity:
high >= low,high >= open, andhigh >= close. - Volume must use
BigIntto prevent overflow errors.
Batch and Connection Management
- Prisma Batch Size:
createManycalls are capped at a batch size of 100 rows to satisfy Prisma Accelerate limits. - Connection Release: All database connections (via
pool.connect()orprisma.$connect()) must be released infinallyblocks to avoid exhausting the connection pool during concurrent Inngest runs.
Sources: cubic.yaml:65-115, cubic.yaml:165-175, scripts/build-lean-dataset.ts:25-30
Vercel Runtime Configuration
Specific exports in API routes (route.ts) control the Vercel execution environment. This prevents runaway compute consumption and ensures long-running data ingestion tasks have sufficient time to complete.
// src/app/api/inngest/route.ts example patterns
export const runtime = 'nodejs'
export const maxDuration = 300 // 5 minutes for Inngest handlers
export const dynamic = 'force-dynamic'
| Component | maxDuration | runtime |
|---|---|---|
| Inngest Routes | 300 seconds | nodejs |
| User APIs | 30-60 seconds | nodejs |
| Chart Analysis | 120 seconds | nodejs |
Sources: cubic.yaml:180-190, src/app/api/analyse/chart/route.ts:10-11
Ingestion System Architecture
The ingestion environment uses a multi-tiered approach for market and macro data, categorized into initial backfills, daily updates, and live streaming.
The ingestion architecture showing the separation between local machine operations, daily cloud automation via Inngest, and live streaming workers.
Sources: README.md:130-160, package.json:15-25
Dataset Generation Parameters
The project includes scripts to generate training datasets for AutoGluon. These scripts define the feature set (technicals and FRED macro series) and timeframe granularities used for model training.
- Timeframes: Supports
15mand1hgranularities via specific build scripts. - Lookback Period: Default configurations typically use a 730-day (
--days-back 730) lookback for comprehensive historical context. - Feature Lag: To prevent data leakage, a conservative lag policy is applied based on frequency (Daily: 1d, Weekly: 8d, Monthly: 35d, Quarterly: 100d).
Sources: scripts/build-lean-dataset.ts:16-24, scripts/build-15m-dataset.ts:114-120, TRAINING-COMPLETE.md:80-95
Conclusion
The Configuration & Environment of Rabid Raccoon prioritizes isolation and technical precision. By enforcing strict client ID namespacing for Inngest, UTC-only timestamps, and validated append-only database operations, the system ensures that the AI analysis models operate on accurate, uncorrupted market data. This robust setup facilitates a reliable transition from local development to production Vercel environments without risking cross-project data leakage.
Sources: cubic.yaml:8-25, README.md:162-168助理:
Rabid Raccoon 平台的“配置与环境”为 MES 期货交易系统建立了一个严格的隔离层。它集成了 Vercel 上的 Next.js 以及通过 Prisma ORM 管理的持久化 PostgreSQL 数据层、通过 Inngest 处理的后台任务,以及与 Databento 和 FRED 的外部数据集成。该环境的设计遵循“零容忍”数据损坏策略,确保 Inngest 客户端 ID 和 UTC 时间戳等配置参数保持不可变,以防止跨项目污染和信号降级。
来源: cubic.yaml:8-16, README.md:120-135
核心环境变量
该项目依赖一组特定的环境变量,用于与 AI 模型、市场数据提供商和后台任务编排器进行安全通信。所有敏感密钥都必须来自 process.env,不允许硬编码字面量。
| 变量名称 | 用途 | 默认值 / 要求 |
|---|---|---|
DATABASE_URL | PostgreSQL 连接字符串 | 必须包含 schema=public |
INNGEST_SIGNING_KEY | 验证 Inngest 后台任务 | 生产环境必需 |
INNGEST_EVENT_KEY | 发送 Inngest 事件的签名密钥 | 生产环境必需 |
OPENAI_API_KEY | AI 分析和预测的身份验证 | /api/analyse/ai 必需 |
ANTHROPIC_API_KEY | 基于 Claude 的图表分析身份验证 | /api/analyse/chart 必需 |
FRED_API_KEY | 访问美联储经济数据 (FRED) | 宏观数据摄取必需 |
OPENAI_ANALYSIS_MODEL | 指定用于信号解读的 LLM | 备选方案: gpt-5.2-pro |
来源: cubic.yaml:145-155, README.md:100-115, src/lib/instant-analysis.ts:40-50, src/app/api/analyse/chart/route.ts:58-62
Inngest 后台任务配置
Inngest 配置是生产环境中最关键的部分。它需要严格的隔离,以防止与其他 Vercel 托管项目(如 ZINC-FUSION-V15)产生“跨项目污染”。
隔离与可靠性规则
- 客户端 ID 隔离:Inngest 客户端 ID 必须始终为 "rabid-raccoon"。使用其他值(如 "fusion-jobs")会导致共享并发池和混合运行。
- 确定性重放 (Deterministic Replay):所有副作用(数据库写入、API 调用)必须封装在
step.run()中。该块之外的代码在每次重试时都会执行,这可能会消耗 Databento 额度或损坏摄取日志。 - 事件命名空间:为防止跨项目事件扇出,所有事件名称必须使用
rr/或backfill/前缀。
该流程图展示了 Inngest 后台任务所需的执行路径,以确保数据完整性并防止重复的 API 成本。
来源: cubic.yaml:30-60, README.md:144-150
数据库与数据完整性设置
该环境通过 Prisma 强制执行严格的数据验证和连接管理。数据层被设计为一个针对时序表的“仅追加 (append-only)”系统。
数据验证约束
系统在插入前会验证 OHLCV(开盘价、最高价、最低价、收盘价、成交量)K 线数据,以确保数学完整性:
- 价格必须
> 0。 - 关系完整性:
high >= low、high >= open且high >= close。 - 成交量必须使用
BigInt以防止溢出错误。
批处理与连接管理
- Prisma 批处理大小:
createMany调用被限制为每批次 100 行,以满足 Prisma Accelerate 的限制。 - 连接释放:所有数据库连接(通过
pool.connect()或prisma.$connect())必须在finally块中释放,以避免在并发 Inngest 运行时耗尽连接池。
来源: cubic.yaml:65-115, cubic.yaml:165-175, scripts/build-lean-dataset.ts:25-30
Vercel 运行时配置
API 路由 (route.ts) 中的特定导出控制着 Vercel 的执行环境。这可以防止失控的计算资源消耗,并确保长时间运行的数据摄取任务有足够的时间完成。
// src/app/api/inngest/route.ts 示例模式
export const runtime = 'nodejs'
export const maxDuration = 300 // Inngest 处理程序为 5 分钟
export const dynamic = 'force-dynamic'
| 组件 | maxDuration | runtime |
|---|---|---|
| Inngest 路由 | 300 秒 | nodejs |
| 用户 APIs | 30-60 秒 | nodejs |
| 图表分析 | 120 秒 | nodejs |
来源: cubic.yaml:180-190, src/app/api/analyse/chart/route.ts:10-11
数据摄取系统架构
摄取环境对市场和宏观数据采用多级处理方式,分为初始回填 (Backfills)、每日更新和实时流处理。
该摄取架构展示了本地操作、通过 Inngest 实现的每日云端自动化以及实时流工作程序之间的分离。
来源: README.md:130-160, package.json:15-25
数据集生成参数
该项目包含为 AutoGluon 生成训练数据集的脚本。这些脚本定义了用于模型训练的功能集(技术指标和 FRED 宏观系列)和时间框架粒度。
- 时间框架:通过特定的构建脚本支持
15m和1h粒度。 - 回溯期:默认配置通常使用 730 天 (
--days-back 730) 的回溯,以获得全面的历史背景。 - 特征滞后 (Feature Lag):为了防止数据泄露,根据频率应用保守的滞后策略(每日:1天,每周:8天,每月:35天,每季度:100天)。
来源: scripts/build-lean-dataset.ts:16-24, scripts/build-15m-dataset.ts:114-120, TRAINING-COMPLETE.md:80-95
总结
Rabid Raccoon 的“配置与环境”将隔离性和技术精确度放在首位。通过强制执行 Inngest 的客户端 ID 命名空间、仅限 UTC 的时间戳以及经过验证的仅追加数据库操作,系统确保 AI 分析模型能够运行在准确、无损的市场数据之上。这种稳健的设置促进了从本地开发到生产 Vercel 环境的可靠过渡,且不会面临跨项目数据泄露的风险。