42 lines
813 B
Rust
42 lines
813 B
Rust
use bitfinex::positions::Position;
|
|
|
|
pub enum PositionState {
|
|
Critical,
|
|
Loss,
|
|
BreakEven,
|
|
MinimumProfit,
|
|
Profit,
|
|
}
|
|
|
|
impl PositionState {
|
|
fn color(self) -> String {
|
|
match self {
|
|
PositionState::Critical | PositionState::Loss => { "red" }
|
|
PositionState::BreakEven => { "yellow" }
|
|
PositionState::MinimumProfit | PositionState::Profit => { "green" }
|
|
}.into()
|
|
}
|
|
}
|
|
|
|
pub struct PositionWrapper {
|
|
position: Position,
|
|
net_pl: f64,
|
|
net_pl_perc: f64,
|
|
state: PositionState,
|
|
}
|
|
|
|
impl PositionWrapper {
|
|
pub fn new(position: Position, net_pl: f64, net_pl_perc: f64, state: PositionState) -> Self {
|
|
PositionWrapper {
|
|
position,
|
|
net_pl,
|
|
net_pl_perc,
|
|
state,
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|