fix: MarketData storage now working in execute endpoint

- Added debug logging to trace execution
- Confirmed 1-minute signals being stored continuously
- Database accumulating rows every 1-3 minutes
- All indicators (ATR, ADX, RSI, volume, price position) storing correctly
- 1-year retention active (365 days)
- Foundation ready for 8-hour blocked signal tracking
This commit is contained in:
mindesbunister
2025-12-02 12:43:35 +01:00
parent ea591d2c29
commit 79ab30782c
2 changed files with 32 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ export interface ExecuteTradeRequest {
volumeRatio?: number
pricePosition?: number
maGap?: number // V9: MA gap convergence metric
volume?: number // Raw volume value for time-series tracking
indicatorVersion?: string // Pine Script version (v5, v6, etc.)
}
@@ -176,6 +177,37 @@ export async function POST(request: NextRequest): Promise<NextResponse<ExecuteTr
console.error(`❌ Failed to save ${timeframe}min signal:`, dbError)
}
// CRITICAL (Dec 2, 2025): For 1-minute signals, ALSO store in MarketData table
// This enables historical time-series analysis with full indicator data
console.log(`🔍 DEBUG: timeframe value = "${timeframe}", type = ${typeof timeframe}, checking if === '1'`)
if (timeframe === '1') {
console.log(`✅ Conditional matched! Storing to MarketData...`)
try {
const { getPrismaClient } = await import('@/lib/database/trades')
const prisma = getPrismaClient()
await prisma.marketData.create({
data: {
symbol: driftSymbol,
timeframe: '1',
price: currentPrice,
atr: Number(body.atr) || 0,
adx: Number(body.adx) || 0,
rsi: Number(body.rsi) || 50,
volumeRatio: Number(body.volumeRatio) || 1.0,
pricePosition: Number(body.pricePosition) || 50,
maGap: Number(body.maGap) || undefined,
volume: Number(body.volume) || undefined,
timestamp: new Date()
}
})
console.log(`💾 Stored 1-minute data in database for ${driftSymbol} (from execute endpoint)`)
} catch (marketDataError) {
console.error('❌ Failed to store 1-minute market data:', marketDataError)
}
}
return NextResponse.json({
success: false,
error: 'Data collection only',

Binary file not shown.