Skip to main content

Candle

Struct Candle 

Source
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: String

Trading symbol (e.g., “EURUSD_otc”)

§timestamp: i64

Unix timestamp of the candle start time

§open: Decimal

Opening price

§high: Decimal

Highest price in the candle period

§low: Decimal

Lowest price in the candle period

§close: Decimal

Closing price

§volume: Option<Decimal>

Volume is not provided by PocketOption

Implementations§

Source§

impl Candle

Source

pub fn new( symbol: String, timestamp: i64, price: f64, ) -> BinaryOptionsResult<Self>

Create a new candle with initial price

§Arguments
  • symbol - Trading symbol
  • timestamp - Unix timestamp for the candle start
  • price - Initial price (used for open, high, low, close)
§Returns

New Candle instance with all OHLC values set to the initial price

Source

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
Source

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 candle
  • price - New price to incorporate into the candle
Source

pub fn price_range(&self) -> Decimal

Get the price range (high - low) of the candle

§Returns

Price range as Decimal

Source

pub fn price_range_f64(&self) -> BinaryOptionsResult<f64>

Source

pub fn is_bullish(&self) -> bool

Check if the candle is bullish (close > open)

§Returns

True if the candle closed higher than it opened

Source

pub fn is_bearish(&self) -> bool

Check if the candle is bearish (close < open)

§Returns

True if the candle closed lower than it opened

Source

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

Source

pub fn body_size(&self) -> Decimal

Get the body size of the candle (absolute difference between open and close)

§Returns

Body size as Decimal

Source

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

Source

pub fn upper_shadow(&self) -> Decimal

Get the upper shadow length

§Returns

Upper shadow length as Decimal

Source

pub fn upper_shadow_f64(&self) -> BinaryOptionsResult<f64>

Get the upper shadow length

§Returns

Upper shadow length as f64

Source

pub fn lower_shadow(&self) -> Decimal

Get the lower shadow length

§Returns

Lower shadow length as Decimal

Source

pub fn lower_shadow_f64(&self) -> BinaryOptionsResult<f64>

Get the lower shadow length

§Returns

Lower shadow length as f64

Source

pub fn datetime(&self) -> DateTime<Utc>

Convert timestamp to DateTime<Utc>

§Returns

DateTime<Utc> representation of the candle timestamp

Trait Implementations§

Source§

impl Clone for Candle

Source§

fn clone(&self) -> Candle

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Candle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Candle

Source§

fn default() -> Candle

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Candle

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Candle

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<(BaseCandle, String)> for Candle

Source§

type Error = BinaryOptionsError

The type returned in the event of a conversion error.
Source§

fn try_from(value: (BaseCandle, String)) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<CandleData> for Candle

Source§

type Error = BinaryOptionsError

The type returned in the event of a conversion error.
Source§

fn try_from(candle_data: CandleData) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,