


I got tired of messy trading scripts, so I built a fully Dockerized algo-trading lab to test strategies mathematically before trading live.
I've been diving into quantitative finance recently. If you look at algorithmic trading online, it's full of tutorials promising guaranteed returns, usually leaving you with unstructured spaghetti code that falls apart in live markets due to slippage and fees.
I wanted to move away from guessing and build a professional "laboratory" to rigorously test strategies, and then actually deploy them. I open-sourced the resulting infrastructure as a template.
GitHub Repo: https://github.com/cbrincoveanu/algo-trading-template
Full Write-up / Research: Algorithmic Trading with VectorBT and Lumibot
My initial goal was to see if I could find "Alpha" (beat the market) using standard technical analysis on the Magnificent Seven tech stocks. I set up the environment to run hyperparameter optimizations on moving average crossovers. The lab proved exactly what the Bogleheads always say: finding true Alpha is incredibly difficult. Once you account for trade friction (fees/slippage) and avoid the trap of overfitting historical data, a simple Buy & Hold or quarterly rebalancing strategy is incredibly hard to beat.
Even though my complex strategies didn't beat the market, the infrastructure to test them is solid, and I wanted to share it so others can use it for their own research.
The repo provides a fully reproducible environment (VSCode Dev Containers / Docker) broken into distinct phases:
- Phase 1: The Research Lab. Uses VectorBT inside Jupyter Notebooks. It uses NumPy broadcasting to run thousands of backtest combinations (testing parameters, Sharpe ratios, etc.) in seconds.
- Phase 2 & 3: Event-Driven Execution. Uses Lumibot to take the validated strategy and run an event-driven backtest (simulating realistic market ticks and slippage), and then deploy it live.
- Broker: Pre-configured for Alpaca (Paper & Live trading via
.envcredentials).
I've included a "Magnificent Seven" simple rebalancing strategy out-of-the-box so you can see how the pipeline works:
- Test your hypothesis in the
notebooks/folder. - Implement it as a production-ready class in the
strategies/folder. - Run
python run_backtest.pyto get an industry-standard tearsheet of your strategy's performance. - Run
python run_live.pyto deploy the bot.
I’d love to hear your feedback, code reviews, or thoughts on what else would make a quantitative template like this useful!