vectorbt-rust 1.1.1__tar.gz → 1.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -301,7 +301,7 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
301
301
 
302
302
  [[package]]
303
303
  name = "vectorbt-rust"
304
- version = "1.1.1"
304
+ version = "1.1.2"
305
305
  dependencies = [
306
306
  "ndarray",
307
307
  "numpy",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "vectorbt-rust"
3
- version = "1.1.1"
3
+ version = "1.1.2"
4
4
  edition = "2021"
5
5
  description = "Rust-accelerated kernels for vectorbt"
6
6
  license = "Apache-2.0 WITH Commons-Clause-1.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vectorbt-rust
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: Intended Audience :: Financial and Insurance Industry
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "vectorbt-rust"
7
- version = "1.1.1"
7
+ version = "1.1.2"
8
8
  description = "Rust-accelerated kernels for vectorbt"
9
9
  readme = "README.md"
10
10
  license = {text = "Apache-2.0 WITH Commons-Clause-1.0"}
@@ -6,7 +6,6 @@ use ndarray::{Array2, ArrayView2};
6
6
  use numpy::{PyArray1, PyArray2, PyReadonlyArray1, PyReadonlyArray2};
7
7
  use pyo3::exceptions::PyValueError;
8
8
  use pyo3::prelude::*;
9
- use std::cmp::Ordering;
10
9
 
11
10
  fn validate_same_shape_2d(a: ArrayView2<'_, f64>, b: ArrayView2<'_, f64>, name: &str) -> PyResult<()> {
12
11
  if a.dim() != b.dim() {
@@ -762,17 +761,12 @@ pub(crate) fn value_at_risk_1d(returns: &[f64], cutoff: f64) -> f64 {
762
761
  }
763
762
 
764
763
  pub(crate) fn cond_value_at_risk_1d(returns: &[f64], cutoff: f64) -> f64 {
765
- if returns.is_empty() {
764
+ let mut vals: Vec<f64> = returns.iter().copied().filter(|value| !value.is_nan()).collect();
765
+ if vals.is_empty() {
766
766
  return f64::NAN;
767
767
  }
768
- let mut vals = returns.to_vec();
769
768
  let cutoff_index = ((vals.len() - 1) as f64 * cutoff) as usize;
770
- vals.select_nth_unstable_by(cutoff_index, |left, right| match (left.is_nan(), right.is_nan()) {
771
- (true, true) => Ordering::Equal,
772
- (true, false) => Ordering::Greater,
773
- (false, true) => Ordering::Less,
774
- (false, false) => left.partial_cmp(right).unwrap(),
775
- });
769
+ vals.select_nth_unstable_by(cutoff_index, |left, right| left.partial_cmp(right).unwrap());
776
770
  mean_strict(&vals[..cutoff_index + 1])
777
771
  }
778
772
 
File without changes
File without changes