use debot_utils::ToDateTimeString;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct PricePoint {
    pub timestamp: i64,
    pub timestamp_str: String,
    pub price: f64,
    pub short_price_ema: f64,
    pub long_price_ema: f64,
    pub rsi: f64,
}

impl PricePoint {
    pub fn new(
        price: f64,
        timestamp: Option<i64>,
        short_price_ema: f64,
        long_price_ema: f64,
        rsi: f64,
    ) -> Self {
        let time = timestamp.unwrap_or_else(|| chrono::Utc::now().timestamp());
        Self {
            timestamp: time,
            timestamp_str: time.to_datetime_string(),
            price,
            short_price_ema,
            long_price_ema,
            rsi,
        }
    }
}
