Skip to content

Fix Kraken nonce recovery and Coinbase balance fallback in trading loop#1090

Merged
dantelrharrell-debug merged 2 commits intomainfrom
copilot/fix-nonce-handling-balance-fallback
Mar 31, 2026
Merged

Fix Kraken nonce recovery and Coinbase balance fallback in trading loop#1090
dantelrharrell-debug merged 2 commits intomainfrom
copilot/fix-nonce-handling-balance-fallback

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

run_broker_trading_loop() had two silent failure paths: Coinbase balance checks bypassed the zero-balance retry logic, and Kraken nonce errors were counted as broker failures (accelerating dead-broker marking) instead of being recovered transparently.

Changes

  • Balance fallback (run_broker_trading_loop): Replace direct broker.get_account_balance() with self._get_broker_balance(broker, broker_type, broker_name), routing Coinbase through _retry_coinbase_balance_if_zero() to handle stale API-cached $0 responses post-connect.

  • Nonce error recovery (run_broker_trading_loop): Before the standard failure path, detect Kraken nonce errors and recover without incrementing the failure counter:

    if "nonce" in _err_lower and broker_name == "kraken" and jump_global_kraken_nonce_forward is not None:
        jump_global_kraken_nonce_forward(60_000)  # jump 60 s forward
        stop_flag.wait(5)
        continue  # retry immediately, no failure recorded
  • Import: Added graceful import of jump_global_kraken_nonce_forward from global_kraken_nonce (falls back to None if unavailable, recovery path is skipped safely).

@railway-app
Copy link
Copy Markdown

railway-app bot commented Mar 31, 2026

🚅 Deployed to the Nija-pr-1090 environment in patient-compassion

Service Status Web Updated (UTC)
Nija ✅ Success (View Logs) Mar 31, 2026 at 6:19 am

@railway-app railway-app bot temporarily deployed to patient-compassion / Nija-pr-1090 March 31, 2026 06:13 Destroyed
Agent-Logs-Url: https://github.com/dantelrharrell-debug/Nija/sessions/dedd56b1-3815-4307-9b41-9fed8d5ef2e5

Co-authored-by: dantelrharrell-debug <232652186+dantelrharrell-debug@users.noreply.github.com>
@railway-app railway-app bot temporarily deployed to patient-compassion / Nija-pr-1090 March 31, 2026 06:18 Destroyed
Copilot AI changed the title [WIP] Fix nonce handling and balance fallback issues Fix Kraken nonce recovery and Coinbase balance fallback in trading loop Mar 31, 2026
@dantelrharrell-debug dantelrharrell-debug marked this pull request as ready for review March 31, 2026 06:20
@dantelrharrell-debug dantelrharrell-debug merged commit 5555d07 into main Mar 31, 2026
23 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants