Fix profit calculation

This commit is contained in:
HojouFotytu 2020-01-17 21:32:52 +09:00
parent 6d2050310c
commit 48b3d7c521
1 changed files with 2 additions and 3 deletions

View File

@ -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));