I'm trying to calculate de
profit of an arbitragetrade, but for some reasson, the program dosn't get the result I expect.
These are the variables of the formula:
moneyToSpend = 0.1 btc (which is give or take depending on the current rate 100$)
askPrice = the lowest askingprice for a coin across a list of exchanges in btc
bidPrice = the highest bidprice for a coin across a list of exchanges in btc
amount (the amount to be bought) = moneyToSpend / askPrice
takerFee (needs to be payed when buying the coin on
exchange a) = takerFeePercentage (is kept in a constant for each exhange) * amount
WithdrawalFee (needs to be payed when transfering the coin from exchange a to b) = a fixed amount based on the coin and exchange kept in an enum
makerFee (needs to be payed when selling on exchange b) = makerFeePercentage(is kept in a constant for each exhange) * (amount - takerFee - withdrawalFee)
profit = (bidPrice - askPrice) * (amount- takerFee - withdrawalFee - makerFee)
In code I translated it to:
The formula seems logic to me, am I that stupid or does
java not follow simple mathrules anymore, like calculate first what's between parentheses?