Vest: projected days trade the next stage after each payout, as the bot does

runClaims claims a same-day type's target and trades its next stage the
same day on the room the claim freed, but the projection paid out once a
day, so Vest's payout calendar showed $1,500 a day instead of $1,500 then
$3,000. Each payout now counts toward its own date, and the same date is
projected again on the next stage, once through the stages a day (the
last one repeats). A cycle that stood complete before today counts
toward today, when it is claimed. Other types project as before.

The account page sums a date's cycles, cuts after the second payout day,
and labels a same-day type's past days from that day's own payout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Li
2026-10-27 14:34:30 -05:00
co-authored by Claude Opus 5.5
parent e33e890a83
commit 266100b65c
3 changed files with 74 additions and 32 deletions
+23 -6
View File
@@ -534,15 +534,23 @@ export function projectPerfectPath(opts: {
};
// A type whose stages reset each day (Vest) counts only the payouts made
// since its day began: today's real ones, and none on a projected day —
// the path pays out at most once a day, as the day's last entry, so
// every projected day trades the base stage.
// since its day began: today's real ones plus the path's own on that
// date, so every projected day starts on the base stage.
const sameDay = opts.stageInputs?.stagesSameDay === true;
/** The path's own payouts, by the date they are claimed on. */
const paidOn = new Map<string, number>();
/** Payouts before the stage traded on `day`: that day's own for a
* same-day type, else every withdrawal so far. */
const paidBefore = (day: string): number => (sameDay
? (day === today ? Math.max(0, Math.floor(opts.stageInputs?.sameDayWithdrawals ?? 0)) : 0)
? (day === today ? Math.max(0, Math.floor(opts.stageInputs?.sameDayWithdrawals ?? 0)) : 0) + (paidOn.get(day) ?? 0)
: funds.filter((f) => f.amount < 0).length);
/** A same-day type trades its next stage on the date a payout lands
* (runClaims claims, then trades again on the room the claim freed) —
* once through its stages a day: the last one repeats, and the path
* stops there. */
const tradesAgain = (day: string): boolean => sameDay
&& (paidOn.get(day) ?? 0) > 0
&& paidBefore(day) <= cfg.withdrawalStages.length;
const effectiveOn = (day: string) => resolveEffectiveConfig(
cfg.profitTarget, cfg.consistency, cfg.minTradingDays, cfg.targetSameEquity,
cfg.withdrawalStages, 0, funds, cfg.minDayPnL,
@@ -604,6 +612,9 @@ export function projectPerfectPath(opts: {
balance = round2(balance - gross);
sim = []; // withdrawal excludes its day — fresh cycle
withdrawals++;
// A cycle that stood complete before today is claimed today.
const claimDay = onDate < today ? today : onDate;
paidOn.set(claimDay, (paidOn.get(claimDay) ?? 0) + 1);
high = Math.max(high, dd); // a payout locks the trail at breakeven
out.push({ date: onDate, pnl: dayPnl, stage, drain, withdrawal: -gross, prob, gross, net });
return false;
@@ -633,9 +644,13 @@ export function projectPerfectPath(opts: {
}
}
// A same-day type's next stage trades on the date its payout landed,
// today's included; anything else moves on a day.
let date = today;
for (let step = 0; step < horizon; step++) {
date = nextDay(date);
let again = todayHasSession && tradesAgain(today);
for (let step = 0; again || step < horizon;) {
if (again) again = false;
else { date = nextDay(date); step++; }
const eff = effectiveOn(date);
const stage = 1 + paidBefore(date);
const plan = computeDayPlan(
@@ -650,6 +665,7 @@ export function projectPerfectPath(opts: {
// The cycle completed mid-projection with nothing left to trade —
// the pending payout lands on this day.
if (finishCycle(date, 0, stage, eff.drain)) break;
again = tradesAgain(date);
continue;
}
@@ -673,6 +689,7 @@ export function projectPerfectPath(opts: {
&& eff2.minTradingDays <= qualifyingDays(eff2.minDayPnL, nd);
if (doneAfter) {
if (finishCycle(date, pnl, stage, eff.drain)) break;
again = tradesAgain(date);
} else {
out.push({ date, pnl, stage, drain: eff.drain, prob });
}