Skip to main content

Crate use_return

Crate use_return 

Source
Expand description

§use-return

Primitive quantitative return vocabulary for RustUse.

use-return stores finite f64 return values and provides tiny helpers for simple and log returns from start/end prices.

§Example

use use_return::{LogReturn, ReturnKind, SimpleReturn};

let simple = SimpleReturn::from_prices(100.0, 105.0)?;
let log = LogReturn::from_prices(100.0, 105.0)?;
let kind: ReturnKind = "simple".parse()?;

assert!((simple.value() - 0.05).abs() < 1.0e-12);
assert!(log.value() > 0.0);
assert_eq!(kind.to_string(), "simple");

§Scope

Use this crate for return values and obvious price-to-return calculations. It does not implement performance analytics, fee/tax accounting, advice, or strategy logic.

§License

Licensed under either MIT or Apache-2.0.

Modules§

prelude
Common return primitives.

Structs§

LogReturn
A finite log return value.
ReturnValue
A return value paired with descriptive return-kind vocabulary.
SimpleReturn
A finite simple return value.

Enums§

ReturnError
Errors returned by return value construction and price-to-return helpers.
ReturnKind
Descriptive return kind vocabulary.
ReturnKindParseError
Errors returned while parsing return kinds.