pub struct OHLCV {
pub timestamp: i64,
pub open: f64,
pub high: f64,
pub low: f64,
pub close: f64,
pub volume: f64,
}Expand description
OHLCV data structure (candlestick data).
Represents open, high, low, close prices and volume for a specific time period.
§Examples
use ccxt_core::types::OHLCV;
let ohlcv = OHLCV {
timestamp: 1637000000000,
open: 50000.0,
high: 51000.0,
low: 49500.0,
close: 50500.0,
volume: 123.45,
};
println!("Candlestick data: {:?}", ohlcv);Fields§
§timestamp: i64Candlestick start time (Unix timestamp in milliseconds).
open: f64Opening price.
high: f64Highest price.
low: f64Lowest price.
close: f64Closing price.
volume: f64Trading volume (in base currency).
Implementations§
Source§impl OHLCV
impl OHLCV
Sourcepub fn new(
timestamp: i64,
open: f64,
high: f64,
low: f64,
close: f64,
volume: f64,
) -> OHLCV
pub fn new( timestamp: i64, open: f64, high: f64, low: f64, close: f64, volume: f64, ) -> OHLCV
Creates a new OHLCV instance.
§Arguments
timestamp- Candlestick timestamp in millisecondsopen- Opening pricehigh- Highest pricelow- Lowest priceclose- Closing pricevolume- Trading volume
Sourcepub fn change_percent(&self) -> f64
pub fn change_percent(&self) -> f64
Calculates the percentage change from open to close.
Returns 0.0 if the opening price is zero to avoid division by zero.
§Examples
let ohlcv = OHLCV::new(1637000000000, 100.0, 110.0, 95.0, 105.0, 1000.0);
assert_eq!(ohlcv.change_percent(), 5.0);Sourcepub fn price_range(&self) -> f64
pub fn price_range(&self) -> f64
Calculates the price range (high - low).
Sourcepub fn amplitude_percent(&self) -> f64
pub fn amplitude_percent(&self) -> f64
Calculates the amplitude percentage relative to the opening price.
Returns 0.0 if the opening price is zero to avoid division by zero.
Sourcepub fn is_bullish(&self) -> bool
pub fn is_bullish(&self) -> bool
Returns true if this is a bullish candle (close >= open).
Sourcepub fn is_bearish(&self) -> bool
pub fn is_bearish(&self) -> bool
Returns true if this is a bearish candle (close < open).
Sourcepub fn body_size(&self) -> f64
pub fn body_size(&self) -> f64
Calculates the body size (absolute difference between close and open).
Sourcepub fn upper_shadow(&self) -> f64
pub fn upper_shadow(&self) -> f64
Calculates the upper shadow length (wick above the body).
Sourcepub fn lower_shadow(&self) -> f64
pub fn lower_shadow(&self) -> f64
Calculates the lower shadow length (wick below the body).