For AI agents: the complete documentation index is at llms.txt. Every page is also available as markdown by appending .md to its URL, or by sending an Accept: text/markdown request header.

Capital Markets Recipes

This section contains SQL recipes for financial market analysis. All recipes use the demo dataset available in the QuestDB web console.

Price-Based Indicators​

Foundation recipes for price analysis and trend identification.

RecipeDescription
OHLC AggregationAggregate tick data into candlestick bars
VWAPVolume-Weighted Average Price
TWAPTime-Weighted Average Price
Bollinger BandsPrice channels based on standard deviation
Bollinger BandWidthMeasure band expansion and contraction

Momentum Indicators​

Measure the speed and strength of price movements.

RecipeDescription
RSIRelative Strength Index for overbought/oversold conditions
MACDMoving Average Convergence Divergence
Stochastic OscillatorCompare closing price to price range
Rate of ChangePercentage price change over N periods

Volatility Indicators​

Quantify market uncertainty and price variability.

RecipeDescription
ATRAverage True Range
Rolling Std DevMoving standard deviation of returns
Donchian ChannelsHigh/low price channels
Keltner ChannelsEMA-based volatility channels
Realized VolatilityHistorical volatility from returns

Volume & Order Flow​

Analyze trading activity and order flow dynamics.

RecipeDescription
OBVOn-Balance Volume
Volume ProfileVolume distribution by price level
Volume SpikeDetect abnormal volume
Aggressor ImbalanceBuy vs sell pressure
Order Flow ImbalanceQuote-based top-of-book buying/selling pressure
VPINVolume-synchronized informed trading probability

Risk Metrics​

Portfolio risk measurement and drawdown analysis.

RecipeDescription
Maximum DrawdownPeak-to-trough decline

Market Microstructure​

Analyze market quality and trading costs.

RecipeDescription
Bid-Ask SpreadSpread metrics and analysis
Gamma Scalping SignalVol-spread ratio for gamma scalping conditions
Liquidity ComparisonCompare liquidity across instruments

Post-Trade Analysis​

Measure execution quality, fill performance, and trading costs. Also available as a top-level sidebar section for quick access.

RecipeDescription
SlippageMeasure execution slippage per fill
Slippage (aggregated)Compare slippage across venues and counterparties
Markout analysisPost-trade price reversion and adverse selection
Last look detectionMillisecond-granularity markout for last-look analysis
Implementation shortfallCost decomposition into spread, permanent, and temporary impact
Implementation shortfall (order)Total IS per order vs arrival mid
ECN scorecardDashboard-style venue comparison combining spread, slippage, and fill metrics

Market Breadth​

Measure overall market participation and sentiment.

RecipeDescription
TICK & TRINMarket breadth indicators

Math Utilities​

General-purpose financial calculations.

RecipeDescription
Compound InterestInterest and growth calculations
Cumulative ProductRunning product for returns
Log ReturnsCompute log returns from consecutive prices