Nija

Multi-Exchange Trading Status Report

Issue: “Still no kraken connection or trade” + Coinbase rate limiting


Executive Summary

Current Situation: The bot is experiencing API rate limiting on Coinbase while Kraken remains disconnected due to missing credentials. This creates a single point of failure where all trading load falls on Coinbase, exacerbating rate limit issues.

Impact:

Solution: Configure Kraken credentials to enable multi-exchange trading and distribute API load.


Detailed Status by Exchange

1. Coinbase Advanced Trade

Status: ✅ CONNECTED but ⚠️ RATE LIMITED

Symptoms:

2026-01-12 10:38:27 | WARNING | ⚠️  API health low (48%), using reduced batch size=5
2026-01-12 10:38:27 | INFO    | 📊 Market rotation: scanning batch 70-75 of 12337 (1% through cycle)
Error fetching candles: {"message": "too many requests."}
2026-01-12 10:38:29 | ERROR   | 🚨 GLOBAL CIRCUIT BREAKER: 4 total errors - stopping scan to prevent API block
2026-01-12 10:38:29 | ERROR   | 💤 Waiting 30s for API to fully recover before next cycle...

Root Cause:

Current Mitigation:

Code References:

2. Kraken Pro

Status: ❌ NOT CONNECTED

Reason: API credentials not configured

Evidence:

Impact:

Solution: See “Quick Fix” section below

Code References:

3. Alpaca Markets

Status: ✅ CONNECTED and RUNNING

Evidence from logs:

2026-01-12 10:38:28 | INFO | 🔄 alpaca - Cycle #9
2026-01-12 10:38:28 | INFO |    alpaca: Running trading cycle...
2026-01-12 10:38:28 | INFO | 🔍 Enforcing position cap (max 8)...

Trading Status: Active (on Cycle #9)

Notes:


Suppressing the Single Exchange Warning

If you prefer to use only Coinbase and want to suppress the single exchange trading warning, you can set an environment variable:

For Railway/Render Deployment:

  1. Go to your deployment platform dashboard
  2. Navigate to Variables or Environment Variables tab
  3. Add this variable:
    SUPPRESS_SINGLE_EXCHANGE_WARNING = true
    
  4. Redeploy to apply changes

For Local Development:

  1. Edit .env file in project root
  2. Add this line:
    SUPPRESS_SINGLE_EXCHANGE_WARNING=true
    
  3. Restart bot: ./start.sh

Note: While this suppresses the warning, using multiple exchanges is still recommended for:


Quick Fix: Enable Kraken Trading

Why This Helps

Enabling Kraken will:

  1. Distribute API load - Split market scanning across Coinbase + Kraken
  2. Reduce rate limiting - Each exchange has independent rate limits
  3. Increase resilience - If one exchange has issues, others continue trading
  4. Access more markets - Kraken has different cryptocurrency pairs

Step 1: Get Kraken API Credentials

  1. Go to: https://www.kraken.com/u/security/api
  2. Click “Generate New Key”
  3. Configure permissions (required for trading):
    • Query Funds - Check account balance
    • Query Open Orders & Trades - Track positions
    • Query Closed Orders & Trades - Trade history
    • Create & Modify Orders - Place trades
    • Cancel/Close Orders - Stop losses
    • Withdraw Funds - DO NOT ENABLE (security)
  4. Copy the API Key and Private Key (Secret)

Step 2: Configure Environment Variables

For Railway Deployment (Recommended):

  1. Go to Railway project dashboard
  2. Navigate to Variables tab
  3. Add these variables:
    KRAKEN_PLATFORM_API_KEY = <your-api-key>
    KRAKEN_PLATFORM_API_SECRET = <your-api-secret>
    
  4. Click “Redeploy” to restart with new credentials

For Local Development:

  1. Edit .env file in project root
  2. Add these lines:
    KRAKEN_PLATFORM_API_KEY=<your-api-key>
    KRAKEN_PLATFORM_API_SECRET=<your-api-secret>
    
  3. Restart bot: ./start.sh

⚠️ SECURITY WARNING:

Step 3: Verify Connection

After configuring credentials and restarting:

Check logs for:

✅ KRAKEN PRO CONNECTED (MASTER)
   Account: MASTER
   USD Balance: $X.XX
   USDT Balance: $X.XX
   Total: $X.XX

Or run verification script:

python3 check_kraken_status.py

Expected output:

✅ Platform account: CONNECTED to Kraken
Balance: $X.XX USD / $X.XX USDT

Understanding the Architecture

Multi-Broker Independent Trading

The bot uses independent broker trading where each exchange operates in isolation:

Key Features:

Code Implementation:

How Brokers Are Discovered

On startup, the bot:

  1. Attempts to connect to each configured broker (Coinbase, Kraken, OKX, Binance, Alpaca)
  2. Checks for credentials in environment variables
  3. If credentials found, attempts connection with retry logic
  4. If credentials missing, gracefully skips that broker (no error)
  5. Only connected brokers participate in trading

From logs:

📊 Attempting to connect Coinbase Advanced Trade (MASTER)...
   ✅ Coinbase MASTER connected

📊 Attempting to connect Kraken Pro (MASTER)...
   ⚠️  Kraken credentials not configured for MASTER (skipping)

📊 Attempting to connect OKX (MASTER)...
   ⚠️  OKX credentials not configured (skipping)

Rate Limiting Strategy

Coinbase Limits:

With Kraken Enabled:

Circuit Breaker:


Expected Behavior After Kraken Connection

Startup Sequence

🌐 MULTI-ACCOUNT TRADING MODE ACTIVATED
   Platform account + User accounts trading independently

⏱️  Waiting 45s before connecting to avoid rate limits...
✅ Startup delay complete, beginning broker connections...

📊 Attempting to connect Coinbase Advanced Trade (MASTER)...
   ✅ Coinbase MASTER connected

📊 Attempting to connect Kraken Pro (MASTER)...
   ✅ Kraken MASTER connected
   USD Balance: $X.XX
   USDT Balance: $X.XX

🚀 STARTING INDEPENDENT MULTI-BROKER TRADING MODE
   Each broker will trade independently in isolated threads.

Trading Cycles

🔄 coinbase - Cycle #1
   coinbase: Running trading cycle...
   📊 Market rotation: scanning batch 0-5 of 732 (1% through cycle)
   ✅ coinbase cycle completed successfully
   coinbase: Waiting 2.5 minutes until next cycle...

🔄 kraken - Cycle #1
   kraken: Running trading cycle...
   📊 Market rotation: scanning batch 0-5 of 365 (1% through cycle)
   ✅ kraken cycle completed successfully
   kraken: Waiting 2.5 minutes until next cycle...

Load Distribution


Troubleshooting Guide

Issue 1: “Invalid nonce” errors on Kraken

Symptoms:

❌ Kraken connection test failed: EAPI:Invalid nonce

Cause: Nonce issues in multi-instance or rapid request scenarios

Solution: Already fixed in code!

Code Fix: bot/broker_manager.py lines 3291-3450

Issue 2: “Permission denied” on Kraken

Symptoms:

❌ Kraken connection test failed: EGeneral:Permission denied

Cause: API key doesn’t have required permissions

Solution:

  1. Go to https://www.kraken.com/u/security/api
  2. Find your API key and click “Edit”
  3. Enable all required permissions (see Step 1 above)
  4. Save and restart bot

Issue 3: Still seeing rate limits after Kraken connection

Possible Causes:

  1. Both exchanges hitting limits simultaneously
  2. Market scan batch size too large
  3. Scan delay too short
  4. Other API calls (balance checks, position queries) adding to load

Solutions:

  1. Reduce MARKET_BATCH_SIZE_MAX in bot/trading_strategy.py (currently 15)
  2. Increase MARKET_SCAN_DELAY (currently 8.0s)
  3. Enable additional exchanges (OKX, Binance) to further distribute load
  4. Monitor API health score in logs

Issue 4: Kraken connected but not trading

Check:

  1. Is Kraken account funded? Minimum $1.00 required
  2. Check logs for balance: USD Balance: $X.XX
  3. Verify trading cycle is running: 🔄 kraken - Cycle #X
  4. Check for errors in trading cycle

Common Issues:


Additional Resources

Documentation

Code References

Verification Scripts


Immediate (Fixes Current Issue)

  1. Configure Kraken credentials (see Quick Fix above)
  2. Restart bot to establish Kraken connection
  3. Monitor logs for connection confirmation
  4. Verify load distribution across both exchanges

Short Term (Optimization)

  1. Consider adding OKX for further load distribution
  2. Monitor API health scores across all exchanges
  3. Adjust batch sizes based on observed rate limits
  4. Fine-tune delays between operations

Long Term (Enhancement)

  1. Add Binance support for even more market coverage
  2. Implement intelligent routing (send orders to exchange with best price)
  3. Add failover logic (if one exchange down, increase load on others)
  4. Implement cross-exchange arbitrage opportunities

Conclusion

Current Problem: Kraken not connected → All load on Coinbase → Rate limiting → Circuit breaker triggering

Root Cause: Missing Kraken API credentials in environment variables

Solution: Configure KRAKEN_PLATFORM_API_KEY and KRAKEN_PLATFORM_API_SECRET in Railway/local environment

Expected Result: Multi-exchange trading with distributed load, reduced rate limiting, improved resilience

Time to Implement: 5-10 minutes (get API key + configure + restart)

Risk: Low - Code is production-ready, just needs credentials


Status: 🟡 WAITING FOR CONFIGURATION Priority: HIGH (blocking multi-exchange trading) Next Action: Configure Kraken credentials per instructions above