#[derive(Debug, Clone, PartialEq, Default)]
pub struct TradeDetail {
    target_price: f64,
    confidence: f64,
}

impl TradeDetail {
    pub fn new(target_price: f64, confidence: f64) -> Self {
        Self {
            target_price,
            confidence,
        }
    }

    pub fn target_price(&self) -> f64 {
        self.target_price
    }

    pub fn confidence(&self) -> f64 {
        self.confidence
    }
}

#[derive(Debug, Clone, PartialEq)]
pub enum TradeAction {
    BuyOpen(TradeDetail),
    BuyClose,
    SellOpen(TradeDetail),
    SellClose,
    None,
}

impl TradeAction {
    pub fn is_open(&self) -> bool {
        matches!(self, TradeAction::BuyOpen(_) | TradeAction::SellOpen(_))
    }

    pub fn is_buy(&self) -> bool {
        matches!(self, TradeAction::BuyOpen(_) | TradeAction::BuyClose)
    }

    pub fn is_sell(&self) -> bool {
        matches!(self, TradeAction::SellOpen(_) | TradeAction::SellClose)
    }

    pub fn target_price(&self) -> Option<f64> {
        match self {
            TradeAction::BuyOpen(detail) => Some(detail.target_price),
            TradeAction::SellOpen(detail) => Some(detail.target_price),
            _ => None,
        }
    }
}
