Require equityProfit; return null when balance invalid
computeDailyTarget now requires equityProfit (amount - accountSize) and returns null when it's undefined/null/NaN. 0 is still a valid value. - Removed totalProfit parameter (was only used as fallback) - Callers handle null by skipping the account (eligibility) or throwing (execution paths) - State API sets dailyTarget to null when no valid balance, avoids incorrect targetHit computation 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
b7430df16e
commit
670ee9fbeb
@@ -50,14 +50,15 @@ export async function GET() {
|
||||
allFundTxns
|
||||
);
|
||||
const equityProfit = cash.amount - cfg.account_size;
|
||||
const target = computeDailyTarget(effective.profitTarget, effective.consistency, totalProfit, dailyPnL, cfg.min_day_pnl, effective.minTradingDays, equityProfit);
|
||||
const target = computeDailyTarget(effective.profitTarget, effective.consistency, dailyPnL, cfg.min_day_pnl, effective.minTradingDays, equityProfit);
|
||||
dailyTarget = target;
|
||||
// Condition 1: profit target already exceeded (target=0), still need days → any activity counts
|
||||
// Condition 2: target > 0 → must have made at least the computed daily target
|
||||
targetHit =
|
||||
// If we are just flipping take any activity as target hit
|
||||
(target.amount === 0 && Math.abs(cash.realizedPnL) > 0 && client.daysTraded[acc.id] <= effective.minTradingDays) ||
|
||||
(cash.realizedPnL >= target.amount);
|
||||
if (target) {
|
||||
targetHit =
|
||||
(target.amount === 0 && Math.abs(cash.realizedPnL) > 0 && client.daysTraded[acc.id] <= effective.minTradingDays) ||
|
||||
(cash.realizedPnL >= target.amount);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user