From 3a38c20f56fba2a248ab3bbc5be913680c82de23 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Mon, 25 Jan 2021 12:28:01 +0000 Subject: [PATCH] fixed sign calculation of pl_perc --- rustybot/src/models.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rustybot/src/models.rs b/rustybot/src/models.rs index 3285dab..9c12914 100644 --- a/rustybot/src/models.rs +++ b/rustybot/src/models.rs @@ -393,10 +393,11 @@ impl Position { best_offer - base_price }; + let profit_loss = delta * self.amount; 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; }