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.
| Field | Type | Default | Meaning |
|---|---|---|---|
timestamp | float | β | Unix epoch seconds (UTC) of the candle |
open | float | β | Open price |
high | float | β | High price |
low | float | β | Low price |
close | float | β | Close price |
volume | float | 0.0 | Volume (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.
| Field | Type | Default | Meaning |
|---|---|---|---|
id | str | β | Trade ID returned by PocketOption buy()/sell() |
direction | str | β | "call" or "put" (string value of Direction) |
asset | str | β | Trading pair, e.g. "EURUSD" |
stake | float | β | Amount risked in $ |
confidence | float | β | Ensemble confidence at entry (fraction, 0β1) |
regime | str | β | Regime string value at entry |
entry_time | float | β | Unix epoch seconds when placed |
expiry | int | 120 | AI-chosen expiry in seconds |
result | Optional[str] | None | "win" / "loss" / "draw" once resolved |
profit | Optional[float] | None | $ profit (stake Γ 0.85 on win, βstake on loss, 0.0 on draw) |
exit_time | Optional[float] | None | Unix epoch seconds when resolved |
features_json | Optional[str] | None | Feature 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
TradeRecordmaps to thetradestable - 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.