Cap consistency at profitTarget × consistency

Caps consistencyCap at the largest day the consistency rule would have
allowed (profitTarget × consistency). Prevents previous overshoots or
losses from expanding future targets beyond what consistency permits.

Day 1: min(remaining × consistency, profitTarget × consistency)
Day 2+: min(maxDay, profitTarget × consistency)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Brandon Li
2026-04-26 02:54:03 -05:00
co-authored by Claude Opus 4.6
parent 8204cd138b
commit c589adec91
+11 -6
View File
@@ -125,19 +125,24 @@ export function computeDailyTarget(
// - 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.
let consistencyCap: number;
let path: 'first_day' | 'normal_day' | 'reduced_day';
if (consistency === 0 || consistency >= 1) {
consistencyCap = Infinity;
path = daysTraded === 0 ? 'first_day' : 'reduced_day';
} else if (daysTraded === 0) {
consistencyCap = remaining * consistency;
path = 'first_day';
} else {
const maxDay = Math.max(...qualifyingDays.map((d) => d.pnl));
consistencyCap = maxDay;
path = 'normal_day';
const maxConsistencyDay = profitTarget * consistency;
if (daysTraded === 0) {
consistencyCap = Math.min(remaining * consistency, maxConsistencyDay);
path = 'first_day';
} else {
const maxDay = Math.max(...qualifyingDays.map((d) => d.pnl));
consistencyCap = Math.min(maxDay, maxConsistencyDay);
path = 'normal_day';
}
}
// 4. Combine caps and apply min-day floor when mandatory days remain.