diff --git a/app/accounts/[id]/page.tsx b/app/accounts/[id]/page.tsx index e2062be..65afdd7 100644 --- a/app/accounts/[id]/page.tsx +++ b/app/accounts/[id]/page.tsx @@ -15,6 +15,7 @@ import { Dot, } from 'recharts'; import type { FirmConfig, FirmState, AccountState, AccountConfig } from '@/types'; +import { computeDailyTarget } from '@/lib/trading-logic'; interface DailyPnL { date: string; @@ -236,8 +237,18 @@ export default function AccountPage() { : Math.round(fifoTotal * 100) / 100; const profitPct = cfg?.accountSize ? (totalProfit / cfg.accountSize) * 100 : null; const profitPassed = cfg != null && totalProfit >= cfg.profitTarget; + const dailyTarget = cfg && !isDead + ? computeDailyTarget(cfg.profitTarget, cfg.consistency, totalProfit, dailyPnL) + : null; const lossPassed = !hasLossLimit || (cfg != null && totalProfit >= cfg.minDayPnL); + // Consistency target: the total profit level at which the best day no longer + // violates the consistency ratio. Only meaningful once a positive day exists. + const maxDayPnL = dailyPnL.length > 0 ? Math.max(...dailyPnL.filter(d => d.pnl > 0).map(d => d.pnl)) : 0; + const consistencyTarget = cfg && maxDayPnL > 0 + ? Math.round(maxDayPnL / cfg.consistency * 100) / 100 + : null; + // Build equity curve: FIFO daily increments, origin at $0 let running = 0; const equityData = [ @@ -260,7 +271,7 @@ export default function AccountPage() { const equityValues = equityData.map((d) => d.equity); // Y-axis domain: include profit target so its reference line stays visible const rawMin = Math.min(0, ...equityValues); - const rawMax = Math.max(0, ...equityValues, cfg?.profitTarget ?? 0); + const rawMax = Math.max(0, ...equityValues, cfg?.profitTarget ?? 0, consistencyTarget ?? 0); // Stroke gradient split: use only the actual equity range, NOT the profit target. // The SVG gradient bounding box is the line's bbox, so inflating by profitTarget @@ -342,6 +353,14 @@ export default function AccountPage() { value={`$${fmt(cfg!.minDayPnL)}`} /> )} + {dailyTarget != null && ( +