diff --git a/app/api/state/route.ts b/app/api/state/route.ts index 506e474..487d8ea 100644 --- a/app/api/state/route.ts +++ b/app/api/state/route.ts @@ -23,11 +23,15 @@ export async function GET() { const accounts = client.accountList.map((acc) => { const cash = client.accountCashBalances[acc.id] ?? { amount: 0, realizedPnL: 0 }; const dailyPnL: { date: string; pnl: number }[] = client.dailyPnL[acc.id] ?? []; - const daysTraded: number = client.daysTraded[acc.id] ?? 0; const totalProfit = dailyPnL.reduce((sum, d) => sum + d.pnl, 0); // Compute daily target and targetHit in one place — the single source of truth. const cfg = getAccountConfig(acc.name, f.accounts); + // Days traded counts only days that hit minDayPnL (when set) — that's what + // the firm requires toward the min trading day rule. + const daysTraded: number = cfg && cfg.min_day_pnl > 0 + ? dailyPnL.filter((d) => d.pnl >= cfg.min_day_pnl).length + : (client.daysTraded[acc.id] ?? 0); const autoLiqThreshold = client.autoLiqThresholds[acc.id] ?? 0; const isDead = autoLiqThreshold > 0 && cash.amount <= autoLiqThreshold; const allFundTxns = client.fundTransactions?.[acc.id] ?? [];