-- Analytical fact table: pnl_daily
-- Daily profit and loss records per symbol per account.
-- Partitioned by dt on MinIO.
-- Path: s3://stonks-lakehouse/warehouse/pnl_daily/dt={yyyy-mm-dd}/part-*.parquet
-- Requirements: 9.4, 9.5, 10.1, 10.3
-- Design ref: Section 7 (lake.pnl_daily)

CREATE TABLE IF NOT EXISTS lakehouse.stonks.pnl_daily (
    ticker            VARCHAR,
    realized_pnl      DOUBLE,
    unrealized_pnl    DOUBLE,
    total_pnl         DOUBLE,
    fees              DOUBLE,
    net_pnl           DOUBLE,
    broker_account    VARCHAR,
    execution_mode    VARCHAR,
    dt                DATE
) WITH (
    format = 'PARQUET',
    partitioned_by = ARRAY['dt'],
    external_location = 's3a://stonks-lakehouse/warehouse/pnl_daily/'
);
