diff --git a/backend/scripts/seed_data.py b/backend/scripts/seed_data.py index 24a078b..800efc3 100644 --- a/backend/scripts/seed_data.py +++ b/backend/scripts/seed_data.py @@ -42,6 +42,15 @@ TARGETS = { "411060": Decimal("15"), } +# Actual total invested amounts per ticker (from brokerage records) +TOTAL_INVESTED = { + "069500": Decimal("541040"), + "148070": Decimal("15432133"), + "284430": Decimal("18375975"), + "360750": Decimal("7683515"), + "411060": Decimal("6829620"), +} + # Historical snapshots from data.txt SNAPSHOTS = [ { @@ -242,13 +251,18 @@ def seed(db: Session): print(f"Created {tx_count} transactions from snapshot diffs") # Set current holdings from latest snapshot + # avg_price = total invested amount / quantity (from actual brokerage records) latest = SNAPSHOTS[-1] for h in latest["holdings"]: + ticker = h["ticker"] + qty = h["qty"] + invested = TOTAL_INVESTED[ticker] + avg_price = (invested / qty).quantize(Decimal("0.01")) db.add(Holding( portfolio_id=portfolio.id, - ticker=h["ticker"], - quantity=h["qty"], - avg_price=h["price"], # Using current price as avg (best available) + ticker=ticker, + quantity=qty, + avg_price=avg_price, )) print(f"Set {len(latest['holdings'])} current holdings from {latest['date']}")