feat: implement comprehensive AI decision display and reasoning panel
Major Features Added: - Complete AI decision tracking system with detailed reasoning display - Prominent gradient-styled AI reasoning panel on automation-v2 page - Test AI decision generator with realistic trading scenarios - Enhanced decision transparency showing entry/exit logic and leverage calculations - Fixed orphaned order cleanup to preserve reduce-only SL/TP orders - Integrated AI leverage calculator with 100x capability (up from 10x limit) - Added lastDecision property to automation status for UI display - Enhanced position monitoring with better cleanup triggers - Beautiful gradient-styled AI Trading Analysis panel - Color-coded confidence levels and recommendation displays - Detailed breakdown of entry strategy, stop loss logic, and take profit targets - Real-time display of AI leverage reasoning with safety buffer explanations - Test AI button for demonstration of decision-making process - SL/TP orders now execute properly (fixed cleanup interference) - AI calculates sophisticated leverage (8.8x-42.2x vs previous 1x hardcoded) - Complete decision audit trail with execution details - Risk management transparency with liquidation safety calculations - Why This Decision? - Prominent reasoning section - Entry & Exit Strategy - Price levels with color coding - AI Leverage Decision - Detailed calculation explanations - Execution status with success/failure indicators - Transaction IDs and comprehensive trade details All systems now provide full transparency of AI decision-making process.
This commit is contained in:
@@ -99,10 +99,13 @@ export async function POST() {
|
||||
// Check if this order is for a market where we have no position
|
||||
const hasPosition = positionMarkets.has(order.marketIndex)
|
||||
|
||||
// Also check if it's a reduce-only order (these should be canceled if no position)
|
||||
// CRITICAL FIX: Only cancel reduce-only orders if there's NO position
|
||||
// Stop Loss and Take Profit orders are reduce-only but should EXIST when we have a position
|
||||
const isReduceOnly = order.reduceOnly
|
||||
|
||||
return !hasPosition || (isReduceOnly && !hasPosition)
|
||||
// Only cancel orders that are truly orphaned (no position for that market)
|
||||
// Do NOT cancel reduce-only orders when we have a position (these are SL/TP!)
|
||||
return !hasPosition && !isReduceOnly
|
||||
})
|
||||
|
||||
// Additionally, find lingering SL/TP orders when position has changed significantly
|
||||
|
||||
Reference in New Issue
Block a user