pub struct ReturnsEstimation;Expand description
Expected-return and return estimators used by CLA when it is given prices.
All take a price matrix with one row per observation (oldest first), optionally
resampled positionally with resample_by ("W"/"week"/"weekly" keeps every 5th row,
"M"/"month"/"monthly" every 21st; anything else is daily), and compute simple
returns.
Implementations§
Source§impl ReturnsEstimation
impl ReturnsEstimation
Sourcepub fn calculate_mean_historical_returns(
asset_prices: &DMatrix<f64>,
resample_by: Option<&str>,
) -> Result<Vec<f64>, ClaError>
pub fn calculate_mean_historical_returns( asset_prices: &DMatrix<f64>, resample_by: Option<&str>, ) -> Result<Vec<f64>, ClaError>
Annualised mean simple return per asset: the mean periodic return times
252 / step.
§Errors
ClaError::NoData if fewer than two (resampled) rows remain, or a price used as a
denominator is zero.
Sourcepub fn calculate_exponential_historical_returns(
asset_prices: &DMatrix<f64>,
resample_by: Option<&str>,
span: usize,
) -> Result<Vec<f64>, ClaError>
pub fn calculate_exponential_historical_returns( asset_prices: &DMatrix<f64>, resample_by: Option<&str>, span: usize, ) -> Result<Vec<f64>, ClaError>
Annualised exponentially weighted mean simple return per asset, with smoothing
alpha = 2 / (span + 1) seeded at the first return (no bias adjustment), times
252 / step.
§Errors
ClaError::NoData if fewer than two (resampled) rows remain, or a price used as a
denominator is zero.
Sourcepub fn calculate_returns(
asset_prices: &DMatrix<f64>,
resample_by: Option<&str>,
) -> Result<DMatrix<f64>, ClaError>
pub fn calculate_returns( asset_prices: &DMatrix<f64>, resample_by: Option<&str>, ) -> Result<DMatrix<f64>, ClaError>
Periodic simple returns, one row per (resampled) period after the first.
§Errors
ClaError::NoData if fewer than two (resampled) rows remain, or a price used as a
denominator is zero.
Auto Trait Implementations§
impl Freeze for ReturnsEstimation
impl RefUnwindSafe for ReturnsEstimation
impl Send for ReturnsEstimation
impl Sync for ReturnsEstimation
impl Unpin for ReturnsEstimation
impl UnsafeUnpin for ReturnsEstimation
impl UnwindSafe for ReturnsEstimation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.