Skip to main content

MetricsError

Enum MetricsError 

Source
pub enum MetricsError {
    BasicError(String),
    ShapeError(String),
    RangeError(String),
    TrendError(String),
    RiskError(String),
    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 errors
  • ShapeError - Errors related to data shape mismatches or incompatible dimensions
  • RangeError - Errors when data falls outside of expected/valid ranges
  • TrendError - Errors in trend analysis, regression, or pattern detection
  • RiskError - Errors in risk metrics calculations (like VaR, Sharpe ratio, etc.)
  • Curve - Errors related to curve-fitting or curve-based calculations
  • Surface - Errors in surface modeling or multi-dimensional metrics

§Examples

use optionstratlib::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.

§

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for MetricsError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for MetricsError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<CurveError> for MetricsError

Source§

fn from(source: CurveError) -> Self

Converts to this type from the input type.
Source§

impl From<MetricsError> for CurveError

Converts a PositionError into a CurvesError by mapping it to an OperationError with the InvalidParameters variant.

This implementation ensures a smooth transition between error types when a PositionError is encountered within a context that operates on the curves module. The InvalidParameters variant is used to provide detailed information about the failed operation and the reason for its failure.

§Details:
  • The operation field is hardcoded as "Position" to indicate the context of the error (i.e., relating to position management).
  • The reason field is derived from the to_string representation of the PositionError, ensuring a human-readable explanation.
§Example Integration:
  1. If a PositionError is encountered during curve calculations, this implementation converts it into a CurvesError for consistent error handling within the curves module.
  2. The generated CurvesError provides detailed diagnostic information about the reason for the failure, enabling effective debugging.
§Implementation Notes:
  • This conversion leverages the OperationErrorKind::InvalidParameters variant to communicate that invalid parameters (or settings) were the root cause of failure.
  • Use this implementation to handle interoperability between error types in modular design contexts.
§Example Use Case:

This conversion is frequently used in scenarios where:

  • A position-related error (e.g., from validation or limits) occurs during a curve operation.
  • Such errors need to be mapped into the CurvesError domain to maintain consistent error handling across the library.
§Debugging:

The resulting CurvesError will include contextual details, making it straightforward to trace and debug the underlying issue.

Source§

fn from(err: MetricsError) -> Self

Converts to this type from the input type.
Source§

impl From<MetricsError> for Error

Source§

fn from(source: MetricsError) -> Self

Converts to this type from the input type.
Source§

impl From<SurfaceError> for MetricsError

Source§

fn from(source: SurfaceError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more