Capital Markets Recipes

This section contains SQL recipes for financial market analysis. Each recipe uses 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
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

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
Liquidity ComparisonCompare liquidity across instruments

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