Write a query or script to calculate the rolling 5-minute average price of a stock asset, handling periods of inactivity where no trades occur for Jane Street’s data.
Use the assets and trades tables and calculate results for the asset with symbol AAPL. Include every five-minute timestamp from the asset observation start through its observation end. A missing average must be represented as NULL, not zero.
AAPLasset_symbol, bucket_start, and rolling_5_min_avg_pricebucket_start ascending| Column | Type | Description |
|---|---|---|
| asset_idPK | INT | Unique asset identifier |
| symbol | VARCHAR(20) | Stock symbol |
| observation_start | TIMESTAMPTZ | Beginning of the reporting interval |
| observation_end | TIMESTAMPTZ | End of the reporting interval |
| Column | Type | Description |
|---|---|---|
| trade_idPK | INT | Unique trade identifier |
| symbol | VARCHAR(20) | Traded stock symbol |
| trade_time | TIMESTAMPTZ | Timestamp when the trade occurred |
| price | NUMERIC(12,4) | Trade price |