feat: Orderbook shadow logging system - Phase 1 complete
Implementation:
- Added 7 orderbook fields to Trade model (spreadBps, imbalanceRatio, depths, impact, walls)
- Oracle-based estimates with 2bps spread assumption
- ENV flag: ENABLE_ORDERBOOK_LOGGING (defaults true)
- Execute wrapper lines 1037-1053 guards orderbook logic
Database:
- Direct SQL ALTER TABLE (avoided migration drift issues)
- All columns nullable DOUBLE PRECISION
- Prisma schema synced via db pull + generate
Deployment:
- Container rebuilt and deployed successfully
- All 7 columns verified accessible
- System operational, ready for live trade validation
Files changed:
- config/trading.ts (enableOrderbookLogging flag, line 127)
- types/trading.ts (orderbook interfaces)
- lib/database/trades.ts (createTrade saves orderbook data)
- app/api/trading/execute/route.ts (ENV wrapper lines 1037-1053)
- prisma/schema.prisma (7 orderbook fields)
- docs/ORDERBOOK_SHADOW_LOGGING.md (complete documentation)
Status: ✅ PRODUCTION READY - awaiting first trade for validation
This commit is contained in:
@@ -55,6 +55,14 @@ export interface CreateTradeParams {
|
||||
pricePositionAtEntry?: number
|
||||
signalQualityScore?: number
|
||||
indicatorVersion?: string // TradingView Pine Script version (v5, v6, etc.)
|
||||
// Orderbook metrics at entry (Phase 1 shadow logging - Dec 17, 2025)
|
||||
obSpreadBps?: number // Bid-ask spread in basis points
|
||||
obImbalance?: number // Buy vs sell pressure (-1 to +1, negative = more sellers)
|
||||
obOppDepth0_2pctUSD?: number // Opposing side liquidity within 0.2% in USD
|
||||
obSameDepth0_2pctUSD?: number // Same side liquidity within 0.2% in USD
|
||||
obImpactBpsAtNotional?: number // Price impact for this trade size in basis points
|
||||
obLargestOppWallBps?: number // Distance to largest opposing wall in basis points
|
||||
obLargestOppWallUSD?: number // Size of largest opposing wall in USD
|
||||
// Phantom trade fields
|
||||
status?: string
|
||||
isPhantom?: boolean
|
||||
|
||||
Reference in New Issue
Block a user