pub struct Constant {
pub min_rate: f64,
pub max_rate: f64,
pub price: f64,
}Expand description
A representation of a flat demand curve supporting interval, half-line, and full-line trading domains
A constant curve represents a fixed price for trades within a specified rate range. This can be used to express indifference to (potentially unbounded) trade rates at a specific price.
The sign convention follows flow trading standards:
- min_rate ≤ 0 (non-positive): maximum selling rate
- max_rate ≥ 0 (non-negative): maximum buying rate
Fields§
§min_rate: f64The fastest rate at which the portfolio may sell (non-positive)
max_rate: f64The fastest rate at which the portfolio may buy (non-negative)
price: f64The fixed price at which trades within the rate range are valued
Implementations§
Source§impl Constant
impl Constant
Sourcepub fn new(
min_rate: f64,
max_rate: f64,
price: f64,
) -> Result<Self, ValidationError>
pub fn new( min_rate: f64, max_rate: f64, price: f64, ) -> Result<Self, ValidationError>
Creates a new validated constant curve
Creates a constant curve with the specified rates and price, ensuring all values satisfy validation requirements:
- min_rate must be non-positive
- max_rate must be non-negative
- price must be finite
- Neither rate nor price can be NaN
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Constant
impl<'de> Deserialize<'de> for Constant
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Constant
Auto Trait Implementations§
impl Freeze for Constant
impl RefUnwindSafe for Constant
impl Send for Constant
impl Sync for Constant
impl Unpin for Constant
impl UnwindSafe for Constant
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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