Skip to content

E2E Backtest Runner Scripts

Convenience scripts to run E2E backtests against the AWS dev environment from local machines.

First Time Setup (macOS)

Configure the AWS SSO profile:

aws configure sso --profile tradai

Use these values:

SSO start URL:  https://d-99675533ed.awsapps.com/start
SSO Region:     eu-central-1
Account:        600802701449 (dev)
Default region: eu-central-1
Output:         json

Usage

macOS / Linux

chmod +x scripts/e2e-backtest.sh
./scripts/e2e-backtest.sh

Windows

scripts\e2e-backtest.bat

Custom Parameters

Both scripts accept the same positional arguments:

e2e-backtest[.sh|.bat] [strategy] [start_date] [end_date]

Examples:

# Default: StochRsiStrategy, 2025-01-01 to 2025-02-01
./scripts/e2e-backtest.sh

# Custom strategy and date range
./scripts/e2e-backtest.sh StochRsiStrategy 2025-03-01 2025-03-31

What the Script Does

  1. Checks AWS SSO authentication (logs in if session expired)
  2. Verifies backend API is reachable
  3. Submits backtest via POST /api/v1/backtests
  4. Polls for completion every 10 seconds (5 min timeout)
  5. Prints result summary: trades, win rate, profit, Sharpe ratio, max drawdown

Typical run takes about 60 seconds.

Output Example

========================================
 TradAI E2E Backtest Runner
========================================
 Strategy:   StochRsiStrategy
 Symbol:     BTC/USDT:USDT
 Timeframe:  1h
 Range:      2025-01-01 to 2025-02-01
 Stake:      1000.0 USDT
 Task Def:   tradai-strategy-stochrsi-dev
========================================

[1/4] Checking AWS authentication...
 OK

[2/4] Checking backend health...
 OK

[3/4] Submitting backtest...
 Submitted! Job ID: 282f7b79-0909-46b3-906c-6783ab9a5fe7

[4/4] Polling for results (timeout: 300s)...

 [10s] Status: pending...
 [20s] Status: running...
 COMPLETED in 60s

========================================
 RESULTS
========================================
  Trades: 73 (W:43 L:30)
  Win Rate: 58.9%
  Profit: -4.83%
  Sharpe: -18.272824265770353
  Max DD: $501.84783593999987

Retrieving Full Results

After the script completes, use the printed curl commands to get detailed data:

# Full backtest result (all trades, metrics)
curl -s http://tradai-dev-1942285475.eu-central-1.elb.amazonaws.com/api/v1/backtests/<JOB_ID> | python3 -m json.tool

# Equity curve, drawdown, monthly returns
curl -s http://tradai-dev-1942285475.eu-central-1.elb.amazonaws.com/api/v1/backtests/<JOB_ID>/equity | python3 -m json.tool

Prerequisites

  • AWS CLI v2 with SSO support
  • curl
  • Python 3 (used for JSON parsing)
  • Access to AWS dev account (600802701449)