PowerTraderAI

Binance Exchange Setup Guide

Overview

Binance is the world’s largest cryptocurrency exchange by trading volume, offering extensive cryptocurrency selection and advanced trading features. Available globally with regional variations.

🌍 Regional Availability

Important: Use Binance.US if you’re a US resident, regular Binance.com for other regions.

📋 Prerequisites

Account Requirements

Trading Prerequisites

🚀 Step 1: Create Binance Account

Registration Process

  1. Visit binance.com or binance.us (US only)
  2. Click “Register” and create account
  3. Enter email and secure password
  4. Verify email through confirmation link
  5. Set up two-factor authentication (required)

Identity Verification (KYC)

  1. Navigate to Account → Identification
  2. Select verification level:
    • Basic: Daily withdrawal limit up to 2 BTC
    • Intermediate: Daily withdrawal limit up to 100 BTC
    • Advanced: Higher limits, fiat deposits
  3. Upload documents:
    • Government-issued photo ID
    • Proof of address (utility bill, bank statement)
    • Selfie for facial verification
  4. Wait for approval (usually 15 minutes to 24 hours)

Enable Two-Factor Authentication

  1. Download Google Authenticator or similar app
  2. Navigate to Account → Security → Two-factor Authentication
  3. Scan QR code with authenticator app
  4. Enter 6-digit verification code
  5. Save backup codes securely

🔑 Step 2: API Key Creation

Generate API Keys

  1. Log in to your Binance account
  2. Navigate to Account → API Management
  3. Click “Create API”
  4. Enter label: “PowerTraderAI+ Bot”
  5. Complete security verification (SMS + 2FA)

Configure API Permissions

Enable these permissions for trading:

  1. IP Access Restriction: Enable and add your IP
  2. Enable Spot & Margin Trading: For buy/sell operations
  3. Disable Withdrawals: For security
  4. Set API Key Expiration: Optional, for additional security

Save Your Credentials

API Key: your_api_key_here Secret Key: your_secret_key_here

⚠️ Warning: Never share these keys - they provide access to your account!

🔐 Step 3: Configure PowerTraderAI+

Credential File Setup

Create credentials/binance_config.json:

{
  "api_key": "your_api_key",
  "api_secret": "your_secret_key",
  "testnet": false,
  "base_url": "https://api.binance.com"
}

For Binance.US Users

Create credentials/binance_config.json:

{
  "api_key": "your_api_key",
  "api_secret": "your_secret_key",
  "testnet": false,
  "base_url": "https://api.binance.us"
}

Environment Variables (Production)

export BINANCE_API_KEY="your_api_key"
export BINANCE_API_SECRET="your_secret_key"
export BINANCE_BASE_URL="https://api.binance.com"

GUI Configuration

  1. Launch PowerTraderAI+: python app/pt_hub.py
  2. Go to SettingsExchange Provider Settings
  3. Set Region: “global” (or “us” for Binance.US)
  4. Select Primary Exchange: “binance”
  5. Click Exchange Setup button
  6. Enter your API credentials when prompted

🔧 Step 4: Testing Connection

Manual Test

cd app
python test_exchanges.py --exchange=binance

Expected Output

Testing Binance connection...
✅ API connection successful
✅ Account information retrieved
✅ Trading permissions verified
✅ Market data available
Current BTC price: $43,250.50

Programmatic Test

from pt_exchanges import BinanceExchange
import asyncio

async def test_binance():
    exchange = BinanceExchange({
        "api_key": "your_api_key",
        "api_secret": "your_secret_key"
    })

    if await exchange.initialize():
        # Test account access
        balance = await exchange.get_balance()
        print(f"Account balance: {balance}")

        # Test market data
        market_data = await exchange.get_market_data("BTCUSDT")
        print(f"BTC price: ${market_data.price}")

        # Test trading permissions
        try:
            # This won't actually place an order (test mode)
            print("✅ Trading permissions verified")
        except Exception as e:
            print(f"❌ Trading test failed: {e}")
    else:
        print("❌ Connection failed")

asyncio.run(test_binance())

💰 Step 5: Funding Your Account

Deposit Methods

  1. Navigate to Wallet → Fiat and Spot
  2. Click “Deposit”
  3. Select cryptocurrency (BTC, ETH, USDT, etc.)
  4. Choose network (BEP20, ERC20, etc.) - Important: Match sender’s network!
  5. Copy deposit address
  6. Send crypto from external wallet
  7. Wait for confirmations (1-50+ depending on network)

Fiat Deposits

Important Notes

📊 Trading Features

Supported Trading Pairs

Binance offers 500+ trading pairs including:

Order Types

Advanced Features

⚙️ Advanced Configuration

Trading Parameters

{
  "api_key": "your_api_key",
  "api_secret": "your_secret_key",
  "trading_config": {
    "default_order_type": "LIMIT",
    "time_in_force": "GTC",
    "iceberg_qty": null,
    "recv_window": 5000
  },
  "risk_management": {
    "max_position_size_usdt": 10000,
    "enable_stop_losses": true,
    "max_slippage_pct": 0.1
  }
}

Symbol Formats

Binance uses specific symbol formats:

# Standard format: No separator between base and quote
"BTCUSDT"  # Bitcoin vs Tether
"ETHUSDT"  # Ethereum vs Tether
"ADAUSDT"  # Cardano vs Tether
"BNBUSDT"  # Binance Coin vs Tether

# PowerTrader converts automatically:
"BTC-USD"  "BTCUSDT"
"ETH-USD"  "ETHUSDT"

Rate Limits

Binance has strict rate limits:

🚨 Troubleshooting

Common Issues

❌ “Invalid API Key”

Causes:

Solutions:

  1. Verify API credentials in Binance account
  2. Check if API key is enabled
  3. Ensure correct base URL for your region
  4. Regenerate API key if necessary

❌ “Signature invalid”

Causes:

Solutions:

  1. Verify API secret is correct
  2. Synchronize system clock (use NTP)
  3. Check request formatting
  4. Increase recv_window parameter

❌ “Rate limit exceeded”

Causes:

Solutions:

  1. Implement request throttling
  2. Use WebSocket streams for market data
  3. Reduce trading frequency
  4. Distribute requests over time

❌ “Account not authorized for trading”

Causes:

Solutions:

  1. Complete identity verification
  2. Enable spot trading in API settings
  3. Check account status
  4. Contact Binance support

❌ “Insufficient balance”

Causes:

Solutions:

  1. Check account balances
  2. Cancel open orders to free funds
  3. Verify minimum trade amounts
  4. Add more funds to account

Support Resources

🔒 Security Best Practices

API Security

Account Security

Trading Security

📈 Performance Optimization

API Optimization

import asyncio
import aiohttp
from datetime import datetime

class BinanceOptimized:
    def __init__(self, api_key, api_secret):
        self.api_key = api_key
        self.api_secret = api_secret
        self.session = None

    async def __aenter__(self):
        # Use connection pooling
        connector = aiohttp.TCPConnector(
            limit=100,  # Connection pool size
            limit_per_host=30,  # Connections per host
            keepalive_timeout=60  # Keep connections alive
        )

        self.session = aiohttp.ClientSession(
            connector=connector,
            timeout=aiohttp.ClientTimeout(total=30)
        )
        return self

    async def __aexit__(self, exc_type, exc_val, exc_tb):
        if self.session:
            await self.session.close()

WebSocket Integration

# Use WebSocket for real-time data
import websockets
import json

async def binance_websocket():
    uri = "wss://stream.binance.com:9443/ws/btcusdt@ticker"

    async with websockets.connect(uri) as websocket:
        async for message in websocket:
            data = json.loads(message)
            price = float(data['c'])  # Current price
            print(f"BTC price update: ${price:,.2f}")

Fee Optimization


Binance Setup Complete! Your world-class cryptocurrency exchange integration is ready for PowerTraderAI+.