Struct yata::core::Candle

source ·
pub struct Candle {
    pub open: ValueType,
    pub high: ValueType,
    pub low: ValueType,
    pub close: ValueType,
    pub volume: ValueType,
}
Expand description

Simple Candlestick structure for implementing OHLCV

Can be also used by an alias Candlestick

You may convert simple tuples of 4 or 5 float values into Candle:

use yata::prelude::Candle;
//               open  high  low  close
let my_candle = (3.0,  5.0,  2.0, 4.0  );
let converted: Candle = my_candle.into();
println!("{:?}", converted);
use yata::prelude::Candle;
//               open  high  low  close  volume
let my_candle = (3.0,  5.0,  2.0, 4.0  ,  50.0 );
let converted: Candle = my_candle.into();
println!("{:?}", converted);

Fields§

§open: ValueType

Open value of the candle

§high: ValueType

High value of the candle

§low: ValueType

Low value of the candle

§close: ValueType

Close value of the candle

§volume: ValueType

Volume value of the candle

Implementations§

source§

impl Candle

source

pub fn from<T: OHLCV + ?Sized>(src: &T) -> Self

Creates Candle from any another OHLCV-object.

Trait Implementations§

source§

impl<T: OHLCV> Add<T> for Candle

§

type Output = Candle

The resulting type after applying the + operator.
source§

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
source§

impl Clone for Candle

source§

fn clone(&self) -> Candle

Returns a copy 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 From<&(dyn OHLCV + 'static)> for Candle

source§

fn from(src: &dyn OHLCV) -> Self

Converts to this type from the input type.
source§

impl From<(f64, f64, f64, f64)> for Candle

source§

fn from(value: (ValueType, ValueType, ValueType, ValueType)) -> Self

Converts to this type from the input type.
source§

impl From<(f64, f64, f64, f64, f64)> for Candle

source§

fn from(value: (ValueType, ValueType, ValueType, ValueType, ValueType)) -> Self

Converts to this type from the input type.
source§

impl OHLCV for Candle

source§

fn open(&self) -> ValueType

Should return an open value of the period
source§

fn high(&self) -> ValueType

Should return an highest value of the period
source§

fn low(&self) -> ValueType

Should return an lowest value of the period
source§

fn close(&self) -> ValueType

Should return an close value of the candle
source§

fn volume(&self) -> ValueType

Should return volume value for the period
source§

fn tp(&self) -> ValueType

Calculates Typical price. It’s just a simple (High + Low + Close) / 3 Read more
source§

fn hl2(&self) -> ValueType

Calculates arithmetic average of high and low values of the candle Read more
source§

fn ohlc4(&self) -> ValueType

Calculates arithmetic average of high, low, open and close values of the candle Read more
source§

fn clv(&self) -> ValueType

CLV = [(close - low) - (high - close)] / (high - low) Read more
source§

fn tr(&self, prev_candle: &dyn OHLCV) -> ValueType

Calculates True Range over last two candles Read more
source§

fn tr_close(&self, prev_close: ValueType) -> ValueType

Calculates True Range over last two candles using close price from the previous candle.
source§

fn validate(&self) -> bool

Validates candle attributes Read more
source§

fn source(&self, source: Source) -> ValueType

Returns Source field value of the candle. Read more
source§

fn volumed_price(&self) -> ValueType

Volumed price Read more
source§

fn is_rising(&self) -> bool

Checks if candle is “rising”: it’s close value greater than open value
source§

fn is_falling(&self) -> bool

Checks if candle is “falling”: it’s close value smaller than open value
source§

impl PartialEq for Candle

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Candle

source§

fn partial_cmp(&self, other: &Candle) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. 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 Copy for Candle

source§

impl Eq for Candle

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,