// learn ยท Data & tools

How to build a robust investing bot

We run a live market bot (Peaky Radar) and a real dYdX execution engine, so this isn't theory. This is the design that keeps a bot from quietly destroying an account, the intuitions, not the code. One day we may open the Peaky bot itself; for now, here's the blueprint we build to.

First principle, before any code. A bot doesn't create an edge, it executes one. Automating a strategy with no real edge just loses money faster, 24/7. Everything below assumes you've proven the idea works before you let a machine run it.

The one idea that matters: separate the brain from the hands

Every robust bot we've studied, Freqtrade, Jesse, and our own, splits into the same three pure stages. Keep them separate and you can test, swap and debug each in isolation:

If your signal logic knows what an exchange is, the design is already wrong. The brain decides; the hands act; they meet through a thin interface.

The four layers

LayerJobHow we do it
Data ingestionFetch candles / feeds on a scheduleScheduled scans, dedup state, cached slow data (e.g. fundamentals) so you don't refetch what rarely changes
Signal logicDecide, purely, from dataIndicator dataframe โ†’ pure buy/sell functions โ†’ a score
Execution adapterPlace & manage ordersdYdX v4 client; market entry + laddered limit exits
State & safetyTrack reality, prevent disasterLocal order ledger, exposure caps, kill-switch, watchdog

Safety, the part amateurs skip (and blow up on)

This is what separates a toy from something you'd trust with money. None of it is optional.

Test before you trust

Strategy archetypes (and when each dies)

StrategyWorks whenFails when
EMA crossover (trend)Clear, sustained trendsChoppy ranges, whipsaws you
Bollinger mean-reversionRange-bound marketsStrong breakouts, fades a runaway move
Momentum breakoutVolatility expansionsFalse breakouts in quiet markets
RSI / MACD hybridMomentum with confirmationLagging in fast reversals
Grid / DCASideways, mean-reverting rangesStrong trends, accumulates into a falling knife

There's no strategy that works in all regimes, the skill is matching the strategy to the market, and having safety rules for when the regime changes underneath you.

Why dYdX specifically

dYdX is a decentralized perpetuals exchange: you trade from your own wallet, no custodian holds your funds. Its v4 client connects to mainnet or testnet, and the testnet has a free faucet, meaning you can run your entire bot end-to-end against real market plumbing with fake money before risking a cent. That's the ideal proving ground: real order flow, zero downside. Practise on testnet until the boring parts (reconnects, partial fills, the kill-switch) are bulletproof.

Automation removes emotion, not accountability. The point of a bot is to execute a proven plan without fear or greed, never to stop watching. Start on paper, graduate to testnet, then live with tiny size. See also our guide on automatic investing.

Educational content about software design, not financial advice and not a recommendation to trade with leverage. Automated systems can and do fail; perpetuals carry high risk of total loss. Do your own research.

โ† Back to Peaky Learn