Debugging Tools for Exchange Connectivity

This directory contains several debugging tools to help diagnose and fix issues with exchange connectivity, particularly for Bybit integration.

Available Debug Tools

1. debug_bybit_api.py

A comprehensive diagnostic tool for Bybit API connectivity issues. This script:

Usage:

python debug_bybit_api.py

2. debug_bybit_auth.py

Specifically tests authentication with Bybit using credentials from different sources:

Usage:

python debug_bybit_auth.py

3. debug_bybit_credentials.py

Prints information about Bybit credentials from different sources to help identify which credentials are being used.

Usage:

python debug_bybit_credentials.py

4. debug_exchange_connection.py

Tests the exchange connection using the current environment variables, attempting to initialize the exchange and fetch basic data.

Usage:

python debug_exchange_connection.py

5. debug_bybit_connection.py

A more advanced diagnostic tool that performs comprehensive connectivity tests:

Usage:

python debug_bybit_connection.py
# For more verbose output
python debug_bybit_connection.py --verbose

Common Issues and Solutions

1. Missing or Invalid API Credentials

Symptoms:

Solutions:

2. Network Connectivity Issues

Symptoms:

Solutions:

3. Testnet vs. Mainnet Configuration

Symptoms:

Solutions:

4. Rate Limiting Issues

Symptoms:

Solutions:

5. Event Loop Issues

Symptoms:

Solutions:

Troubleshooting Process

  1. Run debug_bybit_credentials.py to check which credentials are being used
  2. Run debug_bybit_connection.py for a comprehensive network and API diagnosis
  3. Run debug_bybit_api.py for more detailed API functionality testing
  4. Fix any issues identified by the diagnostic tools
  5. Run debug_exchange_connection.py to verify that the exchange connection works with the application code
  6. If issues persist, check the Bybit API documentation and status page

Environment Variables

Variable Description Default
BYBIT_API_KEY Bybit API key -
BYBIT_API_SECRET Bybit API secret -
BYBIT_TESTNET Whether to use testnet (true/false) false
EXCHANGE_API_KEY Generic exchange API key (fallback) -
EXCHANGE_API_SECRET Generic exchange API secret (fallback) -
EXCHANGE_TESTNET Generic testnet setting (fallback) true
EXCHANGE_TYPE Type of exchange to use bybit