src.utils.candle

πŸ¦‰ 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/utils/candle.py. Two plain dataclasses with no methods.

@dataclass Candle

One OHLCV bar.

FieldTypeDefaultMeaning
timestampfloatβ€”Unix epoch seconds (UTC) of the candle
openfloatβ€”Open price
highfloatβ€”High price
lowfloatβ€”Low price
closefloatβ€”Close price
volumefloat0.0Volume (0 when the feed has none β€” volume features then use neutral fallbacks)

Produced by AITradingBot._parse_candle() (live feed, see bot.md) and src.training.dataset.load_candles() (CSV, see dataset.md); consumed by FeatureEngine.compute() and RegimeDetector.detect().

@dataclass TradeRecord

One placed trade, updated in place when its result arrives.

FieldTypeDefaultMeaning
idstrβ€”Trade ID returned by PocketOption buy()/sell()
directionstrβ€”"call" or "put" (string value of Direction)
assetstrβ€”Trading pair, e.g. "EURUSD"
stakefloatβ€”Amount risked in $
confidencefloatβ€”Ensemble confidence at entry (fraction, 0–1)
regimestrβ€”Regime string value at entry
entry_timefloatβ€”Unix epoch seconds when placed
expiryint120AI-chosen expiry in seconds
resultOptional[str]None"win" / "loss" / "draw" once resolved
profitOptional[float]None$ profit (stake Γ— 0.85 on win, βˆ’stake on loss, 0.0 on draw)
exit_timeOptional[float]NoneUnix epoch seconds when resolved
features_jsonOptional[str]NoneFeature vector at entry, JSON-encoded list β€” this is what the journal reload retrains from

Internals note: src/bot.py additionally attaches two dynamic, non-declared attributes after placing a trade β€” record._features (the raw np.ndarray) and record._direction_int (1 for CALL, 0 for PUT). These are used by _result_checker() for online learning and are never persisted; only features_json reaches the database (journal.md).

Usage

from src.utils.candle import Candle, TradeRecord

c = Candle(timestamp=1720569600.0, open=1.0812, high=1.0815,
           low=1.0810, close=1.0814, volume=132.0)
t = TradeRecord(id="abc123", direction="call", asset="EURUSD",
                stake=25.0, confidence=0.66, regime="ranging",
                entry_time=1720569660.0, expiry=300)

See also

  • journal.md β€” how TradeRecord maps to the trades table
  • bot.md β€” lifecycle of a TradeRecord

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