Add consistency shortfall check to computeDailyTarget
When a big day has been made, total trading profit must be >= maxDay/consistency for the consistency ratio to be satisfied. Previously the function only checked equity vs profitTarget and would coast on min-day even when consistency was still violated. Now the remaining = max(equityShortfall, consistencyShortfall). Per-stage: dailyPnL is already filtered to post-withdrawal entries by filterActivePnL, so tradingProfit, qualifyingDays, and maxDay naturally scope to the current stage. Example PAAPEX5466170000038 (consistency 50%, maxDay $3307.60, total $3306.05): - equityShortfall = 0 (equity way above $6600 target due to $150k deposit) - consistencyShortfall = $6615.20 - $3306.05 = $3309.15 - Target now aims for $3309.15 spread across remaining days, not $350 min-day 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
670ee9fbeb
commit
9928f1cabd
+16
-3
@@ -93,10 +93,23 @@ export function computeDailyTarget(
|
||||
const qualifyingDays = minDayPnL === 0 ? dailyPnL : dailyPnL.filter((d) => d.pnl >= minDayPnL);
|
||||
const daysTraded = qualifyingDays.length;
|
||||
const effectiveMinDay = Math.max(0, minDayPnL);
|
||||
const currentProfit = equityProfit;
|
||||
const remaining = profitTarget - currentProfit;
|
||||
const tradingProfit = dailyPnL.reduce((s, d) => s + d.pnl, 0); // cycle-local trading profit
|
||||
|
||||
// 1. Profit target already met — coast on min-day if mandatory days remain, else nothing to do.
|
||||
// Shortfall to hit profitTarget (measured in equity terms — accounts for deposits/withdrawals)
|
||||
const equityShortfall = Math.max(0, profitTarget - equityProfit);
|
||||
|
||||
// Shortfall to satisfy consistency rule: total trading profit must be ≥ maxDay / consistency,
|
||||
// otherwise the biggest day would exceed the consistency ratio.
|
||||
let consistencyShortfall = 0;
|
||||
if (consistency > 0 && consistency < 1 && qualifyingDays.length > 0) {
|
||||
const maxDay = Math.max(...qualifyingDays.map((d) => d.pnl));
|
||||
const realTarget = maxDay / consistency;
|
||||
consistencyShortfall = Math.max(0, realTarget - tradingProfit);
|
||||
}
|
||||
|
||||
const remaining = Math.max(equityShortfall, consistencyShortfall);
|
||||
|
||||
// 1. Both target and consistency already satisfied — coast on min-day if mandatory days remain.
|
||||
if (remaining <= 0) {
|
||||
const needsMoreDays = minTradingDays > daysTraded;
|
||||
return { amount: needsMoreDays ? effectiveMinDay : 0, path: 'reduced_day' };
|
||||
|
||||
Reference in New Issue
Block a user