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.
- {vectorbt_rust-1.1.1 → vectorbt_rust-1.1.2}/Cargo.lock +1 -1
- {vectorbt_rust-1.1.1 → vectorbt_rust-1.1.2}/Cargo.toml +1 -1
- {vectorbt_rust-1.1.1 → vectorbt_rust-1.1.2}/PKG-INFO +1 -1
- {vectorbt_rust-1.1.1 → vectorbt_rust-1.1.2}/pyproject.toml +1 -1
- {vectorbt_rust-1.1.1 → vectorbt_rust-1.1.2}/src/returns.rs +3 -9
- {vectorbt_rust-1.1.1 → vectorbt_rust-1.1.2}/README.md +0 -0
- {vectorbt_rust-1.1.1 → vectorbt_rust-1.1.2}/rustfmt.toml +0 -0
- {vectorbt_rust-1.1.1 → vectorbt_rust-1.1.2}/src/generic.rs +0 -0
- {vectorbt_rust-1.1.1 → vectorbt_rust-1.1.2}/src/indicators.rs +0 -0
- {vectorbt_rust-1.1.1 → vectorbt_rust-1.1.2}/src/labels.rs +0 -0
- {vectorbt_rust-1.1.1 → vectorbt_rust-1.1.2}/src/lib.rs +0 -0
- {vectorbt_rust-1.1.1 → vectorbt_rust-1.1.2}/src/portfolio.rs +0 -0
- {vectorbt_rust-1.1.1 → vectorbt_rust-1.1.2}/src/records.rs +0 -0
- {vectorbt_rust-1.1.1 → vectorbt_rust-1.1.2}/src/signals.rs +0 -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
|
-
|
|
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|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|