use polars::prelude::*;
use serde::{Deserialize, Serialize};
use thiserror::Error;
pub mod mean_reversion;
pub mod momentum;
pub mod multi_indicator;
pub mod trend_following;
pub mod volatility;
pub mod volume;
#[derive(Error, Debug)]
pub enum StrategyError {
#[error("Missing required data: {0}")]
MissingData(String),
#[error("Invalid parameter: {0}")]
InvalidParameter(String),
#[error("Polars error: {0}")]
PolarsError(#[from] PolarsError),
#[error("Indicator error: {0}")]
IndicatorError(String),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum Signal {
Buy,
Sell,
Hold,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StrategyConfig {
pub parameters: Series,
}
pub trait Strategy {
fn new(config: StrategyConfig) -> Self
where
Self: Sized;
fn generate_signals(&self, data: &DataFrame) -> Result<Series, StrategyError>;
fn name(&self) -> &str;
fn description(&self) -> &str;
fn required_columns(&self) -> Vec<&str>;
}