Skip to content

Backtest

Backtest #3

Workflow file for this run

name: Backtest
permissions:
contents: read # Default read-only (elevated permissions granted per-job)
on:
workflow_dispatch: # Manual trigger
inputs:
symbol:
description: 'Trading pair symbol'
required: true
default: 'BTCUSDT'
timeframe:
description: 'Timeframe'
required: true
default: '1h'
lookback:
description: 'Lookback days'
required: true
default: '90'
schedule:
- cron: '0 0 * * 0' # Weekly on Sunday at midnight
concurrency:
group: backtest-${{ github.event.inputs.symbol || 'BTCUSDT' }}
cancel-in-progress: true
jobs:
backtest:
runs-on: ubuntu-latest
timeout-minutes: 30
environment: testnet # Require approval for testnet API access
permissions:
contents: read # Checkout code
actions: write # Upload artifacts
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a20 # v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install dependencies (with retry)
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
with:
timeout_minutes: 5
max_attempts: 3
retry_wait_seconds: 30
command: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run backtest
env:
BINANCE_TESTNET_API_KEY: ${{ secrets.BINANCE_TESTNET_API_KEY }}
BINANCE_TESTNET_API_SECRET: ${{ secrets.BINANCE_TESTNET_API_SECRET }}
TZ: ${{ vars.TZ || 'Europe/Paris' }}
run: |
python -m src.backtest.run_backtest \
--symbol ${{ github.event.inputs.symbol || 'BTCUSDT' }} \
--timeframe ${{ github.event.inputs.timeframe || '1h' }} \
--lookback ${{ github.event.inputs.lookback || '90' }}
- name: Upload backtest artifacts
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: backtest-results-${{ github.run_number }}
path: artifacts/backtest/*.csv
retention-days: 30