src.core.regime
๐ฆ 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: src/core/regime.py. A single stateless class with one static method.
class RegimeDetector
detect(candles: list[Candle], window: int = 30) -> Regime (static)
| Parameter | Type | Default | Meaning |
|---|---|---|---|
candles | list[Candle] | โ | Chronological candles; only the last window are used |
window | int | 30 | Number of candles analysed (the bot passes BotConfig.regime_window, default 30) |
Returns a Regime enum. If len(candles) < window, returns Regime.RANGING immediately (safe default).
Algorithm, with the v6-calibrated thresholds for 1-minute EURUSD (older thresholds 0.005/0.002 classified everything as ranging):
- Compute per-candle returns
rets = diff(closes) / closes[:-1]. vol = std(rets). Ifvol > 0.0008โRegime.VOLATILE(checked first โ volatility wins over trend).- Fit a linear trend (
np.polyfitdegree 1) over the closes; normalise:rel_trend = slope / last_close * window(roughly the fractional price change over the window). rel_trend > 0.0003โTRENDING_UP;< -0.0003โTRENDING_DOWN; otherwiseRANGING.
No side effects, no logging, no state. Thresholds are hard-coded โ retune them in source for other assets/timeframes.
How it is used
src/bot.py_trade_loop(): detected each iteration; aVOLATILEresult skips the trade whenskip_volatile_regimeis enabled, and the regime string is recorded on every trade and fed toAdaptiveStrategy.ExpirySelector.select(): regime is the highest-weighted scoring input.
Usage example
from src.core.regime import RegimeDetector
regime = RegimeDetector.detect(candles, window=30)
print(regime.value) # e.g. "trending_up"See also
๐ฌ Unsure how this interacts with the rest of the configuration? Ask in the Chipa Discord โ or prototype strategies no-code with ChipaEditor.