pub struct Candle {
pub symbol: String,
pub timestamp: i64,
pub open: Decimal,
pub high: Decimal,
pub low: Decimal,
pub close: Decimal,
pub volume: Option<Decimal>,
}Expand description
Candle data structure for PocketOption price data
This represents OHLC (Open, High, Low, Close) price data for a specific time period. Note: PocketOption doesn’t provide volume data, so the volume field is always None.
Fields§
§symbol: StringTrading symbol (e.g., “EURUSD_otc”)
timestamp: i64Unix timestamp of the candle start time
open: DecimalOpening price
high: DecimalHighest price in the candle period
low: DecimalLowest price in the candle period
close: DecimalClosing price
volume: Option<Decimal>Volume is not provided by PocketOption
Implementations§
Source§impl Candle
impl Candle
Sourcepub fn update_price(&mut self, price: f64) -> BinaryOptionsResult<()>
pub fn update_price(&mut self, price: f64) -> BinaryOptionsResult<()>
Update the candle with a new price
This method updates the high, low, and close prices while maintaining the open price from the initial candle creation.
§Arguments
price- New price to incorporate into the candle
Sourcepub fn update(&mut self, timestamp: i64, price: f64) -> BinaryOptionsResult<()>
pub fn update(&mut self, timestamp: i64, price: f64) -> BinaryOptionsResult<()>
Update the candle with a new timestamp and price
This method updates the high, low, and close prices while maintaining the open price from the initial candle creation.
§Arguments
timestamp- New timestamp for the candleprice- New price to incorporate into the candle
Sourcepub fn price_range(&self) -> Decimal
pub fn price_range(&self) -> Decimal
pub fn price_range_f64(&self) -> BinaryOptionsResult<f64>
Sourcepub fn is_bullish(&self) -> bool
pub fn is_bullish(&self) -> bool
Check if the candle is bullish (close > open)
§Returns
True if the candle closed higher than it opened
Sourcepub fn is_bearish(&self) -> bool
pub fn is_bearish(&self) -> bool
Check if the candle is bearish (close < open)
§Returns
True if the candle closed lower than it opened
Sourcepub fn is_doji(&self) -> bool
pub fn is_doji(&self) -> bool
Check if the candle is a doji (close ≈ open)
§Returns
True if the candle has very little price movement
Sourcepub fn body_size(&self) -> Decimal
pub fn body_size(&self) -> Decimal
Get the body size of the candle (absolute difference between open and close)
§Returns
Body size as Decimal
Sourcepub fn body_size_f64(&self) -> BinaryOptionsResult<f64>
pub fn body_size_f64(&self) -> BinaryOptionsResult<f64>
Get the body size of the candle (absolute difference between open and close)
§Returns
Body size as f64