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
| Flag | Default | Purpose |
|---|---|---|
--data | EURUSD_M1.csv | Input candle CSV (HistData or headered format) |
--out | athena_brain.pkl | Output brain file the bot loads |
--timeframe | 60 | Candle period of the dataset, in seconds |
--expiry | 300 | Trade expiry to label for, in seconds |
--window | 20 | Rolling feature window, in candles |
--lookback | 200 | Max candle history per feature vector |
--max-candles | 500000 | Use at most the N most recent candles |
--test-split | 0.30 | Fraction (0โ1) held out for walk-forward testing |
--no-nn | off | Skip the neural model; sklearn ensemble only |
--cpu | off | Force CPU even if a GPU is available |
--epochs | 30 | Neural model training epochs |
--batch-size | 2048 | Neural model mini-batch size |
--lr | 0.001 | Neural model learning rate (AdamW) |
--hidden | 128,64 | Neural hidden layer sizes, comma-separated |
--check-gpu | off | Print 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 code0(main()returns 0, raised viaSystemExit). - The trainer aborts via
SystemExitwith 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.
- fewer than 50 candles are parsed from
- 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
- ๐ฆ Get AthenaAI on GitLab โ โ clone the source, open issues, and contribute improvements.
- ๐ฌ Join the Chipa Discord โ โ get real-time support, share your results, and swap strategy ideas with other AthenaAI users.
- โก Try ChipaEditor โ โ build, backtest, and deploy trading strategies without writing a line of code, with our AI-powered strategy editor.