Documentation
use std::collections::VecDeque;
use crate::strategy_engine::Strategy;


#[derive(Debug, Clone)]
pub struct DollarCostAveraging {
    prices: VecDeque<f64>,
}

impl DollarCostAveraging {
    pub fn new() -> Self {
        Self {
            prices: VecDeque::new(),
        }
    }

    pub fn update_price(&mut self, price: f64) {
        self.prices.push_back(price);
    }
}

impl Strategy for DollarCostAveraging {
    fn evaluate(&self, _price: &f64) -> f64 {
        1.0 // 始终买入信号
    }

    fn calculate_indicator(&self, prices: &Vec<f64>) -> f64 {
        // 计算平均成本作为指标
        let mut total_cost = 0.0;
        for price in prices {
            total_cost += *price;
        }
        total_cost / prices.len() as f64
    }
}