Use max(maxDay, profitTarget × consistency) for Day 2+ cap

Replaces min() with max(). Both bounds need to be respected on different
sides:
  - Below profitTarget × consistency: cap allows growth up to that ceiling
  - Above profitTarget × consistency: consistency is already broken at target,
    cap must equal maxDay (going higher creates a new maxDay requiring
    even more total to satisfy consistency)

For TDFYSL50724548525 ($3000/40%, maxDay $36.96): target = $1200
For a day-1 $1500 win on same config: target = $1500 (must grow to $3750)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Brandon Li
2026-04-28 03:44:35 -05:00
co-authored by Claude Opus 4.6
parent 7b27de6d61
commit e6a83eed2f
+8 -7
View File
@@ -121,12 +121,13 @@ export function computeDailyTarget(
const futureReserve = (daysLeft - 1) * effectiveMinDay; const futureReserve = (daysLeft - 1) * effectiveMinDay;
const cappedByFuture = remaining - futureReserve; const cappedByFuture = remaining - futureReserve;
// 3. Consistency cap: // 3. Consistency cap.
// - 0% or 100%: no constraint // Day 1: min(remaining × consistency, profitTarget × consistency).
// - Day 1 of cycle: max allowed = remaining × consistency // Day 2+: max(maxDay, profitTarget × consistency).
// - Day 2+ of cycle: max allowed = maxDay (keeps consistency ratio stable) // - If maxDay ≤ profitTarget × consistency: room to grow days up to that ceiling.
// Always capped at profitTarget × consistency — the largest day the consistency // - If maxDay > profitTarget × consistency: consistency already broken at target,
// rule would have allowed. Prevents a previous overshoot/loss from compounding. // total must grow to at least maxDay / consistency. Each day can be up to maxDay
// (going higher creates a new maxDay requiring even more total).
let consistencyCap: number; let consistencyCap: number;
let path: 'first_day' | 'normal_day' | 'reduced_day'; let path: 'first_day' | 'normal_day' | 'reduced_day';
@@ -140,7 +141,7 @@ export function computeDailyTarget(
path = 'first_day'; path = 'first_day';
} else { } else {
const maxDay = Math.max(...qualifyingDays.map((d) => d.pnl)); const maxDay = Math.max(...qualifyingDays.map((d) => d.pnl));
consistencyCap = Math.min(maxDay, maxConsistencyDay); consistencyCap = Math.max(maxDay, maxConsistencyDay);
path = 'normal_day'; path = 'normal_day';
} }
} }