Noureddine RAMDI / QSTrader: a modular, schedule-driven Python framework for systematic equity backtesting

Created Sat, 23 May 2026 20:41:14 +0000 Modified Sat, 23 May 2026 20:41:27 +0000

mhallsmoore/qstrader

QSTrader is a schedule-driven backtesting framework written in Python, designed specifically for systematic trading strategies focused on long-short equities and ETFs. It stands out by enforcing a modular architecture that cleanly separates the different stages of systematic trading: signal generation, portfolio construction, risk management, execution, and simulated brokerage. This modularity allows quants and developers to swap out or customize any component independently without altering the rest of the system.

Under the hood, QSTrader operates primarily on daily OHLC (open-high-low-close) bar data, typically sourced from CSV files such as those downloaded from Yahoo Finance. Its architecture supports calendar-based rebalancing schedules, which means portfolio updates occur on fixed dates (e.g., monthly or quarterly), rather than reacting to every tick or event. This design choice simplifies the modeling of many common systematic strategies that rely on daily data and scheduled portfolio adjustments.

QSTrader targets Python versions 3.9 through 3.12 and is MIT-licensed, making it free and open for both research and commercial use. The project is maintained by QuantStart.com and serves as the engine behind the Advanced Algorithmic Trading ebook, providing a practical codebase for learning and experimentation.

modular architecture for clear separation of trading components

What distinguishes QSTrader is how it decouples the essential components of a systematic trading system. Instead of having a monolithic backtesting engine, it defines independent modules responsible for:

  • Signal generation: The logic that decides when to buy, sell, or hold based on input data.
  • Portfolio construction: How signals translate into actual portfolio positions, including sizing and allocation.
  • Risk management: Overseeing exposure limits, stop-loss rules, or other constraints.
  • Execution: Simulating order placement and fills.
  • Simulated brokerage: Modeling brokerage specifics like commissions and slippage.

Each module can be replaced or extended without touching others, enabling flexible experimentation. For example, you could swap the risk management module with a more sophisticated one or plug in a different execution simulator for slippage modeling.

The code is surprisingly clean and Pythonic, emphasizing separation of concerns and extensibility. This modularity also means there is no built-in support for event-driven or tick-level simulation, which is a tradeoff. The framework is optimized for daily data and schedule-driven rebalancing, which covers a large portion of quant trading use cases but is not suitable for ultra-high-frequency trading.

QSTrader also includes built-in tearsheet performance analytics with JSON export, simplifying the evaluation of strategy results.

quick start with a classic 60/40 portfolio example

Getting started with QSTrader is straightforward. The repository includes example strategies under the /examples directory. One provided example is a classic 60/40 equities/bonds portfolio strategy that rebalances monthly on the last trading day of the calendar month.

To run this example:

  1. Download the sixty_forty.py example script.
  2. Obtain daily OHLC CSV data for the SPY (equities) and AGG (bonds) ETFs from Yahoo Finance, saving these files in the same directory as the script.

The installation can be done either using Anaconda’s conda tool or Python’s venv, as shown by the exact commands below:

conda create -n backtest python
# or to specify python version
conda create -n backtest python==3.9

conda activate backtest
pip3 install qstrader

Alternatively:

python -m venv backtest
source backtest/bin/activate  # activate the environment
pip3 install qstrader

Once dependencies are installed, you can run the backtest by executing the example script in your activated environment. This simple setup demonstrates how easy it is to simulate a basic, schedule-driven portfolio using real historical data.

verdict: solid for daily bar systematic strategies with modular flexibility

QSTrader is a well-structured, modular backtesting framework that fits a specific niche: daily OHLC bar data-driven, schedule-based portfolio strategies. Its architecture promotes clear separation of trading concerns, making it a good choice for quants who want to build or experiment with systematic long-short equity or ETF strategies without getting bogged down in event-driven complexity.

The main limitation is its focus on daily bars and schedule-driven rebalancing. If you need tick-level simulation, event-driven frameworks like Backtrader or Zipline might be more appropriate. However, for many quant researchers and algo traders working at daily granularity, QSTrader’s modular design and clear interfaces offer a maintainable and extensible platform.

The provided installation and example scripts make it easy to get started quickly, and the MIT license encourages adoption in both academic and commercial settings. If your strategy research aligns with its data and architectural assumptions, QSTrader is worth a look.


→ GitHub Repo: mhallsmoore/qstrader ⭐ 3,379 · Python