Setup guide

Set up Charles

Get Charles running 24/7 on your own server in about 30 minutes — most of it waiting for installs. Then, optionally, add Claude Code so you can change the bot by describing what you want.

Before you start

You need three free accounts (plus Telegram if you want phone alerts). Keep the keys somewhere safe — you'll paste them in step 4.

ServiceWhat it's forWhere to get the key
AlpacaBrokerage — paper trading with simulated moneyalpaca.markets → sign up → switch to Paper → API Keys → Generate. Copy the key and the secret.
GroqThe LLM that reasons over each tradeconsole.groq.com → API Keys → Create. The free tier is enough.
DigitalOceanThe server Charles runs ondigitalocean.com — new accounts through this link get free credit.
Telegram (optional)Trade alerts on your phoneMessage @BotFather → /newbot for a token. Send your new bot a message, then message @userinfobot for your chat ID.

Server setup

1Create a server

In DigitalOcean: Create → Droplets, then choose:

SettingChoose
RegionNew York (closest to US markets)
ImageUbuntu 24.04 LTS (22.04 also works)
SizeBasic → Regular. 2 GB / 1 CPU (~$12/mo) runs the bot. Pick 4 GB / 2 CPU (~$24/mo) if you'll also use Claude Code on it.
AuthenticationSSH key if you have one, otherwise a strong password

Click Create Droplet and copy its IPv4 address once it's ready — below it's called YOUR_SERVER_IP.

2Connect to it

Open PowerShell (Windows) or Terminal (Mac/Linux) and log in. Type yes the first time, then your password.

Your computer
ssh root@YOUR_SERVER_IP

Your prompt changes to something like root@charles:~# — every command from here runs on the server.

3Run the installer

One command sets up everything: Python 3.11, the Charles code from GitHub, all packages, swap space, the firewall, an auto-start service and the charles-* commands. It takes 10–20 minutes and is safe to run again.

Server
curl -fsSL https://charles-bot.xyz/install.sh -o install.sh
bash install.sh

Prefer to read it first? View install.sh — it's plain bash.

4Add your keys

Open the keys file the installer created:

Server
nano ~/charles/.env

Replace the placeholder values with your keys (leave the Telegram lines as they are if you're skipping it). Other lines in the file can stay as they are.

ALPACA_API_KEY=your_paper_key
ALPACA_SECRET_KEY=your_paper_secret
GROQ_API_KEY=your_groq_key
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id

Save with Ctrl+X, then Y, then Enter.

Paper vs live. Paper keys trade simulated money. Live trading means swapping in keys from a funded Alpaca live account — only do that once you understand how the bot behaves, and at your own risk.

5Start Charles

Server
charles-start
  1. First run only: open http://YOUR_SERVER_IP:8502 in your browser. A short setup page confirms your keys and settings — click Launch.
  2. The dashboard is then live at http://YOUR_SERVER_IP:8501. Bookmark it — it works on your phone too.
  3. Watch it come up with charles-logs (press Ctrl+C to stop watching). Look for ✅ Alpaca connected and ✅ Groq connected. The first start can take a few minutes.

That's it. Charles now trades during market hours, restarts itself after a crash or reboot, and alerts you on Telegram.

Everyday commands

Run these on the server after logging in with ssh.

CommandWhat it does
charles-statusIs it running? Shows the dashboard address.
charles-logsLive log of everything the bot does
charles-restartRestart — needed after any change to the code or .env
charles-stop / charles-startStop or start the bot
charles-updatePull the latest version from GitHub, update packages and restart

Change the bot with Claude Code

Claude Code is Anthropic's AI coding assistant for the terminal. Installed on the same server, it can read Charles's code, logs and data, explain what the bot did, and make the changes you ask for — then restart the bot and check it came back healthy. You describe the change; it does the editing.

What you need: a Claude Pro or Max subscription, or an Anthropic Console account with API credit. A 4 GB droplet is recommended so the bot and Claude Code both have room.

1Install and sign in

Server
curl -fsSL https://claude.ai/install.sh | bash
exec bash   # reload the shell so the claude command is found

Start it inside tmux, so the session keeps running if your connection drops:

tmux new -s claude
cd ~/charles
claude

The first time, Claude Code asks you to sign in. The server has no browser, so it shows a link: open it on your own computer, sign in, and paste the code it gives you back into the terminal.

To leave Claude running and log out, press Ctrl+B then D. Next time, ssh in and run tmux attach -t claude to pick up where you left off.

2Your first session

  1. Type /init. Claude reads the project and writes a CLAUDE.md file describing it — that file is loaded at the start of every session, so Claude always knows how Charles is laid out.
  2. Add your own house rules to CLAUDE.md (or just ask Claude to add them). For example:
    # My rules
    - Paper trading only. Never switch to live keys.
    - Never print or edit .env.
    - Commit every change with git, one change per commit.
    - After changing code, run charles-restart and check charles-logs for errors.
  3. Make a branch for your own changes, so charles-update never tangles with them: ask Claude to "create a git branch called my-changes", or run git checkout -b my-changes.

3What to ask

Plain English works. A few ideas:

Explain how Charles decides to buy a stock, step by step, with the files involved.
Why didn't it trade today? Check the logs and tell me what blocked each signal.
Summarise this week's closed trades: win rate, average win and loss, best and worst.
Send me a Telegram summary of the day's trades at 4:15 PM Eastern.
Make the trailing stop tighter on losing positions, show me the diff, then restart the bot.
The dashboard won't load — find out why and fix it.

4Working safely

Run on your own computer

Handy for a first look. You need Python 3.11 and git.

Your computer
git clone https://github.com/nswansonprojects/charles.git
cd charles
python -m venv .venv
# Windows: .venv\Scripts\activate    Mac/Linux: source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env    # then add your keys to .env
python main.py

A setup page opens at http://localhost:8502; after you click Launch, the dashboard is at http://localhost:8501. Charles stops when your computer sleeps or shuts down.

Troubleshooting

ProblemFix
Bot won't startRun charles-logs. It's usually a missing or mistyped key in ~/charles/.env — fix it, then charles-restart.
Setup page or dashboard won't loadCheck charles-status. Make sure you're using http:// (not https) and the right port: 8502 for first-run setup, 8501 for the dashboard.
Groq errors in the logCheck the key at console.groq.com. If Groq is unreachable Charles falls back to rule-based signals and keeps running.
Installer stopped partwayRun bash install.sh again — finished steps are skipped.
charles-update says it can't pullYou've changed files on main. Ask Claude Code to move your changes to a branch and update, or run git status to see what changed.
claude: command not foundRun exec bash (or log out and back in) after installing Claude Code.
Reminder. Charles places simulated orders on Alpaca's paper account until you deliberately connect live keys. It makes no profit guarantees, and nothing here is financial advice.