Deduction before splitting for fees
This commit is contained in:
5
bot.py
5
bot.py
@@ -187,9 +187,10 @@ def run_cycle(config: Config) -> bool:
|
|||||||
return bool(closed)
|
return bool(closed)
|
||||||
|
|
||||||
to_buy = opportunities[:num_to_buy]
|
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)
|
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(
|
log.info(
|
||||||
"Buying %d asset(s) @ $%.2f each (total $%.2f, %.1f%% fee reserve applied)",
|
"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,
|
num_to_buy, alloc_per_asset, alloc_per_asset * num_to_buy, config.taker_fee_pct,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class Config:
|
|||||||
# Portfolio limits
|
# Portfolio limits
|
||||||
max_positions: int = 5 # Maximum concurrent holdings
|
max_positions: int = 5 # Maximum concurrent holdings
|
||||||
min_order_usd: float = 15.0 # Kraken minimum is ~$10; keep a small buffer
|
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 ──────────────────────────────────────────────────────
|
# ── Risk management ──────────────────────────────────────────────────────
|
||||||
# Trailing stop: sell if price drops this % below its peak since purchase.
|
# Trailing stop: sell if price drops this % below its peak since purchase.
|
||||||
|
|||||||
Reference in New Issue
Block a user