damn calculations...

This commit is contained in:
Giulio De Pasquale 2021-01-25 13:54:25 +00:00
parent ff17972f5b
commit c4c87ed47b

View File

@ -391,7 +391,7 @@ impl Position {
(base_price, delta) (base_price, delta)
} else { } 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; let delta = best_offer - base_price;
(base_price, delta) (base_price, delta)
@ -399,8 +399,7 @@ impl Position {
}; };
let profit_loss = delta * self.amount.abs(); let profit_loss = delta * self.amount.abs();
let profit_loss_percentage = let profit_loss_percentage = delta / base_price * 100.0;
((1.0 - (base_price + delta) / base_price) * 100.0).abs() * profit_loss.signum();
self.pl = profit_loss; self.pl = profit_loss;
self.pl_perc = profit_loss_percentage; self.pl_perc = profit_loss_percentage;