feat: Add interactive Trade Follow-up Assistant with ChatGPT integration

- Interactive chat interface to ask questions about active trades
- Automatic position detection and context-aware responses
- Fresh screenshot capture with updated market analysis
- Smart conversation flow with trade-specific insights
- Quick action buttons for common trade management questions

- TradeFollowUpPanel.tsx: Full-featured chat interface with position tracking
- /api/trade-followup: GPT-4o mini integration with screenshot analysis
- Enhanced AIAnalysisPanel with Follow-up button integration

- 'Should I exit now?' - Real-time exit recommendations
- 'Update my stop loss' - SL adjustment guidance based on current conditions
- 'Move to break even' - Risk-free position management
- 'Current market analysis' - Fresh chart analysis with updated screenshots
- 'Risk assessment' - Position risk evaluation
- 'Take profit strategy' - TP optimization recommendations

- Enter trade based on AI analysis → Use Follow-up for ongoing management
- Ask specific questions: 'Is this still a valid setup?'
- Get updated analysis: 'What do the charts look like now?'
- Risk management: 'Should I move my stop loss?'
- Exit timing: 'Is this a good time to take profits?'

The assistant provides context-aware guidance by:
 Tracking your current position details (entry, size, P&L)
 Capturing fresh screenshots when needed for updated analysis
 Combining position context with current market conditions
 Providing specific price levels and actionable advice
 Maintaining conversation history for continuity

Perfect for traders who want ongoing AI guidance throughout their trades!
This commit is contained in:
mindesbunister
2025-07-17 15:29:52 +02:00
parent 48446f9722
commit 47d7b8b364
4 changed files with 685 additions and 69 deletions

View File

@@ -2,6 +2,7 @@
import React, { useState, useEffect, useRef } from 'react'
import TradeModal from './TradeModal'
import ScreenshotGallery from './ScreenshotGallery'
import TradeFollowUpPanel from './TradeFollowUpPanel'
const layouts = (process.env.NEXT_PUBLIC_TRADINGVIEW_LAYOUTS || 'ai,Diy module').split(',').map(l => l.trim())
@@ -88,6 +89,7 @@ export default function AIAnalysisPanel({ onAnalysisComplete }: AIAnalysisPanelP
const analysisInProgress = useRef(false)
const [tradeModalOpen, setTradeModalOpen] = useState(false)
const [tradeModalData, setTradeModalData] = useState<any>(null)
const [followUpPanelOpen, setFollowUpPanelOpen] = useState(false)
// Helper function to safely render any value
const safeRender = (value: any): string => {
@@ -807,6 +809,17 @@ export default function AIAnalysisPanel({ onAnalysisComplete }: AIAnalysisPanelP
</div>
)}
</button>
{/* Trade Follow-up Button */}
<button
className="w-full py-3 px-6 rounded-lg font-semibold transition-all duration-300 bg-gradient-to-r from-green-600 to-emerald-600 hover:from-green-700 hover:to-emerald-700 text-white transform hover:scale-[1.02] active:scale-[0.98] border border-green-500/30"
onClick={() => setFollowUpPanelOpen(true)}
>
<div className="flex items-center justify-center space-x-2">
<span>💬</span>
<span>Trade Follow-up Assistant</span>
</div>
</button>
</div>
{/* Results Section */}
@@ -1541,6 +1554,13 @@ export default function AIAnalysisPanel({ onAnalysisComplete }: AIAnalysisPanelP
tradeData={tradeModalData}
onExecute={executeTrade}
/>
{/* Trade Follow-up Panel */}
{followUpPanelOpen && (
<TradeFollowUpPanel
onClose={() => setFollowUpPanelOpen(false)}
/>
)}
</div>
)
}