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


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

impl BlockchainPerformance {
    pub fn new() -> Self {
        Self {
            performance_scores: VecDeque::new(),
        }
    }

    pub fn update_performance(&mut self, performance_score: f64) {
        self.performance_scores.push_back(performance_score);
    }
}

impl Strategy for BlockchainPerformance {
    fn evaluate(&self, _price: &f64) -> f64 {
        let last_performance = self.performance_scores.back().unwrap();
        if *last_performance > 0.5 {
            1.0 // 买入信号
        } else if *last_performance < -0.5 {
            -1.0 // 卖出信号
        } else {
            0.0 // 无信号
        }
    }

    fn calculate_indicator(&self, _prices: &Vec<f64>) -> f64 {
        // 计算性能得分平均值作为指标
        let mut total_score = 0.0;
        for score in &self.performance_scores {
            total_score += *score;
        }
        total_score / self.performance_scores.len() as f64
    }
}