PO_RETRAIN

๐Ÿฆ‰ 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

Force-retrain flag. When set to exactly 1, the bot deletes the saved brain file at startup and rebuilds its models from the trade journal and dataset.

Typeflag (1 = on, anything else = off)
Default(unset โ€” off)
RequiredNo
Maps to(no BotConfig field)
Read insrc/bot.py (AITradingBot.start())

What it does

Unlike every other variable on this reference, PO_RETRAIN is not read in main.pyโ€™s build_config() and has no BotConfig field. It is read directly inside AITradingBot.start() in src/bot.py:

force_retrain = os.environ.get("PO_RETRAIN", "").strip() == "1"

The value is whitespace-stripped and must be exactly "1". true, yes, on, etc. are all treated as off. Because main.py runs _load_dotenv() before starting the bot, a PO_RETRAIN=1 line in .env works too (unless a real environment variable already sets it to something else โ€” real env vars win).

When the flag is on:

  1. The bot logs ๐Ÿ”„ Force retrain requested โ€” ignoring saved brain.
  2. If the file at PO_BRAIN_PATH exists, it is deleted with os.remove(). This is destructive and immediate โ€” back the file up first if you might want it back. The sibling *_expiry.pkl stats file is not deleted, but it is not loaded either (loading only happens inside _load_brain(), which is skipped).
  3. _load_brain() is skipped, so the bot follows the fresh-start path: replay past trades from the SQLite journal (_reload_from_journal()), then pre-train from PO_DATASET if set. The newly trained brain is saved back to PO_BRAIN_PATH when pre-training finishes.

When the flag is off (unset or any value other than 1), the bot tries to load the existing brain and only falls back to journal replay plus dataset training if loading fails.

The old *_expiry.pkl file will be loaded again on the next normal start (after the retrain run rewrites the brain), so expiry statistics effectively survive a forced retrain via the re-saved sibling file.

Valid values

ValueEffect
1 (exactly, after stripping whitespace)Delete saved brain, retrain from journal + dataset
unset, empty, or anything elseNormal startup โ€” load saved brain if present

Examples

Usually set for a single run rather than persisted:

PO_RETRAIN=1 python main.py
$env:PO_RETRAIN = '1'; python main.py; Remove-Item Env:PO_RETRAIN
# .env โ€” remember to remove this line afterwards,
# or every restart will delete the brain and retrain!
PO_RETRAIN=1

Leaving PO_RETRAIN=1 in .env permanently means every start deletes the brain and re-runs pre-training โ€” slow and it discards all live-trading learning that accumulated in the brain since the last journal write.

Interactions

See also

๐Ÿ’ฌ Unsure how this interacts with the rest of the configuration? Ask in the Chipa Discord โ€” or prototype strategies no-code with ChipaEditor.