Every exchange API implementation has a method
getFeeForOrder()
https://github.com/ReAzem/cryptocoin-tradelib/blob/master/core/src/de/andreas_rueckert/trade/site/TradeSite.javaand you can pass an order (before you actually trade) to get an hopefully acurrate price for this order execution.
But things are actually quite complicated in some cases and my code does not handle every situation 100% accurate, because I implement stuff, as I actually use it.
One problem are the fees on some exchanges, that change with the traded volume of the user. So you trade x coins and you pay fee a for the first x/2 coins, but fee b (usually lower then a) for the other x/2 coins.
Another problem (mainly for the bots) are fees, that are paid in a different currency than the actually traded currency. So you withdraw usd from an exchange and pay x euro as the fee. You have to convert this fee to figure, if the trade would be profitable, but sometimes the conversion rates are unknown etc.
Every exchange, that has complex fees should add a method, that returns the fee for an order. So an API implementation would just pass an order to the exchange and would get the fee as a return. But most exchanges don't do it yet...
So it's a moving target for every bot coder, I guess.
If anyone has a perfect solution, please post it here! Thanks!!!