diff --git a/src/modules/trading/components/PaperTradingPanel.tsx b/src/modules/trading/components/PaperTradingPanel.tsx index 4d9bbca..7a1b720 100644 --- a/src/modules/trading/components/PaperTradingPanel.tsx +++ b/src/modules/trading/components/PaperTradingPanel.tsx @@ -10,10 +10,12 @@ import OrderForm from './OrderForm'; import PositionsList from './PositionsList'; import TradesHistory from './TradesHistory'; -type TabType = 'order' | 'positions' | 'history'; +type TabType = 'order' | 'positions' | 'history' | 'settings'; export default function PaperTradingPanel() { const [activeTab, setActiveTab] = useState('order'); + const [resetting, setResetting] = useState(false); + const [showResetConfirm, setShowResetConfirm] = useState(false); // Get state and actions from store const { @@ -31,8 +33,23 @@ export default function PaperTradingPanel() { createOrder, closePosition, initializePaperAccount, + resetPaperAccount, } = useTradingStore(); + // Handle reset account + const handleResetAccount = async () => { + setResetting(true); + try { + await resetPaperAccount(); + setShowResetConfirm(false); + setActiveTab('order'); + } catch (error) { + console.error('Failed to reset account:', error); + } finally { + setResetting(false); + } + }; + // Initialize paper trading data useEffect(() => { const initializePaperTrading = async () => { @@ -119,6 +136,20 @@ export default function PaperTradingPanel() { > History + {/* Tab Content */} @@ -146,6 +177,63 @@ export default function PaperTradingPanel() { isLoading={loadingPaperTrades} /> )} + + {activeTab === 'settings' && ( +
+

Paper Trading Settings

+ + {/* Account Info */} +
+
+ Initial Balance + $100,000.00 +
+
+ Total Trades + {paperTrades.length} +
+
+ Open Positions + {paperPositions.length} +
+
+ + {/* Reset Account */} +
+

Reset Account

+

+ This will reset your paper trading account to the initial balance and clear all positions and trade history. +

+ {showResetConfirm ? ( +
+

Are you sure? This cannot be undone.

+
+ + +
+
+ ) : ( + + )} +
+
+ )} {/* Loading Overlay */}