pub enum MetricsError {
BasicError(String),
ShapeError(String),
RangeError(String),
TrendError(String),
RiskError(String),
ZeroMean {
metric: &'static str,
},
Curve(CurveError),
Surface(SurfaceError),
}Expand description
Error types specifically related to financial and statistical metrics calculations.
This enum represents various error conditions that can occur during metrics processing, analysis, and validation within the library’s metrics module. Each variant provides context about the specific type of error encountered.
§Variants
BasicError- General metrics calculation errorsShapeError- Errors related to data shape mismatches or incompatible dimensionsRangeError- Errors when data falls outside of expected/valid rangesTrendError- Errors in trend analysis, regression, or pattern detectionRiskError- Errors in risk metrics calculations (like VaR, Sharpe ratio, etc.)ZeroMean- A ratio over the mean, such as the coefficient of variation, asked of data whose mean is zeroCurve- Errors related to curve-fitting or curve-based calculationsSurface- Errors in surface modeling or multi-dimensional metrics
§Examples
use optionstratlib_math::error::MetricsError;
// Creating different error types
let basic_err = MetricsError::BasicError("Calculation failed".to_string());
let range_err = MetricsError::RangeError("Value outside expected bounds".to_string());Variants§
BasicError(String)
General errors in metrics calculations.
ShapeError(String)
Errors related to data shape mismatches or dimensional incompatibility. This typically occurs when input data has an unexpected structure.
RangeError(String)
Errors when data falls outside expected or valid ranges. This can indicate outliers or invalid input values.
TrendError(String)
Errors in trend analysis, regression, or pattern detection algorithms.
RiskError(String)
Errors specifically related to financial risk metrics calculations, such as Value at Risk (VaR), Conditional VaR, or Sharpe ratio.
ZeroMean
A ratio over the mean, such as the coefficient of variation in
crate::geometrics::RiskMetrics, asked of data whose mean is zero,
where the ratio is undefined (#824).
Curve(CurveError)
Errors encountered during curve-fitting or curve-based calculations, such as yield curves or volatility curves.
Surface(SurfaceError)
Errors in surface modeling or multi-dimensional metrics, such as volatility surfaces or correlation matrices.
Trait Implementations§
Source§impl Debug for MetricsError
impl Debug for MetricsError
Source§impl Display for MetricsError
impl Display for MetricsError
Source§impl Error for MetricsError
impl Error for MetricsError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<CurveError> for MetricsError
impl From<CurveError> for MetricsError
Source§fn from(source: CurveError) -> Self
fn from(source: CurveError) -> Self
Source§impl From<MetricsError> for CurveError
Wraps a metrics failure as CurveError::MetricsError carrying its
Display text, so curve builders that call analytics can use ?.
impl From<MetricsError> for CurveError
Wraps a metrics failure as CurveError::MetricsError carrying its
Display text, so curve builders that call analytics can use ?.
Source§fn from(err: MetricsError) -> Self
fn from(err: MetricsError) -> Self
Source§impl From<SurfaceError> for MetricsError
impl From<SurfaceError> for MetricsError
Source§fn from(source: SurfaceError) -> Self
fn from(source: SurfaceError) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for MetricsError
impl !UnwindSafe for MetricsError
impl Freeze for MetricsError
impl Send for MetricsError
impl Sync for MetricsError
impl Unpin for MetricsError
impl UnsafeUnpin for MetricsError
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§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).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.