pub struct FixedPoint(pub i64);Expand description
Fixed-point decimal representation using i64 with 8 decimal precision
This avoids floating point rounding errors while maintaining performance. All prices and volumes are stored as integers scaled by SCALE (1e8).
Example:
- 50000.12345678 → 5000012345678
- 1.5 → 150000000
Tuple Fields§
§0: i64Implementations§
Source§impl FixedPoint
impl FixedPoint
Sourcepub fn from_str(s: &str) -> Result<FixedPoint, FixedPointError>
pub fn from_str(s: &str) -> Result<FixedPoint, FixedPointError>
Sourcepub fn to_string(&self) -> String
pub fn to_string(&self) -> String
Convert FixedPoint to string representation with 8 decimal places
Sourcepub fn compute_range_thresholds(
&self,
threshold_decimal_bps: u32,
) -> (FixedPoint, FixedPoint)
pub fn compute_range_thresholds( &self, threshold_decimal_bps: u32, ) -> (FixedPoint, FixedPoint)
Compute range thresholds for given basis points
§Arguments
threshold_decimal_bps- Threshold in decimal basis points- Example:
250→ 25bps = 0.25% - Example:
10→ 1bps = 0.01% - Minimum:
1→ 0.1bps = 0.001%
- Example:
§Returns
Tuple of (upper_threshold, lower_threshold)
§Breaking Change (v3.0.0)
Prior to v3.0.0, threshold_decimal_bps was in 1 dbps units.
Migration: Multiply all threshold values by 10.
Sourcepub fn compute_range_thresholds_cached(
&self,
threshold_ratio: i64,
) -> (FixedPoint, FixedPoint)
pub fn compute_range_thresholds_cached( &self, threshold_ratio: i64, ) -> (FixedPoint, FixedPoint)
Issue #96 Task #98: Fast threshold computation using pre-computed ratio
Avoids repeated division by BASIS_POINTS_SCALE in hot path (every bar creation). Instead of: delta = (price * threshold_dbps) / 100_000 We use: delta = (price * ratio) / SCALE, where ratio is pre-computed.
§Arguments
threshold_ratio- Pre-computed (threshold_dbps * SCALE) / 100_000 This should be computed once at OpenDeviationBarProcessor initialization.
Trait Implementations§
Source§impl Clone for FixedPoint
impl Clone for FixedPoint
Source§fn clone(&self) -> FixedPoint
fn clone(&self) -> FixedPoint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FixedPoint
impl Debug for FixedPoint
Source§impl Default for FixedPoint
impl Default for FixedPoint
Source§fn default() -> FixedPoint
fn default() -> FixedPoint
Source§impl<'de> Deserialize<'de> for FixedPoint
impl<'de> Deserialize<'de> for FixedPoint
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<FixedPoint, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<FixedPoint, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for FixedPoint
impl Display for FixedPoint
Source§impl FromStr for FixedPoint
impl FromStr for FixedPoint
Source§type Err = FixedPointError
type Err = FixedPointError
Source§fn from_str(s: &str) -> Result<FixedPoint, <FixedPoint as FromStr>::Err>
fn from_str(s: &str) -> Result<FixedPoint, <FixedPoint as FromStr>::Err>
s to return a value of this type. Read moreSource§impl Ord for FixedPoint
impl Ord for FixedPoint
Source§fn cmp(&self, other: &FixedPoint) -> Ordering
fn cmp(&self, other: &FixedPoint) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for FixedPoint
impl PartialEq for FixedPoint
Source§impl PartialOrd for FixedPoint
impl PartialOrd for FixedPoint
Source§impl Serialize for FixedPoint
impl Serialize for FixedPoint
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for FixedPoint
impl Eq for FixedPoint
impl StructuralPartialEq for FixedPoint
Auto Trait Implementations§
impl Freeze for FixedPoint
impl RefUnwindSafe for FixedPoint
impl Send for FixedPoint
impl Sync for FixedPoint
impl Unpin for FixedPoint
impl UnsafeUnpin for FixedPoint
impl UnwindSafe for FixedPoint
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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 more