We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
EfficiencyRatio
NaN
let mut ker = EfficiencyRatio::new(14)?; println!("1 {}", ker.next(1.69)); println!("2 {}", ker.next(1.69)); println!("3 {}", ker.next(1.70)); println!("4 {}", ker.next(1.70)); println!("5 {}", ker.next(1.69));
Output:
1 1 2 NaN 3 1 4 1 5 0
If you keep passing 1.69, it subsequently outputs NaN.
ad hoc workaround
// https://github.com/greyblake/ta-rs/issues/73 struct FixEfficiencyRatio { er: EfficiencyRatio, } impl FixEfficiencyRatio { fn new(period: usize) -> ta::errors::Result<Self> { Ok(Self { er: EfficiencyRatio::new(period)?, }) } } impl<T: Close> ta::Next<&T> for FixEfficiencyRatio { type Output = f64; fn next(&mut self, input: &T) -> f64 { match self.er.next(input) { v if v.is_nan() => 1.0, v => v, } } }
KER implementation could be simplified with VecDeque.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Output:
If you keep passing 1.69, it subsequently outputs NaN.
ad hoc workaround
KER implementation could be simplified with VecDeque.
The text was updated successfully, but these errors were encountered: