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) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
c589adec91
commit
009f7471c2
@@ -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] ?? [];
|
||||
|
||||
Reference in New Issue
Block a user