-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
The following condition appears never entered because there is no market_analysis on the PortfolioSnapshotData
Lines 599 to 601 in 1d4546b
| if (snapshot.snapshot_data?.market_analysis) { | |
| marketConditions = snapshot.snapshot_data.market_analysis; | |
| } |
See here:
Lines 376 to 381 in 1d4546b
| export interface PortfolioSnapshotData { | |
| positions: PositionWithPnL[]; | |
| timestamp: string; | |
| reasoning: string; | |
| raw_ai_response: string; | |
| } |
Generally, there appears to be some inconsistency with the definition of this table:
Based on the following:
Upsert Query:
Lines 317 to 320 in 1d4546b
| const query = ` | |
| INSERT INTO public.portfolio_snapshots (account_id, snapshot_data, total_usd_value, pnl_usd, pnl_percent) | |
| VALUES ($1, $2, $3, $4, $5) | |
| `; |
Snapshot Query:
Lines 571 to 578 in 1d4546b
| const snapshotQuery = ` | |
| SELECT id, snapshot_data, total_usd_value, created_at | |
| FROM public.portfolio_snapshots | |
| WHERE account_id = $1 | |
| AND created_at BETWEEN $2 AND $3 | |
| ORDER BY ABS(EXTRACT(EPOCH FROM (created_at - $2::timestamp))) | |
| LIMIT 1 | |
| `; |
GetQuery:
Lines 403 to 408 in 1d4546b
| const query = ` | |
| SELECT id, snapshot_data, total_usd_value, pnl_usd, pnl_percent, created_at | |
| FROM public.portfolio_snapshots | |
| WHERE account_id = $1 | |
| ORDER BY created_at DESC | |
| `; |
Table CreationQuery:
Lines 91 to 99 in 1d4546b
| `CREATE TABLE IF NOT EXISTS public.portfolio_snapshots ( | |
| id SERIAL PRIMARY KEY, | |
| account_id TEXT NOT NULL, | |
| snapshot_data JSONB NOT NULL, | |
| total_usd_value NUMERIC(20,6) NOT NULL, | |
| pnl_usd NUMERIC(20,6) DEFAULT 0, | |
| pnl_percent NUMERIC(10,4) DEFAULT 0, | |
| created_at TIMESTAMP DEFAULT now() | |
| )`, |
export interface PortfolioSnapshot {
id: number;
snapshot_data: PortfolioSnapshotData;
total_usd_value: number;
created_at: string;
}Metadata
Metadata
Assignees
Labels
No labels