Revert "Attribute evening-session Cash History rows to the next trade date"

This reverts commit 57846d2b5f.
This commit is contained in:
Brandon Li
2026-09-08 21:21:09 -05:00
parent f07721019b
commit 3443fac75c
2 changed files with 7 additions and 57 deletions
-17
View File
@@ -234,23 +234,6 @@ export function saveDailyPnL(accountId: number, accountName: string, entries: {
txn();
}
/**
* Replace all rows on/after fromDate with the given entries, keeping older rows.
* Used when a full Cash History report succeeded: it is authoritative for its window,
* so stale rows there (e.g. saved under a pre-roll calendar date) must not survive.
*/
export function replaceDailyPnLWindow(accountId: number, accountName: string, fromDate: string, entries: { date: string; pnl: number }[]): void {
const del = db.prepare('DELETE FROM daily_pnl WHERE account_id = ? AND date >= ?');
const ins = db.prepare('INSERT OR REPLACE INTO daily_pnl (account_id, account_name, date, pnl) VALUES (?, ?, ?, ?)');
const txn = db.transaction(() => {
del.run(accountId, fromDate);
for (const e of entries) {
ins.run(accountId, accountName, e.date, e.pnl);
}
});
txn();
}
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 }[]);
}