Skip to main content
CryptoView Pro supports both Binance and Kraken exchanges for collecting real-time cryptocurrency data. The application uses the CCXT library to communicate with exchange APIs.

Supported Exchanges

The data collector (data/collectors.py:12-32) supports:
  • Kraken (default) - Public data access without API keys
  • Binance - Requires API keys for enhanced rate limits
Public endpoints work without authentication, but API keys provide higher rate limits and access to additional features.

Quick Setup

Option 1: Kraken (No API Keys Required)

Kraken is the default exchange and works immediately without configuration:
from data.collectors import CryptoDataCollector

# Initialize with Kraken (default)
collector = CryptoDataCollector(exchange_name='kraken')
No .env configuration needed for basic usage.

Option 2: Binance with API Keys

For Binance or enhanced features, configure API credentials:
.env
BINANCE_API_KEY=your_api_key_here
BINANCE_API_SECRET=your_api_secret_here

Getting Binance API Keys

Follow these steps to create API keys on Binance:

Step 1: Create Binance Account

  1. Visit binance.com
  2. Complete registration and KYC verification
  3. Enable two-factor authentication (2FA)

Step 2: Generate API Keys

  1. Log in to your Binance account
  2. Navigate to ProfileAPI Management
  3. Click Create API
  4. Choose System Generated API
  5. Label it (e.g., “CryptoView Pro”)
  6. Complete 2FA verification
  7. Save your API Key and Secret Key securely
Never share your API Secret Key! Store it securely and never commit it to version control.

Step 3: Configure API Restrictions

For security, restrict your API key permissions:
  • Enable Reading - Required for market data
  • Disable Spot & Margin Trading - Not needed
  • Disable Withdrawals - Not needed
  • Optional: Restrict to specific IP addresses
CryptoView Pro only needs read permissions for public market data. Never enable trading or withdrawal permissions.

Getting Kraken API Keys (Optional)

Kraken works without API keys, but you can add them for increased rate limits:
  1. Log in to kraken.com
  2. Navigate to SettingsAPI
  3. Click Generate New Key
  4. Set permissions to Query Funds and Query Open Orders
  5. Save API Key and Private Key
Add to .env:
KRAKEN_API_KEY=your_kraken_key
KRAKEN_API_SECRET=your_kraken_secret
Currently the application is configured for Binance credentials in config/settings.py:8-9. To use Kraken keys, modify the settings file accordingly.

Data Collector Usage

The CryptoDataCollector class handles all exchange interactions (data/collectors.py:12-101).

Initialize Collector

from data.collectors import CryptoDataCollector

# Use Kraken (default, no API keys needed)
collector = CryptoDataCollector(exchange_name='kraken')

# Or use Binance
collector = CryptoDataCollector(exchange_name='binance')

Fetch Historical Data

Retrieve OHLCV (Open, High, Low, Close, Volume) data:
# Get 1000 hourly candles for BTC/USDT
df = collector.fetch_ohlcv(
    symbol='BTC/USDT',
    timeframe='1h',
    limit=1000
)

# Returns pandas DataFrame with columns:
# - timestamp (index)
# - open, high, low, close, volume
# - returns (percentage change)
# - log_returns (logarithmic returns)
See data/collectors.py:35-60 for implementation details.

Get Current Price

price = collector.get_current_price('BTC/USDT')
print(f"Current BTC price: ${price:,.2f}")

Get 24-Hour Statistics

stats = collector.get_24h_stats('BTC/USDT')

print(f"Last: ${stats['last']:,.2f}")
print(f"24h High: ${stats['high']:,.2f}")
print(f"24h Low: ${stats['low']:,.2f}")
print(f"24h Volume: ${stats['volume']:,.2f}")
print(f"24h Change: {stats['percentage']:.2f}%")
See implementation at data/collectors.py:74-91.

Connection Testing

Test your exchange configuration:
from data.collectors import test_connection

# Test Kraken connection
if test_connection('kraken'):
    print("✅ Kraken connection successful")
else:
    print("❌ Kraken connection failed")

# Test Binance connection
if test_connection('binance'):
    print("✅ Binance connection successful")
else:
    print("❌ Binance connection failed")
See data/collectors.py:93-100 for the test function.

Configuration Details

The collector is initialized with these settings (data/collectors.py:19-32):
exchange_class({
    'enableRateLimit': True,  # Automatic rate limiting
    'timeout': 30000,         # 30 second timeout
    'apiKey': BINANCE_API_KEY,
    'secret': BINANCE_API_SECRET,
})

Features

  • Automatic rate limiting - Respects exchange API limits
  • Data caching - Results cached for 60 seconds (configurable)
  • Error handling - Graceful failures with error messages
  • Multiple timeframes - Supports 1m, 5m, 15m, 1h, 4h, 1d
  • Calculated fields - Auto-computes returns and log returns

Rate Limits

Binance

  • Without API keys: 1200 requests/minute
  • With API keys: 2400 requests/minute
  • Weight-based system: Different endpoints cost different weights

Kraken

  • Public endpoints: 1 request/second
  • With API keys: Higher tier limits available
Exceeding rate limits will result in temporary IP bans. The collector automatically handles rate limiting with enableRateLimit: True.

Troubleshooting

Connection Errors

If you see “Error conectando a exchange”:
  1. Verify API keys are correct in .env
  2. Check API key permissions on exchange
  3. Ensure API key is not IP-restricted
  4. Verify your internet connection

Invalid API Keys

❌ Error obteniendo datos: Invalid API-key, IP, or permissions
Solution:
  • Double-check BINANCE_API_KEY and BINANCE_API_SECRET in .env
  • Verify API key is active on Binance
  • Check API key permissions include “Enable Reading”

Rate Limit Exceeded

❌ Error: Rate limit exceeded
Solution:
  • The collector automatically handles rate limiting
  • If you’re making manual requests, add delays between calls
  • Consider using API keys for higher limits

Symbol Not Found

❌ Error obteniendo datos: Symbol not found
Solution:
  • Verify the trading pair exists on the exchange (e.g., ‘BTC/USDT’)
  • Use correct format: BASE/QUOTE (e.g., ‘ETH/USDT’, not ‘ETHUSDT’)
  • Check supported pairs in settings: config/settings.py:12-16

Security Best Practices

  • Store keys in .env file, never in code
  • Add .env to .gitignore
  • Use environment variables in production
  • Rotate keys periodically
  • Only enable “Enable Reading” permission
  • Disable all trading and withdrawal permissions
  • Use IP restrictions when possible
  • Create separate keys for different applications
  • Regularly check API key activity on exchange
  • Set up email alerts for unusual activity
  • Revoke keys immediately if compromised
  • Keep backup access methods configured

Next Steps

Configuration Settings

Learn about all configuration options

Telegram Setup

Configure price alerts and notifications

Build docs developers (and LLMs) love