Vest: a claim within $25 of target names its cycle, the newest goes first, and a batch on a turned day stops
The auto-claim takes a cycle as done within LEG_COMPLETION_EPSILON of its target, so the cycle it names is judged at that tolerance too. Each saved cycle keeps its claim's time, and the report lists a day's claims newest first, so the master's per-slice cap can't hold the latest back. A batch or copy whose client's day turned while it chose (Vest, at the first sync after 8 PM ET) is abandoned rather than sized and counted on the old day. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
dc210ffcb7
commit
bf7e147507
+13
-1
@@ -1224,6 +1224,13 @@ async function runTradeLocked(
|
||||
console.warn('[auto-trade] superseded while collecting accounts — abandoning this batch');
|
||||
return { outcome: 'skipped-in-flight', results: [], detail: 'superseded by another batch while choosing' };
|
||||
}
|
||||
// A Vest lane's day turns with its client's numbers (tradeDateFor). One
|
||||
// that turned while choosing would size and count these legs on the day
|
||||
// that ended — the next tick plans on the new one.
|
||||
if (batch.some((item) => tradeDateFor(item.client) !== tradeDate)) {
|
||||
console.warn(`[auto-trade] ${laneName(lane)}: the trade date turned while choosing — abandoning this batch`);
|
||||
return { outcome: 'skipped-in-flight', results: [], detail: 'the trade date turned while choosing' };
|
||||
}
|
||||
|
||||
console.log(`[auto-trade] ${laneName(lane)}: ${allEligible.length} eligible account(s) across ${groups.size} prefix group(s) — firing batch of ${batch.length} ${batchPrefix || '(no prefix)'} on ${resolvedSymbol}`);
|
||||
runtime().lastFireAt = Date.now();
|
||||
@@ -1826,6 +1833,10 @@ async function copyTradeLocked(lease: number, lane: string): Promise<unknown[]>
|
||||
console.warn('[copy-trade] superseded while collecting accounts — abandoning this copy');
|
||||
return [];
|
||||
}
|
||||
if (batch.some((item) => tradeDateFor(item.client) !== tradeDate)) {
|
||||
console.warn('[copy-trade] the trade date turned while choosing — abandoning this copy');
|
||||
return [];
|
||||
}
|
||||
|
||||
console.log(`[copy-trade] copying ${resolvedAction} ${resolvedSymbol} to ${batch.length} account(s)`);
|
||||
runtime().lastFireAt = Date.now();
|
||||
@@ -2074,7 +2085,8 @@ async function claimTick(): Promise<void> {
|
||||
function claimEnds(client: PlatformClient, acc: { id: number; name: string }): ClaimedCycle | null {
|
||||
try {
|
||||
const cfg = getAccountConfig(acc.id).accountType;
|
||||
return cfg && !client.lastFetchErrors?.[acc.name] ? claimedCycle(client, acc.id, cfg) : null;
|
||||
// Judged as claimDue claims: within LEG_COMPLETION_EPSILON of the target.
|
||||
return cfg && !client.lastFetchErrors?.[acc.name] ? claimedCycle(client, acc.id, cfg, new Date(), LEG_COMPLETION_EPSILON) : null;
|
||||
} catch (err) {
|
||||
console.error(`[claim] ${acc.name}: the cycle the claim ends couldn't be read — ${errorMessage(err)}`);
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user