Building my trading bot: rules before code.
Every trading bot post starts with the code. This one starts with the rules — because the code is the easy part, and the rules are the only part that keeps money alive.
Why build at all. I do not sell signals, I do not copy trade, and I do not want a black box. A bot that executes my rules, on my risk settings, with a kill switch I control — that is the only automation I trust. Everything else is renting somebody else’s judgment.
The rules, written before any strategy code:
- Spot only. No leverage. Leverage does not increase edge; it increases the speed of ruin. The bot cannot borrow, short, or touch margin — enforced at the exchange-API level, not by willpower.
- Backtest first, testnet second, tiny size third. No real capital until the strategy survives historical data, then paper trading, then the smallest size that still hurts a little.
- Only the yield enters the market. The principal from the investing pillar is never traded. The bot gets an allowance carved out of realized yield — if it blows up, the portfolio does not notice.
- Specs before code. Every behavior is written as a specification first: inputs, order types, failure modes, what happens when the exchange API goes down mid-order. Code implements the spec; nothing freelances.
- Kill switches everywhere. Max daily loss, max consecutive losses, stale-data halt, manual panic button. A bot without a leash is not a tool — it is a liability with an API key.
The stack is deliberately boring: TypeScript, a fast runtime, a small HTTP framework for the control panel, and a unified exchange library so the venue is a configuration value, not a rewrite. Boring stacks have fewer 3 AM surprises.
What the bot will never do: martingale into a losing position, trade without a stop, run a strategy with negative expectancy (Expectancy Calculator gets the final vote on every idea), or risk more per trade than the math allows (Kelly & Risk of Ruin sets the ceiling, Position Size Calculator sets the floor).
Right now there is no strategy code — and that is the point of Part 1. Rules first, then the first backtest. Part 2 will cover what the backtest actually said, including the ideas that died.
This is a build log, not a signal service. Nothing here tells you what to buy.
| Rev | Date | Description |
|---|---|---|
| A | 2026-09-30 | Initial issue. |