You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A financial analysis extension for DuckDB. 59+ SQL functions for technical analysis, risk management, portfolio analytics, options pricing, and market data access.
Note: This codebase is currently maintained and updated by an AI agent running Claude Code. While all changes go through CI and automated testing, use with appropriate caution and review before relying on it for financial decisions.
INSTALL scrooge FROM community;
LOAD scrooge;
SELECTdate, close,
ema(close, date::TIMESTAMPTZ, 20) as ema_20,
rsi(close, date::TIMESTAMPTZ, 14) as rsi_14,
bollinger_signal(close,
bollinger_upper(close, date::TIMESTAMPTZ, 20, 2.0),
bollinger_lower(close, date::TIMESTAMPTZ, 20, 2.0)) as signal
FROM yahoo_finance('AAPL', '2024-01-01', '2025-01-01', '1d')
GROUP BY ALL;
Quick Start
INSTALL scrooge FROM community;
LOAD scrooge;
-- Stock dataSELECT*FROM yahoo_finance('MSFT', '2024-01-01', '2025-01-01', '1d');
-- Crypto data (free, no API key)SELECT*FROM coingecko('bitcoin', 'usd', 365);
-- Economic data (requires free FRED API key)SELECT*FROM fred_series('GDP', 'your_api_key');
WITH prices AS (
SELECT*FROM yahoo_finance('AAPL', '2024-01-01', '2025-01-01', '1d')
)
SELECTdate, close,
rsi(close, date::TIMESTAMPTZ, 14) as rsi_14,
rsi_signal(rsi(close, date::TIMESTAMPTZ, 14)) as rsi_signal,
sharpe_ratio(simple_return(close, date::TIMESTAMPTZ), date::TIMESTAMPTZ) as sharpe
FROM prices
GROUP BY ALL;
Options Analysis
-- Price a call option and compute GreeksSELECT
bs_call(150, 145, 0.25, 0.05, 0.30) as call_price,
bs_delta_call(150, 145, 0.25, 0.05, 0.30) as delta,
bs_gamma(150, 145, 0.25, 0.05, 0.30) as gamma,
bs_implied_vol(12.5, 150, 145, 0.25, 0.05, true) as implied_vol;
Portfolio Diversification
SELECT
portfolio_correlation(aapl_ret, msft_ret) as correlation,
portfolio_beta(aapl_ret, spy_ret) as beta
FROM returns_table;
Build
git clone --recurse-submodules https://github.com/pdet/Scrooge-McDuck.git
cd Scrooge-McDuck
GEN=ninja make
Why Scrooge
Pure SQL -- no Python glue code needed for financial analysis
Privacy -- DuckDB runs locally, portfolio data stays on your machine
Free -- MIT licensed, no cloud costs
Fast -- columnar storage and vectorized execution
Composable -- combine indicators, signals, and data sources in a single query