From 009f7471c2473c90a56c438e0a4f159fb3316243 Mon Sep 17 00:00:00 2001 From: Brandon Li Date: Sun, 26 Apr 2026 02:57:14 -0500 Subject: [PATCH] Count only days that hit minDayPnL toward trading day requirement The state API was returning client.daysTraded (any non-zero day) as the displayed daysTraded. Firms count only days that hit minDayPnL toward the min trading day requirement. When cfg.min_day_pnl > 0, filter dailyPnL by that threshold and use the filtered count. Otherwise fall back to client.daysTraded. Co-Authored-By: Claude Opus 4.6 (1M context) --- app/api/state/route.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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] ?? [];