Reset days traded counter from last fund transaction date

Tracks Fund Transaction entries in the Cash History report to find the
most recent account funding/reset date. Only trading days on or after
that date count toward daysTraded and the daily target calculation.
The last fund date is persisted in SQLite so it survives beyond the
28-day Tradovate report window.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Brandon Li
2026-03-21 04:10:02 -05:00
co-authored by Claude Sonnet 4.6
parent 6b299f5359
commit 6d960ceb7b
2 changed files with 53 additions and 9 deletions
+20
View File
@@ -227,6 +227,26 @@ export function loadDailyPnL(accountId: number): { date: string; pnl: number }[]
return (db.prepare('SELECT date, pnl FROM daily_pnl WHERE account_id = ? ORDER BY date').all(accountId) as { date: string; pnl: number }[]);
}
// ── Account Meta ─────────────────────────────────────────────────────────────
db.exec(`
CREATE TABLE IF NOT EXISTS account_meta (
account_id INTEGER NOT NULL,
key TEXT NOT NULL,
value TEXT NOT NULL,
PRIMARY KEY (account_id, key)
);
`);
export function saveAccountMeta(accountId: number, key: string, value: string): void {
db.prepare('INSERT OR REPLACE INTO account_meta (account_id, key, value) VALUES (?, ?, ?)').run(accountId, key, value);
}
export function loadAccountMeta(accountId: number, key: string): string | null {
const row = db.prepare('SELECT value FROM account_meta WHERE account_id = ? AND key = ?').get(accountId, key) as { value: string } | undefined;
return row?.value ?? null;
}
// ── Firm banned symbols ───────────────────────────────────────────────────────
db.exec(`