From e6a83eed2f225857aac0a591a6673385f74179d3 Mon Sep 17 00:00:00 2001 From: Brandon Li Date: Tue, 28 Apr 2026 03:44:35 -0500 Subject: [PATCH] =?UTF-8?q?Use=20max(maxDay,=20profitTarget=20=C3=97=20con?= =?UTF-8?q?sistency)=20for=20Day=202+=20cap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- lib/trading-logic.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/trading-logic.ts b/lib/trading-logic.ts index d3f14c1..2d756e8 100644 --- a/lib/trading-logic.ts +++ b/lib/trading-logic.ts @@ -121,12 +121,13 @@ export function computeDailyTarget( const futureReserve = (daysLeft - 1) * effectiveMinDay; const cappedByFuture = remaining - futureReserve; - // 3. Consistency cap: - // - 0% or 100%: no constraint - // - Day 1 of cycle: max allowed = remaining × consistency - // - Day 2+ of cycle: max allowed = maxDay (keeps consistency ratio stable) - // Always capped at profitTarget × consistency — the largest day the consistency - // rule would have allowed. Prevents a previous overshoot/loss from compounding. + // 3. Consistency cap. + // Day 1: min(remaining × consistency, profitTarget × consistency). + // Day 2+: max(maxDay, profitTarget × consistency). + // - If maxDay ≤ profitTarget × consistency: room to grow days up to that ceiling. + // - If maxDay > profitTarget × consistency: consistency already broken at target, + // 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 path: 'first_day' | 'normal_day' | 'reduced_day'; @@ -140,7 +141,7 @@ export function computeDailyTarget( path = 'first_day'; } else { const maxDay = Math.max(...qualifyingDays.map((d) => d.pnl)); - consistencyCap = Math.min(maxDay, maxConsistencyDay); + consistencyCap = Math.max(maxDay, maxConsistencyDay); path = 'normal_day'; } }