This project is a REST API built in Python for backtesting various trading strategies. It’s designed to run as an AWS Lambda function, making it scalable and serverless. The API allows traders and developers to send JSON requests specifying a strategy, asset(s), and parameters, and then receive backtest results.
Inputs: asset, start/end dates, entry/exit thresholds, investment percentage.
Detects momentum shifts in assets using MACD crossover signals.
Sample Request:
{
"strategy": "macd",
"asset": "AAPL",
"start_date": "2025-01-01",
"end_date": "2025-06-30",
"entry_threshold": 25,
"exit_threshold": 50,
"investment_percentage": 20
}Inputs: asset, investment percentage, start/end dates.
Identifies when an asset price breaks above resistance levels.
Sample Request:
{
"strategy": "breakout",
"ticker": "TSLA",
"investment_percentage": 20,
"start_date": "2025-08-18",
"end_date": "2025-08-25"
}Inputs: two related assets, start/end dates, moving window, entry/exit thresholds.
Exploits temporary mispricing between correlated assets.
Sample Request:
{
"strategy": "pairs",
"asset1": "BTC-EUR",
"asset2": "BTC-USD",
"start_date": "2024-02-21",
"end_date": "2025-02-21",
"window": 5,
"entry_threshold": 1,
"exit_threshold": 0.5
}Inputs: a portfolio of assets with target weights and rebalance frequency.
Simulates rebalancing over time to maintain allocation discipline.
In this strategy we also tested implementing spread and slippage percentage for a more realistic backtest.
Sample Request:
{
"strategy": "rebalance",
"tickers": ["AMD", "NVDA", "MSFT"],
"start_date": "2024-10-01",
"end_date": "2024-12-31",
"returns_weight": 0.6,
"m": 2,
"x": 1,
"slippage_pct": 0.05,
"spread_pct": 0.01
}Make commits to main and raise a PR on GitHub to merge changes into production. This will trigger Github actions to rebuild the Docker image, push it to AWS ECR and update the Lambda function.