From 415944bde5dd163dcc4e9c633a1b855231ea9903 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Thu, 25 Feb 2021 19:21:50 +0000 Subject: [PATCH] Added is_long(), is_short() functions --- src/models.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/models.rs b/src/models.rs index 890c213..cb602fb 100644 --- a/src/models.rs +++ b/src/models.rs @@ -260,7 +260,7 @@ impl Clone for ActiveOrder { order_form: self.order_form.clone(), creation_timestamp: self.creation_timestamp, update_timestamp: self.update_timestamp, - strategy: self.strategy.as_ref().map(|x| clone_box(&**x)) + strategy: self.strategy.as_ref().map(|x| clone_box(&**x)), } } } @@ -389,19 +389,15 @@ impl OrderForm { pub fn pair(&self) -> &SymbolPair { &self.pair } - pub fn kind(&self) -> OrderKind { self.kind } - pub fn platform(&self) -> &TradingPlatform { &self.platform } - pub fn amount(&self) -> f64 { self.amount } - pub fn price(&self) -> Option { match self.kind { OrderKind::Limit { price, .. } => Some(price), @@ -413,14 +409,18 @@ impl OrderForm { OrderKind::ImmediateOrCancel { price, .. } => Some(price), } } - pub fn leverage(&self) -> Option { self.leverage } - pub fn metadata(&self) -> &Option { &self.metadata } + pub fn is_long(&self) -> bool { + self.amount.is_sign_positive() + } + pub fn is_short(&self) -> bool { + self.amount.is_sign_negative() + } } #[derive(Debug)]