Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod telemetry;
pub mod price_data;
pub mod prices;
pub mod telemetry;
pub mod types;
pub mod price_data;
2 changes: 1 addition & 1 deletion src/price_data/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pub mod spot;
pub mod perps;
pub mod spot;
4 changes: 2 additions & 2 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod price;
mod meta;
pub use price::*;
mod price;
pub use meta::*;
pub use price::*;

use std::{collections::HashMap, fmt};

Expand Down
11 changes: 8 additions & 3 deletions src/types/price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down