P1.1: Report each account's status to the master's ledger
Every FirmStats now carries statusVersion 1, the catalog firmId and, once synced, syncedAt (from lastSyncAt), including the no-accounts branch, which is now built by emptyFirmStats(). Each accounts[] entry adds status, reason, balance, floor, accountTypeId, firstFundDate, positiveFunds and brokerStatus, each left out when null or at its default. accountStatus() in platform-client.ts is pure: a missing balance is unknown (cash_missing), never dead; with a balance, dead is exactly the old floor test (legacyDead); then history_pending, locked, live. Only the reporter uses it. The aggregates, totals and every trading decision keep their own dead test, unchanged. The reporter reads history readiness through a new Tradovate peekHistoryReady(), because historyReady() there can start a hold and move the balance baseline. DXTrade exposes accountStatus and registrationTime via brokerAccountMeta(). A throw in the new fields reports the account as unknown instead of losing the report. sendReport skips the socket for a firms payload over 900,000 chars (the master's frame cap is 1,000,000 bytes) and POSTs it, logging once per switch. scripts/check-account-status.mjs proves the legacy invariant over the full matrix and the size budget (worst 228 B added per account, 154 B typical live; 2000 accounts 592,501 B). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8747dd6b08
commit
0c3a36845a
@@ -1544,6 +1544,15 @@ export class TradovateClient {
|
||||
return !this.balanceDrifted(accountId);
|
||||
}
|
||||
|
||||
/** historyReady() without its drift check, which can start a hold and
|
||||
* moves the balance baseline — for the reporter, which must change
|
||||
* neither. A drift not yet held reads ready until the scheduler looks. */
|
||||
public peekHistoryReady(accountId: number): boolean {
|
||||
if (!this.historyLoadedIds.has(accountId)) return false;
|
||||
if (this.dailyPnL[accountId] === undefined || this.fundTransactions[accountId] === undefined) return false;
|
||||
return !this.historyHolds.has(accountId);
|
||||
}
|
||||
|
||||
/** Drop the account's history from memory (a wipe): it reads unloaded, and
|
||||
* stays out of trading, until a Cash History rebuilds it — the wipe took
|
||||
* its fund transactions, which neither the Fills report nor the cache can
|
||||
|
||||
Reference in New Issue
Block a user