fixed sign calculation of pl_perc
This commit is contained in:
parent
b02554778e
commit
3a38c20f56
@ -393,10 +393,11 @@ impl Position {
|
|||||||
best_offer - base_price
|
best_offer - base_price
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let profit_loss = delta * self.amount;
|
||||||
let profit_loss_percentage =
|
let profit_loss_percentage =
|
||||||
((1.0 - (base_price + delta) / base_price) * 100.0).abs() * delta.signum();
|
((1.0 - (base_price + delta) / base_price) * 100.0).abs() * profit_loss.signum();
|
||||||
|
|
||||||
self.pl = delta * self.amount;
|
self.pl = profit_loss;
|
||||||
self.pl_perc = profit_loss_percentage;
|
self.pl_perc = profit_loss_percentage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user