Charles

Build a trading bot from scratch or start from Charles?

What writing your own trading bot involves beyond the strategy, what Charles already handles, and when starting from scratch is the better call.

The strategy is the part people picture when they think about building a trading bot. It's usually the smallest part. Most of the work is everything around it: the pieces that place orders, run on time, keep a record and stop when something looks wrong.

This post compares writing all of that yourself with starting from Charles, a free bot with all of its code public on GitHub. Both are reasonable. They suit different people.

What a bot needs besides the strategy

A rule like "buy the four strongest stocks each month" fits in a few lines of Python. To run it unattended, you also need:

  1. A broker connection. Code that reads your account, turns target weights into orders, places them and handles the ones that don't go through. For practice, that usually means a paper account such as Alpaca's.
  2. A schedule. Something that wakes up at the right time, knows when the market is closed, and doesn't run the same step twice.
  3. Records. A history of what the bot held, what it did and why. Without it, you can't tell a bug from a bad week.
  4. A way to watch it. Logs work at a desk. On a phone you want a page that shows holdings, recent actions and a button to stop.
  5. Safety limits. A daily loss limit, a pause that holds every order, and checks that refuse a setting that makes no sense.
  6. Updates. When you change the code, a way to see what changed and go back if the new version misbehaves.
  7. A server. A machine that stays on, with your keys kept somewhere private, a login for the dashboard and HTTPS.

None of these is hard on its own. Together they take far longer than the strategy, and they're the parts that fail quietly.

What starting from Charles gives you

Charles already has those pieces, written in plain Python you can read.

  • It runs on a server you own. Your keys, settings and history stay on it. There's no subscription. One command installs it on a fresh Ubuntu server, and the setup guide takes about 30 minutes, mostly waiting for installs. A server at DigitalOcean costs about $6 a month.
  • It trades paper money by default, linked to real market data through a free Alpaca paper account.
  • It has a dashboard that works on a phone. It shows what each bot holds, what it did and why, the news about what it holds, and Pause. The login has no passwords: the server prints a one-time link.
  • It has limits built in. A daily loss limit pauses buys for the rest of the day, and Pause holds all orders. Most days it places no orders, so there's not much to watch.
  • Updates are careful. Each one shows what changed, asks first when a change affects trading, and can be undone with Restore. Nothing updates by itself.

The trade-off is that you start with someone else's structure. You'll spend time reading it before you change much.

Making it your plan

Charles comes with a default plan: 80% in the whole market (SPY), plus 4 momentum picks at 5% each. Two rules sit on top of that.

  • Aggressive mode, on by default. While SPY is above its 200-day average and calm, the core sits in SSO, a 2x S&P 500 fund that moves about twice as much as the market each day, up and down. Any choppy day sends it back to SPY. You can turn it off.
  • A safety switch. When SPY ends a month below its 200-day average, the plan moves to T-bills until a month ends back above it.

You don't have to keep any of it. There are three levels of change, from least to most work:

  1. Sliders and presets. Change the plan's numbers on the dashboard, test the change on past prices before you save it, and undo it later if you want.
  2. Your own plan. Build one from your own tickers, using long-term, sector and momentum blocks. No code needed.
  3. The code itself. Because it's plain Python on your own server, you can change anything. Claude Code can read the code, make a change you describe in plain words and run the tests. It isn't free and it doesn't fit on the small server: it needs a Claude subscription or Anthropic API credit on your own bill, and a bigger server with more memory than Charles needs by itself. The setup guide explains how to move up. Read what it changed before you keep it, and keep your own changes on a git branch so they're easy to find later.

The third level is where Charles stops being a product and becomes a starting point. You keep the broker connection, schedule, records, dashboard and limits, and replace the parts you care about.

When building from scratch is the better choice

Starting from scratch makes sense in two cases.

You want to learn every piece. If the point is to understand how orders get placed, how a scheduler handles a market holiday or how to store a trade history, writing each part teaches you more than reading someone else's. You'll make mistakes Charles has already made, and that's the lesson. Use a paper account the whole time.

Your strategy is very different. Charles is built around a slow plan: monthly picks, a daily check, most days without orders. If you want something that trades many times a day, reacts to every price tick or uses a broker Charles doesn't connect to, much of its structure won't fit. Bending it might take longer than writing the parts you need.

There's also a middle path. Read the Charles code on GitHub before you start your own. The plan's rules sit apart from the parts that place orders and run the dashboard, so you can see how one bot splits the work and borrow the shape, even if you write every line yourself.

Set it upRead the code on GitHub