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, auto-start services, the monthly rule check and the charles-* commands. It takes 5–10 minutes and is safe to run again (re-run it to update an older install).

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. To change a key later, run charles-keys: it saves the new key and restarts the bot.

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. Open the dashboard at http://YOUR_SERVER_IP:8502. Bookmark it — it works on your phone too.
  2. 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
kalshi-logsLive log of the Kalshi paper bot (it scans every 15 minutes)
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 did Charles pick these stocks this month? Show me the ranking.
How is Charles doing against SPY since the new plan started?
Send me a Telegram summary of the day's trades at 4:15 PM Eastern.
Backtest the plan with 6 momentum picks instead of 4 and show me the difference.
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           # the bot
python webdash.py        # the dashboard, in a second terminal

The dashboard is at http://localhost:8502. 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.
Dashboard won't loadRun systemctl status charles-web. Make sure you're using http:// (not https) and port 8502.
Upgraded from the old version (dashboard on 8501)Run bash install.sh again: it adds the new dashboard service on 8502. Your keys and history are kept.
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.