From 653212b7285ff390e0c3917d9f5fb194c76130d5 Mon Sep 17 00:00:00 2001 From: Naman Garg <0708ng@gmail.com> Date: Wed, 19 Feb 2025 14:50:40 +0530 Subject: [PATCH] nit --- src/lib.rs | 4 ++-- src/price_data/mod.rs | 2 +- src/types/mod.rs | 4 ++-- src/types/price.rs | 11 ++++++++--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0611921..89acd92 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -pub mod telemetry; +pub mod price_data; pub mod prices; +pub mod telemetry; pub mod types; -pub mod price_data; diff --git a/src/price_data/mod.rs b/src/price_data/mod.rs index 15c6091..6a6149c 100644 --- a/src/price_data/mod.rs +++ b/src/price_data/mod.rs @@ -1,2 +1,2 @@ -pub mod spot; pub mod perps; +pub mod spot; diff --git a/src/types/mod.rs b/src/types/mod.rs index 3bbd638..212e3d0 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -1,7 +1,7 @@ -mod price; mod meta; -pub use price::*; +mod price; pub use meta::*; +pub use price::*; use std::{collections::HashMap, fmt}; diff --git a/src/types/price.rs b/src/types/price.rs index 1e418bc..2771fd2 100644 --- a/src/types/price.rs +++ b/src/types/price.rs @@ -131,10 +131,15 @@ impl Price { self.get_true_size(ad_size) } - pub fn get_true_price_for_asset(&self, price: f64) -> f64 { + /// Returns the true price for the asset, rounded to the correct number of decimals + pub fn get_true_price_for_asset(&self) -> f64 { match self { - Price::Spot { meta, .. } => Self::round_price(price, 8, meta.get_sz_decimals()), - Price::Perp { meta, .. } => Self::round_price(price, 6, meta.get_sz_decimals()), + Price::Spot { meta, .. } => { + Self::round_price(self.get_value(), 8, meta.get_sz_decimals()) + } + Price::Perp { meta, .. } => { + Self::round_price(self.get_value(), 6, meta.get_sz_decimals()) + } Price::None => 0.0_f64, } }