The finance developer workbenchSearch the reference Development · 0.1.4 · unpublished

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 data

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.

Loading the local calculator. The verified sample is displayed below.

Final value11,129.8976USD
Maximum drawdown0.0396decimal fraction
Trades10
Execution lag1bar · no same-bar signal fill
Equity on the synthetic price series
02,860.85745,721.71488,582.572211.44K0120Observation index

Moving-average strategyPortfolio equity · USD

Exact chart data
SeriesObservation indexPortfolio equity · USD
Moving-average strategy010000
Moving-average strategy110000
Moving-average strategy210000
Moving-average strategy310000
Moving-average strategy410000
Moving-average strategy510000
Moving-average strategy610000
Moving-average strategy710000
Moving-average strategy810000
Moving-average strategy910000
Moving-average strategy1010000
Moving-average strategy1110000
Moving-average strategy1210000
Moving-average strategy1310000
Moving-average strategy1410000
Moving-average strategy1510000
Moving-average strategy1610000
Moving-average strategy1710000
Moving-average strategy1810000
Moving-average strategy1910000
Moving-average strategy2010000
Moving-average strategy219990
Moving-average strategy229900.772995179695
Moving-average strategy239900.772995179695
Moving-average strategy249900.772995179695
Moving-average strategy259900.772995179695
Moving-average strategy269900.772995179695
Moving-average strategy279900.772995179695
Moving-average strategy289900.772995179695
Moving-average strategy299900.772995179695
Moving-average strategy309900.772995179695
Moving-average strategy319900.772995179695
Moving-average strategy329900.772995179695
Moving-average strategy339900.772995179695
Moving-average strategy349900.772995179695
Moving-average strategy359900.772995179695
Moving-average strategy369900.772995179695
Moving-average strategy379900.772995179695
Moving-average strategy389900.772995179695
Moving-average strategy399890.872222184516
Moving-average strategy409938.239149290801
Moving-average strategy419980.31723037804
Moving-average strategy4210018.433421320091
Moving-average strategy4310054.798321427646
Moving-average strategy4410092.187130617453
Moving-average strategy4510133.513734554232
Moving-average strategy4610181.38436860422
Moving-average strategy4710237.6825858876
Moving-average strategy4810303.233828965007
Moving-average strategy4910377.589140494503
Moving-average strategy5010458.954378544167
Moving-average strategy5110544.275178039465
Moving-average strategy5210629.470598278062
Moving-average strategy5310709.79182539692
Moving-average strategy5410780.268286500996
Moving-average strategy5510836.193626404267
Moving-average strategy5610873.599294843269
Moving-average strategy5710889.664515758654
Moving-average strategy5810883.018055033275
Moving-average strategy5910853.898744733393
Moving-average strategy6010804.156897381494
Moving-average strategy6110737.095890093875
Moving-average strategy6210657.170435501537
Moving-average strategy6310569.573493968748
Moving-average strategy6410469.275971439081
Moving-average strategy6510469.275971439081
Moving-average strategy6610469.275971439081
Moving-average strategy6710469.275971439081
Moving-average strategy6810469.275971439081
Moving-average strategy6910469.275971439081
Moving-average strategy7010469.275971439081
Moving-average strategy7110469.275971439081
Moving-average strategy7210469.275971439081
Moving-average strategy7310469.275971439081
Moving-average strategy7410469.275971439081
Moving-average strategy7510469.275971439081
Moving-average strategy7610469.275971439081
Moving-average strategy7710469.275971439081
Moving-average strategy7810469.275971439081
Moving-average strategy7910469.275971439081
Moving-average strategy8010469.275971439081
Moving-average strategy8110469.275971439081
Moving-average strategy8210469.275971439081
Moving-average strategy8310469.275971439081
Moving-average strategy8410469.275971439081
Moving-average strategy8510469.275971439081
Moving-average strategy8610458.806695467641
Moving-average strategy8710543.62305299288
Moving-average strategy8810643.545097879116
Moving-average strategy8910754.86190574017
Moving-average strategy9010872.661438088915
Moving-average strategy9110991.31324188103
Moving-average strategy9211104.957001932476
Moving-average strategy9311208.01908173412
Moving-average strategy9411295.702896510797
Moving-average strategy9511364.401645416576
Moving-average strategy9611411.990315952553
Moving-average strategy9711437.966955297972
Moving-average strategy9811443.429544411925
Moving-average strategy9911430.892617699148
Moving-average strategy10011403.965089370087
Moving-average strategy10111366.925677444342
Moving-average strategy10211324.243221199982
Moving-average strategy10311280.094874788883
Moving-average strategy10411237.935010401636
Moving-average strategy10511200.161703020965
Moving-average strategy10611167.916559430996
Moving-average strategy10711129.897588578056
Moving-average strategy10811129.897588578056
Moving-average strategy10911129.897588578056
Moving-average strategy11011129.897588578056
Moving-average strategy11111129.897588578056
Moving-average strategy11211129.897588578056
Moving-average strategy11311129.897588578056
Moving-average strategy11411129.897588578056
Moving-average strategy11511129.897588578056
Moving-average strategy11611129.897588578056
Moving-average strategy11711129.897588578056
Moving-average strategy11811129.897588578056
Moving-average strategy11911129.897588578056
Moving-average strategy12011129.897588578056
Drawdown from the running equity peak
00.00990.01980.02970.03960120Observation index

Drawdown (positive = below peak)Drawdown · decimal fraction

Exact chart data
SeriesObservation indexDrawdown · decimal fraction
Drawdown (positive = below peak)00
Drawdown (positive = below peak)10
Drawdown (positive = below peak)20
Drawdown (positive = below peak)30
Drawdown (positive = below peak)40
Drawdown (positive = below peak)50
Drawdown (positive = below peak)60
Drawdown (positive = below peak)70
Drawdown (positive = below peak)80
Drawdown (positive = below peak)90
Drawdown (positive = below peak)100
Drawdown (positive = below peak)110
Drawdown (positive = below peak)120
Drawdown (positive = below peak)130
Drawdown (positive = below peak)140
Drawdown (positive = below peak)150
Drawdown (positive = below peak)160
Drawdown (positive = below peak)170
Drawdown (positive = below peak)180
Drawdown (positive = below peak)190
Drawdown (positive = below peak)200
Drawdown (positive = below peak)210.001
Drawdown (positive = below peak)220.00992270048203045
Drawdown (positive = below peak)230.00992270048203045
Drawdown (positive = below peak)240.00992270048203045
Drawdown (positive = below peak)250.00992270048203045
Drawdown (positive = below peak)260.00992270048203045
Drawdown (positive = below peak)270.00992270048203045
Drawdown (positive = below peak)280.00992270048203045
Drawdown (positive = below peak)290.00992270048203045
Drawdown (positive = below peak)300.00992270048203045
Drawdown (positive = below peak)310.00992270048203045
Drawdown (positive = below peak)320.00992270048203045
Drawdown (positive = below peak)330.00992270048203045
Drawdown (positive = below peak)340.00992270048203045
Drawdown (positive = below peak)350.00992270048203045
Drawdown (positive = below peak)360.00992270048203045
Drawdown (positive = below peak)370.00992270048203045
Drawdown (positive = below peak)380.00992270048203045
Drawdown (positive = below peak)390.010912777781548358
Drawdown (positive = below peak)400.0061760850709199075
Drawdown (positive = below peak)410.0019682769621960686
Drawdown (positive = below peak)420
Drawdown (positive = below peak)430
Drawdown (positive = below peak)440
Drawdown (positive = below peak)450
Drawdown (positive = below peak)460
Drawdown (positive = below peak)470
Drawdown (positive = below peak)480
Drawdown (positive = below peak)490
Drawdown (positive = below peak)500
Drawdown (positive = below peak)510
Drawdown (positive = below peak)520
Drawdown (positive = below peak)530
Drawdown (positive = below peak)540
Drawdown (positive = below peak)550
Drawdown (positive = below peak)560
Drawdown (positive = below peak)570
Drawdown (positive = below peak)580.0006103457747261285
Drawdown (positive = below peak)590.003284377675134367
Drawdown (positive = below peak)600.007852181144186766
Drawdown (positive = below peak)610.014010406421978705
Drawdown (positive = below peak)620.021349976385468025
Drawdown (positive = below peak)630.029394020479390826
Drawdown (positive = below peak)640.03860436138424829
Drawdown (positive = below peak)650.03860436138424829
Drawdown (positive = below peak)660.03860436138424829
Drawdown (positive = below peak)670.03860436138424829
Drawdown (positive = below peak)680.03860436138424829
Drawdown (positive = below peak)690.03860436138424829
Drawdown (positive = below peak)700.03860436138424829
Drawdown (positive = below peak)710.03860436138424829
Drawdown (positive = below peak)720.03860436138424829
Drawdown (positive = below peak)730.03860436138424829
Drawdown (positive = below peak)740.03860436138424829
Drawdown (positive = below peak)750.03860436138424829
Drawdown (positive = below peak)760.03860436138424829
Drawdown (positive = below peak)770.03860436138424829
Drawdown (positive = below peak)780.03860436138424829
Drawdown (positive = below peak)790.03860436138424829
Drawdown (positive = below peak)800.03860436138424829
Drawdown (positive = below peak)810.03860436138424829
Drawdown (positive = below peak)820.03860436138424829
Drawdown (positive = below peak)830.03860436138424829
Drawdown (positive = below peak)840.03860436138424829
Drawdown (positive = below peak)850.03860436138424829
Drawdown (positive = below peak)860.03956575702286411
Drawdown (positive = below peak)870.03177705449649162
Drawdown (positive = below peak)880.022601193776298
Drawdown (positive = below peak)890.012378949766855335
Drawdown (positive = below peak)900.0015613959130819008
Drawdown (positive = below peak)910
Drawdown (positive = below peak)920
Drawdown (positive = below peak)930
Drawdown (positive = below peak)940
Drawdown (positive = below peak)950
Drawdown (positive = below peak)960
Drawdown (positive = below peak)970
Drawdown (positive = below peak)980
Drawdown (positive = below peak)990.0010955567702952463
Drawdown (positive = below peak)1000.003448656269405642
Drawdown (positive = below peak)1010.006685396774688208
Drawdown (positive = below peak)1020.01041526255301186
Drawdown (positive = below peak)1030.01427322718151411
Drawdown (positive = below peak)1040.01795742554386914
Drawdown (positive = below peak)1050.021258298523780642
Drawdown (positive = below peak)1060.024076085225295776
Drawdown (positive = below peak)1070.027398425849265898
Drawdown (positive = below peak)1080.027398425849265898
Drawdown (positive = below peak)1090.027398425849265898
Drawdown (positive = below peak)1100.027398425849265898
Drawdown (positive = below peak)1110.027398425849265898
Drawdown (positive = below peak)1120.027398425849265898
Drawdown (positive = below peak)1130.027398425849265898
Drawdown (positive = below peak)1140.027398425849265898
Drawdown (positive = below peak)1150.027398425849265898
Drawdown (positive = below peak)1160.027398425849265898
Drawdown (positive = below peak)1170.027398425849265898
Drawdown (positive = below peak)1180.027398425849265898
Drawdown (positive = below peak)1190.027398425849265898
Drawdown (positive = below peak)1200.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.