Skip to content

Catalog

Strategy catalog

Every ranking rule the engine ships with, explained and runnable. The demos execute the same functions your backtests use — on a deterministic sample universe, right in your browser.

Built-in strategies

The three ranking families the backtester ships with. Each demo below calls the actual engine function — the identical code that ranks assets inside your backtests.

Momentum
Selects assets with the strongest recent price momentum, betting that recent winners will continue to outperform.

Formula

Momentum(i) = P(i, today) − P(i, today − t)

Where P(i, t) is the price of asset i at time t, and t is the lookback period in trading days.

Parameters

  • t: number Lookback period in trading days (engine default: 10)
  • prices: Map<string, number[]> Symbol → historical price series

How it works

  1. Fetch historical closing prices for all assets in the universe
  2. Calculate momentum = current price − price t periods ago
  3. Rank assets by momentum score (highest first)
  4. Select the top N assets for the portfolio
  5. Pass the selection to the optimizer for weight allocation

Pros

  • Simple and intuitive
  • Well-documented academic support
  • Works in trending markets
  • Easy to implement and backtest

Cons

  • Suffers in mean-reverting markets
  • Can lead to high turnover
  • Momentum crashes during regime changes
  • Lookback-period sensitivity

When to use: Best for trending markets with clear directional moves. Commonly used in cross-sectional equity strategies.

See it rank

Live output of momentumStrategy() on 252 days of seeded sample data for AAPL, MSFT, GOOGL, AMZN, TSLA, NVDA, META, JPM.

RankSymbolSignal
#1AMZNSelect
#2AAPLSelect
#3TSLASelect
#4GOOGLHold
#5METAHold
#6MSFTHold
#7JPMHold
#8NVDAHold
Mean reversion
Identifies oversold assets trading below their moving average, betting they will revert to the mean.

Formula

Deviation(i) = P(i, today) − SMA(i, t)

Where SMA(i, t) is the Simple Moving Average of asset i over t periods. Most negative = most oversold, ranked first.

Parameters

  • t: number Moving-average window in trading days (engine default: 20)
  • prices: Map<string, number[]> Symbol → historical price series

How it works

  1. Calculate the t-period Simple Moving Average for each asset
  2. Compute deviation = current price − SMA
  3. Rank assets by deviation ascending — most oversold first
  4. Select the top N most oversold assets
  5. Allocate weights via the chosen optimizer

Pros

  • Contrarian approach captures rebounds
  • Works well in range-bound markets
  • Can identify undervalued assets
  • Natural buy-low mechanism

Cons

  • Can catch falling knives
  • Underperforms in strong trends
  • Requires accurate mean estimation
  • Risk of value traps

When to use: Best for range-bound or mean-reverting markets. Pairs well with a minimum-variance optimizer for risk management.

See it rank

Live output of meanReversionStrategy() on 252 days of seeded sample data for AAPL, MSFT, GOOGL, AMZN, TSLA, NVDA, META, JPM.

RankSymbolSignal
#1NVDASelect
#2JPMSelect
#3MSFTSelect
#4METAHold
#5GOOGLHold
#6AAPLHold
#7TSLAHold
#8AMZNHold
Smart beta
Ranks assets by their risk-adjusted returns (return per unit of risk), similar to a per-asset Sharpe ratio.

Formula

SmartBeta(i) = mean(Rᵢ) / std(Rᵢ)

Where Rᵢ are the period returns of asset i. Higher ratio = better risk-adjusted performance, ranked first.

Parameters

  • prices: Map<string, number[]> Symbol → historical price series

How it works

  1. Calculate daily returns for each asset
  2. Compute mean return and standard deviation for each
  3. Score each asset as mean / std (risk-adjusted return)
  4. Rank by score descending — best risk-adjusted performers first
  5. Select the top N assets and optimize weights

Pros

  • Risk-aware selection
  • Favors consistent performers
  • Produces less volatile portfolios
  • Built on the academic Sharpe-ratio foundation

Cons

  • Backward-looking (past ≠ future)
  • Penalizes high-growth volatile stocks
  • Sensitive to the estimation period
  • May underperform in strong bull markets

When to use: Best for investors seeking risk-adjusted returns. Works well for long-term portfolio construction.

See it rank

Live output of smartBetaStrategy() on 252 days of seeded sample data for AAPL, MSFT, GOOGL, AMZN, TSLA, NVDA, META, JPM.

RankSymbolSignal
#1JPMSelect
#2TSLASelect
#3AMZNSelect
#4NVDAHold
#5AAPLHold
#6GOOGLHold
#7MSFTHold
#8METAHold

AI strategy templates

Five ready-made strategies the AI Strategy Builder can load, tweak, or use as few-shot seeds. Each one runs in the same sandboxed executor that vets custom code — try them on the sample universe right here.

Momentum Crossover
Buy when fast moving average crosses above slow moving average
How it works

Momentum Crossover Strategy This strategy uses two moving averages (fast and slow) to detect momentum shifts: 1. Fast MA (10-day): Reacts quickly to recent price changes 2. Slow MA (50-day): Represents the longer-term trend 3. Signal: When the fast MA crosses above the slow MA, it indicates bullish momentum 4. Ranking: Stocks are ranked by crossover strength — how far above the slow MA the fast MA sits This is a classic trend-following approach. Stocks with the strongest upward momentum crossover get the highest priority.

RSI Mean Reversion
Buy oversold stocks based on RSI, sell overbought ones
How it works

RSI Mean Reversion Strategy This strategy identifies oversold stocks using the Relative Strength Index (RSI): 1. RSI Calculation: Measures the ratio of recent gains to recent losses over 14 days 2. Oversold Signal: RSI below 30 indicates a stock may be oversold 3. Ranking: The most oversold stocks (lowest RSI) get the highest priority 4. Mean Reversion: The assumption is that oversold stocks will bounce back toward their average This is a contrarian approach — buying when others are selling, expecting a reversion to the mean.

Volatility Breakout
Buy stocks breaking out on expanding volatility
How it works

Volatility Breakout Strategy This strategy uses Bollinger Bands to detect price breakouts: 1. Bollinger Bands: A 20-day moving average with bands at 2 standard deviations above and below 2. Breakout Signal: When price exceeds the upper band, it signals strong upward momentum 3. Ranking: Stocks are ranked by how far above the upper band they are (in standard deviations) 4. Volatility Expansion: Breakouts accompanied by expanding volatility tend to continue This strategy captures strong momentum moves as prices break out of their normal trading range.

Relative Value
Rank stocks by their recent performance relative to the group average
How it works

Relative Value Strategy This strategy identifies stocks that have underperformed their peers: 1. Relative Performance: Each stock's return is compared to the group average over 20 days 2. Underperformers First: Stocks that lagged the group the most are ranked highest 3. Mean Reversion: The assumption is that relative underperformers will catch up to the group 4. Market Neutral Concept: By focusing on relative performance, this approach is less sensitive to overall market direction This is a pairs-trading-inspired strategy applied across the whole universe — buying laggards and expecting convergence.

Dual Momentum
Combine absolute and relative momentum for robust stock selection
How it works

Dual Momentum Strategy This strategy combines two types of momentum for more robust stock selection: 1. Absolute Momentum Filter: Only considers stocks trading above their 200-day moving average (confirming uptrend) 2. Relative Momentum Ranking: Among qualifying stocks, ranks by 60-day return (strongest performers first) 3. Dual Filter: Requires both conditions — this avoids buying stocks with short-term bounces in long-term downtrends 4. Risk Management: The absolute momentum filter naturally reduces exposure during bear markets This approach, popularized by Gary Antonacci, combines trend-following with relative strength for improved risk-adjusted returns.

Want to backtest one of these, or draft your own? Open the Strategy Builder →

Unsure which family fits which market? Start with the Learn page.

Report an issue

Show diagnostics

Environment

 

Console errors

 

Failed requests