main
๐ฆ 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
Source: main.py. The live-trading entry point. It reads configuration exclusively from environment variables (optionally loaded from a .env file), constructs a BotConfig, and runs AITradingBot under asyncio.run(). No secrets live in source code โ the PocketOption session ID must come from the PO_SSID environment variable (see PO_SSID).
Functions
_load_dotenv(path: str = ".env") -> None
Minimal .env loader with no external dependency.
| Parameter | Type | Default | Meaning |
|---|---|---|---|
path | str | ".env" | Path to the dotenv file |
Behavior:
- Returns silently if
pathis not a file. - Reads the file as UTF-8, line by line. Skips blank lines, lines starting with
#, and lines without=. - Splits on the first
=; strips whitespace and surrounding single/double quotes from the value. - Uses
os.environ.setdefault(...)โ real environment variables always win over.envvalues. Side effect: mutatesos.environ.
Edge cases: no interpolation, no export prefix support, no multi-line values. A malformed line is simply skipped.
_int_tuple(raw: str, fallback: tuple) -> tuple
Parses a comma-separated string of integers (e.g. "120,300,600") into a tuple.
| Parameter | Type | Default | Meaning |
|---|---|---|---|
raw | str | โ | Comma-separated integers; empty items are ignored |
fallback | tuple | โ | Returned when raw is empty or unparseable |
Returns the parsed tuple, or fallback if the result is empty. On ValueError it prints Warning: could not parse '<raw>', using <fallback> to stdout and returns fallback. Used only for PO_EXPIRY_OPTIONS.
build_config() -> BotConfig
Builds a BotConfig from environment variables. Only these fields are settable via the environment; everything else keeps the dataclass default from src/config.py:
| Env var | BotConfig field | Default used here |
|---|---|---|
PO_SSID | ssid | "" |
PO_ASSET | asset | "EURUSD" |
PO_TIMEFRAME | timeframe | 60 (seconds) |
PO_EXPIRY_OPTIONS | expiry_options | (120, 300, 600) (seconds) |
PO_DEFAULT_EXPIRY | default_expiry | 300 (seconds) |
PO_BASE_STAKE | base_stake | 25.0 ($) |
PO_MAX_STAKE | max_stake | 100.0 ($) |
PO_MIN_CONF | min_confidence | 0.63 (fraction) |
PO_MAX_CONF | max_confidence | 0.85 (fraction) |
PO_MAX_DAILY_LOSS | max_daily_loss | 300.0 ($) |
PO_DATASET | dataset_path | "EURUSD_M1.csv" |
PO_BRAIN_PATH | brain_path | "athena_brain.pkl" |
PO_REQUIRE_ALIGNMENT | require_indicator_alignment | True (any value other than "0" enables it) |
Note: PO_DATASET and PO_BRAIN_PATH defaults here ("EURUSD_M1.csv", "athena_brain.pkl") override the BotConfig dataclass defaults ("", "athena_po_brain.pkl"). PO_RETRAIN is not read here โ it is read directly by AITradingBot.start() (see bot.md).
Failure behavior: int(...)/float(...) conversions raise ValueError unhandled if an env var contains a non-numeric value; the process exits with a traceback.
main() -> int
- Calls
_load_dotenv()(default.envin the working directory). - Calls
build_config(). - If
config.ssidis empty, prints an error withexport/$env:examples to stderr and returns1. - Otherwise constructs
AITradingBot(config)and runsasyncio.run(bot.start()). - On
KeyboardInterrupt(Ctrl+C), printsInterrupted, shutting down...and runsasyncio.run(bot.stop())โ which saves the brain file to disk (side effect; see bot.md).
Returns 0 on normal shutdown, 1 when PO_SSID is missing.
The module guard is raise SystemExit(main()), so the return value becomes the process exit code.
Usage
export PO_SSID='your-session-id'
export PO_ASSET='EURUSD'
python main.py$env:PO_SSID='your-session-id'
python main.pySee also
- Environment variable reference
- bot.md โ what
start()actually does - Quickstart
๐ฌ Unsure how this interacts with the rest of the configuration? Ask in the Chipa Discord โ or prototype strategies no-code with ChipaEditor.