Revert "Attribute evening-session Cash History rows to the next trade date"
This reverts commit 57846d2b5f.
This commit is contained in:
@@ -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 }[]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user