Report per-account-type days-traded histograms to the master

Adds daysHist ({daysTraded: accountCount}) to AccountTypeStats, computed
from the same combined-day view the trade path uses and covering every
live account including ones mid-trade. Feeds the master's payout
calendar; an older master simply ignores the field.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Brandon Li
2026-09-10 16:21:17 -05:00
co-authored by Claude Fable 5
parent 0d01539338
commit 6c501d00ed
2 changed files with 17 additions and 6 deletions
+4
View File
@@ -22,6 +22,10 @@ export interface AccountTypeStats {
targetHit?: number;
partial?: number;
loss?: number;
/** Live accounts by trading days completed toward the current target:
* {daysTraded: accountCount}. Feeds the master's payout calendar.
* Optional so an older master simply ignores it. */
daysHist?: Record<number, number>;
}
export interface FirmStats {
+13 -6
View File
@@ -80,6 +80,18 @@ function collectFirmStats() {
totalAccounts++;
slice.totalAccounts++;
// Same combined-day view as the trade path: for a combining firm,
// "today" spans the holiday stretch. Computed for every live
// account — including ones mid-trade — so the days-traded
// histogram below covers the whole slice.
const combined = cfg ? combineCmeSessions(
cfg.combineCmeHolidays, client.dailyPnL[acc.id] ?? [], currentTradeDateCT(), cash.realizedPnL,
) : null;
if (combined) {
const hist = (slice.daysHist ??= {});
hist[combined.daysTraded] = (hist[combined.daysTraded] ?? 0) + 1;
}
if (client.positions[acc.id]) {
inTrade++;
accountsTraded++;
@@ -100,12 +112,7 @@ function collectFirmStats() {
}
// Check if target was hit today
if (cfg) {
// Same combined-day view as the trade path: for a combining
// firm, "today" spans the holiday stretch.
const combined = combineCmeSessions(
cfg.combineCmeHolidays, client.dailyPnL[acc.id] ?? [], currentTradeDateCT(), cash.realizedPnL,
);
if (cfg && combined) {
const equityProfit = cash.amount - cfg.accountSize;
const plan = computeDayPlan(
acc.id, combined.tradeDate, cfg.profitTarget, cfg.consistency,