The following condition appears never entered because there is no market_analysis on the PortfolioSnapshotData
|
if (snapshot.snapshot_data?.market_analysis) { |
|
marketConditions = snapshot.snapshot_data.market_analysis; |
|
} |
See here:
|
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:
|
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:
|
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:
|
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:
|
`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;
}
The following condition appears never entered because there is no
market_analysison thePortfolioSnapshotDataauto-trader/lib/memory.ts
Lines 599 to 601 in 1d4546b
See here:
auto-trader/lib/memory.ts
Lines 376 to 381 in 1d4546b
Generally, there appears to be some inconsistency with the definition of this table:
Based on the following:
Upsert Query:
auto-trader/lib/memory.ts
Lines 317 to 320 in 1d4546b
Snapshot Query:
auto-trader/lib/memory.ts
Lines 571 to 578 in 1d4546b
GetQuery:
auto-trader/lib/memory.ts
Lines 403 to 408 in 1d4546b
Table CreationQuery:
auto-trader/lib/memory.ts
Lines 91 to 99 in 1d4546b