Trading Bot Code Review: What Gets Checked and What You Get
A trading bot code review is an independent check of the code that turns your rules into orders: order and risk logic, failure handling, restarts and position reconciliation, the separation of paper and live trading, data handling, tests and secrets. It covers Python bots for Interactive Brokers as well as MQL5 Expert Advisors for MetaTrader 5, whether written by hand or with AI coding tools. What it does not deliver is a verdict on profitability: a review assesses software and method, not whether a strategy will make money. You hand over a copy of the code and its documentation, never passwords, 2FA codes or account numbers, and you receive a report with findings ranked by severity and concrete fixes. This guide explains what gets checked, what stays outside the scope, how the review runs and how to prepare, as of November 2026.
What is a trading bot code review?
A trading bot code review is a structured reading and testing of the source code by someone who did not write it. The question is narrow: does the software do what the specification says, including in the situations a backtest rarely shows? Typical occasions are the step from paper to live trading, the takeover of code from a previous developer, the purchase of an Expert Advisor and code written with ChatGPT, Claude or Codex.
A code review examines the source code itself. An architecture or system audit looks at the whole: components, data flows, backtest method and operations. The two overlap; the page on trading system code review and audit describes them as separate packages.
The order and risk code deserves the most attention, because the broker does not know your limits. Interactive Brokers states that its TWS API contains no logic beyond ensuring the integrity of the exchanged messages; requests are validated in TWS and on IBKR’s servers. Your maximum position, your daily loss limit and your rule that every entry carries a stop hold only if your own code enforces them, and only a reader who checks that code knows whether it does.
What a trading bot code review checks
The scope follows the path from signal to order to position. The table lists the areas with one example finding each; the examples are typical patterns, invented for illustration.
| Area | Question | Example finding |
|---|---|---|
| Rules vs specification | Does every rule map to code, on closed bars? | The signal reads the bar that is still forming |
| Risk limits | Do size, position and daily loss limits apply before every order, including working orders? | The position limit counts fills but ignores open orders |
| Order states | Are rejections, partial fills, cancellations and timeouts handled? | After a timeout the order is sent again without a status query |
| Restart and reconciliation | Does the bot load positions and open orders from the broker before it trades again? | After a restart the bot assumes it is flat |
| Paper and live | Are the configurations separate, and is the account checked on connect? | One flag switches port, account and limits at once |
| Data | Are stale or missing prices detected, are time zones explicit? | A frozen price feed keeps producing signals |
| Tests and logs | Are the core rules tested, and can every order be traced from signal to final status? | The log shows prices but not why an order was sent |
| Secrets and dependencies | Are keys in the code or its history, are versions pinned, are licenses known? | An API key sits in an old commit |
| Dead code and flags | Can unused functions still be triggered? | An old feature flag now means something else |
Platform details come on top. In a Python bot for Interactive Brokers, order IDs must keep increasing: IBKR rejects an order whose ID is lower than or equal to a previous one from the same client as a duplicate (error 103), so the review checks where the next ID comes from after a restart. In an MQL5 Expert Advisor, the review checks how results are read. The MQL5 reference states that OrderSend() returns true after a successful basic check of the request structures, which is not a sign that the trade operation succeeded; the outcome sits in the MqlTradeResult structure. Code that treats true as a fill can end up managing a position that does not exist.
What a code review does not do
A review brings clarity about software and method, within clear limits:
- No profitability verdict. Whether a strategy makes money depends on markets, costs and changing conditions. A review can point out flaws in a backtest, such as missing costs, but it cannot say whether the rules will earn money in the future.
- No investment advice. Instruments, position sizes and risk appetite remain your decisions; the review checks that the code enforces the limits you set.
- No proof of correctness. A review lowers the risk of defects; it does not prove there are none. Its results apply to the version reviewed, so every later change needs its own tests.
- No substitute for paper and live tests. IBKR notes that its paper trading environment relies on more simulated technology than live trading, so behavior such as order execution may vary.
- No operation of the bot. The reviewer neither trades on your account nor switches the bot on.
Automated trading can lose money quickly, and with leveraged products such as futures, short options or forex the losses can exceed the capital deployed. A clean review lowers the technical risk; the market risk stays with the account holder.
How a trading bot code review works
- Scope: a short call clarifies the question (go-live, takeover, AI-written code), the platform and the package. A non-disclosure agreement can be signed first on request.
- Handover: you provide a copy of the code, the documentation and test data, as described in the next section. Nobody needs access to your broker account.
- Reading: order paths, risk checks and state handling are traced against the specification, from signal to final order status.
- Running: where possible, the code is built and its tests run in an isolated environment, with stubs instead of a broker connection. Failure cases such as a rejection, a partial fill or a disconnect are provoked deliberately.
- Report and walkthrough: the findings are ranked by severity and discussed in a call. You decide what gets fixed and by whom.
- Retest, on request and by agreement: after the fixes, critical and high findings can be checked again against their retest criteria.
When I review code, I work on a copy, change nothing unless asked to, and delete the copy afterwards; on request I confirm the deletion in writing. The code remains yours, and so does the decision to go live.
What you provide, and what you never need to share
The quality of a review depends on the material. Useful, roughly in this order:
- The code with its history. A Git bundle is a single file for offline transfer:
git bundle create review.bundle --allpacks all refs, andgit bundle verify review.bundlechecks that the file is valid. According to the Git documentation, a bundle does not contain the working tree, the stash, per-repository configuration or hooks, so commit everything that should be reviewed. - The specification: rules, order types, limits and the intended failure behavior. Parameter values can be replaced by placeholders; the review checks that the code implements the rules, not the values.
- Configuration templates with placeholders instead of secrets, and the pinned dependency versions.
- Tests, test data and backtest or Strategy Tester reports, plus logs from the paper phase with account IDs removed, if available.
- Known issues and the question that matters most to you.
Never needed: passwords, 2FA codes, API keys, tokens or account numbers. The Twelve-Factor App offers a simple test for clean configuration: could the codebase be made open source at any moment without compromising any credentials? If a key ever landed in the repository, deleting the file is not enough, because the history keeps it. GitHub’s documentation names revoking or rotating the secret as the first step; once rotated, the old value no longer grants access. Dependencies can be checked for known vulnerabilities beforehand as well: pip-audit -r requirements.txt, maintained under the Python Packaging Authority, uses the Python Packaging Advisory Database.
The deliverable: findings ranked by severity
The report opens with a summary: the version reviewed (commit hash), the scope, what was not reviewed and the most important findings. Each finding then gets its own entry with its location in the code, what happens, the evidence (a test, a log excerpt or a code path), the risk, a suggested fix and a retest criterion. A typical severity scale:
| Severity | Meaning | Typical example |
|---|---|---|
| Critical | Can cause unintended orders or uncontrolled exposure; fix before live trading | A timeout leads to a second order without a status query |
| High | A protective function fails in a plausible situation | The daily loss limit ignores open positions |
| Medium | Wrong behavior in rare cases, or missing traceability | Rejections are logged without the reason code |
| Low | Maintainability, readability, documentation | Limits as bare numbers scattered through the code |
Typical example of a single entry, invented for illustration: “F-03, high. risk/limits.py, check_position(): the limit compares only filled positions with the maximum, so three working buy orders can together exceed it. Evidence: unit test with three working orders. Fix: add working orders on the same side. Retest: the test passes, and a paper session shows the block in the log.”
Dead code and deployment belong in the scope because a reused flag can wake code that has not been used for years, which is what the SEC found at Knight Capital in 2012; the case is summarized in the trading system audit guide.
How to prepare for a trading bot code review
A few steps before the first call make the review faster and the report more useful:
- Freeze a version: commit everything, tag it and note the Python version or MetaTrader build, the TWS or IB Gateway version and the library versions.
- Write the rules on one page: instruments, signals, order types, size, exits, limits and what should happen on a disconnect.
- Remove secrets from code and configuration, and rotate any that were ever committed.
- Run your own tests and
pip-audit, or compile the Expert Advisor without warnings, and note what fails. - Work through a self-check such as the pre-live checklist for AI-built trading bots; open points make good questions for the review.
- Decide what the review should answer: go live or not, take over or not, fix or rebuild.
Effort depends on the number of modules, the platform and whether tests and documentation exist. A reliable quote therefore follows a short conversation about the code and the question, not a price list.
Frequently asked questions
What does a trading bot code review check?
It checks whether the code implements the specified rules and enforces risk limits before every order, and how it behaves on rejections, partial fills, disconnects and restarts. It also covers position reconciliation with the broker, the separation of paper and live configurations, data handling, tests and logs, secrets in the code or its history, dependencies and dead code. The result is a report with findings ranked by severity and suggested fixes.
Does a code review tell me whether my trading strategy is profitable?
No. A code review assesses software and method: whether the code does what the specification says and fails in a controlled way. It can point out flaws in a backtest, such as missing costs or results taken from the optimization period, but it cannot predict whether a strategy will make money. A review that promises a profitability verdict or returns oversteps what a review can deliver.
Do I need to share my broker login or API keys for a code review?
No. A copy of the code with its history, the documentation, test data and reports is enough. Passwords, 2FA codes, API keys, tokens and account numbers are not needed and should not be in the material. If a secret was ever committed to the repository, revoke or rotate it before the handover, because the version history still contains the old value.
Can a code review cover an MQL5 Expert Advisor or code written with ChatGPT or Claude?
Yes. The method is the same for Python bots, MQL5 Expert Advisors and code generated with AI tools: rules against code, risk limits, failure paths and the state after a restart. Code from AI assistants usually runs, so the review puts particular weight on the paths that rarely occur in a backtest, such as rejections, partial fills, disconnects and a restart with open positions.
How long does a trading bot code review take, and what does it cost?
Both depend on the scope: the number of modules, the platform, whether tests and documentation exist and how many failure cases have to be simulated. A small Expert Advisor is a different job from a Python system with several strategies and its own risk engine. There is no meaningful flat price; a reliable quote follows a short conversation about the code and the question the review should answer.
Sources and status
- TWS API Limitations (no logic beyond message integrity, paper trading environment) — Interactive Brokers (retrieved November 19, 2026)
- TWS API Error Codes (103: duplicate order ID) — Interactive Brokers (retrieved November 19, 2026)
- OrderSend (return value and MqlTradeResult) — MQL5 Reference, MetaQuotes (retrieved November 19, 2026)
- Order in the Matter of Knight Capital Americas LLC, Release No. 70694 (October 16, 2013) — U.S. Securities and Exchange Commission (retrieved November 19, 2026)
- Removing sensitive data from a repository — GitHub Docs (retrieved November 19, 2026)
- git-bundle documentation — Git project (git-scm.com) (retrieved November 19, 2026)
- pip-audit (README) — Python Packaging Authority on GitHub (retrieved November 19, 2026)
- The Twelve-Factor App: III. Config — The Twelve-Factor App (retrieved November 19, 2026)
As of November 2026. Third-party rules, prices and APIs may have changed since; the providers' current documentation and the official texts are authoritative.
This article is also available in German: Code-Review für Trading-Bots: was unabhängige Prüfer finden.
Want an independent review of your trading bot before it goes live? Get in touch — a free intro call clarifies the scope, the material and which package fits. More: Trading system code review and audit.