Order execution and using decimal
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
use hypersdk::Decimal;
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Symbol(pub String);
|
||||
|
||||
#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize)]
|
||||
pub struct USD(pub f64);
|
||||
pub struct USD(pub Decimal);
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub enum Direction {
|
||||
@@ -25,10 +27,10 @@ impl std::fmt::Display for Symbol {
|
||||
|
||||
impl std::fmt::Display for USD {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
if self.0 > 0.0 {
|
||||
write!(f, "\x1b[32m${}\x1b[0m", format_f64(self.0))
|
||||
if self.0.is_sign_positive() {
|
||||
write!(f, "\x1b[32m${}\x1b[0m", format_f64(self.0.as_f64()))
|
||||
} else {
|
||||
write!(f, "\x1b[31m${}\x1b[0m", format_f64(self.0))
|
||||
write!(f, "\x1b[31m${}\x1b[0m", format_f64(self.0.as_f64()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user