diff --git a/app/projection/page.tsx b/app/projection/page.tsx index cb6d642..4d1f31f 100644 --- a/app/projection/page.tsx +++ b/app/projection/page.tsx @@ -40,6 +40,7 @@ export default function ProjectionPage() { const [selectedScenario, setSelectedScenario] = useState(70) const [tradingStats, setTradingStats] = useState(null) const [totalDeposits, setTotalDeposits] = useState(0) + const [btcPrice, setBtcPrice] = useState(100000) // Default, will be fetched // Strategy Parameters (Jan 2026) const STARTING_CAPITAL = 1437 // Actual starting balance when v11.2 went live @@ -59,6 +60,17 @@ export default function ProjectionPage() { useEffect(() => { async function fetchData() { try { + // Fetch current BTC price from CoinGecko + try { + const btcResponse = await fetch('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd') + const btcData = await btcResponse.json() + if (btcData.bitcoin?.usd) { + setBtcPrice(btcData.bitcoin.usd) + } + } catch (btcError) { + console.error('Failed to fetch BTC price, using default:', btcError) + } + // Fetch account summary const accountResponse = await fetch('/api/drift/account-summary') const accountData = await accountResponse.json() @@ -141,14 +153,35 @@ export default function ProjectionPage() { return months } - // Pre-calculate all scenarios - const scenarios: ScenarioResult[] = [ + // Calculate current actual monthly rate + const daysElapsed = Math.max(1, Math.floor((new Date().getTime() - START_DATE.getTime()) / (1000 * 60 * 60 * 24))) + const actualMonthlyRate = currentCapital > STARTING_CAPITAL && daysElapsed >= 1 + ? Math.round((Math.pow(currentCapital / STARTING_CAPITAL, 30 / daysElapsed) - 1) * 100) / 100 + : 0 + + // Pre-calculate all scenarios (including current rate if positive) + const baseScenarios: ScenarioResult[] = [ { monthlyRate: 0.50, label: '50%/mo (Very Conservative)', finalNetWorth: 0, finalTrading: 0, finalBTC: 0, totalCashOut: 0, color: 'text-gray-400' }, { monthlyRate: 0.70, label: '70%/mo (Base Case)', finalNetWorth: 0, finalTrading: 0, finalBTC: 0, totalCashOut: 0, color: 'text-green-400' }, { monthlyRate: 0.90, label: '90%/mo (Optimistic)', finalNetWorth: 0, finalTrading: 0, finalBTC: 0, totalCashOut: 0, color: 'text-blue-400' }, { monthlyRate: 1.10, label: '110%/mo (Strong)', finalNetWorth: 0, finalTrading: 0, finalBTC: 0, totalCashOut: 0, color: 'text-purple-400' }, { monthlyRate: 1.50, label: '150%/mo (Exceptional)', finalNetWorth: 0, finalTrading: 0, finalBTC: 0, totalCashOut: 0, color: 'text-yellow-400' }, - ].map(scenario => { + ] + + // Add current rate as first scenario if it's a valid positive rate + if (actualMonthlyRate > 0 && !loading) { + baseScenarios.unshift({ + monthlyRate: actualMonthlyRate, + label: `⚡ ${Math.round(actualMonthlyRate * 100)}%/mo (Current Actual)`, + finalNetWorth: 0, + finalTrading: 0, + finalBTC: 0, + totalCashOut: 0, + color: 'text-cyan-400' + }) + } + + const scenarios = baseScenarios.map(scenario => { const projection = generateProjection(scenario.monthlyRate) const final = projection[projection.length - 1] return { @@ -172,6 +205,12 @@ export default function ProjectionPage() { }).format(value) } + // Format BTC values with both USD and BTC quantity + const formatBTC = (usdValue: number) => { + const btcAmount = usdValue / btcPrice + return `${formatCurrency(usdValue)} / ${btcAmount.toFixed(2)} BTC` + } + return (
@@ -265,8 +304,8 @@ export default function ProjectionPage() {
Total P&L
-
= 0 ? 'text-green-400' : 'text-red-400'}`}> - {loading ? '...' : tradingStats ? formatCurrency(tradingStats.totalPnL) : '$0'} +
= 0 ? 'text-green-400' : 'text-red-400'}`}> + {loading ? '...' : formatCurrency(currentCapital - STARTING_CAPITAL)}
@@ -347,6 +386,21 @@ export default function ProjectionPage() {

🎯 Select Monthly Return Scenario

+ {/* Current Actual Rate Button */} + {actualMonthlyRate > 0 && !loading && ( + + )} + + {/* Preset Scenarios */} {[50, 70, 90, 110, 150].map(rate => (