train.py CLI reference

๐Ÿฆ‰ AthenaAI is an AI-powered ensemble machine-learning trading bot for PocketOption, built on BinaryOptionsToolsV2 โ†’ Get it on GitLab
๐Ÿ’ฌ Need help? Join the Chipa Discord ยท โšก Go no-code with ChipaEditor

train.py is the standalone trainer. It reads a historical candle CSV, trains the full ensemble (online sklearn models, batch GBM/RF, and an optional PyTorch neural model), runs a walk-forward evaluation, and saves a brain file that main.py loads at startup via PO_BRAIN_PATH. No PocketOption connection is needed.

For a task-oriented walkthrough see the training guide. For accepted CSV layouts see data formats.

Synopsis

python train.py [--data PATH] [--out PATH]
                [--timeframe SECONDS] [--expiry SECONDS]
                [--window CANDLES] [--lookback CANDLES]
                [--max-candles N] [--test-split FRACTION]
                [--no-nn] [--cpu]
                [--epochs N] [--batch-size N] [--lr FLOAT] [--hidden SIZES]
                [--check-gpu]

All flags are optional. Each maps to a field of TrainerConfig (src/training/trainer.py), which Trainer.run() consumes.

Flags

FlagDefaultPurpose
--dataEURUSD_M1.csvInput candle CSV (HistData or headered format)
--outathena_brain.pklOutput brain file the bot loads
--timeframe60Candle period of the dataset, in seconds
--expiry300Trade expiry to label for, in seconds
--window20Rolling feature window, in candles
--lookback200Max candle history per feature vector
--max-candles500000Use at most the N most recent candles
--test-split0.30Fraction (0โ€“1) held out for walk-forward testing
--no-nnoffSkip the neural model; sklearn ensemble only
--cpuoffForce CPU even if a GPU is available
--epochs30Neural model training epochs
--batch-size2048Neural model mini-batch size
--lr0.001Neural model learning rate (AdamW)
--hidden128,64Neural hidden layer sizes, comma-separated
--check-gpuoffPrint the detected training device and exit

--help prints all flags with their defaults (the parser uses argparse.ArgumentDefaultsHelpFormatter).

Exit behavior

  • Successful training (and --check-gpu) exits with code 0 (main() returns 0, raised via SystemExit).
  • The trainer aborts via SystemExit with an error message when:
    • fewer than 50 candles are parsed from --data: Dataset too small (N candles).
    • fewer than 200 valid samples remain after feature generation: Only N valid samples โ€” need at least 200.
  • If the holdout set has fewer than 100 samples, the walk-forward test is skipped with a warning, but training still completes and the brain is saved.
  • If PyTorch is not installed, the neural model is skipped with an informational log line; the sklearn ensemble still trains and the run succeeds.

Examples

Train from a HistData M1 export for 2-minute trades and save an asset-specific brain:

python train.py --data GBPUSD_M1.csv --out brains/gbpusd.pkl --expiry 120

Fast CPU-only iteration on a capped dataset, skipping the neural model:

python train.py --data EURUSD_M1.csv --max-candles 100000 --no-nn

Longer neural training with a wider network:

python train.py --epochs 60 --hidden 256,128,64 --lr 5e-4 --batch-size 1024

Check what device the neural model would train on:

python train.py --check-gpu
# Device: cuda  (GPU: NVIDIA GeForce RTX 4070 (12.0 GB VRAM))

See also


Level Up Your AthenaAI Setup