use crate::{Ohlcv, PriceSource};
use std::{
fmt::{Debug, Display},
hash::Hash,
};
pub trait IndicatorConfig: Default + Sized + PartialEq + Eq + Hash + Display + Debug {
type Builder: IndicatorConfigBuilder<Self>;
fn builder() -> Self::Builder;
fn source(&self) -> PriceSource;
fn convergence(&self) -> usize;
fn to_builder(&self) -> Self::Builder;
}
pub trait IndicatorConfigBuilder<Config>
where
Config: IndicatorConfig,
{
#[must_use]
fn source(self, source: PriceSource) -> Self;
#[must_use]
fn build(self) -> Config;
}
pub trait Indicator: Sized + Clone + Display + Debug {
type Config: IndicatorConfig;
type Output: Send + Sync + Display + Debug;
fn new(config: Self::Config) -> Self;
fn compute(&mut self, ohlcv: &impl Ohlcv) -> Option<Self::Output>;
fn value(&self) -> Option<Self::Output>;
}