From 5c188e5d3aef684132e893f6f942c332180055cc Mon Sep 17 00:00:00 2001 From: mike Date: Sun, 5 Jul 2026 15:20:35 -0500 Subject: [PATCH] fix(main): read balance instead of nonexistent balance_dollars field Kalshi's /portfolio/balance response has no balance_dollars key, only balance (integer cents). The stale field check always failed, so the bot silently fell back to the hardcoded BANKROLL default instead of sizing off the live account balance. Co-Authored-By: Claude Sonnet 5 --- src/main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index 3cf6f40..103e3af 100644 --- a/src/main.py +++ b/src/main.py @@ -18,7 +18,16 @@ def main(): try: api = KalshiAPI(KALSHI_API_KEY) notifier = Notifier(TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID) - trader = Trader(api, notifier, logger, BANKROLL) + + balance_response = api.get_account_balance() + if balance_response and 'balance' in balance_response: + bankroll = float(balance_response['balance']) / 100 + logger.info(f"Using live Kalshi account balance as bankroll: ${bankroll:.2f}") + else: + bankroll = BANKROLL + logger.warning(f"Could not fetch live balance; falling back to configured BANKROLL: ${bankroll:.2f}") + + trader = Trader(api, notifier, logger, bankroll) # Start market data streaming (Phase 3 feature) trader.market_data_streamer.start_streaming()