#!/usr/bin/env bash # # Run / backtest a compiled .algo headlessly using Spotware's OFFICIAL cTrader CLI # Docker image — no cTrader desktop GUI, no Windows. Available since cTrader 5.4. # # This is a thin wrapper: it mounts your built .algo files (dist/) into the # container at /mnt/Robots and forwards all arguments to the cTrader console. # # Discover the exact subcommands/flags for your image version first: # # ./scripts/run-console.sh --help # # Then backtest or run, e.g. (flag names follow the container's --help output): # # ./scripts/run-console.sh backtest --robot SmaCrossOverBot.algo \ # --symbol EURUSD --period h1 --start 2024-01-01 --end 2024-06-01 \ # --balance 10000 # # Live trading additionally needs cTrader ID credentials passed to the console. # # Official image + documented commands: # https://github.com/spotware/ctrader-console-docker # set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" IMAGE="${CTRADER_CONSOLE_IMAGE:-ghcr.io/spotware/ctrader-console:latest}" if ! command -v docker >/dev/null 2>&1; then echo "docker not found — install Docker to run the cTrader console image." >&2 exit 1 fi docker pull "$IMAGE" exec docker run --rm -it \ -v "$REPO_ROOT/dist:/mnt/Robots" \ "$IMAGE" "$@"