Research Here · Trade Anywhere
☰
★ Option Tips Provider · Trading Education

Automation Pitfalls in Algo Execution: Where Automated Orders Go Wrong

Automation pitfalls in algo execution are mostly about plumbing, not strategy: orders sent twice, prices that are stale, legs that fill unevenly, and loops nobody can stop. A sound strategy can still lose money through these faults. Knowing each failure by name, and building a switch for it, matters more than refining entry rules.

In-DepthComplete Guide
Research-LedEvery Section
PracticalTakeaways

Short answer

Most algo losses come from execution faults rather than bad ideas: duplicate or rejected orders, stale quotes, partial fills, dropped connections and loops with no stop. The defence is layered limits, a manual kill switch, reconciliation against the broker’s position book and a small-size live trial first.

TL;DR

  • Execution faults repeat at machine speed, so one bug can generate many bad orders quickly.
  • Reconcile your system’s belief about positions against the broker’s book regularly.
  • Every automated strategy needs a hard kill switch that works without the strategy’s own code.
  • Test live with the smallest size before scaling anything.
  • Backtest results ignore rejections, latency and partial fills, which dominate real-world drift.

Why a Correct Strategy Can Still Lose Through Its Plumbing

Key points

  • Faults repeat. A human mistakes once; a loop can mistake hundreds of times before anyone looks up.
  • The strategy is only one layer. Data feed, order router, broker gateway and exchange all sit between your signal and a fill.
  • Backtests are silent on plumbing. They assume every order fills at a tidy price and nothing is rejected.
  • Safeguards are cheap; incidents are not. Most protections are a few lines of logic or a manual routine.

Retail traders who move from manual to automated trading usually spend months on signal logic and an afternoon on everything else. That ratio is backwards. The signal decides what you want to do; the execution layer decides what actually happens, and the gap between the two is where unexplained losses live.

This article walks through the day in order: before the open, at the open, during the session and after the close. Each stage has failures that are specific to it, and each has a matching protection. If you are new to the whole topic, start with the beginner’s overview of algo trading and come back.

Before the Open: Stale State and Wrong Assumptions

Many incidents are born overnight. A contract rolled, a lot size was revised, a symbol changed its format, a holiday shifted the calendar. The code still runs, but it runs on yesterday’s world.

  • Expired or rolled contracts. A hard-coded instrument that no longer trades will either be rejected or, worse, map to a different contract.
  • Changed contract specifications. Quantity logic built on an old lot assumption sends orders the exchange rejects or sizes the position wrongly. Always read the current specification.
  • Leftover positions. If yesterday’s position was never closed, today’s logic may open a fresh one on top of it.
  • Wrong session flags. Holiday and special-session days can break assumptions about open and close time.

Watch out

A system that starts cleanly and shows no errors is not necessarily healthy. It may simply have no idea that the world changed. Print the contract, quantity and starting position at startup and read them every morning.

A pre-open checklist worth automating

  1. Load the instrument list from a fresh source. Never trust a cached file from a previous day.
  2. Pull the broker’s current positions and open orders. Compare with your internal records before any new order.
  3. Check available margin. Confirm the day’s planned size fits with room to spare.
  4. Run a dry order test. Send a harmless, immediately cancelled order to confirm the connection really accepts instructions.

At the Open: Gaps, Auctions and Thin Books

The first minutes of the session combine the widest spreads, the fastest price changes and the heaviest message traffic. A system that was well behaved at midday can misfire here.

Market orders sent into a thin opening book can fill far from the last seen price. Strategies that rely on a prior close as their reference can also misjudge a gap, as explained in our piece on how opening prices are discovered. A common protection is simply to forbid trading for a fixed window after the open and let the book settle.

Worked example

A trend-following script is coded to buy when price crosses above yesterday’s high. On a gap-up morning the first tick is already above that level. The script fires instantly with a market order and fills at the poorest price of the session. A cooling-off window, plus a limit price tied to a maximum allowed slippage, would have turned a bad fill into a skipped trade.

Related: Options Tips for Managing Slippage in Order Execution

During the Session: The Failure Modes That Hurt Most

Mid-session faults are the ones people picture when they hear the phrase runaway algorithm. They tend to fall into a handful of repeatable patterns.

FailureWhat happensTypical protection
Duplicate ordersA retry after a slow response sends the same order twiceUnique order tags and an idempotency check
Stale quotesData feed freezes, logic acts on old pricesTimestamp check; halt if data is older than a limit
Partial fillsOnly some quantity executes; the rest hangsTrack filled quantity, cancel or complete explicitly
Rejected legsOne leg of a spread is refused, leaving naked riskSend protective legs first; verify all legs
Infinite loopExit triggers re-entry, re-entry triggers exitCap orders per minute and per day

Common misreading

Retrying a failed request without checking whether the first attempt actually reached the exchange is how duplicate positions are born. A timeout does not mean the order was not placed.

Multi-leg orders deserve extra suspicion

Spreads and hedged positions depend on every leg arriving. If the hedge leg is rejected for margin or price reasons while the main leg fills, you hold an unintended directional position. Read how this plays out in our guide to basket orders, then design your own code to verify each leg’s final status before moving on.

Connectivity, Latency and the Moment You Need Control Most

Connections fail at inconvenient times because volatile moments also stress networks and gateways. If your system loses its link while holding positions, it cannot adjust a stop or exit. That is a risk you can reduce but not remove.

Reduce the exposure

  • Place protective stop orders at the broker rather than only inside your code
  • Keep a second connection or a mobile app ready for manual exits
  • Restrict automated positions to a size you can live with if you lose control

Accept what remains

  • Latency varies and fills will never match a backtest
  • Exchange or broker outages can freeze everything
  • A manual plan for outages must exist before the outage

The principle is that automation should degrade gracefully. If the code disappears, resting orders at the broker should still limit damage. This is closely related to the idea of GTT orders, which live outside your own program.

The Kill Switch: Your Most Important Line of Code

A kill switch is a mechanism that stops all new orders and, if you choose, flattens positions, regardless of what the strategy thinks. It must work even when the strategy is confused, so it cannot depend on the strategy’s own logic.

  • Daily loss limit. If realised plus open losses exceed a preset amount, the system stops sending orders for the day.
  • Order-rate limit. If more than a set count of orders go out in a short time, halt and alert.
  • Position limit. If net exposure exceeds a ceiling, reject further orders in that direction.
  • Manual override. One command or button you can reach in seconds, tested regularly.

Write the limits down before you go live, not after the first scare. Choosing them while emotional tends to produce numbers that are too loose. If you want a framework for the limits themselves, see drawdown management.

Related: Algo Trading for Beginners: From Idea to Live System

Signal-Side Faults: When the Data Is Wrong but Looks Right

Not every fault lives in the order path. Sometimes the strategy is fed bad inputs and does exactly what it was told. These errors are subtle because every component reports success.

  • Bad ticks. A single erroneous print can trigger a stop or an entry. Filter prices that jump implausibly versus neighbours.
  • Time misalignment. Mixing data stamped in different time zones or with different bar conventions shifts signals by a bar or more.
  • Adjusted versus raw history. Indicators computed on history that was adjusted for corporate actions can differ from live calculations.
  • Missing bars. A gap in the feed can make an average or a range calculation behave oddly for a few periods.

Watch out

Two indicators with the same name can give different values on different platforms because of small differences in smoothing or bar construction. Validate your live calculation against a trusted reference before trading it.

A good habit is a sanity layer between data and logic. It rejects readings that violate simple rules, such as a price outside the day’s allowed band, and raises an alert instead of acting. Understanding how circuit bands work, as covered in circuit limits and trading halts, helps you write those rules.

The Human Side: Tinkering, Over-Trust and Alert Fatigue

Automation does not remove psychology; it moves it. Instead of fearing the next entry, the trader now fears the next bug, or worse, stops fearing anything because the machine seems calm.

BehaviourWhy it is riskyBetter habit
Editing live code mid-sessionUntested changes meet real moneyChange only after the close, test in a sandbox
Overriding the system on a hunchBreaks the statistics you are measuringLog overrides and review them honestly
Ignoring repeated warningsAlerts become background noiseKeep few alerts, each requiring action
Assuming silence means safetyDead feeds also look quietSend a heartbeat message and alert when it stops

Keep a change log

Every modification, however small, should be recorded with the date and reason. When behaviour shifts a week later, the log is the first place to look. Without it, you are debugging from memory.

The same discipline that supports a trading journal applies here: write down what changed and what you expected, then compare with what happened.

Related: Sensex Trading Complete Guide: A Five-Stage Roadmap

After the Close: Reconciliation and Learning

The session ending does not end the work. Compare what the strategy believes it did with what the broker’s records say it did. Discrepancies, even small ones, are early warnings of a deeper fault.

  1. Export the day’s trade book and your own log. Both should list the same orders, quantities and times.
  2. Match every order to a signal. Any order with no matching signal is a defect.
  3. Measure slippage. Compare intended price with actual fill, per trade, and watch the trend over weeks.
  4. Record incidents. Write down every near-miss; patterns show up quickly.

Why this matters

A day that ends in profit can still hide a serious bug. Reconcile every day, especially the good ones, because nobody investigates a profit.

Rolling Out Safely: Small, Slow and Observed

The final protection is procedural. Move from backtest to paper trading, then to the smallest live size, and only scale after a run of days where reconciliation is clean. Our article on paper trading discusses how long a trial period should last and what to measure in it.

Worked example

A trader finishes a backtest and wants to run his script at full size on day one. Instead he runs it for a few weeks at the smallest tradable size. In that period he discovers that rejected orders occur whenever two signals fire in the same second, a case the backtest could never show. He fixes the sequencing, then raises size gradually. The bug would have been costly at full scale.

Related: Inverted Hammer Candlestick: Rules, Failures and Shooting Star Test

What a good review log contains

  • Date and version. Which code ran, so you can tie behaviour to changes.
  • Rejections and retries. Counts and reasons, not just totals.
  • Latency observations. Rough delay between signal and fill.
  • Manual interventions. Every time a human stepped in, and why.

Frequently Asked Questions

Can a small retail trader safely run an algo?

Yes, if the system is built with limits, tested at small size and monitored. The risks are real, but they are manageable when you treat execution as seriously as the strategy.

Does my broker protect me from algo errors?

Brokers apply risk checks, but those checks are generic and cannot know your intent. You remain responsible for your own limits and for confirming what orders actually went out.

Why does live performance differ from my backtest?

Backtests ignore rejections, latency, partial fills and spread costs. These small frictions add up, which is why measuring slippage in live trading is so important.

Should I run an algo unattended?

Even a well-built system benefits from supervision, especially in the opening minutes and around events. Unattended running is something to earn gradually, after a long clean record.

Want Research-Backed Ideas, Not Just Education?

Explore our Our Services service or get in touch with our research team.