From c4c87ed47ba2d19a84cf0ec6fe5bff4d4c6138c2 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Mon, 25 Jan 2021 13:54:25 +0000 Subject: [PATCH] damn calculations... --- rustybot/src/models.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rustybot/src/models.rs b/rustybot/src/models.rs index a5fb122..04e833b 100644 --- a/rustybot/src/models.rs +++ b/rustybot/src/models.rs @@ -391,7 +391,7 @@ impl Position { (base_price, delta) } else { - let base_price = self.base_price * (1.0 - fee_perc / 100.0); + let base_price = self.base_price * (1.0 + fee_perc / 100.0); let delta = best_offer - base_price; (base_price, delta) @@ -399,8 +399,7 @@ impl Position { }; let profit_loss = delta * self.amount.abs(); - let profit_loss_percentage = - ((1.0 - (base_price + delta) / base_price) * 100.0).abs() * profit_loss.signum(); + let profit_loss_percentage = delta / base_price * 100.0; self.pl = profit_loss; self.pl_perc = profit_loss_percentage;