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 relative_timestamp: Option<i64>,
    confidence: f64,
    pub price: f64,
    pub upper_price: f64,
    pub lower_price: f64,
}

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