Quant BuffetRelax, Not Over Thinking

Quant Buffet API

Templates

Pre-built make_* factories in backtest.templates.

`backtest.templates` provides reusable **make_*** functions that return (on_day, ready) — the same contract as your own make_on_day body. Import and delegate instead of rewriting common patterns.

Pattern

from backtest.templates import make_sma_trend

ASSETS = ["SPY", "QQQ", "IWM"]

def make_on_day(prices: pd.DataFrame):
    return make_sma_trend(prices, ASSETS, {"sma_days": 200})

Available factories

FunctionIdeaKey params
make_sma_trendLong assets above SMAsma_days (default 200)
make_dual_maFast MA > slow MAfast, slow
make_abs_momentumRank by trailing return, top Nlookback, top_n, cash_symbol
make_dual_momentumAbsolute + relative momentum filterlookback, top_n
make_momentum_rotationMonthly rotate into winnerslookback, top_n
make_equal_weightStatic equal weight rebalancerebalance cadence in params
make_mean_reversionBuy recent losers (z-score)lookback, entry_z
make_vol_targetScale exposure to vol targetlookback, target_vol
make_risk_parityInverse-vol weightslookback

Custom params

from backtest.templates import make_abs_momentum

ASSETS = ["SPY", "EFA", "EEM", "TLT", "GLD", "BIL"]

def make_on_day(prices: pd.DataFrame):
    return make_abs_momentum(
        prices,
        ASSETS,
        {"lookback": 126, "top_n": 3, "cash_symbol": "BIL"},
    )