
SMA Crossover Strategy for E-mini S&P 500
This project implements and evaluates an algorithmic trading strategy based on a Simple Moving Average (SMA) crossover for E-mini S&P 500 (ES) futures. It uses
nautilus-trader for backtesting and databento for high-quality historical data.Features
Strategy: Crossover of a fast (20-period) and a slow (50-period) SMA.
Instrument: E-mini S&P 500 Futures.
Timeframe: 1-minute data.
Backtest Period: 2024.
Tech Stack: Python, NautilusTrader, Databento, Pandas.
1. Prerequisites
Python 3.11 or higher.
A Databento API key (the free plan is sufficient).
2. Installation
Clone the Repository
Create and Activate a Virtual Environment (Recommended)
Install Dependencies The
requirements.txt file contains all the necessary libraries.3. Configuration
Set up the Databento API Key You must set your API key as an environment variable.
Windows (Command Prompt):
Windows (PowerShell):
macOS/Linux:
Replace
"YOUR_API_KEY" with the key you obtained from Databento.(Optional) Adjust Strategy Parameters You can modify parameters such as the SMA periods, trade size, or instrument ID directly in the
run_backtest.py file.4. Running the Backtest
The process is divided into two main steps:
Step 1: Download Data
The
data_handler.py script downloads the data for the quarterly ES futures contracts for 2024 and consolidates them into a single Parquet file.The data will be saved in
data/raw/ES_2024.parquet.Step 2: Run the Backtest
Once the data is ready, the
run_backtest.py script runs the strategy simulation.5. Results
The backtest results (PnL, number of trades, etc.) are saved in
results/backtest_results.csv.For a detailed analysis of the strategy's performance, design decisions, and potential improvements, please refer to the full report at STRATEGY_REPORT.md.
6. Project Structure
7. Useful Resources
0 likes · 8 views · Oct 7, 2025
Implemented SMA crossover strategy for E-mini S&P 500 using NautilusTrader and Databento.
Timeline
Dec 31, 2023 - Dec 30, 2024