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
}
}