import React, { useState } from 'react'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Label } from '@/components/ui/label'; import { Input } from '@/components/ui/input'; import { Switch } from '@/components/ui/switch'; import { Slider } from '@/components/ui/slider'; import { Button } from '@/components/ui/button'; import { Shield, AlertTriangle, TrendingDown, TrendingUp, DollarSign } from 'lucide-react'; import { useToast } from '@/hooks/use-toast'; export const RiskManagement: React.FC = () => { const [settings, setSettings] = useState({ stopLossEnabled: true, stopLossPercentage: [5], takeProfitEnabled: true, takeProfitPercentage: [15], maxPositionSize: [20], maxDailyLoss: [100], enableTrailingStop: false, trailingStopPercentage: [3], maxConcurrentTrades: [5] }); const { toast } = useToast(); const handleSaveSettings = () => { toast({ title: "Risk Settings Saved", description: "Your risk management preferences have been updated", }); }; const handleResetToDefaults = () => { setSettings({ stopLossEnabled: true, stopLossPercentage: [5], takeProfitEnabled: true, takeProfitPercentage: [15], maxPositionSize: [20], maxDailyLoss: [100], enableTrailingStop: false, trailingStopPercentage: [3], maxConcurrentTrades: [5] }); toast({ title: "Settings Reset", description: "Risk management settings have been reset to defaults", }); }; return (
Stop Loss & Take Profit {/* Stop Loss */}
setSettings(prev => ({ ...prev, stopLossEnabled: checked })) } />
{settings.stopLossEnabled && (
Percentage Loss Limit -{settings.stopLossPercentage[0]}%
setSettings(prev => ({ ...prev, stopLossPercentage: value })) } max={20} min={1} step={0.5} className="py-2" />
)}
{/* Take Profit */}
setSettings(prev => ({ ...prev, takeProfitEnabled: checked })) } />
{settings.takeProfitEnabled && (
Percentage Profit Target +{settings.takeProfitPercentage[0]}%
setSettings(prev => ({ ...prev, takeProfitPercentage: value })) } max={50} min={5} step={1} className="py-2" />
)}
{/* Trailing Stop */}
setSettings(prev => ({ ...prev, enableTrailingStop: checked })) } />
{settings.enableTrailingStop && (
Trailing Distance {settings.trailingStopPercentage[0]}%
setSettings(prev => ({ ...prev, trailingStopPercentage: value })) } max={10} min={1} step={0.5} className="py-2" />
)}
Position & Risk Limits {/* Max Position Size */}
Per Trade (% of wallet) {settings.maxPositionSize[0]}%
setSettings(prev => ({ ...prev, maxPositionSize: value })) } max={50} min={1} step={1} className="py-2" />
{/* Max Daily Loss */}
Maximum Daily Loss ($) ${settings.maxDailyLoss[0]}
setSettings(prev => ({ ...prev, maxDailyLoss: value })) } max={1000} min={10} step={10} className="py-2" />
{/* Max Concurrent Trades */}
Maximum Active Trades {settings.maxConcurrentTrades[0]}
setSettings(prev => ({ ...prev, maxConcurrentTrades: value })) } max={20} min={1} step={1} className="py-2" />
{/* Action Buttons */}
); };