From 39200a542d1bc08ae6b80b04ec13380cd641b4ef Mon Sep 17 00:00:00 2001 From: jerick Date: Mon, 4 May 2026 16:15:06 -0400 Subject: [PATCH] Deduction before splitting for fees --- bot.py | 5 +++-- config.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bot.py b/bot.py index 1f0eea2..231bc3e 100644 --- a/bot.py +++ b/bot.py @@ -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, diff --git a/config.py b/config.py index e542359..10512ce 100644 --- a/config.py +++ b/config.py @@ -23,7 +23,7 @@ class Config: # Portfolio limits max_positions: int = 5 # Maximum concurrent holdings min_order_usd: float = 15.0 # Kraken minimum is ~$10; keep a small buffer - taker_fee_pct: float = 0.4 # Reserve this % per order for Kraken's taker fee (actual ~0.26%) + taker_fee_pct: float = 1.5 # Reserve this % of balance for fees/rounding (Kraken actual ~0.26%) # ── Risk management ────────────────────────────────────────────────────── # Trailing stop: sell if price drops this % below its peak since purchase.