Deduction before splitting for fees

This commit is contained in:
2026-05-04 16:15:06 -04:00
parent 4347b846bf
commit 39200a542d
2 changed files with 4 additions and 3 deletions

5
bot.py
View File

@@ -187,9 +187,10 @@ def run_cycle(config: Config) -> bool:
return bool(closed)
to_buy = opportunities[:num_to_buy]
# Deduct fee reserve before splitting so each order has room for Kraken's taker fee
# Deduct fee reserve before splitting so each order has room for Kraken's taker fee.
# Floor to the nearest cent so floating point never pushes us over the available balance.
fee_multiplier = 1 - (config.taker_fee_pct / 100)
alloc_per_asset = (balance * fee_multiplier) / num_to_buy
alloc_per_asset = math.floor((balance * fee_multiplier / num_to_buy) * 100) / 100
log.info(
"Buying %d asset(s) @ $%.2f each (total $%.2f, %.1f%% fee reserve applied)",
num_to_buy, alloc_per_asset, alloc_per_asset * num_to_buy, config.taker_fee_pct,