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,

View File

@@ -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.