[ DuckDB stock data Parquet guide ]
Run SQL directly against OHLCV Parquet files without loading a database first.
[ File layout ]
MarketParquet files are partitioned by date:
by_date/{asset}_{timeframe}/YYYY/YYYY-MM-DD.parquet.
Each file contains all symbols for a single trading day.
Daily files use a date column; intraday files use a
US/Eastern timestamp column. Both include symbol, asset type,
open, high, low, close, and volume.
[ Query one day ]
import duckdb
con = duckdb.connect()
result = con.execute("""
SELECT symbol, close, volume
FROM 'stock_daily_2024-01-15.parquet'
WHERE symbol IN ('AAPL', 'MSFT', 'SPY')
ORDER BY symbol
""").fetchdf()
[ Query many files ]
import duckdb
con = duckdb.connect()
monthly = con.execute("""
SELECT symbol, AVG(close) AS avg_close, SUM(volume) AS total_volume
FROM 'by_date/stock_daily/2024/*.parquet'
GROUP BY symbol
ORDER BY total_volume DESC
LIMIT 20
""").fetchdf()
[ Related ]
stock data hub · browse stock daily · pricing · Polars guide · local data lake guide