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.
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
- Fetch historical closing prices for all assets in the universe
- Calculate momentum = current price − price t periods ago
- Rank assets by momentum score (highest first)
- Select the top N assets for the portfolio
- 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.
| Rank | Symbol | Signal |
|---|---|---|
| #1 | AMZN | Select |
| #2 | AAPL | Select |
| #3 | TSLA | Select |
| #4 | GOOGL | Hold |
| #5 | META | Hold |
| #6 | MSFT | Hold |
| #7 | JPM | Hold |
| #8 | NVDA | Hold |
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
- Calculate the t-period Simple Moving Average for each asset
- Compute deviation = current price − SMA
- Rank assets by deviation ascending — most oversold first
- Select the top N most oversold assets
- 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.
| Rank | Symbol | Signal |
|---|---|---|
| #1 | NVDA | Select |
| #2 | JPM | Select |
| #3 | MSFT | Select |
| #4 | META | Hold |
| #5 | GOOGL | Hold |
| #6 | AAPL | Hold |
| #7 | TSLA | Hold |
| #8 | AMZN | Hold |
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
- Calculate daily returns for each asset
- Compute mean return and standard deviation for each
- Score each asset as mean / std (risk-adjusted return)
- Rank by score descending — best risk-adjusted performers first
- 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.
| Rank | Symbol | Signal |
|---|---|---|
| #1 | JPM | Select |
| #2 | TSLA | Select |
| #3 | AMZN | Select |
| #4 | NVDA | Hold |
| #5 | AAPL | Hold |
| #6 | GOOGL | Hold |
| #7 | MSFT | Hold |
| #8 | META | Hold |
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.
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.
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.
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.
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.
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.