Diego Ringleb’s Post

Most backtests are quietly lying to you - and look-ahead bias is why. Built a vectorized SMA crossover backtesting engine in Python that makes results much closer to real trading outcomes. Every crossover signal is shifted by one day, so a signal on day N only enters on day N+1, no trades based on information from the future. The engine uses pandas.rolling() with boolean masking instead of row-by-row iteration, keeping signal generation at O(n) complexity. On AAPL from 2020 to 2024, a simple SMA 20/50 strategy returned 69.08% vs. 180% buy-and-hold, with a Sharpe of ~0.45 and a max drawdown of ~-18%. Most of this came together during long flights to and from South Africa, which turned into surprisingly productive coding time at 35,000 feet. The architecture is split into four modules: data_loader, strategy, backtest, and visualizer, with yfinance as the data layer and CSV caching to cut redundant API calls. The goal is a modular setup where strategies can be swapped without touching the backtesting core. Repo is open source: https://lnkd.in/dgavp8DG #Quant #AlgoTrading #Python #Backtesting #QuantFinance #OpenSource

To view or add a comment, sign in

Explore content categories