One query, a tearsheet per instrument
This is the whole interface: one aggregate call over a long table of prices, no grouping to write, no Python. On the right is the report it returns for GOOGL, with the S&P 500 as its benchmark — the real output, rendered in an iframe.
duckdb
-- once per session: INSTALL duckfn_quantstats FROM community; LOAD duckfn_quantstats;
WITH prices AS (
SELECT *
FROM read_csv('https://shijianjs.github.io/duckfn-quantstats/demo/prices.csv')
)
SELECT (r).symbol, (r).benchmark, length((r).html) AS html_bytes
FROM (
SELECT unnest(qs_html_reports_by_prices(
symbol, date, price,
{'benchmark': ['SPX'],
'benchmark_title': ['S&P 500'],
'title': symbol,
'strategy_title': symbol}::qs_html_report_options)) AS r
FROM prices
);