imported profitstate
This commit is contained in:
parent
545bfe28de
commit
f4431f26c0
@ -9,7 +9,7 @@ use crate::BoxError;
|
|||||||
use crate::events::{ActionMessage, Event, EventKind, EventMetadata};
|
use crate::events::{ActionMessage, Event, EventKind, EventMetadata};
|
||||||
use crate::managers::OptionUpdate;
|
use crate::managers::OptionUpdate;
|
||||||
use crate::models::{ActiveOrder, OrderBook, OrderForm, OrderKind, OrderMetadata, Position, PositionProfitState, TradingFees};
|
use crate::models::{ActiveOrder, OrderBook, OrderForm, OrderKind, OrderMetadata, Position, PositionProfitState, TradingFees};
|
||||||
use crate::models::PositionProfitState::{BreakEven, Critical, Loss};
|
use crate::models::PositionProfitState::{BreakEven, Critical, Loss, MinimumProfit, Profit};
|
||||||
use crate::sounds::{GOOD_PROFIT_SOUND_PATH, LOSS_TO_BREAK_EVEN_PATH, MIN_PROFIT_SOUND_PATH, play_sound};
|
use crate::sounds::{GOOD_PROFIT_SOUND_PATH, LOSS_TO_BREAK_EVEN_PATH, MIN_PROFIT_SOUND_PATH, play_sound};
|
||||||
|
|
||||||
/***************
|
/***************
|
||||||
@ -230,15 +230,15 @@ impl PositionStrategy for TrailingStop {
|
|||||||
// setting the state of the position based on its profit/loss percentage
|
// setting the state of the position based on its profit/loss percentage
|
||||||
let state = {
|
let state = {
|
||||||
if pl_perc > self.good_profit_percentage {
|
if pl_perc > self.good_profit_percentage {
|
||||||
PositionProfitState::Profit
|
Profit
|
||||||
} else if (self.min_profit_percentage..self.good_profit_percentage).contains(&pl_perc) {
|
} else if (self.min_profit_percentage..self.good_profit_percentage).contains(&pl_perc) {
|
||||||
PositionProfitState::MinimumProfit
|
MinimumProfit
|
||||||
} else if (0.0..self.min_profit_percentage).contains(&pl_perc) {
|
} else if (0.0..self.min_profit_percentage).contains(&pl_perc) {
|
||||||
PositionProfitState::BreakEven
|
BreakEven
|
||||||
} else if (self.max_loss_percentage..0.0).contains(&pl_perc) {
|
} else if (self.max_loss_percentage..0.0).contains(&pl_perc) {
|
||||||
PositionProfitState::Loss
|
Loss
|
||||||
} else {
|
} else {
|
||||||
PositionProfitState::Critical
|
Critical
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user