Added is_long(), is_short() functions
This commit is contained in:
parent
6d873f3c14
commit
415944bde5
@ -260,7 +260,7 @@ impl Clone for ActiveOrder {
|
|||||||
order_form: self.order_form.clone(),
|
order_form: self.order_form.clone(),
|
||||||
creation_timestamp: self.creation_timestamp,
|
creation_timestamp: self.creation_timestamp,
|
||||||
update_timestamp: self.update_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 {
|
pub fn pair(&self) -> &SymbolPair {
|
||||||
&self.pair
|
&self.pair
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kind(&self) -> OrderKind {
|
pub fn kind(&self) -> OrderKind {
|
||||||
self.kind
|
self.kind
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn platform(&self) -> &TradingPlatform {
|
pub fn platform(&self) -> &TradingPlatform {
|
||||||
&self.platform
|
&self.platform
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn amount(&self) -> f64 {
|
pub fn amount(&self) -> f64 {
|
||||||
self.amount
|
self.amount
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn price(&self) -> Option<f64> {
|
pub fn price(&self) -> Option<f64> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
OrderKind::Limit { price, .. } => Some(price),
|
OrderKind::Limit { price, .. } => Some(price),
|
||||||
@ -413,14 +409,18 @@ impl OrderForm {
|
|||||||
OrderKind::ImmediateOrCancel { price, .. } => Some(price),
|
OrderKind::ImmediateOrCancel { price, .. } => Some(price),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn leverage(&self) -> Option<f64> {
|
pub fn leverage(&self) -> Option<f64> {
|
||||||
self.leverage
|
self.leverage
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn metadata(&self) -> &Option<OrderMetadata> {
|
pub fn metadata(&self) -> &Option<OrderMetadata> {
|
||||||
&self.metadata
|
&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)]
|
#[derive(Debug)]
|
||||||
|
Loading…
Reference in New Issue
Block a user