From 48b3d7c5218a966592d0d3cd5cb63c753a19af03 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Fri, 17 Jan 2020 21:32:52 +0900 Subject: [PATCH] Fix profit calculation --- Core/DataObjects/ProfitTrailerData.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Core/DataObjects/ProfitTrailerData.cs b/Core/DataObjects/ProfitTrailerData.cs index d5ff224..07d146f 100644 --- a/Core/DataObjects/ProfitTrailerData.cs +++ b/Core/DataObjects/ProfitTrailerData.cs @@ -304,9 +304,8 @@ namespace Core.Main.DataObjects sellLogData.AverageBuyPrice = rsld.avgPrice; sellLogData.TotalCost = sellLogData.SoldAmount * sellLogData.AverageBuyPrice; - - - if (sellLogData.ProfitPercent >0) + // check if sale was a short position + if ((sellLogData.ProfitPercent > 0) && (sellLogData.AverageBuyPrice > sellLogData.SoldPrice)) { double soldValueRaw = (sellLogData.SoldAmount * sellLogData.SoldPrice); double soldValueAfterFees = soldValueRaw + (soldValueRaw * ((double)rsld.fee / 100));