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
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Candle
impl<'de> Deserialize<'de> for Candle
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl OHLCV for Candle
impl OHLCV for Candle
sourcefn tp(&self) -> ValueType
fn tp(&self) -> ValueType
Calculates Typical price.
It’s just a simple (High
+ Low
+ Close
) / 3
Read more
sourcefn hl2(&self) -> ValueType
fn hl2(&self) -> ValueType
Calculates arithmetic average of high
and low
values of the candle Read more
sourcefn ohlc4(&self) -> ValueType
fn ohlc4(&self) -> ValueType
Calculates arithmetic average of high
, low
, open
and close
values of the candle Read more
sourcefn tr(&self, prev_candle: &dyn OHLCV) -> ValueType
fn tr(&self, prev_candle: &dyn OHLCV) -> ValueType
Calculates True Range over last two candles Read more
sourcefn tr_close(&self, prev_close: ValueType) -> ValueType
fn tr_close(&self, prev_close: ValueType) -> ValueType
Calculates True Range over last two candles using close
price from the previous candle.
sourcefn volumed_price(&self) -> ValueType
fn volumed_price(&self) -> ValueType
Volumed price Read more
sourcefn is_rising(&self) -> bool
fn is_rising(&self) -> bool
Checks if candle is “rising”: it’s close value greater than open value
sourcefn is_falling(&self) -> bool
fn is_falling(&self) -> bool
Checks if candle is “falling”: it’s close value smaller than open value
sourceimpl PartialOrd<Candle> for Candle
impl PartialOrd<Candle> for Candle
sourcefn partial_cmp(&self, other: &Candle) -> Option<Ordering>
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 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
impl Copy for Candle
impl Eq for Candle
Auto Trait Implementations
impl RefUnwindSafe for Candle
impl Send for Candle
impl Sync for Candle
impl Unpin for Candle
impl UnwindSafe for Candle
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more