Show fund transactions (W/D) on calendar, equity curve, and cash history table

- Persist fund transactions to SQLite (fund_transactions table) so they
  survive beyond Tradovate's 28-day report window
- Calendar: highlight W/D dates in amber with the amount shown below the day
- Equity curve: reduce running equity at withdrawal dates and show a vertical
  dashed amber line labelled W/D
- New Cash History table below calendar listing all trades and W/D events
  sorted newest-first

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Brandon Li
2026-03-21 04:16:24 -05:00
co-authored by Claude Sonnet 4.6
parent 6d960ceb7b
commit 4252adfbea
5 changed files with 144 additions and 18 deletions
+24
View File
@@ -227,6 +227,30 @@ 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 }[]);
}
// ── Fund Transactions Cache ───────────────────────────────────────────────────
db.exec(`
CREATE TABLE IF NOT EXISTS fund_transactions (
account_id INTEGER NOT NULL,
account_name TEXT NOT NULL,
date TEXT NOT NULL,
amount REAL NOT NULL,
PRIMARY KEY (account_id, date)
);
`);
export function saveFundTransactions(accountId: number, accountName: string, entries: { date: string; amount: number }[]): void {
const ins = db.prepare('INSERT OR REPLACE INTO fund_transactions (account_id, account_name, date, amount) VALUES (?, ?, ?, ?)');
const txn = db.transaction(() => {
for (const e of entries) ins.run(accountId, accountName, e.date, e.amount);
});
txn();
}
export function loadFundTransactions(accountId: number): { date: string; amount: number }[] {
return db.prepare('SELECT date, amount FROM fund_transactions WHERE account_id = ? ORDER BY date').all(accountId) as { date: string; amount: number }[];
}
// ── Account Meta ─────────────────────────────────────────────────────────────
db.exec(`