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'; } }