fix: recordSnapshot type annotation + datetime quotes

This commit is contained in:
Manohar 2026-05-08 17:13:17 +00:00
parent e97a2ca643
commit 03035b3965

View file

@ -208,13 +208,13 @@ export async function forcePoll(): Promise<void> {
* Record a portfolio-level P&L snapshot after every fetch.
* Called by both pollTick (market hours) and forcePoll (manual/startup).
*/
function recordSnapshot(positions: import(../angel/types.js).Position[]): void {
function recordSnapshot(positions: Position[]): void {
const totalUnrealised = positions.reduce((s, p) => s + p.unrealisedPnl, 0);
const totalRealised = positions.reduce((s, p) => s + p.realisedPnl, 0);
const totalPnl = totalUnrealised + totalRealised;
db.prepare(`
INSERT INTO pnl_snapshots (total_unrealised, total_realised, total_pnl, open_positions, recorded_at)
VALUES (?, ?, ?, ?, datetime(now))
VALUES (?, ?, ?, ?, datetime('now'))
`).run(totalUnrealised, totalRealised, totalPnl, positions.length);
}