Learn / backtest a strategy
Backtest a moving-average signal
A deterministic, synthetic 120-session series. Hold the asset when its close is above its moving average. Signals execute with a one-bar lag; this is a research demonstration, not evidence of an investable edge.
Try it
Sample dataA deterministic, synthetic 120-session series. Hold the asset when its close is above its moving average. Signals execute with a one-bar lag; this is a research demonstration, not evidence of an investable edge.
Moving-average strategyPortfolio equity · USD
Exact chart data
| Series | Observation index | Portfolio equity · USD |
|---|---|---|
| Moving-average strategy | 0 | 10000 |
| Moving-average strategy | 1 | 10000 |
| Moving-average strategy | 2 | 10000 |
| Moving-average strategy | 3 | 10000 |
| Moving-average strategy | 4 | 10000 |
| Moving-average strategy | 5 | 10000 |
| Moving-average strategy | 6 | 10000 |
| Moving-average strategy | 7 | 10000 |
| Moving-average strategy | 8 | 10000 |
| Moving-average strategy | 9 | 10000 |
| Moving-average strategy | 10 | 10000 |
| Moving-average strategy | 11 | 10000 |
| Moving-average strategy | 12 | 10000 |
| Moving-average strategy | 13 | 10000 |
| Moving-average strategy | 14 | 10000 |
| Moving-average strategy | 15 | 10000 |
| Moving-average strategy | 16 | 10000 |
| Moving-average strategy | 17 | 10000 |
| Moving-average strategy | 18 | 10000 |
| Moving-average strategy | 19 | 10000 |
| Moving-average strategy | 20 | 10000 |
| Moving-average strategy | 21 | 9990 |
| Moving-average strategy | 22 | 9900.772995179695 |
| Moving-average strategy | 23 | 9900.772995179695 |
| Moving-average strategy | 24 | 9900.772995179695 |
| Moving-average strategy | 25 | 9900.772995179695 |
| Moving-average strategy | 26 | 9900.772995179695 |
| Moving-average strategy | 27 | 9900.772995179695 |
| Moving-average strategy | 28 | 9900.772995179695 |
| Moving-average strategy | 29 | 9900.772995179695 |
| Moving-average strategy | 30 | 9900.772995179695 |
| Moving-average strategy | 31 | 9900.772995179695 |
| Moving-average strategy | 32 | 9900.772995179695 |
| Moving-average strategy | 33 | 9900.772995179695 |
| Moving-average strategy | 34 | 9900.772995179695 |
| Moving-average strategy | 35 | 9900.772995179695 |
| Moving-average strategy | 36 | 9900.772995179695 |
| Moving-average strategy | 37 | 9900.772995179695 |
| Moving-average strategy | 38 | 9900.772995179695 |
| Moving-average strategy | 39 | 9890.872222184516 |
| Moving-average strategy | 40 | 9938.239149290801 |
| Moving-average strategy | 41 | 9980.31723037804 |
| Moving-average strategy | 42 | 10018.433421320091 |
| Moving-average strategy | 43 | 10054.798321427646 |
| Moving-average strategy | 44 | 10092.187130617453 |
| Moving-average strategy | 45 | 10133.513734554232 |
| Moving-average strategy | 46 | 10181.38436860422 |
| Moving-average strategy | 47 | 10237.6825858876 |
| Moving-average strategy | 48 | 10303.233828965007 |
| Moving-average strategy | 49 | 10377.589140494503 |
| Moving-average strategy | 50 | 10458.954378544167 |
| Moving-average strategy | 51 | 10544.275178039465 |
| Moving-average strategy | 52 | 10629.470598278062 |
| Moving-average strategy | 53 | 10709.79182539692 |
| Moving-average strategy | 54 | 10780.268286500996 |
| Moving-average strategy | 55 | 10836.193626404267 |
| Moving-average strategy | 56 | 10873.599294843269 |
| Moving-average strategy | 57 | 10889.664515758654 |
| Moving-average strategy | 58 | 10883.018055033275 |
| Moving-average strategy | 59 | 10853.898744733393 |
| Moving-average strategy | 60 | 10804.156897381494 |
| Moving-average strategy | 61 | 10737.095890093875 |
| Moving-average strategy | 62 | 10657.170435501537 |
| Moving-average strategy | 63 | 10569.573493968748 |
| Moving-average strategy | 64 | 10469.275971439081 |
| Moving-average strategy | 65 | 10469.275971439081 |
| Moving-average strategy | 66 | 10469.275971439081 |
| Moving-average strategy | 67 | 10469.275971439081 |
| Moving-average strategy | 68 | 10469.275971439081 |
| Moving-average strategy | 69 | 10469.275971439081 |
| Moving-average strategy | 70 | 10469.275971439081 |
| Moving-average strategy | 71 | 10469.275971439081 |
| Moving-average strategy | 72 | 10469.275971439081 |
| Moving-average strategy | 73 | 10469.275971439081 |
| Moving-average strategy | 74 | 10469.275971439081 |
| Moving-average strategy | 75 | 10469.275971439081 |
| Moving-average strategy | 76 | 10469.275971439081 |
| Moving-average strategy | 77 | 10469.275971439081 |
| Moving-average strategy | 78 | 10469.275971439081 |
| Moving-average strategy | 79 | 10469.275971439081 |
| Moving-average strategy | 80 | 10469.275971439081 |
| Moving-average strategy | 81 | 10469.275971439081 |
| Moving-average strategy | 82 | 10469.275971439081 |
| Moving-average strategy | 83 | 10469.275971439081 |
| Moving-average strategy | 84 | 10469.275971439081 |
| Moving-average strategy | 85 | 10469.275971439081 |
| Moving-average strategy | 86 | 10458.806695467641 |
| Moving-average strategy | 87 | 10543.62305299288 |
| Moving-average strategy | 88 | 10643.545097879116 |
| Moving-average strategy | 89 | 10754.86190574017 |
| Moving-average strategy | 90 | 10872.661438088915 |
| Moving-average strategy | 91 | 10991.31324188103 |
| Moving-average strategy | 92 | 11104.957001932476 |
| Moving-average strategy | 93 | 11208.01908173412 |
| Moving-average strategy | 94 | 11295.702896510797 |
| Moving-average strategy | 95 | 11364.401645416576 |
| Moving-average strategy | 96 | 11411.990315952553 |
| Moving-average strategy | 97 | 11437.966955297972 |
| Moving-average strategy | 98 | 11443.429544411925 |
| Moving-average strategy | 99 | 11430.892617699148 |
| Moving-average strategy | 100 | 11403.965089370087 |
| Moving-average strategy | 101 | 11366.925677444342 |
| Moving-average strategy | 102 | 11324.243221199982 |
| Moving-average strategy | 103 | 11280.094874788883 |
| Moving-average strategy | 104 | 11237.935010401636 |
| Moving-average strategy | 105 | 11200.161703020965 |
| Moving-average strategy | 106 | 11167.916559430996 |
| Moving-average strategy | 107 | 11129.897588578056 |
| Moving-average strategy | 108 | 11129.897588578056 |
| Moving-average strategy | 109 | 11129.897588578056 |
| Moving-average strategy | 110 | 11129.897588578056 |
| Moving-average strategy | 111 | 11129.897588578056 |
| Moving-average strategy | 112 | 11129.897588578056 |
| Moving-average strategy | 113 | 11129.897588578056 |
| Moving-average strategy | 114 | 11129.897588578056 |
| Moving-average strategy | 115 | 11129.897588578056 |
| Moving-average strategy | 116 | 11129.897588578056 |
| Moving-average strategy | 117 | 11129.897588578056 |
| Moving-average strategy | 118 | 11129.897588578056 |
| Moving-average strategy | 119 | 11129.897588578056 |
| Moving-average strategy | 120 | 11129.897588578056 |
Drawdown (positive = below peak)Drawdown · decimal fraction
Exact chart data
| Series | Observation index | Drawdown · decimal fraction |
|---|---|---|
| Drawdown (positive = below peak) | 0 | 0 |
| Drawdown (positive = below peak) | 1 | 0 |
| Drawdown (positive = below peak) | 2 | 0 |
| Drawdown (positive = below peak) | 3 | 0 |
| Drawdown (positive = below peak) | 4 | 0 |
| Drawdown (positive = below peak) | 5 | 0 |
| Drawdown (positive = below peak) | 6 | 0 |
| Drawdown (positive = below peak) | 7 | 0 |
| Drawdown (positive = below peak) | 8 | 0 |
| Drawdown (positive = below peak) | 9 | 0 |
| Drawdown (positive = below peak) | 10 | 0 |
| Drawdown (positive = below peak) | 11 | 0 |
| Drawdown (positive = below peak) | 12 | 0 |
| Drawdown (positive = below peak) | 13 | 0 |
| Drawdown (positive = below peak) | 14 | 0 |
| Drawdown (positive = below peak) | 15 | 0 |
| Drawdown (positive = below peak) | 16 | 0 |
| Drawdown (positive = below peak) | 17 | 0 |
| Drawdown (positive = below peak) | 18 | 0 |
| Drawdown (positive = below peak) | 19 | 0 |
| Drawdown (positive = below peak) | 20 | 0 |
| Drawdown (positive = below peak) | 21 | 0.001 |
| Drawdown (positive = below peak) | 22 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 23 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 24 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 25 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 26 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 27 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 28 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 29 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 30 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 31 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 32 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 33 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 34 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 35 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 36 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 37 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 38 | 0.00992270048203045 |
| Drawdown (positive = below peak) | 39 | 0.010912777781548358 |
| Drawdown (positive = below peak) | 40 | 0.0061760850709199075 |
| Drawdown (positive = below peak) | 41 | 0.0019682769621960686 |
| Drawdown (positive = below peak) | 42 | 0 |
| Drawdown (positive = below peak) | 43 | 0 |
| Drawdown (positive = below peak) | 44 | 0 |
| Drawdown (positive = below peak) | 45 | 0 |
| Drawdown (positive = below peak) | 46 | 0 |
| Drawdown (positive = below peak) | 47 | 0 |
| Drawdown (positive = below peak) | 48 | 0 |
| Drawdown (positive = below peak) | 49 | 0 |
| Drawdown (positive = below peak) | 50 | 0 |
| Drawdown (positive = below peak) | 51 | 0 |
| Drawdown (positive = below peak) | 52 | 0 |
| Drawdown (positive = below peak) | 53 | 0 |
| Drawdown (positive = below peak) | 54 | 0 |
| Drawdown (positive = below peak) | 55 | 0 |
| Drawdown (positive = below peak) | 56 | 0 |
| Drawdown (positive = below peak) | 57 | 0 |
| Drawdown (positive = below peak) | 58 | 0.0006103457747261285 |
| Drawdown (positive = below peak) | 59 | 0.003284377675134367 |
| Drawdown (positive = below peak) | 60 | 0.007852181144186766 |
| Drawdown (positive = below peak) | 61 | 0.014010406421978705 |
| Drawdown (positive = below peak) | 62 | 0.021349976385468025 |
| Drawdown (positive = below peak) | 63 | 0.029394020479390826 |
| Drawdown (positive = below peak) | 64 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 65 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 66 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 67 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 68 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 69 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 70 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 71 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 72 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 73 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 74 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 75 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 76 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 77 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 78 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 79 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 80 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 81 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 82 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 83 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 84 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 85 | 0.03860436138424829 |
| Drawdown (positive = below peak) | 86 | 0.03956575702286411 |
| Drawdown (positive = below peak) | 87 | 0.03177705449649162 |
| Drawdown (positive = below peak) | 88 | 0.022601193776298 |
| Drawdown (positive = below peak) | 89 | 0.012378949766855335 |
| Drawdown (positive = below peak) | 90 | 0.0015613959130819008 |
| Drawdown (positive = below peak) | 91 | 0 |
| Drawdown (positive = below peak) | 92 | 0 |
| Drawdown (positive = below peak) | 93 | 0 |
| Drawdown (positive = below peak) | 94 | 0 |
| Drawdown (positive = below peak) | 95 | 0 |
| Drawdown (positive = below peak) | 96 | 0 |
| Drawdown (positive = below peak) | 97 | 0 |
| Drawdown (positive = below peak) | 98 | 0 |
| Drawdown (positive = below peak) | 99 | 0.0010955567702952463 |
| Drawdown (positive = below peak) | 100 | 0.003448656269405642 |
| Drawdown (positive = below peak) | 101 | 0.006685396774688208 |
| Drawdown (positive = below peak) | 102 | 0.01041526255301186 |
| Drawdown (positive = below peak) | 103 | 0.01427322718151411 |
| Drawdown (positive = below peak) | 104 | 0.01795742554386914 |
| Drawdown (positive = below peak) | 105 | 0.021258298523780642 |
| Drawdown (positive = below peak) | 106 | 0.024076085225295776 |
| Drawdown (positive = below peak) | 107 | 0.027398425849265898 |
| Drawdown (positive = below peak) | 108 | 0.027398425849265898 |
| Drawdown (positive = below peak) | 109 | 0.027398425849265898 |
| Drawdown (positive = below peak) | 110 | 0.027398425849265898 |
| Drawdown (positive = below peak) | 111 | 0.027398425849265898 |
| Drawdown (positive = below peak) | 112 | 0.027398425849265898 |
| Drawdown (positive = below peak) | 113 | 0.027398425849265898 |
| Drawdown (positive = below peak) | 114 | 0.027398425849265898 |
| Drawdown (positive = below peak) | 115 | 0.027398425849265898 |
| Drawdown (positive = below peak) | 116 | 0.027398425849265898 |
| Drawdown (positive = below peak) | 117 | 0.027398425849265898 |
| Drawdown (positive = below peak) | 118 | 0.027398425849265898 |
| Drawdown (positive = below peak) | 119 | 0.027398425849265898 |
| Drawdown (positive = below peak) | 120 | 0.027398425849265898 |
Assumptions & conventions
{
"conventionsVersion": "0.0.1",
"initialCapital": 10000,
"fill": "close",
"cost": "bps(10)",
"slippage": "none",
"cashSettlement": "immediate",
"corporateAction": "none",
"calendar": "everyBar",
"margin": "maxLeverage"
}Diagnostics & warnings
{
"warnings": [],
"benchmarkFixtureVersion": "0.0.1",
"sampleNotice": "Synthetic observations; 252 periods/year is an explicit annualization assumption, not a real trading-calendar dataset."
}Full result · JSON
{
"backtest": {
"points": [
{
"timestampMs": 1767225600000,
"equity": 10000
},
{
"timestampMs": 1767225600000,
"equity": 10000
},
{
"timestampMs": 1767312000000,
"equity": 10000
},
{
"timestampMs": 1767398400000,
"equity": 10000
},
{
"timestampMs": 1767484800000,
"equity": 10000
},
{
"timestampMs": 1767571200000,
"equity": 10000
},
{
"timestampMs": 1767657600000,
"equity": 10000
},
{
"timestampMs": 1767744000000,
"equity": 10000
},
{
"timestampMs": 1767830400000,
"equity": 10000
},
{
"timestampMs": 1767916800000,
"equity": 10000
},
{
"timestampMs": 1768003200000,
"equity": 10000
},
{
"timestampMs": 1768089600000,
"equity": 10000
},
{
"timestampMs": 1768176000000,
"equity": 10000
},
{
"timestampMs": 1768262400000,
"equity": 10000
},
{
"timestampMs": 1768348800000,
"equity": 10000
},
{
"timestampMs": 1768435200000,
"equity": 10000
},
{
"timestampMs": 1768521600000,
"equity": 10000
},
{
"timestampMs": 1768608000000,
"equity": 10000
},
{
"timestampMs": 1768694400000,
"equity": 10000
},
{
"timestampMs": 1768780800000,
"equity": 10000
},
{
"timestampMs": 1768867200000,
"equity": 10000
},
{
"timestampMs": 1768953600000,
"equity": 9990
},
{
"timestampMs": 1769040000000,
"equity": 9900.772995179695
},
{
"timestampMs": 1769126400000,
"equity": 9900.772995179695
},
{
"timestampMs": 1769212800000,
"equity": 9900.772995179695
},
{
"timestampMs": 1769299200000,
"equity": 9900.772995179695
},
{
"timestampMs": 1769385600000,
"equity": 9900.772995179695
},
{
"timestampMs": 1769472000000,
"equity": 9900.772995179695
},
{
"timestampMs": 1769558400000,
"equity": 9900.772995179695
},
{
"timestampMs": 1769644800000,
"equity": 9900.772995179695
},
{
"timestampMs": 1769731200000,
"equity": 9900.772995179695
},
{
"timestampMs": 1769817600000,
"equity": 9900.772995179695
},
{
"timestampMs": 1769904000000,
"equity": 9900.772995179695
},
{
"timestampMs": 1769990400000,
"equity": 9900.772995179695
},
{
"timestampMs": 1770076800000,
"equity": 9900.772995179695
},
{
"timestampMs": 1770163200000,
"equity": 9900.772995179695
},
{
"timestampMs": 1770249600000,
"equity": 9900.772995179695
},
{
"timestampMs": 1770336000000,
"equity": 9900.772995179695
},
{
"timestampMs": 1770422400000,
"equity": 9900.772995179695
},
{
"timestampMs": 1770508800000,
"equity": 9890.872222184516
},
{
"timestampMs": 1770595200000,
"equity": 9938.239149290801
},
{
"timestampMs": 1770681600000,
"equity": 9980.31723037804
},
{
"timestampMs": 1770768000000,
"equity": 10018.433421320091
},
{
"timestampMs": 1770854400000,
"equity": 10054.798321427646
},
{
"timestampMs": 1770940800000,
"equity": 10092.187130617453
},
{
"timestampMs": 1771027200000,
"equity": 10133.513734554232
},
{
"timestampMs": 1771113600000,
"equity": 10181.38436860422
},
{
"timestampMs": 1771200000000,
"equity": 10237.6825858876
},
{
"timestampMs": 1771286400000,
"equity": 10303.233828965007
},
{
"timestampMs": 1771372800000,
"equity": 10377.589140494503
},
{
"timestampMs": 1771459200000,
"equity": 10458.954378544167
},
{
"timestampMs": 1771545600000,
"equity": 10544.275178039465
},
{
"timestampMs": 1771632000000,
"equity": 10629.470598278062
},
{
"timestampMs": 1771718400000,
"equity": 10709.79182539692
},
{
"timestampMs": 1771804800000,
"equity": 10780.268286500996
},
{
"timestampMs": 1771891200000,
"equity": 10836.193626404267
},
{
"timestampMs": 1771977600000,
"equity": 10873.599294843269
},
{
"timestampMs": 1772064000000,
"equity": 10889.664515758654
},
{
"timestampMs": 1772150400000,
"equity": 10883.018055033275
},
{
"timestampMs": 1772236800000,
"equity": 10853.898744733393
},
{
"timestampMs": 1772323200000,
"equity": 10804.156897381494
},
{
"timestampMs": 1772409600000,
"equity": 10737.095890093875
},
{
"timestampMs": 1772496000000,
"equity": 10657.170435501537
},
{
"timestampMs": 1772582400000,
"equity": 10569.573493968748
},
{
"timestampMs": 1772668800000,
"equity": 10469.275971439081
},
{
"timestampMs": 1772755200000,
"equity": 10469.275971439081
},
{
"timestampMs": 1772841600000,
"equity": 10469.275971439081
},
{
"timestampMs": 1772928000000,
"equity": 10469.275971439081
},
{
"timestampMs": 1773014400000,
"equity": 10469.275971439081
},
{
"timestampMs": 1773100800000,
"equity": 10469.275971439081
},
{
"timestampMs": 1773187200000,
"equity": 10469.275971439081
},
{
"timestampMs": 1773273600000,
"equity": 10469.275971439081
},
{
"timestampMs": 1773360000000,
"equity": 10469.275971439081
},
{
"timestampMs": 1773446400000,
"equity": 10469.275971439081
},
{
"timestampMs": 1773532800000,
"equity": 10469.275971439081
},
{
"timestampMs": 1773619200000,
"equity": 10469.275971439081
},
{
"timestampMs": 1773705600000,
"equity": 10469.275971439081
},
{
"timestampMs": 1773792000000,
"equity": 10469.275971439081
},
{
"timestampMs": 1773878400000,
"equity": 10469.275971439081
},
{
"timestampMs": 1773964800000,
"equity": 10469.275971439081
},
{
"timestampMs": 1774051200000,
"equity": 10469.275971439081
},
{
"timestampMs": 1774137600000,
"equity": 10469.275971439081
},
{
"timestampMs": 1774224000000,
"equity": 10469.275971439081
},
{
"timestampMs": 1774310400000,
"equity": 10469.275971439081
},
{
"timestampMs": 1774396800000,
"equity": 10469.275971439081
},
{
"timestampMs": 1774483200000,
"equity": 10469.275971439081
},
{
"timestampMs": 1774569600000,
"equity": 10458.806695467641
},
{
"timestampMs": 1774656000000,
"equity": 10543.62305299288
},
{
"timestampMs": 1774742400000,
"equity": 10643.545097879116
},
{
"timestampMs": 1774828800000,
"equity": 10754.86190574017
},
{
"timestampMs": 1774915200000,
"equity": 10872.661438088915
},
{
"timestampMs": 1775001600000,
"equity": 10991.31324188103
},
{
"timestampMs": 1775088000000,
"equity": 11104.957001932476
},
{
"timestampMs": 1775174400000,
"equity": 11208.01908173412
},
{
"timestampMs": 1775260800000,
"equity": 11295.702896510797
},
{
"timestampMs": 1775347200000,
"equity": 11364.401645416576
},
{
"timestampMs": 1775433600000,
"equity": 11411.990315952553
},
{
"timestampMs": 1775520000000,
"equity": 11437.966955297972
},
{
"timestampMs": 1775606400000,
"equity": 11443.429544411925
},
{
"timestampMs": 1775692800000,
"equity": 11430.892617699148
},
{
"timestampMs": 1775779200000,
"equity": 11403.965089370087
},
{
"timestampMs": 1775865600000,
"equity": 11366.925677444342
},
{
"timestampMs": 1775952000000,
"equity": 11324.243221199982
},
{
"timestampMs": 1776038400000,
"equity": 11280.094874788883
},
{
"timestampMs": 1776124800000,
"equity": 11237.935010401636
},
{
"timestampMs": 1776211200000,
"equity": 11200.161703020965
},
{
"timestampMs": 1776297600000,
"equity": 11167.916559430996
},
{
"timestampMs": 1776384000000,
"equity": 11129.897588578056
},
{
"timestampMs": 1776470400000,
"equity": 11129.897588578056
},
{
"timestampMs": 1776556800000,
"equity": 11129.897588578056
},
{
"timestampMs": 1776643200000,
"equity": 11129.897588578056
},
{
"timestampMs": 1776729600000,
"equity": 11129.897588578056
},
{
"timestampMs": 1776816000000,
"equity": 11129.897588578056
},
{
"timestampMs": 1776902400000,
"equity": 11129.897588578056
},
{
"timestampMs": 1776988800000,
"equity": 11129.897588578056
},
{
"timestampMs": 1777075200000,
"equity": 11129.897588578056
},
{
"timestampMs": 1777161600000,
"equity": 11129.897588578056
},
{
"timestampMs": 1777248000000,
"equity": 11129.897588578056
},
{
"timestampMs": 1777334400000,
"equity": 11129.897588578056
},
{
"timestampMs": 1777420800000,
"equity": 11129.897588578056
},
{
"timestampMs": 1777507200000,
"equity": 11129.897588578056
}
],
"returns": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
-0.0010000000000000009,
-0.008931632114144605,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
-0.0009999999999998899,
0.004788953495935777,
0.004233957389749632,
0.0038191362120267858,
0.0036297990492373255,
0.0037185041404685926,
0.0040949105879539704,
0.004723991628565516,
0.0055295247920297275,
0.00640293763041333,
0.00721669650168133,
0.00784047594755588,
0.008157679669234197,
0.008079779671914533,
0.0075564654303545975,
0.006580563119532368,
0.005187750287560133,
0.0034519195326905283,
0.001477451989885692,
-0.0006103457747260732,
-0.0026756649812240685,
-0.004582855296677124,
-0.006206963479387428,
-0.007443861488289127,
-0.008219530884200132,
-0.009489268662250083,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
-0.001000000000000112,
0.008109563547244347,
0.009477012255087347,
0.010458621336911111,
0.010953142251493908,
0.01091285739629999,
0.010339416005215929,
0.00928072749707276,
0.007823310625833635,
0.006081848074014129,
0.0041875209994157725,
0.002276258446268331,
0.0004775839216271116,
-0.0010955567702952695,
-0.002355680280590411,
-0.003247941539234467,
-0.0037549692375534738,
-0.0038985692508307634,
-0.003737545194010261,
-0.0033612320542615315,
-0.002878989111493979,
-0.003404302910987811,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"trades": [
{
"symbol": "SAMPLE",
"timestampMs": 1768953600000,
"side": "buy",
"quantity": 96.0467279706395,
"price": 104.11598824123294,
"commission": 10,
"slippage": 0,
"multiplier": 1
},
{
"symbol": "SAMPLE",
"timestampMs": 1769040000000,
"side": "sell",
"quantity": 96.0467279706395,
"price": 103.2902827455113,
"commission": 9.920693688868562,
"slippage": 0,
"multiplier": 1
},
{
"symbol": "SAMPLE",
"timestampMs": 1770508800000,
"side": "buy",
"quantity": 98.5520429661631,
"price": 100.46238207947684,
"commission": 9.900772995179695,
"slippage": 0,
"multiplier": 1
},
{
"symbol": "SAMPLE",
"timestampMs": 1770595200000,
"side": "sell",
"quantity": 0.09808270110261219,
"price": 100.94311110805259,
"commission": 0.009900772995178895,
"slippage": 0,
"multiplier": 1
},
{
"symbol": "SAMPLE",
"timestampMs": 1770681600000,
"side": "sell",
"quantity": 0.0000976691742806679,
"price": 101.37049961405812,
"commission": 0.000009900772993723821,
"slippage": 0,
"multiplier": 1
},
{
"symbol": "SAMPLE",
"timestampMs": 1772668800000,
"side": "sell",
"quantity": 98.4538625958862,
"price": 106.44331731393967,
"commission": 10.479755737076932,
"slippage": 0,
"multiplier": 1
},
{
"symbol": "SAMPLE",
"timestampMs": 1774569600000,
"side": "buy",
"quantity": 101.10626007113875,
"price": 103.5472577471747,
"commission": 10.469275971439082,
"slippage": 0,
"multiplier": 1
},
{
"symbol": "SAMPLE",
"timestampMs": 1774656000000,
"side": "sell",
"quantity": 0.10029363550459891,
"price": 104.38624463820919,
"commission": 0.010469275971438447,
"slippage": 0,
"multiplier": 1
},
{
"symbol": "SAMPLE",
"timestampMs": 1774742400000,
"side": "sell",
"quantity": 0.00009935207550881842,
"price": 105.37551347926511,
"commission": 0.00001046927597197246,
"slippage": 0,
"multiplier": 1
},
{
"symbol": "SAMPLE",
"timestampMs": 1776384000000,
"side": "sell",
"quantity": 101.00586708355864,
"price": 110.30090587181856,
"commission": 11.14103863768502,
"slippage": 0,
"multiplier": 1
}
],
"finalValue": 11129.897588578056,
"turnover": 5.899100116219262,
"performance": {
"periods": 120,
"totalReturn": 0.11298975885780571,
"annualizedReturn": 0.2520781975286486,
"annualizedVolatility": 0.060972337960084964,
"sharpe": 3.7188051735031453,
"sortino": 7.338619005838668,
"calmar": 6.371120294323683,
"maxDrawdown": 0.03956575702286411,
"drawdown": {
"maxDrawdown": 0.03956575702286411,
"peakIndex": 57,
"troughIndex": 86,
"longestDurationPeriods": 33,
"recoveryIndex": 91
},
"omega": 2.368573102249796,
"hitRate": 0.6,
"profitFactor": 2.368573102249796,
"expectancy": 0.0008997787533593099,
"warnings": [],
"assumptions": {
"periodsPerYear": 252,
"riskFreeRate": 0
}
},
"assumptions": {
"conventionsVersion": "0.0.1",
"initialCapital": 10000,
"fill": "close",
"cost": "bps(10)",
"slippage": "none",
"cashSettlement": "immediate",
"corporateAction": "none",
"calendar": "everyBar",
"margin": "maxLeverage"
},
"diagnostics": {
"warnings": [],
"benchmarkFixtureVersion": "0.0.1"
}
},
"drawdowns": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0.001,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.00992270048203045,
0.010912777781548358,
0.0061760850709199075,
0.0019682769621960686,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0.0006103457747261285,
0.003284377675134367,
0.007852181144186766,
0.014010406421978705,
0.021349976385468025,
0.029394020479390826,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03860436138424829,
0.03956575702286411,
0.03177705449649162,
0.022601193776298,
0.012378949766855335,
0.0015613959130819008,
0,
0,
0,
0,
0,
0,
0,
0,
0.0010955567702952463,
0.003448656269405642,
0.006685396774688208,
0.01041526255301186,
0.01427322718151411,
0.01795742554386914,
0.021258298523780642,
0.024076085225295776,
0.027398425849265898,
0.027398425849265898,
0.027398425849265898,
0.027398425849265898,
0.027398425849265898,
0.027398425849265898,
0.027398425849265898,
0.027398425849265898,
0.027398425849265898,
0.027398425849265898,
0.027398425849265898,
0.027398425849265898,
0.027398425849265898,
0.027398425849265898
]
}Use it in your project
vectorized returns a backtest report with points, returns, trades, performance, assumptions and diagnostics. This example prints selected summary fields. The moving average returns an ordinary number array; warmup NaN values are deliberately excluded from signals.
Sample inputs
120 synthetic observations, not historical market data. Preview: the first three bars. Expand for the complete literal dataset and imports; Copy setup + call includes all of it. The 252-period annualization is a stated assumption, not a trading calendar.
[
{
"symbol": "SAMPLE",
"timestampMs": 1767225600000,
"open": 101.2,
"high": 101.2,
"low": 101.2,
"close": 101.2
},
{
"symbol": "SAMPLE",
"timestampMs": 1767312000000,
"open": 101.92580698453901,
"high": 101.92580698453901,
"low": 101.92580698453901,
"close": 101.92580698453901
},
{
"symbol": "SAMPLE",
"timestampMs": 1767398400000,
"open": 102.51227897354339,
"high": 102.51227897354339,
"low": 102.51227897354339,
"close": 102.51227897354339
}
]Complete sample setup · included when copying
import { vectorized, fees } from '@insiderfinance/totalfinance/backtest';
import { sma } from '@insiderfinance/totalfinance/technical-analysis';
// Synthetic sample data, not market history.
const data = [
{"symbol":"SAMPLE","timestampMs":1767225600000,"open":101.2,"high":101.2,"low":101.2,"close":101.2},
{"symbol":"SAMPLE","timestampMs":1767312000000,"open":101.92580698453901,"high":101.92580698453901,"low":101.92580698453901,"close":101.92580698453901},
{"symbol":"SAMPLE","timestampMs":1767398400000,"open":102.51227897354339,"high":102.51227897354339,"low":102.51227897354339,"close":102.51227897354339},
{"symbol":"SAMPLE","timestampMs":1767484800000,"open":102.96622204200703,"high":102.96622204200703,"low":102.96622204200703,"close":102.96622204200703},
{"symbol":"SAMPLE","timestampMs":1767571200000,"open":103.30645615475774,"high":103.30645615475774,"low":103.30645615475774,"close":103.30645615475774},
{"symbol":"SAMPLE","timestampMs":1767657600000,"open":103.56052122827535,"high":103.56052122827535,"low":103.56052122827535,"close":103.56052122827535},
{"symbol":"SAMPLE","timestampMs":1767744000000,"open":103.7605006218771,"high":103.7605006218771,"low":103.7605006218771,"close":103.7605006218771},
{"symbol":"SAMPLE","timestampMs":1767830400000,"open":103.93844515633963,"high":103.93844515633963,"low":103.93844515633963,"close":103.93844515633963},
{"symbol":"SAMPLE","timestampMs":1767916800000,"open":104.12192268284997,"high":104.12192268284997,"low":104.12192268284997,"close":104.12192268284997},
{"symbol":"SAMPLE","timestampMs":1768003200000,"open":104.33020191891289,"high":104.33020191891289,"low":104.33020191891289,"close":104.33020191891289},
{"symbol":"SAMPLE","timestampMs":1768089600000,"open":104.57150657620733,"high":104.57150657620733,"low":104.57150657620733,"close":104.57150657620733},
{"symbol":"SAMPLE","timestampMs":1768176000000,"open":104.84165478914336,"high":104.84165478914336,"low":104.84165478914336,"close":104.84165478914336},
{"symbol":"SAMPLE","timestampMs":1768262400000,"open":105.12424289926277,"high":105.12424289926277,"low":105.12424289926277,"close":105.12424289926277},
{"symbol":"SAMPLE","timestampMs":1768348800000,"open":105.39235899828917,"high":105.39235899828917,"low":105.39235899828917,"close":105.39235899828917},
{"symbol":"SAMPLE","timestampMs":1768435200000,"open":105.61163947244212,"high":105.61163947244212,"low":105.61163947244212,"close":105.61163947244212},
{"symbol":"SAMPLE","timestampMs":1768521600000,"open":105.74433015153213,"high":105.74433015153213,"low":105.74433015153213,"close":105.74433015153213},
{"symbol":"SAMPLE","timestampMs":1768608000000,"open":105.7538993189893,"high":105.7538993189893,"low":105.7538993189893,"close":105.7538993189893},
{"symbol":"SAMPLE","timestampMs":1768694400000,"open":105.60968544789529,"high":105.60968544789529,"low":105.60968544789529,"close":105.60968544789529},
{"symbol":"SAMPLE","timestampMs":1768780800000,"open":105.29105525598366,"high":105.29105525598366,"low":105.29105525598366,"close":105.29105525598366},
{"symbol":"SAMPLE","timestampMs":1768867200000,"open":104.79059839027981,"high":104.79059839027981,"low":104.79059839027981,"close":104.79059839027981},
{"symbol":"SAMPLE","timestampMs":1768953600000,"open":104.11598824123294,"high":104.11598824123294,"low":104.11598824123294,"close":104.11598824123294},
{"symbol":"SAMPLE","timestampMs":1769040000000,"open":103.2902827455113,"high":103.2902827455113,"low":103.2902827455113,"close":103.2902827455113},
{"symbol":"SAMPLE","timestampMs":1769126400000,"open":102.35060872468866,"high":102.35060872468866,"low":102.35060872468866,"close":102.35060872468866},
{"symbol":"SAMPLE","timestampMs":1769212800000,"open":101.3453496852592,"high":101.3453496852592,"low":101.3453496852592,"close":101.3453496852592},
{"symbol":"SAMPLE","timestampMs":1769299200000,"open":100.33012068901839,"high":100.33012068901839,"low":100.33012068901839,"close":100.33012068901839},
{"symbol":"SAMPLE","timestampMs":1769385600000,"open":99.36294689423667,"high":99.36294689423667,"low":99.36294689423667,"close":99.36294689423667},
{"symbol":"SAMPLE","timestampMs":1769472000000,"open":98.49915003763171,"high":98.49915003763171,"low":98.49915003763171,"close":98.49915003763171},
{"symbol":"SAMPLE","timestampMs":1769558400000,"open":97.78647982361417,"high":97.78647982361417,"low":97.78647982361417,"close":97.78647982361417},
{"symbol":"SAMPLE","timestampMs":1769644800000,"open":97.26100130011444,"high":97.26100130011444,"low":97.26100130011444,"close":97.26100130011444},
{"symbol":"SAMPLE","timestampMs":1769731200000,"open":96.9441676574348,"high":96.9441676574348,"low":96.9441676574348,"close":96.9441676574348},
{"symbol":"SAMPLE","timestampMs":1769817600000,"open":96.84137944355435,"high":96.84137944355435,"low":96.84137944355435,"close":96.84137944355435},
{"symbol":"SAMPLE","timestampMs":1769904000000,"open":96.94217004405276,"high":96.94217004405276,"low":96.94217004405276,"close":96.94217004405276},
{"symbol":"SAMPLE","timestampMs":1769990400000,"open":97.22198111647037,"high":97.22198111647037,"low":97.22198111647037,"close":97.22198111647037},
{"symbol":"SAMPLE","timestampMs":1770076800000,"open":97.64531983158169,"high":97.64531983158169,"low":97.64531983158169,"close":97.64531983158169},
{"symbol":"SAMPLE","timestampMs":1770163200000,"open":98.16994110955119,"high":98.16994110955119,"low":98.16994110955119,"close":98.16994110955119},
{"symbol":"SAMPLE","timestampMs":1770249600000,"open":98.75158884280263,"high":98.75158884280263,"low":98.75158884280263,"close":98.75158884280263},
{"symbol":"SAMPLE","timestampMs":1770336000000,"open":99.34877231645562,"high":99.34877231645562,"low":99.34877231645562,"close":99.34877231645562},
{"symbol":"SAMPLE","timestampMs":1770422400000,"open":99.92705395573014,"high":99.92705395573014,"low":99.92705395573014,"close":99.92705395573014},
{"symbol":"SAMPLE","timestampMs":1770508800000,"open":100.46238207947684,"high":100.46238207947684,"low":100.46238207947684,"close":100.46238207947684},
{"symbol":"SAMPLE","timestampMs":1770595200000,"open":100.94311110805259,"high":100.94311110805259,"low":100.94311110805259,"close":100.94311110805259},
{"symbol":"SAMPLE","timestampMs":1770681600000,"open":101.37049961405812,"high":101.37049961405812,"low":101.37049961405812,"close":101.37049961405812},
{"symbol":"SAMPLE","timestampMs":1770768000000,"open":101.75764735958134,"high":101.75764735958134,"low":101.75764735958134,"close":101.75764735958134},
{"symbol":"SAMPLE","timestampMs":1770854400000,"open":102.12700717085477,"high":102.12700717085477,"low":102.12700717085477,"close":102.12700717085477},
{"symbol":"SAMPLE","timestampMs":1770940800000,"open":102.50676686949932,"high":102.50676686949932,"low":102.50676686949932,"close":102.50676686949932},
{"symbol":"SAMPLE","timestampMs":1771027200000,"open":102.92652291407838,"high":102.92652291407838,"low":102.92652291407838,"close":102.92652291407838},
{"symbol":"SAMPLE","timestampMs":1771113600000,"open":103.4127469462068,"high":103.4127469462068,"low":103.4127469462068,"close":103.4127469462068},
{"symbol":"SAMPLE","timestampMs":1771200000000,"open":103.98457029370167,"high":103.98457029370167,"low":103.98457029370167,"close":103.98457029370167},
{"symbol":"SAMPLE","timestampMs":1771286400000,"open":104.65037701117367,"high":104.65037701117367,"low":104.65037701117367,"close":104.65037701117367},
{"symbol":"SAMPLE","timestampMs":1771372800000,"open":105.40560702012411,"high":105.40560702012411,"low":105.40560702012411,"close":105.40560702012411},
{"symbol":"SAMPLE","timestampMs":1771459200000,"open":106.23203714591445,"high":106.23203714591445,"low":106.23203714591445,"close":106.23203714591445},
{"symbol":"SAMPLE","timestampMs":1771545600000,"open":107.09864407474065,"high":107.09864407474065,"low":107.09864407474065,"close":107.09864407474065},
{"symbol":"SAMPLE","timestampMs":1771632000000,"open":107.96397752121284,"high":107.96397752121284,"low":107.96397752121284,"close":107.96397752121284},
{"symbol":"SAMPLE","timestampMs":1771718400000,"open":108.77980358431556,"high":108.77980358431556,"low":108.77980358431556,"close":108.77980358431556},
{"symbol":"SAMPLE","timestampMs":1771804800000,"open":109.49563594727071,"high":109.49563594727071,"low":109.49563594727071,"close":109.49563594727071},
{"symbol":"SAMPLE","timestampMs":1771891200000,"open":110.06367196362106,"high":110.06367196362106,"low":110.06367196362106,"close":110.06367196362106},
{"symbol":"SAMPLE","timestampMs":1771977600000,"open":110.4436029023648,"high":110.4436029023648,"low":110.4436029023648,"close":110.4436029023648},
{"symbol":"SAMPLE","timestampMs":1772064000000,"open":110.60677802309445,"high":110.60677802309445,"low":110.60677802309445,"close":110.60677802309445},
{"symbol":"SAMPLE","timestampMs":1772150400000,"open":110.53926964353336,"high":110.53926964353336,"low":110.53926964353336,"close":110.53926964353336},
{"symbol":"SAMPLE","timestampMs":1772236800000,"open":110.24350359096715,"high":110.24350359096715,"low":110.24350359096715,"close":110.24350359096715},
{"symbol":"SAMPLE","timestampMs":1772323200000,"open":109.7382735670719,"high":109.7382735670719,"low":109.7382735670719,"close":109.7382735670719},
{"symbol":"SAMPLE","timestampMs":1772409600000,"open":109.05713211137424,"high":109.05713211137424,"low":109.05713211137424,"close":109.05713211137424},
{"symbol":"SAMPLE","timestampMs":1772496000000,"open":108.2453259263757,"high":108.2453259263757,"low":108.2453259263757,"close":108.2453259263757},
{"symbol":"SAMPLE","timestampMs":1772582400000,"open":107.35560012768012,"high":107.35560012768012,"low":107.35560012768012,"close":107.35560012768012},
{"symbol":"SAMPLE","timestampMs":1772668800000,"open":106.44331731393967,"high":106.44331731393967,"low":106.44331731393967,"close":106.44331731393967},
{"symbol":"SAMPLE","timestampMs":1772755200000,"open":105.56140992203751,"high":105.56140992203751,"low":105.56140992203751,"close":105.56140992203751},
{"symbol":"SAMPLE","timestampMs":1772841600000,"open":104.7557002118784,"high":104.7557002118784,"low":104.7557002118784,"close":104.7557002118784},
{"symbol":"SAMPLE","timestampMs":1772928000000,"open":104.0610797148074,"high":104.0610797148074,"low":104.0610797148074,"close":104.0610797148074},
{"symbol":"SAMPLE","timestampMs":1773014400000,"open":103.4989438013756,"high":103.4989438013756,"low":103.4989438013756,"close":103.4989438013756},
{"symbol":"SAMPLE","timestampMs":1773100800000,"open":103.07613779766388,"high":103.07613779766388,"low":103.07613779766388,"close":103.07613779766388},
{"symbol":"SAMPLE","timestampMs":1773187200000,"open":102.78550415306421,"high":102.78550415306421,"low":102.78550415306421,"close":102.78550415306421},
{"symbol":"SAMPLE","timestampMs":1773273600000,"open":102.60794392328543,"high":102.60794392328543,"low":102.60794392328543,"close":102.60794392328543},
{"symbol":"SAMPLE","timestampMs":1773360000000,"open":102.51573968158225,"high":102.51573968158225,"low":102.51573968158225,"close":102.51573968158225},
{"symbol":"SAMPLE","timestampMs":1773446400000,"open":102.47674918840181,"high":102.47674918840181,"low":102.47674918840181,"close":102.47674918840181},
{"symbol":"SAMPLE","timestampMs":1773532800000,"open":102.45898488071076,"high":102.45898488071076,"low":102.45898488071076,"close":102.45898488071076},
{"symbol":"SAMPLE","timestampMs":1773619200000,"open":102.43505383252253,"high":102.43505383252253,"low":102.43505383252253,"close":102.43505383252253},
{"symbol":"SAMPLE","timestampMs":1773705600000,"open":102.38595069410142,"high":102.38595069410142,"low":102.38595069410142,"close":102.38595069410142},
{"symbol":"SAMPLE","timestampMs":1773792000000,"open":102.30377022243125,"high":102.30377022243125,"low":102.30377022243125,"close":102.30377022243125},
{"symbol":"SAMPLE","timestampMs":1773878400000,"open":102.19302815324691,"high":102.19302815324691,"low":102.19302815324691,"close":102.19302815324691},
{"symbol":"SAMPLE","timestampMs":1773964800000,"open":102.07043582438166,"high":102.07043582438166,"low":102.07043582438166,"close":102.07043582438166},
{"symbol":"SAMPLE","timestampMs":1774051200000,"open":101.96314782491588,"high":101.96314782491588,"low":101.96314782491588,"close":101.96314782491588},
{"symbol":"SAMPLE","timestampMs":1774137600000,"open":101.90567380028733,"high":101.90567380028733,"low":101.90567380028733,"close":101.90567380028733},
{"symbol":"SAMPLE","timestampMs":1774224000000,"open":101.93579639467438,"high":101.93579639467438,"low":101.93579639467438,"close":101.93579639467438},
{"symbol":"SAMPLE","timestampMs":1774310400000,"open":102.0899504746907,"high":102.0899504746907,"low":102.0899504746907,"close":102.0899504746907},
{"symbol":"SAMPLE","timestampMs":1774396800000,"open":102.39858171864448,"high":102.39858171864448,"low":102.39858171864448,"close":102.39858171864448},
{"symbol":"SAMPLE","timestampMs":1774483200000,"open":102.88200837042154,"high":102.88200837042154,"low":102.88200837042154,"close":102.88200837042154},
{"symbol":"SAMPLE","timestampMs":1774569600000,"open":103.5472577471747,"high":103.5472577471747,"low":103.5472577471747,"close":103.5472577471747},
{"symbol":"SAMPLE","timestampMs":1774656000000,"open":104.38624463820919,"high":104.38624463820919,"low":104.38624463820919,"close":104.38624463820919},
{"symbol":"SAMPLE","timestampMs":1774742400000,"open":105.37551347926511,"high":105.37551347926511,"low":105.37551347926511,"close":105.37551347926511},
{"symbol":"SAMPLE","timestampMs":1774828800000,"open":106.47759607184327,"high":106.47759607184327,"low":106.47759607184327,"close":106.47759607184327},
{"symbol":"SAMPLE","timestampMs":1774915200000,"open":107.64386032707998,"high":107.64386032707998,"low":107.64386032707998,"close":107.64386032707998},
{"symbol":"SAMPLE","timestampMs":1775001600000,"open":108.81856242328553,"high":108.81856242328553,"low":108.81856242328553,"close":108.81856242328553},
{"symbol":"SAMPLE","timestampMs":1775088000000,"open":109.94368280819776,"high":109.94368280819776,"low":109.94368280819776,"close":109.94368280819776},
{"symbol":"SAMPLE","timestampMs":1775174400000,"open":110.96404016740328,"high":110.96404016740328,"low":110.96404016740328,"close":110.96404016740328},
{"symbol":"SAMPLE","timestampMs":1775260800000,"open":111.83214632111945,"high":111.83214632111945,"low":111.83214632111945,"close":111.83214632111945},
{"symbol":"SAMPLE","timestampMs":1775347200000,"open":112.51229244420503,"high":112.51229244420503,"low":112.51229244420503,"close":112.51229244420503},
{"symbol":"SAMPLE","timestampMs":1775433600000,"open":112.98344003107351,"high":112.98344003107351,"low":112.98344003107351,"close":112.98344003107351},
{"symbol":"SAMPLE","timestampMs":1775520000000,"open":113.24061954049677,"high":113.24061954049677,"low":113.24061954049677,"close":113.24061954049677},
{"symbol":"SAMPLE","timestampMs":1775606400000,"open":113.2947014396149,"high":113.2947014396149,"low":113.2947014396149,"close":113.2947014396149},
{"symbol":"SAMPLE","timestampMs":1775692800000,"open":113.1705806625277,"high":113.1705806625277,"low":113.1705806625277,"close":113.1705806625277},
{"symbol":"SAMPLE","timestampMs":1775779200000,"open":112.90398695756218,"high":112.90398695756218,"low":112.90398695756218,"close":112.90398695756218},
{"symbol":"SAMPLE","timestampMs":1775865600000,"open":112.53728140871418,"high":112.53728140871418,"low":112.53728140871418,"close":112.53728140871418},
{"symbol":"SAMPLE","timestampMs":1775952000000,"open":112.11470737933577,"high":112.11470737933577,"low":112.11470737933577,"close":112.11470737933577},
{"symbol":"SAMPLE","timestampMs":1776038400000,"open":111.67762042898488,"high":111.67762042898488,"low":111.67762042898488,"close":111.67762042898488},
{"symbol":"SAMPLE","timestampMs":1776124800000,"open":111.26022027585942,"high":111.26022027585942,"low":111.26022027585942,"close":111.26022027585942},
{"symbol":"SAMPLE","timestampMs":1776211200000,"open":110.8862488574524,"high":110.8862488574524,"low":110.8862488574524,"close":110.8862488574524},
{"symbol":"SAMPLE","timestampMs":1776297600000,"open":110.56700855467578,"high":110.56700855467578,"low":110.56700855467578,"close":110.56700855467578},
{"symbol":"SAMPLE","timestampMs":1776384000000,"open":110.30090587181856,"high":110.30090587181856,"low":110.30090587181856,"close":110.30090587181856},
{"symbol":"SAMPLE","timestampMs":1776470400000,"open":110.07455475426454,"high":110.07455475426454,"low":110.07455475426454,"close":110.07455475426454},
{"symbol":"SAMPLE","timestampMs":1776556800000,"open":109.86529917954812,"high":109.86529917954812,"low":109.86529917954812,"close":109.86529917954812},
{"symbol":"SAMPLE","timestampMs":1776643200000,"open":109.64485594830019,"high":109.64485594830019,"low":109.64485594830019,"close":109.64485594830019},
{"symbol":"SAMPLE","timestampMs":1776729600000,"open":109.38365325185012,"high":109.38365325185012,"low":109.38365325185012,"close":109.38365325185012},
{"symbol":"SAMPLE","timestampMs":1776816000000,"open":109.05536244335418,"high":109.05536244335418,"low":109.05536244335418,"close":109.05536244335418},
{"symbol":"SAMPLE","timestampMs":1776902400000,"open":108.64109812421049,"high":108.64109812421049,"low":108.64109812421049,"close":108.64109812421049},
{"symbol":"SAMPLE","timestampMs":1776988800000,"open":108.13279765508621,"high":108.13279765508621,"low":108.13279765508621,"close":108.13279765508621},
{"symbol":"SAMPLE","timestampMs":1777075200000,"open":107.53538155881812,"high":107.53538155881812,"low":107.53538155881812,"close":107.53538155881812},
{"symbol":"SAMPLE","timestampMs":1777161600000,"open":106.86743105310215,"high":106.86743105310215,"low":106.86743105310215,"close":106.86743105310215},
{"symbol":"SAMPLE","timestampMs":1777248000000,"open":106.16028328640736,"high":106.16028328640736,"low":106.16028328640736,"close":106.16028328640736},
{"symbol":"SAMPLE","timestampMs":1777334400000,"open":105.45562063762007,"high":105.45562063762007,"low":105.45562063762007,"close":105.45562063762007},
{"symbol":"SAMPLE","timestampMs":1777420800000,"open":104.80179829427318,"high":104.80179829427318,"low":104.80179829427318,"close":104.80179829427318},
{"symbol":"SAMPLE","timestampMs":1777507200000,"open":104.24929572520446,"high":104.24929572520446,"low":104.24929572520446,"close":104.24929572520446},
];const averages = sma(data.map(bar => bar.close), { period: 20 });
const signal = data.map((bar, index) =>
Number.isFinite(averages[index]) && bar.close > averages[index]!
);
const backtest = vectorized({
data,
signal,
initialCapital: 10000,
executionLag: 1, // Execute the previous bar's signal.
periodsPerYear: 252,
fees: fees.bps(10),
});
const result = {
finalValue: backtest.finalValue,
maxDrawdown: backtest.performance.maxDrawdown,
tradeCount: backtest.trades.length,
};
console.log(result);
Output of this example
{
"finalValue": 11129.897588578056,
"maxDrawdown": 0.03956575702286411,
"tradeCount": 10
}
Reproduce this entire playground
This complete example reproduces every chart point and the full playground result. Sample generation and chart mapping are example setup, not required conversions of library outputs.
import { vectorized, fees } from '@insiderfinance/totalfinance/backtest';
import { sma } from '@insiderfinance/totalfinance/technical-analysis';
import { underwater } from '@insiderfinance/totalfinance/performance';
// Synthetic data, not a historical market series.
const data = Array.from({ length: 120 }, (_, index) => {
const close = 100 + index * 0.08 + Math.sin(index / 7) * 5 + Math.cos(index / 3) * 1.2;
return { symbol: 'SAMPLE', timestampMs: Date.UTC(2026, 0, 1) + index * 86400000, open: close, high: close, low: close, close };
});
const averages = sma(data.map(bar => bar.close), { period: 20 });
const signal = data.map((bar, index) => Number.isFinite(averages[index]) && bar.close > averages[index]!);
const backtest = vectorized({ data, signal, initialCapital: 10000, executionLag: 1, periodsPerYear: 252, fees: fees.bps(10) });
const result = { backtest, drawdowns: underwater(backtest.points.map(point => point.equity)) };
console.log(result);Both examples use the last successfully calculated inputs. The first call may show fewer scenarios or selected report fields, as labeled above. Displayed metrics are rounded; copied calculations retain exact values.
Continue with the full API reference or the API levels guide.