Skip to content

Commit 23e1132

Browse files
committed
Improved fee calculation when the token of the pairing is used for the transaction fee
1 parent e0ec58b commit 23e1132

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/com/nubebuster/cryptoprofittracker/BinanceProfitTracker.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public void printCalculations(String pair, double bnbFeeValue, Iterator<Row> row
159159
double amountInWallet = 0;
160160
double volume = 0;
161161
double accruedFees = 0;
162+
double addDisplayFees = 0;
162163

163164
for (TradeOrder order : orders) {
164165
if (order.isBuy()) {
@@ -179,6 +180,8 @@ public void printCalculations(String pair, double bnbFeeValue, Iterator<Row> row
179180
throw new UnexpectedException("Fee coin for " + pair + " was in " + order.getFeeCoin()
180181
+ ". This is not supported yet. Report this to the github repository.");
181182
amountInWallet -= order.getFee();
183+
//fees are deducted from total profit. This is in order to not calculate native token fees twice
184+
addDisplayFees += order.getFee() * order.getPrice();
182185
}
183186
}
184187

@@ -191,7 +194,7 @@ public void printCalculations(String pair, double bnbFeeValue, Iterator<Row> row
191194
log("Amount in wallet: " + roundedToSignificance(amountInWallet) + " (current value: " +
192195
Math.floor(walletValue) + ")");
193196

194-
log("Fees total: " + roundedToSignificance(accruedFees));
197+
log("Fees total: " + roundedToSignificance(accruedFees + addDisplayFees));
195198

196199
log("\nTotal profit: " + Math.floor(cumProfit + walletValue - accruedFees) + "\n-----------------------");
197200
}

0 commit comments

Comments
 (0)