retrain_every
π¦ 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
How many resolved live trades the bot accumulates before calling partial_fit() on the online-learning ensemble.
This field has no environment variable β to change it, edit the default in src/config.py or construct BotConfig yourself.
| Type | int |
| Default | 10 |
| Field | BotConfig.retrain_every |
| Consumed in | src/bot.py (AITradingBot._result_checker) |
What it does
When a pending trade resolves as a win or loss, _result_checker in src/bot.py converts the outcome into a training label (win β the predicted direction was correct; loss β the opposite direction was correct), adds the stored feature vector as a sample, and increments a counter:
self.ensemble.add_sample(features, label)
self._samples_since_fit += 1
...
if self._samples_since_fit >= self.cfg.retrain_every:
self.ensemble.partial_fit()
self._samples_since_fit = 0
So retrain_every counts resolved trades (wins and losses only β draws produce no sample) between incremental partial_fit() calls on the ensembleβs online models (SGD, Passive-Aggressive, Naive Bayes). Buffered samples are not learned from until the fit runs.
This counter only governs the online models. The batch models (GBM/RF) are retrained on a separate schedule in the same function: once the batch buffer reaches 200 samples and every 100 samples thereafter, on a sliding window of the last 500 samples. That schedule is hard-coded and not affected by retrain_every.
Note the same field name does not control dataset pre-training (_load_dataset fits every 5000 samples) or journal reload (one fit after loading).
Valid values
Any positive integer.
- Lower values (e.g.
1β5): the model adapts faster to recent results but each fit is on fewer samples, so updates are noisier. - Higher values (e.g.
20β50): smoother, slower adaptation; recent trade outcomes take longer to influence predictions.
Examples
# src/config.py
retrain_every: int = 5 # partial_fit after every 5 resolved tradesfrom src.config import BotConfig
cfg = BotConfig(ssid="...", retrain_every=5)Interactions
- Trade frequency (gated by
min_wait_between_trades,trading_hours, confidence gates) determines how quicklyretrain_everytrades accumulate in wall-clock time. - The learned state is persisted via
PO_BRAIN_PATH(auto-saved every 10 resolved trades) and the trade journal atdb_path, which is replayed on restart.
See also
π¬ Unsure how this interacts with the rest of the configuration? Ask in the Chipa Discord β or prototype strategies no-code with ChipaEditor.