Commissions are currently not in the gain_operations list and are consequently sorted after SELL and FEE.
This can lead to having not enough coins in queue for selling.
Since 100 - 0.1 is 99.9, the last line produces Not enough COIN1 in queue to sell.
The correct calculation would be 100 - 0.1 + 0.02 = 99.92 (before selling).
Commissions are currently not in the gain_operations list and are consequently sorted after SELL and FEE. This can lead to having not enough coins in queue for selling.
Minimum example:
Since 100 - 0.1 is 99.9, the last line produces
Not enough COIN1 in queue to sell
. The correct calculation would be 100 - 0.1 + 0.02 = 99.92 (before selling).