pub struct FixedPrice(/* private fields */);Expand description
Fixed-point price representation. 1 tick = 0.0001 (scale factor 10,000).
Eliminates f64 comparison issues (no PRICE_EPSILON), enables Ord (no NaN),
and uses integer arithmetic (1-5ns vs 20-100ns for f64 ops).
Serializes as f64 on the wire for JSON backward compatibility.
Implementations§
Source§impl FixedPrice
impl FixedPrice
pub const SCALE: u64 = 10_000
pub const ZERO: Self
pub const ONE: Self
pub fn from_f64(price: f64) -> Self
pub fn to_f64(self) -> f64
pub fn raw(self) -> u64
pub fn from_raw(raw: u64) -> Self
Sourcepub fn complement(self) -> Self
pub fn complement(self) -> Self
1.0 - self, exact in fixed-point. Used for NO-side price inversion.
pub fn midpoint(self, other: Self) -> Self
Trait Implementations§
Source§impl Clone for FixedPrice
impl Clone for FixedPrice
Source§fn clone(&self) -> FixedPrice
fn clone(&self) -> FixedPrice
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FixedPrice
impl Debug for FixedPrice
Source§impl Default for FixedPrice
impl Default for FixedPrice
Source§impl<'de> Deserialize<'de> for FixedPrice
impl<'de> Deserialize<'de> for FixedPrice
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for FixedPrice
impl Display for FixedPrice
Source§impl From<FixedPrice> for f64
impl From<FixedPrice> for f64
Source§fn from(v: FixedPrice) -> Self
fn from(v: FixedPrice) -> Self
Converts to this type from the input type.
Source§impl From<f64> for FixedPrice
impl From<f64> for FixedPrice
Source§impl Hash for FixedPrice
impl Hash for FixedPrice
Source§impl Ord for FixedPrice
impl Ord for FixedPrice
Source§fn cmp(&self, other: &FixedPrice) -> Ordering
fn cmp(&self, other: &FixedPrice) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for FixedPrice
impl PartialEq for FixedPrice
Source§impl PartialOrd for FixedPrice
impl PartialOrd for FixedPrice
Source§impl Serialize for FixedPrice
impl Serialize for FixedPrice
impl Copy for FixedPrice
impl Eq for FixedPrice
impl StructuralPartialEq for FixedPrice
Auto Trait Implementations§
impl Freeze for FixedPrice
impl RefUnwindSafe for FixedPrice
impl Send for FixedPrice
impl Sync for FixedPrice
impl Unpin for FixedPrice
impl UnsafeUnpin for FixedPrice
impl UnwindSafe for FixedPrice
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