What You’ll Set Up
By the end of this guide, you’ll have:
- A Binance account with API keys configured for trading
- Claude Code installed and ready to use
- A Python environment with the CCXT library
- A working script that fetches your account balance
Prerequisites
- A computer with Python 3.10+ installed
- A Binance account (we’ll show you how to get API keys)
Step 1: Get Your Binance API Keys
- Log into your Binance account
- Navigate to Account → API Management (see the Binance API documentation for full details)
- Click “Create API” and choose “System Generated”
- Name it something like
trading-bot-dev
Important: Only enable “Enable Spot & Margin Trading”. Do NOT enable withdrawals.
Save your API key and secret somewhere safe — you won’t be able to see the secret again.
Step 2: Install Claude Code
Open your terminal and install Claude Code:
npm install -g @anthropic-ai/claude-code
Verify the installation:
claude --version
Step 3: Set Up Your Python Project
Create a new project directory and set up a virtual environment:
mkdir my-trading-bot && cd my-trading-bot
python3 -m venv venv
source venv/bin/activate
pip install ccxt python-dotenv
Create a .env file for your API keys:
BINANCE_API_KEY=your_api_key_here
BINANCE_API_SECRET=your_secret_here
Step 4: Your First API Call
Ask Claude Code to generate a simple script:
claude "Write a Python script that uses ccxt to connect to Binance
and fetch my USDT balance. Use python-dotenv to load API keys
from a .env file."
Claude Code will generate something like:
import ccxt
import os
from dotenv import load_dotenv
load_dotenv()
exchange = ccxt.binance({
'apiKey': os.getenv('BINANCE_API_KEY'),
'secret': os.getenv('BINANCE_API_SECRET'),
})
balance = exchange.fetch_balance()
usdt = balance['total'].get('USDT', 0)
print(f"USDT Balance: {usdt}")
Run it:
python balance.py
If you see your USDT balance printed, everything is working.
Next Steps
- Build a DCA bot — Now that your setup is complete, follow the AI DCA Bot in Python tutorial to build your first trading bot
- Build a grid bot — Ready for something more active? Try building a grid trading bot with Claude Code