Fix multi-timeframe analysis display and database issues
- Fixed analysis-details API to display multi-timeframe analysis results - Added comprehensive timeframe breakdown (15m, 1h, 2h, 4h) with confidence levels - Fixed database field recognition issues with Prisma client - Enhanced analysis display with entry/exit levels and technical analysis - Added proper stop loss and take profit calculations from AI analysis - Improved multi-layout analysis display (AI + DIY layouts) - Fixed automation service to handle database schema sync issues - Added detailed momentum, trend, and volume analysis display - Enhanced decision visibility on automation dashboard
This commit is contained in:
BIN
prisma/dev.db
BIN
prisma/dev.db
Binary file not shown.
Binary file not shown.
@@ -8,17 +8,17 @@ datasource db {
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
email String @unique
|
||||
name String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
apiKeys ApiKey[]
|
||||
trades Trade[]
|
||||
journals TradingJournal[]
|
||||
settings UserSettings?
|
||||
id String @id @default(cuid())
|
||||
email String @unique
|
||||
name String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
aiLearningData AILearningData[]
|
||||
apiKeys ApiKey[]
|
||||
automationSessions AutomationSession[]
|
||||
aiLearningData AILearningData[]
|
||||
trades Trade[]
|
||||
journals TradingJournal[]
|
||||
settings UserSettings?
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
@@ -46,8 +46,7 @@ model UserSettings {
|
||||
riskPercentage Float @default(2)
|
||||
maxDailyTrades Int @default(5)
|
||||
enableNotifications Boolean @default(true)
|
||||
// Automation settings
|
||||
automationMode String @default("SIMULATION") // SIMULATION, LIVE
|
||||
automationMode String @default("SIMULATION")
|
||||
autoTimeframe String @default("1h")
|
||||
autoSymbol String @default("SOLUSD")
|
||||
autoTradingEnabled Boolean @default(false)
|
||||
@@ -63,40 +62,38 @@ model UserSettings {
|
||||
}
|
||||
|
||||
model Trade {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
symbol String
|
||||
side String
|
||||
amount Float
|
||||
price Float
|
||||
status String @default("PENDING")
|
||||
driftTxId String?
|
||||
profit Float?
|
||||
fees Float?
|
||||
screenshotUrl String?
|
||||
aiAnalysis String?
|
||||
// Automation fields
|
||||
isAutomated Boolean @default(false)
|
||||
entryPrice Float?
|
||||
exitPrice Float?
|
||||
stopLoss Float?
|
||||
takeProfit Float?
|
||||
leverage Float?
|
||||
timeframe String?
|
||||
tradingMode String? // SIMULATION, LIVE
|
||||
confidence Float?
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
symbol String
|
||||
side String
|
||||
amount Float
|
||||
price Float
|
||||
status String @default("PENDING")
|
||||
driftTxId String?
|
||||
profit Float?
|
||||
fees Float?
|
||||
screenshotUrl String?
|
||||
aiAnalysis String?
|
||||
isAutomated Boolean @default(false)
|
||||
entryPrice Float?
|
||||
exitPrice Float?
|
||||
stopLoss Float?
|
||||
takeProfit Float?
|
||||
leverage Float?
|
||||
timeframe String?
|
||||
tradingMode String?
|
||||
confidence Float?
|
||||
marketSentiment String?
|
||||
// Learning fields
|
||||
outcome String? // WIN, LOSS, BREAKEVEN
|
||||
pnlPercent Float?
|
||||
actualRR Float? // Actual risk/reward ratio
|
||||
executionTime DateTime?
|
||||
learningData Json? // Store additional learning data
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
executedAt DateTime?
|
||||
closedAt DateTime?
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
outcome String?
|
||||
pnlPercent Float?
|
||||
actualRR Float?
|
||||
executionTime DateTime?
|
||||
learningData Json?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
executedAt DateTime?
|
||||
closedAt DateTime?
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("trades")
|
||||
}
|
||||
@@ -112,20 +109,18 @@ model TradingJournal {
|
||||
recommendation String
|
||||
confidence Float
|
||||
notes String?
|
||||
// Automation fields
|
||||
isAutomated Boolean @default(false)
|
||||
symbol String?
|
||||
timeframe String?
|
||||
tradingMode String? // SIMULATION, LIVE
|
||||
tradeId String? // Link to actual trade if executed
|
||||
outcome String? // WIN, LOSS, BREAKEVEN, PENDING
|
||||
actualPrice Float? // Actual price when trade was executed
|
||||
priceAtAnalysis Float? // Price at time of analysis
|
||||
// Learning fields
|
||||
accuracyScore Float? // How accurate the prediction was
|
||||
executionDelay Int? // Minutes between analysis and execution
|
||||
marketCondition String? // TRENDING, RANGING, VOLATILE
|
||||
sessionId String? // Link to automation session
|
||||
tradingMode String?
|
||||
tradeId String?
|
||||
outcome String?
|
||||
actualPrice Float?
|
||||
priceAtAnalysis Float?
|
||||
accuracyScore Float?
|
||||
executionDelay Int?
|
||||
marketCondition String?
|
||||
sessionId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
@@ -156,55 +151,56 @@ model SystemLog {
|
||||
}
|
||||
|
||||
model AutomationSession {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
status String @default("ACTIVE") // ACTIVE, PAUSED, STOPPED
|
||||
mode String @default("SIMULATION") // SIMULATION, LIVE
|
||||
symbol String
|
||||
timeframe String
|
||||
totalTrades Int @default(0)
|
||||
successfulTrades Int @default(0)
|
||||
failedTrades Int @default(0)
|
||||
totalPnL Float @default(0)
|
||||
totalPnLPercent Float @default(0)
|
||||
winRate Float @default(0)
|
||||
avgRiskReward Float @default(0)
|
||||
maxDrawdown Float @default(0)
|
||||
startBalance Float?
|
||||
currentBalance Float?
|
||||
settings Json? // Store automation settings
|
||||
lastAnalysis DateTime?
|
||||
lastTrade DateTime?
|
||||
nextScheduled DateTime?
|
||||
errorCount Int @default(0)
|
||||
lastError String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
status String @default("ACTIVE")
|
||||
mode String @default("SIMULATION")
|
||||
symbol String
|
||||
timeframe String
|
||||
totalTrades Int @default(0)
|
||||
successfulTrades Int @default(0)
|
||||
failedTrades Int @default(0)
|
||||
totalPnL Float @default(0)
|
||||
totalPnLPercent Float @default(0)
|
||||
winRate Float @default(0)
|
||||
avgRiskReward Float @default(0)
|
||||
maxDrawdown Float @default(0)
|
||||
startBalance Float?
|
||||
currentBalance Float?
|
||||
settings Json?
|
||||
lastAnalysis DateTime?
|
||||
lastAnalysisData Json?
|
||||
lastTrade DateTime?
|
||||
nextScheduled DateTime?
|
||||
errorCount Int @default(0)
|
||||
lastError String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([userId, symbol, timeframe])
|
||||
@@map("automation_sessions")
|
||||
}
|
||||
|
||||
model AILearningData {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
sessionId String?
|
||||
tradeId String?
|
||||
analysisData Json // Store the AI analysis
|
||||
marketConditions Json // Store market conditions at time of analysis
|
||||
outcome String? // WIN, LOSS, BREAKEVEN
|
||||
actualPrice Float?
|
||||
predictedPrice Float?
|
||||
confidenceScore Float?
|
||||
accuracyScore Float? // Calculated after outcome is known
|
||||
timeframe String
|
||||
symbol String
|
||||
screenshot String? // Link to screenshot used for analysis
|
||||
feedbackData Json? // Store feedback for learning
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
sessionId String?
|
||||
tradeId String?
|
||||
analysisData Json
|
||||
marketConditions Json
|
||||
outcome String?
|
||||
actualPrice Float?
|
||||
predictedPrice Float?
|
||||
confidenceScore Float?
|
||||
accuracyScore Float?
|
||||
timeframe String
|
||||
symbol String
|
||||
screenshot String?
|
||||
feedbackData Json?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("ai_learning_data")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user