Added is_long(), is_short() functions

This commit is contained in:
Giulio De Pasquale 2021-02-25 19:21:50 +00:00
parent 6d873f3c14
commit 415944bde5

View File

@ -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<f64> {
match self.kind {
OrderKind::Limit { price, .. } => Some(price),
@ -413,14 +409,18 @@ impl OrderForm {
OrderKind::ImmediateOrCancel { price, .. } => Some(price),
}
}
pub fn leverage(&self) -> Option<f64> {
self.leverage
}
pub fn metadata(&self) -> &Option<OrderMetadata> {
&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)]