//! Data models for OHLC candles

use serde::{Deserialize, Serialize};

/// OHLC candlestick data point
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct OhlcCandle {
    /// Unix timestamp in milliseconds
    pub timestamp: i64,
    /// Opening price
    pub open: f64,
    /// Highest price
    pub high: f64,
    /// Lowest price
    pub low: f64,
    /// Closing price
    pub close: f64,
}

#[allow(dead_code)]
impl OhlcCandle {
    /// Get timestamp as seconds
    pub fn timestamp_secs(&self) -> i64 {
        self.timestamp / 1000
    }

    /// Calculate candle body size (absolute)
    pub fn body_size(&self) -> f64 {
        (self.close - self.open).abs()
    }

    /// Calculate full range (high - low)
    pub fn range(&self) -> f64 {
        self.high - self.low
    }

    /// Check if bullish (close > open)
    pub fn is_bullish(&self) -> bool {
        self.close > self.open
    }
}
