Skip to content
SlashClone
Made by@qtrader

Backtest runner

@qtrader/backtest-runner

Backtest a trading idea on an OHLCV CSV with honest assumptions: next-bar fills, slippage, commission, no look-ahead. Built-in SMA crossover, RSI mean reversion, and buy-and-hold, plus a one-file plug-in format for your own strategies. Writes equity curve and trades CSVs and metrics (CAGR, volatility, Sharpe, Sortino, max drawdown, win rate, exposure). Not financial advice.

SkillTradingv1.0.0 (latest)Tested
Activity
New: be the first to try it
  1. 1{
  2. 2 "name": "backtest-runner",
  3. 3 "owner": "qtrader",
  4. 4 "version": "1.0.0",
  5. 5 "type": "skill",
  6. 6 "description": "Backtest a trading idea on an OHLCV CSV with honest assumptions: next-bar fills, slippage, commission, no look-ahead. Built-in SMA crossover, RSI mean reversion, and buy-and-hold, plus a one-file plug-in format for your own strategies. Writes equity curve and trades CSVs and metrics (CAGR, volatility, Sharpe, Sortino, max drawdown, win rate, exposure). Not financial advice.",
  7. 7 "category": "trading",
  8. 8 "license": "MIT",
  9. 9 "compat": ["claude-code"],
  10. 10 "permissions": {
  11. 11 "shell": ["node scripts/backtest.mjs", "node scripts/selftest.mjs"],
  12. 12 "files": { "read": ["./data/**", "./strategies/**"], "write": ["./out/**", "./strategies/**"] }
  13. 13 },
  14. 14 "tests": {
  15. 15 "cases": [
  16. 16 {
  17. 17 "name": "engine and metrics match the hand-checked synthetic series",
  18. 18 "inputs": {},
  19. 19 "checks": [{ "type": "command_exits_zero", "command": "node scripts/selftest.mjs" }]
  20. 20 },
  21. 21 {
  22. 22 "name": "sma-cross on the example series writes all three outputs",
  23. 23 "inputs": {},
  24. 24 "checks": [
  25. 25 {
  26. 26 "type": "command_exits_zero",
  27. 27 "command": "node scripts/backtest.mjs --data examples/prices.csv --strategy sma-cross --param fast=10 --param slow=30 --out out/sma"
  28. 28 },
  29. 29 { "type": "file_contains", "path": "out/sma-equity.csv", "text": "date,close,position,cash,equity,drawdown" },
  30. 30 { "type": "file_contains", "path": "out/sma-trades.csv", "text": "id,side,entry_date,entry_price,exit_date,exit_price,qty,commission,pnl,return_pct,bars_held,status" },
  31. 31 {
  32. 32 "type": "output_matches_schema",
  33. 33 "path": "out/sma-metrics.json",
  34. 34 "schema": {
  35. 35 "type": "object",
  36. 36 "required": ["strategy", "params", "options", "metrics"],
  37. 37 "properties": {
  38. 38 "strategy": { "const": "sma-cross" },
  39. 39 "params": { "type": "object", "properties": { "fast": { "const": 10 }, "slow": { "const": 30 } } },
  40. 40 "metrics": {
  41. 41 "type": "object",
  42. 42 "required": ["total_return", "cagr", "volatility", "sharpe", "sortino", "max_drawdown", "win_rate", "exposure", "trades", "buy_hold_return"],
  43. 43 "properties": {
  44. 44 "bars": { "const": 320 },
  45. 45 "max_drawdown": { "type": "number", "maximum": 0, "minimum": -1 },
  46. 46 "exposure": { "type": "number", "minimum": 0, "maximum": 1 },
  47. 47 "trades": { "type": "integer", "minimum": 1 }
  48. 48 }
  49. 49 }
  50. 50 }
  51. 51 }
  52. 52 }
  53. 53 ]
  54. 54 },
  55. 55 {
  56. 56 "name": "plug-in strategy file loads and runs",
  57. 57 "inputs": {},
  58. 58 "checks": [
  59. 59 {
  60. 60 "type": "command_exits_zero",
  61. 61 "command": "node scripts/backtest.mjs --data examples/prices.csv --strategy-file examples/strategies/donchian-breakout.mjs --commission-per-share 0.005 --out out/donchian"
  62. 62 },
  63. 63 {
  64. 64 "type": "output_matches_schema",
  65. 65 "path": "out/donchian-metrics.json",
  66. 66 "schema": {
  67. 67 "type": "object",
  68. 68 "required": ["strategy", "metrics"],
  69. 69 "properties": { "strategy": { "const": "donchian-breakout" }, "metrics": { "type": "object", "properties": { "total_commission": { "type": "number", "minimum": 0.01 } } } }
  70. 70 }
  71. 71 }
  72. 72 ]
  73. 73 }
  74. 74 ]
  75. 75 }