I am trying to fetch future pairs by volume. My settings seem pretty clean (even with a dedicated IP). It was able to return output for the spot but not the futures market.
I am willing to learn from anyone who has been able to work around this. I have provided my python code. Please review and help me navigate this challenge.
import asyncio
import ccxt.async_support as ccxt_async
import os
from dotenv import load_dotenv
load_dotenv()
async def debug_binance_connection():
"""Debug function to check Binance connection and symbol availability"""
api_key = os.getenv("BINANCE_FUTURES_API_KEY")
secret_key = os.getenv("BINANCE_FUTURES_SECRET_KEY")
print("=" * 60)
print("BINANCE CONNECTION DEBUG")
print("=" * 60)
if not api_key or not secret_key:
print("❌ Missing API credentials!")
print(f"API Key present: {bool(api_key)}")
print(f"Secret Key present: {bool(secret_key)}")
return
print("✅ API credentials found")
# Try both spot and futures
for market_type in ['spot', 'future']:
print(f"\n{'='*60}")
print(f"Testing {market_type.upper()} market...")
print("="*60)
exchange = ccxt_async.binance({
'apiKey': api_key,
'secret': secret_key,
'options': {'defaultType': market_type},
'enableRateLimit': True
})
try:
# Test API connection
print(f"\n1. Loading markets...")
markets = await exchange.load_markets()
print(f"✅ Successfully loaded {len(markets)} markets")
# Get USDT pairs
usdt_pairs = [s for s in markets if s.endswith('/USDT')]
print(f"✅ Found {len(usdt_pairs)} USDT pairs")
# Test ticker fetching
print(f"\n2. Fetching tickers...")
tickers = await exchange.fetch_tickers()
print(f"✅ Successfully fetched {len(tickers)} tickers")
# Analyze symbols
print(f"\n3. Analyzing tradable symbols...")
# Volume thresholds to test
volume_thresholds = [1_000_000, 500_000, 200_000, 100_000, 50_000, 10_000]
for threshold in volume_thresholds:
qualifying_symbols = []
for symbol in usdt_pairs:
if symbol in tickers:
ticker = tickers[symbol]
volume = ticker.get('quoteVolume', 0)
if volume > threshold:
qualifying_symbols.append((symbol, volume))
print(f" Volume > ${threshold:,}: {len(qualifying_symbols)} symbols")
if len(qualifying_symbols) > 0 and threshold == 200_000:
# Show top 10 for the current threshold
qualifying_symbols.sort(key=lambda x: x[1], reverse=True)
print(f"\n Top 10 symbols with volume > $200,000:")
for i, (sym, vol) in enumerate(qualifying_symbols[:10]):
print(f" {i+1}. {sym}: ${vol:,.0f}")
# Check spread analysis
print(f"\n4. Analyzing spreads...")
spread_analysis = {'< 0.05%': 0, '0.05-0.1%': 0, '0.1-0.2%': 0, '> 0.2%': 0}
for symbol in usdt_pairs[:100]: # Check first 100 symbols
if symbol in tickers:
ticker = tickers[symbol]
if ticker.get('bid') and ticker.get('ask') and ticker['bid'] > 0:
spread = (ticker['ask'] - ticker['bid']) / ticker['bid'] * 100
if spread < 0.05:
spread_analysis['< 0.05%'] += 1
elif spread < 0.1:
spread_analysis['0.05-0.1%'] += 1
elif spread < 0.2:
spread_analysis['0.1-0.2%'] += 1
else:
spread_analysis['> 0.2%'] += 1
print(" Spread distribution (first 100 symbols):")
for range_name, count in spread_analysis.items():
print(f" {range_name}: {count} symbols")
except Exception as e:
print(f"❌ Error with {market_type} market: {str(e)}")
finally:
await exchange.close()
if __name__ == "__main__":
asyncio.run(debug_binance_connection())
============================================================
Testing SPOT market...
============================================================
1. Loading markets...
✅ Successfully loaded 3779 markets
✅ Found 595 USDT pairs
2. Fetching tickers...
✅ Successfully fetched 3185 tickers
3. Analyzing tradable symbols...
Volume > $1,000,000: 314 symbols
Volume > $500,000: 377 symbols
Volume > $200,000: 408 symbols
Top 10 symbols with volume > $200,000:
1. BTC/USDT: $2,772,388,764
2. ETH/USDT: $2,274,294,156
3. USDC/USDT: $1,690,662,665
4. SOL/USDT: $620,571,290
5. XRP/USDT: $598,080,842
6. FDUSD/USDT: $550,642,659
7. ENA/USDT: $467,234,153
8. DOGE/USDT: $354,330,141
9. ERA/USDT: $254,137,923
10. SUI/USDT: $231,924,496
Volume > $100,000: 409 symbols
Volume > $50,000: 409 symbols
Volume > $10,000: 410 symbols
4. Analyzing spreads...
Spread distribution (first 100 symbols):
< 0.05%: 30 symbols
0.05-0.1%: 12 symbols
0.1-0.2%: 14 symbols
> 0.2%: 3 symbols
============================================================
Testing FUTURE market...
============================================================
1. Loading markets...
✅ Successfully loaded 3779 markets
✅ Found 595 USDT pairs
2. Fetching tickers...
✅ Successfully fetched 534 tickers
3. Analyzing tradable symbols...
Volume > $1,000,000: 0 symbols
Volume > $500,000: 0 symbols
Volume > $200,000: 0 symbols
Volume > $100,000: 0 symbols
Volume > $50,000: 0 symbols
Volume > $10,000: 0 symbols
4. Analyzing spreads...
Spread distribution (first 100 symbols):
< 0.05%: 0 symbols
0.05-0.1%: 0 symbols
0.1-0.2%: 0 symbols
> 0.2%: 0 symbols
============================================================
Testing SPOT market...
============================================================
1. Loading markets...
✅ Successfully loaded 3779 markets
✅ Found 595 USDT pairs
2. Fetching tickers...
✅ Successfully fetched 3185 tickers
3. Analyzing tradable symbols...
Volume > $1,000,000: 314 symbols
Volume > $500,000: 377 symbols
Volume > $200,000: 408 symbols
Top 10 symbols with volume > $200,000:
1. BTC/USDT: $2,772,388,764
2. ETH/USDT: $2,274,294,156
3. USDC/USDT: $1,690,662,665
4. SOL/USDT: $620,571,290
5. XRP/USDT: $598,080,842
6. FDUSD/USDT: $550,642,659
7. ENA/USDT: $467,234,153
8. DOGE/USDT: $354,330,141
9. ERA/USDT: $254,137,923
10. SUI/USDT: $231,924,496
Volume > $100,000: 409 symbols
Volume > $50,000: 409 symbols
Volume > $10,000: 410 symbols
4. Analyzing spreads...
Spread distribution (first 100 symbols):
< 0.05%: 30 symbols
0.05-0.1%: 12 symbols
0.1-0.2%: 14 symbols
> 0.2%: 3 symbols
============================================================
Testing FUTURE market...
============================================================
1. Loading markets...
✅ Successfully loaded 3779 markets
✅ Found 595 USDT pairs
2. Fetching tickers...
✅ Successfully fetched 534 tickers
3. Analyzing tradable symbols...
Volume > $1,000,000: 0 symbols
Volume > $500,000: 0 symbols
Volume > $200,000: 0 symbols
Volume > $100,000: 0 symbols
Volume > $50,000: 0 symbols
Volume > $10,000: 0 symbols
4. Analyzing spreads...
Spread distribution (first 100 symbols):
< 0.05%: 0 symbols
0.05-0.1%: 0 symbols
0.1-0.2%: 0 symbols
> 0.2%: 0 symbols