Skip to content

Never Entered Condition #2

Description

@bh2smith

The following condition appears never entered because there is no market_analysis on the PortfolioSnapshotData

auto-trader/lib/memory.ts

Lines 599 to 601 in 1d4546b

if (snapshot.snapshot_data?.market_analysis) {
marketConditions = snapshot.snapshot_data.market_analysis;
}

See here:

auto-trader/lib/memory.ts

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:

auto-trader/lib/memory.ts

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:

auto-trader/lib/memory.ts

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:

auto-trader/lib/memory.ts

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:
`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;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions