Examples / Research
Golden cross backtest with stops
Level 3 · ResearchPOST/v1/backtest
What it answers
Buys SPY when the 50-day average crosses above the 200-day and sells on the opposite cross, with an 8% stop loss and a 15% trailing stop, fees and slippage included, since 2000.
Request
Input
POST /v1/backtest{ "symbol": "SPY", "entry": "cross_above(sma(50), sma(200))", "exit": "cross_below(sma(50), sma(200))", "start_date": "2000-01-01", "stop_loss": 0.08, "trailing_stop": 0.15, "fee_bps": 1, "slippage_bps": 2 }
Live output billed to your account
Response
Output 200 OK
{ "ok": true, "data": { "symbol": "SPY", "start": "2000-01-03", "end": "2026-11-12", "rules": { "entry": "cross_above(sma(50), sma(200))", "exit": "cross_below(sma(50), sma(200))", "side": "long", "initial_capital": 10000, "position_size": 1.0, "stop_loss": 0.08, "take_profit": null, "trailing_stop": 0.15, "max_bars": null, "cooldown_bars": 0, "fill": "next_open", "fee_bps": 1.0, "slippage_bps": 2.0 }, "stats": { "initial_capital": 10000.0, "final_equity": 83087.79, "net_profit": 73087.79, "total_return": 7.308779, "cagr": 0.081715, "max_drawdown": -0.20408, "sharpe": 0.753515, "sortino": 1.045296, "trades": 12, "win_rate": 0.75, "avg_trade_return": 0.18606, "median_trade_return": 0.157892, "avg_trade_pnl": 4758.09, "best_trade_return": 0.581233, "worst_trade_return": -0.08056, "avg_win": 6618.01, "avg_loss": -821.66, "profit_factor": 24.163251, "avg_bars_held": 365.8, "exposure": 0.701791, "total_fees": 66.93, "total_slippage": 133.85, "buy_hold_return": 7.303326, "buy_hold_max_drawdown": -0.551908 }, "trades": [ { "entry_date": "2002-04-22", "exit_date": "2002-05-17", "side": "long", "entry_price": 72.2515, "exit_price": 71.1215, "shares": 138.405428, "pnl": -158.38, "return": -0.015838, "fees": 1.98, "bars": 19, "exit_reason": "exit_rule" }, { "entry_date": "2003-05-13", "exit_date": "2004-08-26", "side": "long", "entry_price": 61.8247, "exit_price": 73.9619, "shares": 159.185929, "pnl": 1929.91, "return": 0.196097, "fees": 2.16, "bars": 325, "exit_reason": "exit_rule" }, { "entry_date": "2004-10-28", "exit_date": "2006-07-26", "side": "long", "entry_price": 75.5205, "exit_price": 87.6363, "shares": 155.871891, "pnl": 1885.96, "return": 0.160214, "fees": 2.54, "bars": 438, "exit_reason": "exit_rule" }, { "entry_date": "2006-08-30", "exit_date": "2007-12-31", "side": "long", "entry_price": 90.6335, "exit_price": 104.753, "shares": 150.689163, "pnl": 2124.7, "return": 0.15557, "fees": 2.94, "bars": 335, "exit_reason": "exit_rule" }, { "entry_date": "2009-06-19", "exit_date": "2010-06-30", "side": "long", "entry_price": 68.4126, "exit_price": 77.7739, "shares": 230.691174, "pnl": 2156.19, "return": 0.136622, "fees": 3.37, "bars": 259, "exit_reason": "trailing_stop" }, { "entry_date": "2010-10-14", "exit_date": "2011-08-08", "side": "long", "entry_price": 89.2128, "exit_price": 89.1079, "shares": 201.074067, "pnl": -24.69, "return": -0.001376, "fees": 3.59, "bars": 205, "exit_reason": "trailing_stop" }, { "entry_date": "2012-01-24", "exit_date": "2015-09-04", "side": "long", "entry_price": 101.6475, "exit_price": 160.7546, "shares": 176.2335, "pnl": 10412.02, "return": 0.581233, "fees": 4.62, "bars": 910, "exit_reason": "exit_rule" }, { "entry_date": "2015-12-10", "exit_date": "2016-01-14", "side": "long", "entry_price": 172.1973, "exit_price": 158.3581, "shares": 164.495762, "pnl": -2281.92, "return": -0.08056, "fees": 5.44, "bars": 23, "exit_reason": "stop_loss" }, { "entry_date": "2016-04-21", "exit_date": "2018-12-13", "side": "long", "entry_price": 178.1002, "exit_price": 237.0054, "shares": 146.231228, "pnl": 8607.72, "return": 0.330509, "fees": 6.07, "bars": 667, "exit_reason": "exit_rule" }, { "entry_date": "2019-03-27", "exit_date": "2020-02-28", "side": "long", "entry_price": 252.6525, "exit_price": 262.6778, "shares": 137.150958, "pnl": 1367.92, "return": 0.039477, "fees": 7.07, "bars": 233, "exit_reason": "trailing_stop" }, { "entry_date": "2020-07-07", "exit_date": "2022-03-17", "side": "long", "entry_price": 290.5116, "exit_price": 407.9002, "shares": 123.986251, "pnl": 14545.91, "return": 0.403835, "fees": 8.66, "bars": 428, "exit_reason": "exit_rule" }, { "entry_date": "2023-01-27", "exit_date": "2025-04-04", "side": "long", "entry_price": 386.0656, "exit_price": 512.3752, "shares": 130.976059, "pnl": 16531.76, "return": 0.326939, "fees": 11.77, "bars": 548, "exit_reason": "trailing_stop" } ], "trades_truncated": false, "open_trade": { "entry_date": "2025-06-30", "entry_price": 610.7373, "shares": 109.862493, "unrealized_pnl": 15990.67, "unrealized_return": 0.238421 }, "equity_curve": [ { "date": "2000-01-03", "equity": 10000.0, "drawdown": 0.0 }, { "date": "2000-01-26", "equity": 10000.0, "drawdown": 0.0 }, { "date": "2000-02-17", "equity": 10000.0, "drawdown": 0.0 }, { "date": "2000-03-13", "equity": 10000.0, "drawdown": 0.0 }, { "date": "2000-04-04", "equity": 10000.0, "drawdown": 0.0 }, "… 416 more items …", { "date": "2026-10-15", "equity": 84784.06, "drawdown": -0.009371 }, { "date": "2026-11-06", "equity": 80774.08, "drawdown": -0.056224 }, { "date": "2026-11-12", "equity": 83087.79, "drawdown": -0.02919 } ], "monthly_returns": [ { "year": 2026, "months": [ 0.014729, -0.008645, -0.049376, 0.105054, 0.052626, -0.010298, 0.000348, 0.024258, -0.003294, -0.009061, 0.000834, null ], "total": 0.115028 }, { "year": 2025, "months": [ 0.026867, -0.012693, -0.055722, -0.071276, 0.0, 0.000461, 0.023043, 0.020525, 0.035631, 0.02384, 0.001951, 0.000797 ], "total": -0.012584 }, { "year": 2024, "months": [ 0.015931, 0.052186, 0.032707, -0.04033, 0.050597, 0.035268, 0.012114, 0.023363, 0.021013, -0.00893, 0.059642, -0.024069 ], "total": 0.248872 }, { "year": 2023, "months": [ 0.006672, -0.025139, 0.037084, 0.015983, 0.004609, 0.064806, 0.032738, -0.016258, -0.047437, -0.02173, 0.091372, 0.045646 ], "total": 0.195034 }, { "year": 2022, "months": [ -0.052743, -0.029529, -0.007255, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], "total": -0.087385 }, "… 19 more items …", { "year": 2002, "months": [ 0.0, 0.0, 0.0, -0.040535, 0.02574, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], "total": -0.015838 }, { "year": 2001, "months": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], "total": 0.0 }, { "year": 2000, "months": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], "total": 0.0 } ], "notes": [ "Rules are evaluated on each bar's close; with fill=next_open orders fill at the next bar's open (no look-ahead). Daily prices are split- and dividend-adjusted.", "Trade prices include slippage; pnl is net of fees on both legs." ], "interval": "1day" }, "meta": { "op": "backtest", "units": 9, "cost_usd": 0.0, "billing": "internal", "free_call": false, "free_calls_left": 0, "balance_usd": 5.0, "ms": 27, "interval": "1day", "data_as_of": "2026-11-12", "partial_last_bar": false } }
How to read it
stats compares the strategy with buy-and-hold over the same dates: look at max_drawdown next to total_return, and at exposure (the share of time invested). trades lists every round trip with its exit_reason (signal, stop_loss, trailing_stop).
Parameters and limits: Backtest reference. Analytics, not advice.