SPB Git

Repository Public

job_backtest.json 33.1 KB 2 lines json

1{"job":{"id":"1e5367ff-a0ea-4481-a27d-3fddbb9fd1af","tool":"backtest","params":{"symbols":["SPY"],"strategy":"ma_cross","years":10,"execution":"next_open","rebalance":"auto","position_size":1,"allow_short":false,"max_leverage":1,"vol_window":20,"cost_bps":5,"slippage_bps":2,"slippage_model":"fixed","financing_rate":0,"risk_free":0,"walk_forward":false,"train_days":756,"test_days":126,"sensitivity":true},"status":"done","startedAt":1795217730677,"finishedAt":1795217735606,"error":null,"progress":1,"engineVersion":"1.0.0","durationMs":4929,"projectId":null,"sessionId":null,"cancellable":false,"code":"from vqlab import backtest as bt\nr = bt.run({'symbols': ['SPY'], 'strategy': 'ma_cross', 'years': 10, 'execution': 'next_open', 'rebalance': 'auto', 'position_size': 1, 'allow_short': False, 'max_leverage': 1, 'vol_window': 20, 'cost_bps': 5, 'slippage_bps': 2, 'slippage_model': 'fixed', 'financing_rate': 0, 'risk_free': 0, 'walk_forward': False, 'train_days': 756, 'test_days': 126, 'sensitivity': True, 'start': '2016-11-21', 'end': '2026-11-20'})\nprint(r[\"headline\"])\n# step by step: bars = bt.load_bars(symbols, start, end); w = bt.decisions(bars, \"ma_cross\", {'fast': 50, 'slow': 200}, P)  # decisions at each close\n#               sim = bt.simulate(bars, w, \"next_open\", cost_rate, \"daily\", False)        # orders = decisions lagged one bar","result":{"success":true,"schema":"lab/1","engine":"backtest","engineVersion":"1.0.0","title":"Backtest — Moving-average crossover on SPY","headline":"Moving-average crossover on SPY, 2016-11-21 → 2026-11-20: CAGR 7.8% (benchmark 13.9%), Sharpe 0.57 (benchmark 0.81), max drawdown -33.7%, net of costs.","summary":[{"label":"CAGR","value":0.07802157184239356,"unit":"percent","kind":"calculated"},{"label":"Volatility (annual)","value":0.15321848758399087,"unit":"percent","kind":"calculated"},{"label":"Sharpe ratio","value":0.567323537233204,"unit":"ratio","kind":"calculated","decimals":2,"note":"risk-free 0.00%"},{"label":"Sortino ratio","value":0.7791006681074885,"unit":"ratio","kind":"calculated","decimals":2},{"label":"Calmar ratio","value":0.23140933422556395,"unit":"ratio","kind":"calculated","decimals":2},{"label":"Maximum drawdown","value":-0.337158274550597,"unit":"percent","kind":"calculated"},{"label":"Total return","value":1.1152816218770867,"unit":"percent","kind":"calculated"},{"label":"Benchmark CAGR","value":0.13923182714959714,"unit":"percent","kind":"calculated","note":"SPY buy & hold"},{"label":"Benchmark Sharpe ratio","value":0.8114380511998528,"unit":"ratio","kind":"calculated","decimals":2},{"label":"Alpha vs benchmark (annual)","value":-0.018346038708654172,"unit":"percent","kind":"calculated","note":"HAC t = -0.70"},{"label":"Beta vs benchmark","value":0.7171281450372706,"unit":"ratio","kind":"calculated","decimals":2},{"label":"Probabilistic Sharpe ratio","value":0.961333045321974,"unit":"percent","kind":"calculated","note":"P[true Sharpe > 0]"},{"label":"Deflated Sharpe ratio","value":0.8536778190296859,"unit":"percent","kind":"calculated","note":"17 configuration(s) accounted for"},{"label":"Hit rate (days in the market)","value":0.5561944589649764,"unit":"percent","kind":"calculated"},{"label":"Exposure (average gross)","value":0.761241543971349,"unit":"percent","kind":"calculated"},{"label":"Time in the market","value":0.761241543971349,"unit":"percent","kind":"calculated"},{"label":"Turnover (annual)","value":0.9025069637883009,"unit":"ratio","kind":"calculated","decimals":2,"note":"sum of |weight changes| per year"},{"label":"Average holding period","value":382.6,"unit":"days","kind":"calculated","note":"sessions"},{"label":"Trades (rebalancing days)","value":9,"unit":"count","kind":"calculated"},{"label":"Costs paid (total)","value":0.0063,"unit":"percent","kind":"calculated","note":"sum of daily cost drags"},{"label":"Sensitivity: median Sharpe over the grid","value":0.609505679422952,"unit":"ratio","kind":"calculated","decimals":2,"note":"15 configurations, best 0.94, worst 0.43"}],"tables":[{"id":"years","title":"Returns by year","columns":[{"key":"year","label":"Year","type":"year"},{"key":"strategy","label":"Strategy","unit":"percent","type":"number"},{"key":"benchmark","label":"Benchmark","unit":"percent","type":"number"},{"key":"excess","label":"Excess","unit":"percent","type":"number"}],"rows":[{"year":2016,"strategy":0,"benchmark":0.0213818413914153,"excess":-0.0213818413914153},{"year":2017,"strategy":0.09251688809880232,"benchmark":0.21699734416497307,"excess":-0.12448045606617075},{"year":2018,"strategy":0.011058985879334626,"benchmark":-0.04574240479246949,"excess":0.05680139067180412},{"year":2019,"strategy":0.16068724746973584,"benchmark":0.31222815120398284,"excess":-0.151540903734247},{"year":2020,"strategy":-0.07779870579740833,"benchmark":0.18339939857845677,"excess":-0.2611981043758651},{"year":2021,"strategy":0.2872859576679827,"benchmark":0.2872859576679867,"excess":-3.9968028886505635e-15},{"year":2022,"strategy":-0.08774086810228832,"benchmark":-0.18176312247644633,"excess":0.09402225437415801},{"year":2023,"strategy":0.19455567243260008,"benchmark":0.26175398196123734,"excess":-0.06719830952863726},{"year":2024,"strategy":0.24882129277566567,"benchmark":0.24882129277566656,"excess":-8.881784197001252e-16},{"year":2025,"strategy":0.0017155738449528002,"benchmark":0.17721871357238417,"excess":-0.17550313972743137},{"year":2026,"strategy":0.019478888018564344,"benchmark":0.01947888801856279,"excess":1.5543122344752192e-15}],"note":"The first and last years may be partial."},{"id":"sensitivity","title":"Parameter sensitivity","columns":[{"key":"config","label":"Configuration","type":"text"},{"key":"sharpe","label":"Sharpe ratio","decimals":2,"type":"number"}],"rows":[{"config":"fast=10, slow=100","sharpe":0.937012957559505},{"config":"fast=10, slow=200","sharpe":0.7239976460566923},{"config":"fast=10, slow=150","sharpe":0.7079100875649011},{"config":"fast=20, slow=100","sharpe":0.6717124022388753},{"config":"fast=50, slow=150","sharpe":0.6489673718939627},{"config":"fast=20, slow=200","sharpe":0.6365482790455579},{"config":"fast=50, slow=250","sharpe":0.6249839612017476},{"config":"fast=100, slow=250","sharpe":0.609505679422952},{"config":"fast=100, slow=200","sharpe":0.5964579405351412},{"config":"fast=50, slow=200","sharpe":0.567323537233204},{"config":"fast=20, slow=150","sharpe":0.5312145085622021},{"config":"fast=100, slow=150","sharpe":0.5079376675473977},{"config":"fast=10, slow=250","sharpe":0.4952591947976731},{"config":"fast=50, slow=100","sharpe":0.46990606136474494},{"config":"fast=20, slow=250","sharpe":0.4279781524632781}]}],"charts":[{"id":"equity","title":"Equity curve (growth of 100)","type":"line","x":{"label":"Date","type":"time"},"y":{"label":"Value","log":true},"series":[{"name":"Strategy (net of costs)","kind":"calculated","x":["2016-11-22","2016-12-15","2017-01-09","2017-02-02","2017-02-23","2017-03-20","2017-04-10","2017-05-04","2017-05-24","2017-06-19","2017-07-11","2017-08-02","2017-08-23","2017-09-18","2017-10-11","2017-10-31","2017-11-24","2017-12-15","2018-01-10","2018-02-01","2018-02-27","2018-03-20","2018-04-12","2018-05-03","2018-05-29","2018-06-20","2018-07-12","2018-08-06","2018-08-27","2018-09-19","2018-10-10","2018-11-02","2018-11-23","2018-12-19","2019-01-11","2019-02-06","2019-02-27","2019-03-22","2019-04-16","2019-05-07","2019-05-31","2019-06-21","2019-07-17","2019-08-06","2019-08-29","2019-09-20","2019-10-14","2019-11-04","2019-11-27","2019-12-23","2020-01-14","2020-02-07","2020-03-02","2020-03-25","2020-04-15","2020-05-08","2020-06-01","2020-06-23","2020-07-15","2020-08-07","2020-08-27","2020-09-22","2020-10-15","2020-11-05","2020-11-30","2020-12-21","2021-01-15","2021-02-08","2021-03-03","2021-03-24","2021-04-19","2021-05-07","2021-06-02","2021-06-23","2021-07-19","2021-08-10","2021-08-31","2021-09-24","2021-10-14","2021-11-08","2021-11-30","2021-12-23","2022-01-13","2022-02-08","2022-03-02","2022-03-24","2022-04-19","2022-05-10","2022-06-03","2022-06-24","2022-07-20","2022-08-10","2022-09-01","2022-09-23","2022-10-18","2022-11-08","2022-12-01","2022-12-22","2023-01-19","2023-02-13","2023-03-06","2023-03-29","2023-04-20","2023-05-12","2023-06-05","2023-06-29","2023-07-20","2023-08-14","2023-09-05","2023-09-28","2023-10-18","2023-11-10","2023-12-06","2023-12-28","2024-01-23","2024-02-13","2024-03-08","2024-03-28","2024-04-23","2024-05-14","2024-06-07","2024-06-28","2024-07-24","2024-08-16","2024-09-06","2024-10-01","2024-10-22","2024-11-14","2024-12-05","2024-12-31","2025-01-24","2025-02-18","2025-03-11","2025-04-03","2025-04-25","2025-05-19","2025-06-12","2025-07-07","2025-07-29","2025-08-19","2025-09-12","2025-10-03","2025-10-27","2025-11-17","2025-12-11","2026-01-02","2026-01-28","2026-02-23","2026-03-16","2026-04-08","2026-04-29","2026-05-22","2026-06-12","2026-07-09","2026-07-30","2026-08-24","2026-09-14","2026-10-07","2026-10-28","2026-11-20"],"y":[100,100,100,100,100,100,100,100,100,100,100,100,100,101.7157999625748,103.87558944610777,104.74044021332334,106.04940353667665,109.11144273952098,112.22490550149699,115.27759496631738,112.35112696482041,111.3694044723054,109.30778723802402,107.947400355539,110.57467674026962,113.94058242889238,115.34304313248515,117.52153209206604,119.64392262350323,120.23763098802418,115.42251590568884,112.7625154378745,109.17689090568892,110.45990169372217,110.45990169372217,110.45990169372217,110.45990169372217,110.45990169372217,113.93567649551595,113.0594504207985,108.09124857715034,116.00357003184934,117.4800109677483,113.55889928338745,115.4427853440301,118.23356539200529,117.3135280135519,121.83923568946777,125.05498538368103,127.9552936909959,130.43939461282,132.3320429342097,123.12290688892877,98.88649366224284,99.29448204715283,99.29448204715283,99.29448204715283,99.29448204715283,100.94228530250756,104.92999379311595,109.24545914596622,104.00817761806091,109.42299411301384,110.28677001038021,114.00817605041718,116.32978715796318,118.80844842866667,123.49264025153883,120.61793943895987,122.94637881446924,131.73435968332714,133.9262336995691,133.35607332462763,134.5168788784006,135.27140248835298,140.9081376921153,143.73504062895077,141.75484291957324,141.30417723399074,149.7439164367167,145.47283482562833,150.8057121050208,148.8596557354602,144.50322077482977,140.32090664726528,138.84774914518917,138.84774914518917,138.84774914518917,138.84774914518917,138.84774914518917,138.84774914518917,138.84774914518917,138.84774914518917,138.84774914518917,138.84774914518917,138.84774914518917,138.84774914518917,138.84774914518917,138.84774914518917,141.90381363610857,139.03164614066762,138.48388019423464,142.1164333126845,142.01552905939428,147.3670582071105,151.72756343858293,156.5997973831703,155.19074156043825,155.5799436802722,148.93107413310963,149.5184810361923,153.1330155379831,158.05209788588382,166.34066154901333,169.1912067044636,172.40933163975686,178.56449109046343,183.09437131853025,176.99687144113247,183.17365323182986,186.92152549689698,191.11265573177502,190.06036851889078,194.65511576692995,189.75405203568812,200.29133905785807,205.46628576231623,209.0015383508076,213.68998240547353,207.1312059416058,214.86839993497063,216.11168448444005,196.47499604948675,190.25136585547602,186.90952005298956,186.90952005298956,186.90952005298956,187.77528611594985,192.18486987417205,193.56171487239305,198.88817313945296,203.0187081341158,207.87906297193373,201.94237718895872,209.07191977440132,207.8667970922168,211.5925580562225,207.62761243773755,203.56453978151742,206.25076743951638,217.1030045190354,227.4922046392418,226.30548077663266,229.93924764276156,226.87277771353908,233.53621686973995,232.74506762800056,238.33217583904428,236.826539103796,211.52816218770866]},{"name":"SPY buy & hold","kind":"calculated","x":["2016-11-22","2016-12-15","2017-01-09","2017-02-02","2017-02-23","2017-03-20","2017-04-10","2017-05-04","2017-05-24","2017-06-19","2017-07-11","2017-08-02","2017-08-23","2017-09-18","2017-10-11","2017-10-31","2017-11-24","2017-12-15","2018-01-10","2018-02-01","2018-02-27","2018-03-20","2018-04-12","2018-05-03","2018-05-29","2018-06-20","2018-07-12","2018-08-06","2018-08-27","2018-09-19","2018-10-10","2018-11-02","2018-11-23","2018-12-19","2019-01-11","2019-02-06","2019-02-27","2019-03-22","2019-04-16","2019-05-07","2019-05-31","2019-06-21","2019-07-17","2019-08-06","2019-08-29","2019-09-20","2019-10-14","2019-11-04","2019-11-27","2019-12-23","2020-01-14","2020-02-07","2020-03-02","2020-03-25","2020-04-15","2020-05-08","2020-06-01","2020-06-23","2020-07-15","2020-08-07","2020-08-27","2020-09-22","2020-10-15","2020-11-05","2020-11-30","2020-12-21","2021-01-15","2021-02-08","2021-03-03","2021-03-24","2021-04-19","2021-05-07","2021-06-02","2021-06-23","2021-07-19","2021-08-10","2021-08-31","2021-09-24","2021-10-14","2021-11-08","2021-11-30","2021-12-23","2022-01-13","2022-02-08","2022-03-02","2022-03-24","2022-04-19","2022-05-10","2022-06-03","2022-06-24","2022-07-20","2022-08-10","2022-09-01","2022-09-23","2022-10-18","2022-11-08","2022-12-01","2022-12-22","2023-01-19","2023-02-13","2023-03-06","2023-03-29","2023-04-20","2023-05-12","2023-06-05","2023-06-29","2023-07-20","2023-08-14","2023-09-05","2023-09-28","2023-10-18","2023-11-10","2023-12-06","2023-12-28","2024-01-23","2024-02-13","2024-03-08","2024-03-28","2024-04-23","2024-05-14","2024-06-07","2024-06-28","2024-07-24","2024-08-16","2024-09-06","2024-10-01","2024-10-22","2024-11-14","2024-12-05","2024-12-31","2025-01-24","2025-02-18","2025-03-11","2025-04-03","2025-04-25","2025-05-19","2025-06-12","2025-07-07","2025-07-29","2025-08-19","2025-09-12","2025-10-03","2025-10-27","2025-11-17","2025-12-11","2026-01-02","2026-01-28","2026-02-23","2026-03-16","2026-04-08","2026-04-29","2026-05-22","2026-06-12","2026-07-09","2026-07-30","2026-08-24","2026-09-14","2026-10-07","2026-10-28","2026-11-20"],"y":[100.1967980426573,103.02643476410826,103.47321950960054,104.07425136960798,108.03680655284296,108.65911387692144,108.00489335673635,109.57395883197701,110.41965852880165,112.82378596883144,111.68554864102971,114.10563267911277,112.78123504068931,115.72788681453112,118.18520291473855,119.1691931280251,120.65847561299925,124.14233285463534,127.68469762246684,131.15791713206738,127.82830700494652,126.71134514121589,124.36572522738155,122.81793521621186,125.80713791819585,129.63672145098667,131.2323812563161,133.7109728205946,136.1257379926599,136.80123397691605,131.3228019786181,128.2963672145098,124.21679697888402,118.56284240199982,122.91899367054937,129.45056114036473,132.51422796659736,133.12057869262256,138.32242965799682,137.25865645444378,131.2270623902982,140.83293441838185,142.6253922663687,137.86500718046904,140.15211956810805,143.54023722142443,142.4232753576937,147.917663954045,151.82171161108448,155.3428009148449,158.35859794691766,160.65634806659216,149.47609169725007,120.05212488697401,135.12047231530224,142.25839051114284,148.63571086644308,152.47061326525164,157.2575926812401,163.47002818998965,170.19307483644462,162.03393436519312,170.46965586936835,171.81532897186284,177.6128929312267,181.22972182330685,185.0912185522042,192.38870272857784,187.91021754161974,191.53768416573553,205.2284452954626,208.6431572788677,207.754906653901,209.563321099941,210.73879048986703,219.52023828519717,223.92425934790663,220.83931705760293,220.13722674325797,233.28546353917292,226.63156215094892,234.9396308706978,231.9078772405718,225.12100420190362,218.60539333014154,225.59970214350255,222.86580501037125,199.85639061751996,205.59012818467065,196.1863730652622,198.5479495771498,211.22812616350154,199.3776926759211,185.81458433062036,187.42088186798534,192.9099515983189,205.7284187011326,193.1493005691184,197.17036327854862,209.4409871815326,205.2018509653738,204.39338333067343,209.75480027658057,209.60587202808304,217.504388064464,223.94021594595964,231.13132280197797,229.05164618903177,229.6260837189505,219.81277591617405,220.67975107706977,226.01457369288806,233.2748258071373,245.50821764799687,249.71544066804904,254.46518802191332,263.5498111802558,270.2356257645863,261.2361044625279,270.3526408169772,275.88426147545283,282.0701026541135,280.516993776926,287.29854794957646,280.0648901654161,295.61725440136115,303.25514600287175,308.47295356629934,315.39279825541166,305.71246210307925,317.13206744322065,318.9670762193496,289.98457528854806,280.798893675868,288.0910589862238,311.2228072974838,315.8768150630283,325.70076059784026,333.34928993138647,335.737460773363,344.97633104622093,352.14084357215035,360.571246210308,350.27392159991496,362.6402850912185,360.54997074623697,367.01239295782153,360.13509919685134,353.0876017233127,357.746928354875,376.5703951917454,394.59071325993324,392.53231211105816,398.8351683421098,393.51630232434457,405.0741981809479,403.70193074836453,413.39290463273244,410.78134141800956,366.90069677144817],"style":"dashed"}]},{"id":"drawdown","title":"Drawdown","type":"area","x":{"label":"Date","type":"time"},"y":{"label":"Drawdown","unit":"percent"},"series":[{"name":"Strategy","kind":"calculated","x":["2016-11-22","2016-12-15","2017-01-09","2017-02-02","2017-02-23","2017-03-20","2017-04-10","2017-05-04","2017-05-24","2017-06-19","2017-07-11","2017-08-02","2017-08-23","2017-09-18","2017-10-11","2017-10-31","2017-11-24","2017-12-15","2018-01-10","2018-02-01","2018-02-27","2018-03-20","2018-04-12","2018-05-03","2018-05-29","2018-06-20","2018-07-12","2018-08-06","2018-08-27","2018-09-19","2018-10-10","2018-11-02","2018-11-23","2018-12-19","2019-01-11","2019-02-06","2019-02-27","2019-03-22","2019-04-16","2019-05-07","2019-05-31","2019-06-21","2019-07-17","2019-08-06","2019-08-29","2019-09-20","2019-10-14","2019-11-04","2019-11-27","2019-12-23","2020-01-14","2020-02-07","2020-03-02","2020-03-25","2020-04-15","2020-05-08","2020-06-01","2020-06-23","2020-07-15","2020-08-07","2020-08-27","2020-09-22","2020-10-15","2020-11-05","2020-11-30","2020-12-21","2021-01-15","2021-02-08","2021-03-03","2021-03-24","2021-04-19","2021-05-07","2021-06-02","2021-06-23","2021-07-19","2021-08-10","2021-08-31","2021-09-24","2021-10-14","2021-11-08","2021-11-30","2021-12-23","2022-01-13","2022-02-08","2022-03-02","2022-03-24","2022-04-19","2022-05-10","2022-06-03","2022-06-24","2022-07-20","2022-08-10","2022-09-01","2022-09-23","2022-10-18","2022-11-08","2022-12-01","2022-12-22","2023-01-19","2023-02-13","2023-03-06","2023-03-29","2023-04-20","2023-05-12","2023-06-05","2023-06-29","2023-07-20","2023-08-14","2023-09-05","2023-09-28","2023-10-18","2023-11-10","2023-12-06","2023-12-28","2024-01-23","2024-02-13","2024-03-08","2024-03-28","2024-04-23","2024-05-14","2024-06-07","2024-06-28","2024-07-24","2024-08-16","2024-09-06","2024-10-01","2024-10-22","2024-11-14","2024-12-05","2024-12-31","2025-01-24","2025-02-18","2025-03-11","2025-04-03","2025-04-25","2025-05-19","2025-06-12","2025-07-07","2025-07-29","2025-08-19","2025-09-12","2025-10-03","2025-10-27","2025-11-17","2025-12-11","2026-01-02","2026-01-28","2026-02-23","2026-03-16","2026-04-08","2026-04-29","2026-05-22","2026-06-12","2026-07-09","2026-07-30","2026-08-24","2026-09-14","2026-10-07","2026-10-28","2026-11-20"],"y":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-0.0021822392446777528,0,0,-0.0015389094538950099,-0.017452285133681245,-0.042395505438896586,-0.05076303940710025,-0.06833486074032702,-0.07992987209626579,-0.057536757381358994,-0.028848069490375994,-0.016894449535799994,0,0,-0.0008934467622265796,-0.047747608762727656,-0.06969299598889211,-0.09927491514964448,-0.08868989123727222,-0.08868989123727222,-0.08868989123727222,-0.08868989123727222,-0.08868989123727222,-0.06001424818410217,-0.06724323958467004,-0.1082316208258921,-0.04295382847876017,-0.03077297796880263,-0.06312271448634632,-0.047580382975124125,-0.024556045364314327,-0.03214648633491124,0,0,0,-0.001509155543631402,-0.005301982480405809,-0.08646750967070882,-0.2662939245197158,-0.2632667815232588,-0.2632667815232588,-0.2632667815232588,-0.2632667815232588,-0.2510406097289648,-0.2214530913688023,-0.18943372218451637,-0.22829267181164825,-0.18811646965478324,-0.1817075294620426,-0.15409588989647993,-0.13687027989227563,-0.11847940803484602,-0.08372420667342262,-0.10505356494333395,-0.08777729138029378,-0.022573291158497377,-0.006310288772175099,-0.010540695934972644,-0.0030112097978189922,-0.027705521472392913,0,-0.0014942010767734493,-0.017324623686452933,-0.020448736154502045,0,-0.030180949129396062,0,-0.027588206432044182,-0.05604621080333627,-0.08336678710022749,-0.09299005084972611,-0.09299005084972611,-0.09299005084972611,-0.09299005084972611,-0.09299005084972611,-0.09299005084972611,-0.09299005084972611,-0.09299005084972611,-0.09299005084972611,-0.09299005084972611,-0.09299005084972611,-0.09299005084972611,-0.09299005084972611,-0.09299005084972611,-0.07302659508199683,-0.09178876090772359,-0.09536699077662059,-0.07163767690920142,-0.07229682451662933,-0.0373384603369501,-0.008853867301655938,-0.006629329066179079,-0.021139246260853617,-0.018684366049915413,-0.060621902986770504,-0.05691685229804022,-0.034118288857571066,-0.009440780558315987,0,0,-0.01421742355559219,-0.006018054162487463,-0.0001967845406064539,-0.033492728811224115,0,-0.001251588554703864,-0.004579923417673992,-0.041840015987500756,-0.01867630761404726,-0.04338426321239797,-0.008951338242898732,-0.0021876093804689134,-0.009038872276804666,-0.001649970536240386,-0.0325203252032521,-0.002926470342313525,0,-0.09301126249771252,-0.12174144499342887,-0.13716842840744603,-0.13716842840744603,-0.13716842840744603,-0.13317178718487088,-0.11281579845247669,-0.10645986038512956,-0.08187129819586003,-0.06280348399381941,-0.04036659794316244,-0.06777215718232421,-0.03486000572000447,-0.040423220999441734,-0.023223967654615874,-0.04152737059688694,-0.06028375798939234,-0.04788330866423485,-0.005017145426949199,-0.0033853222101318803,-0.02346075979516482,-0.007780556547973161,-0.021012795575138132,-0.018519234486758074,-0.02184419099168733,-0.0024002361729711374,-0.00870246056296442,-0.1145952328999229]}]},{"id":"exposure","title":"Gross exposure","type":"area","x":{"label":"Date","type":"time"},"y":{"label":"Gross exposure","unit":"percent"},"series":[{"name":"Gross exposure","kind":"calculated","x":["2016-11-22","2016-12-15","2017-01-09","2017-02-02","2017-02-23","2017-03-20","2017-04-10","2017-05-04","2017-05-24","2017-06-19","2017-07-11","2017-08-02","2017-08-23","2017-09-18","2017-10-11","2017-10-31","2017-11-24","2017-12-15","2018-01-10","2018-02-01","2018-02-27","2018-03-20","2018-04-12","2018-05-03","2018-05-29","2018-06-20","2018-07-12","2018-08-06","2018-08-27","2018-09-19","2018-10-10","2018-11-02","2018-11-23","2018-12-19","2019-01-11","2019-02-06","2019-02-27","2019-03-22","2019-04-16","2019-05-07","2019-05-31","2019-06-21","2019-07-17","2019-08-06","2019-08-29","2019-09-20","2019-10-14","2019-11-04","2019-11-27","2019-12-23","2020-01-14","2020-02-07","2020-03-02","2020-03-25","2020-04-15","2020-05-08","2020-06-01","2020-06-23","2020-07-15","2020-08-07","2020-08-27","2020-09-22","2020-10-15","2020-11-05","2020-11-30","2020-12-21","2021-01-15","2021-02-08","2021-03-03","2021-03-24","2021-04-19","2021-05-07","2021-06-02","2021-06-23","2021-07-19","2021-08-10","2021-08-31","2021-09-24","2021-10-14","2021-11-08","2021-11-30","2021-12-23","2022-01-13","2022-02-08","2022-03-02","2022-03-24","2022-04-19","2022-05-10","2022-06-03","2022-06-24","2022-07-20","2022-08-10","2022-09-01","2022-09-23","2022-10-18","2022-11-08","2022-12-01","2022-12-22","2023-01-19","2023-02-13","2023-03-06","2023-03-29","2023-04-20","2023-05-12","2023-06-05","2023-06-29","2023-07-20","2023-08-14","2023-09-05","2023-09-28","2023-10-18","2023-11-10","2023-12-06","2023-12-28","2024-01-23","2024-02-13","2024-03-08","2024-03-28","2024-04-23","2024-05-14","2024-06-07","2024-06-28","2024-07-24","2024-08-16","2024-09-06","2024-10-01","2024-10-22","2024-11-14","2024-12-05","2024-12-31","2025-01-24","2025-02-18","2025-03-11","2025-04-03","2025-04-25","2025-05-19","2025-06-12","2025-07-07","2025-07-29","2025-08-19","2025-09-12","2025-10-03","2025-10-27","2025-11-17","2025-12-11","2026-01-02","2026-01-28","2026-02-23","2026-03-16","2026-04-08","2026-04-29","2026-05-22","2026-06-12","2026-07-09","2026-07-30","2026-08-24","2026-09-14","2026-10-07","2026-10-28","2026-11-20"],"y":[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}]},{"id":"monthly","title":"Monthly returns","type":"heatmap","x":{"label":"Month","type":"category"},"y":{"label":"Year","unit":"percent"},"series":[],"z":{"label":"Monthly return","unit":"percent"},"matrix":{"x":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"y":["2016","2017","2018","2019","2020","2021","2022","2023","2024","2025","2026"],"z":[[null,null,null,null,null,null,null,null,null,null,0,0],[0,0,0,0,0,0,0,0,0.023328826721557006,0.023526724531750087,0.03057353269359453,0.01212646167171938],[0.05635430038510947,-0.036334913112163525,-0.027448507776376863,0.005186497817349256,0.024293761018188365,0.0057509864830831425,0.037021578529989,0.031916606294775995,0.005967471430242899,-0.06912996277915628,0.018576367195634935,-0.03379887548558613],[0,0,0.004178503671363076,0.040840508728967384,-0.063752276867031,0.0695525291828798,0.015120509322419373,-0.016724530555866646,0.019438854929951566,0.02208483855349841,0.036219210027692794,0.029045643153527312],[-0.0003758884636422266,-0.0791713670392783,-0.12484686490700536,-0.038596589462967734,0,0,0.031345817706362133,0.06977829638273025,-0.03742832211418545,-0.024929582024800667,0.10877577447952946,0.03707363818764442],[-0.010193179521238438,0.027802088803314584,0.04538616559280184,0.052918816182459194,0.0065499368214752,0.022442548612712443,0.024430579568517352,0.029742686625575665,-0.046603325415677466,0.0701828691015991,-0.008054941217554012,0.046257832852215186],[-0.052736653207716144,-0.02952947026924624,-0.007649404616661526,0,0,0,0,0,0,0,0,0],[0.006281759389122676,-0.025147661912253816,0.037067414541220645,0.015996122152205805,0.004595218963438619,0.06481365760991764,0.03272300469483502,-0.01625221621130124,-0.047413295131587985,-0.021709074150435437,0.09134186254091059,0.045642493638676784],[0.015926127104834986,0.05218358355789432,0.03270458148705213,-0.04032908851142558,0.05059682513638797,0.03527574426549451,0.012105898325539544,0.023363267131199406,0.0209911156422955,-0.00891567554073558,0.05962469189111408,-0.024076746752695444],[0.026862919080675063,-0.012690398332796726,-0.055721444261394915,-0.05741629077691923,0,5.4683959940682314e-05,0.023033007415184548,0.020509942270686476,0.035622809912160935,0.023836979941128655,0.0019414022555837018,0.0008135131937045958],[0.01473478858460342,-0.008636760850567526,-0.04937781891371795,0.10504435446481075,0.05262716249667876,-0.010283527754895716,0.00034903076840508973,0.02679889422689885,-0.003293471868260678,-0.009060750298310438,-0.08721484147567982,null]]}},{"id":"sensitivity","title":"Sharpe ratio over fast × slow","type":"heatmap","x":{"label":"fast","type":"category"},"y":{"label":"slow","unit":"ratio"},"series":[],"z":{"label":"Sharpe ratio","unit":"ratio"},"matrix":{"x":["10","20","50","100"],"y":["100","150","200","250"],"z":[[0.937012957559505,0.6717124022388753,0.46990606136474494,null],[0.7079100875649011,0.5312145085622021,0.6489673718939627,0.5079376675473977],[0.7239976460566923,0.6365482790455579,0.567323537233204,0.5964579405351412],[0.4952591947976731,0.4279781524632781,0.6249839612017476,0.609505679422952]]},"note":"Empty cells are invalid combinations."}],"diagnostics":[{"name":"No look-ahead (truncation test)","statistic":0,"pvalue":null,"conclusion":"Decisions recomputed on histories cut at 5 dates equal the full-run decisions (max difference 0.0e+00).","passed":true},{"name":"Signals traded one bar later","statistic":1,"pvalue":null,"conclusion":"Decisions of bar t are executed at the open of bar t+1 through a single lag function.","passed":true},{"name":"Deflated Sharpe ratio","statistic":0.8536778190296859,"pvalue":null,"conclusion":"Probability that the true Sharpe ratio exceeds the best expected from 17 unskilled trial(s) (threshold 0.23 annualized; variance of the 15 Sharpe ratios of this run's grid). Above 95 % is the usual bar.","passed":false},{"name":"Alpha vs benchmark (HAC)","statistic":-0.7009821667439333,"pvalue":0.4833141444897271,"conclusion":"Alpha -1.83% a year, Newey-West t = -0.70 (8 lags, 2513 days), beta 0.72, R² 0.72. Not statistically different from zero at 5 %.","passed":null,"df":2511}],"assumptions":["Past performance does not guarantee future results. A backtest is a hypothetical reconstruction, not a track record.","Timing: a decision uses data up to the close of bar t and is executed at the open of bar t+1, at that bar's price, in full, whatever the size (no market impact, no partial fill).","Costs: 5 bps commission + 2 bps slippage on every unit of traded value; no financing cost, and idle cash earns nothing.","Prices are split- and dividend-adjusted daily bars: dividends are reinvested implicitly, and adjusted opens are used for next-open execution.","Rebalancing: daily; a trade happens only when the target changes, so weights drift in between. Sharpe and Sortino use a risk-free rate of 0.00%; 252 sessions a year."],"warnings":["Multiple testing: 15 configurations were evaluated on the same data. The best one is biased upward by selection — judge the strategy on the whole grid (median, dispersion), on the walk-forward result and on the deflated Sharpe ratio, not on the best cell."],"methodology":"**Timing.** Let $w_t$ be the target weights decided with data up to the close of bar $t$. Orders are $o_{t+1} = w_t$ (one lag function, nothing else moves decisions in time).\nWith next-open execution the day's gross growth is $(1 + h_{t}^\\top r^{ov}_{t+1})(1 + o_{t+1}^\\top r^{id}_{t+1})$ with overnight returns $r^{ov} = O_{t+1}/C_t - 1$,\nintraday returns $r^{id} = C_{t+1}/O_{t+1} - 1$ and $h_t$ the weights held at the close of $t$ (drifted with prices); with next-close execution the trade is at $C_{t+1}$ and earns from $t+2$.\n\n**Costs.** Each trade costs $\\sum_i |o_i - h_i| \\times (c + s_i)$ of equity ($c$ commission, $s_i$ slippage); net growth is multiplied by one minus that.\n\n**No look-ahead test.** For sampled dates $t$, decisions are recomputed from bars $\\le t$ only and compared with the full run; any dependence on later data shows up as a difference.\n\n**Statistics.** CAGR $= V_T^{252/T} - 1$; Sharpe $= \\sqrt{252}\\,\\overline{(r - r_f)}/\\sigma_r$; Sortino uses the downside deviation $\\sqrt{\\overline{\\min(r - r_f, 0)^2}}$;\nCalmar = CAGR / |max drawdown|. Alpha and beta: OLS of excess returns on benchmark excess returns with Newey-West errors.\nProbabilistic Sharpe ratio: $PSR(SR^*) = \\Phi\\!\\left(\\frac{(\\widehat{SR} - SR^*)\\sqrt{T-1}}{\\sqrt{1 - \\gamma_3 \\widehat{SR} + \\frac{\\gamma_4 - 1}{4}\\widehat{SR}^2}}\\right)$ (per-period Sharpe, skewness $\\gamma_3$, kurtosis $\\gamma_4$).\nDeflated Sharpe ratio: $PSR(SR_0)$ with $SR_0 = \\sqrt{V}\\left[(1-\\gamma)\\Phi^{-1}(1 - \\tfrac1N) + \\gamma\\,\\Phi^{-1}(1 - \\tfrac{1}{Ne})\\right]$, $N$ the number of configurations tried and $V$ the variance of their Sharpe ratios (Bailey & López de Prado).\n\n**Walk-forward.** On each fold the configuration with the best Sharpe ratio on the training window is held over the next test window; the stitched test windows form the out-of-sample curve.","provenance":{"data":[{"symbol":"SPY","provider":"FMP","retrievedAt":"2026-11-20T23:35:34+00:00","start":"2016-11-21","end":"2026-11-20","observations":2514,"frequency":"1d","adjusted":"split_div","currency":null}],"spec":{"symbols":["SPY"],"strategy":"ma_cross","strategy_params":{"fast":50,"slow":200},"rule":null,"years":10,"start":"2016-11-21","end":"2026-11-20","execution":"next_open","rebalance":"auto","position_size":1,"allow_short":false,"max_leverage":1,"vol_target":null,"vol_window":20,"cost_bps":5,"slippage_bps":2,"slippage_model":"fixed","financing_rate":0,"benchmark":null,"risk_free":0,"n_trials":null,"walk_forward":false,"train_days":756,"test_days":126,"sensitivity":true,"grid":null,"schedule":"daily","driftRebalance":false,"sessions":2514,"benchmarkUsed":"SPY buy & hold","configurationsEvaluated":17,"trialsForDeflatedSharpe":17,"lookAheadChecked":true,"lookAheadPassed":true,"lookAheadDates":["2020-03-24","2021-11-17","2023-07-21","2025-03-21","2026-11-19"],"survivorshipWarning":false,"look_ahead":{"checked":true,"passed":true,"method":"truncation","datesTested":5,"maxDifference":0},"leakage":false,"signal_lag":1,"signal_lag_unit":"bar","survivorship_warning":false},"seed":null,"software":{"python":"3.14.4","numpy":"2.4.6","pandas":"3.0.3","scipy":"1.17.1","statsmodels":"0.14.6","arch":"8.0.0","scikit-learn":"1.8.0"},"computedAt":"2026-11-20T23:35:35+00:00","durationMs":3838,"reproduce":"from vqlab import backtest as bt\nr = bt.run({'symbols': ['SPY'], 'strategy': 'ma_cross', 'years': 10, 'execution': 'next_open', 'rebalance': 'auto', 'position_size': 1, 'allow_short': False, 'max_leverage': 1, 'vol_window': 20, 'cost_bps': 5, 'slippage_bps': 2, 'slippage_model': 'fixed', 'financing_rate': 0, 'risk_free': 0, 'walk_forward': False, 'train_days': 756, 'test_days': 126, 'sensitivity': True, 'start': '2016-11-21', 'end': '2026-11-20'})\nprint(r[\"headline\"])\n# step by step: bars = bt.load_bars(symbols, start, end); w = bt.decisions(bars, \"ma_cross\", {'fast': 50, 'slow': 200}, P)  # decisions at each close\n#               sim = bt.simulate(bars, w, \"next_open\", cost_rate, \"daily\", False)        # orders = decisions lagged one bar"}}}}2
Files main
Menu

Theme