Update stop percentage and print before checking for existing stop percentage
This commit is contained in:
parent
fdc93e9cbe
commit
1948b0f032
@ -171,6 +171,7 @@ impl Default for TrailingStop {
|
|||||||
TrailingStop {
|
TrailingStop {
|
||||||
stop_percentages: Default::default(),
|
stop_percentages: Default::default(),
|
||||||
stop_loss_flags: Default::default(),
|
stop_loss_flags: Default::default(),
|
||||||
|
trail_set_flags: Default::default(),
|
||||||
capital_max_loss,
|
capital_max_loss,
|
||||||
capital_min_profit,
|
capital_min_profit,
|
||||||
capital_good_profit,
|
capital_good_profit,
|
||||||
@ -272,8 +273,6 @@ impl PositionStrategy for TrailingStop {
|
|||||||
_: &HashMap<u64, Position>,
|
_: &HashMap<u64, Position>,
|
||||||
fees: &Vec<TradingFees>,
|
fees: &Vec<TradingFees>,
|
||||||
) -> (Position, Option<Vec<Event>>, Option<Vec<ActionMessage>>) {
|
) -> (Position, Option<Vec<Event>>, Option<Vec<ActionMessage>>) {
|
||||||
self.print_status(&position);
|
|
||||||
|
|
||||||
let taker_fee = fees
|
let taker_fee = fees
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|x| match x {
|
.filter_map(|x| match x {
|
||||||
@ -335,6 +334,9 @@ impl PositionStrategy for TrailingStop {
|
|||||||
self.stop_loss_flags.insert(position.id(), false);
|
self.stop_loss_flags.insert(position.id(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.update_stop_percentage(&position);
|
||||||
|
self.print_status(&position);
|
||||||
|
|
||||||
// let's check if we surpassed an existing stop percentage
|
// let's check if we surpassed an existing stop percentage
|
||||||
if let Some(existing_stop_percentage) = self.stop_percentages.get(&position.id()) {
|
if let Some(existing_stop_percentage) = self.stop_percentages.get(&position.id()) {
|
||||||
if &position.pl_perc() <= existing_stop_percentage {
|
if &position.pl_perc() <= existing_stop_percentage {
|
||||||
@ -344,8 +346,6 @@ impl PositionStrategy for TrailingStop {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.update_stop_percentage(&position);
|
|
||||||
|
|
||||||
(position, None, Some(messages))
|
(position, None, Some(messages))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user