# Backtesting and risk guides for trading bots

URL: https://fincodelabs.com/en/blog/backtesting-and-risk · Publisher: Fincode (Fincode Yazılım ve Teknoloji A.Ş.), Istanbul, Turkey · Updated: 2026-11-06

What a backtest can and cannot show, what funding and fills really cost, and the limits and checks that belong outside the trading rules.

**Short answer:** Backtesting is only as accurate as its data and assumptions: a backtest shows how written rules would have behaved on past data and does not guarantee future results. A sound test adds realistic fees and slippage, then paper trading, then a small staged live start, with risk limits that sit outside the trading rules and a process that reconciles the bot's state with the exchange.

Read these before you trust a test result or put real money behind a bot. They describe methods and failure cases, not strategies.

The page starts with how to test, moves on to what a position costs beyond the price, and ends with the limits and kill switches a live bot needs. Examples use hypothetical numbers, and automated trading can lose money.

## Testing before you go live

The biases that fake profits, the Python libraries people test with, and how far a test result can be trusted.

- [How to test trading bots: a plan before going live](https://fincodelabs.com/en/blog/how-to-test-trading-bots): How to test trading bots: fault injection in pytest, which CCXT errors are safe to retry, testnet gaps, a kill switch drill and behavior-based acceptance.
- [Backtesting pitfalls: biases that fake strategy profits](https://fincodelabs.com/en/blog/backtesting-trading-strategy-pitfalls): Backtesting pitfalls explained: look-ahead bias, survivorship bias, overfitting, unrealistic costs and small samples, with walk-forward and other remedies.
- [Python backtesting libraries compared on one strategy](https://fincodelabs.com/en/blog/backtesting-python-libraries): Python backtesting: backtesting.py, backtrader, vectorbt, zipline-reloaded and bt compared by license and maintenance, with walk-forward and Monte Carlo code.
- [Backtrader vs vectorbt: one test, reconciled to the cent](https://fincodelabs.com/en/blog/backtrader-vs-vectorbt): Backtrader vs vectorbt on one synthetic schedule: why defaults differ, how to match them to the cent, and speed measured on stated hardware. No winner named.
- [Paper trading API: testnets, demo modes and what they hide](https://fincodelabs.com/en/blog/paper-trading-api): Paper trading API compared: Binance, Bybit, OKX, Kraken, Coinbase and Alpaca test hosts, what each can prove, measured gaps and a tested Python live-host guard.

## Biases and simulations in detail

Look-ahead and survivorship bias can make rules look better on past data than they could be in live trading. A Monte Carlo simulation shows how widely results could vary, but it cannot fix bad data.

- [Look-ahead bias in backtesting: Python tests that catch it](https://fincodelabs.com/en/blog/look-ahead-bias): Look-ahead bias in backtesting, run on coin-flip data: pandas lines that fake an edge, a truncation test that catches them, and what a backtest cannot show.
- [Monte Carlo backtesting: trade bootstrap vs path simulation](https://fincodelabs.com/en/blog/monte-carlo-backtesting): Monte Carlo backtesting tested in Python on synthetic trades: what shuffles, bootstraps and path simulation show, and the failures they hide.

## Costs beyond the price

What a position and its orders cost beyond the price, including funding on perpetual futures.

- [Slippage crypto meaning: measure it from the order book](https://fincodelabs.com/en/blog/slippage-crypto): Slippage in crypto explained: formula and sign for buys and sells, reference prices, a tested order book walk, fees, AMM tolerance and TradingView's tick unit.
- [Transaction cost analysis: TCA for crypto, with Python](https://fincodelabs.com/en/blog/transaction-cost-analysis): Transaction cost analysis (TCA) for crypto: cost types, arrival, VWAP and TWAP benchmarks, implementation shortfall in tested Python, and what to log.
- [Perpetual futures and funding rate explained with examples](https://fincodelabs.com/en/blog/perpetual-futures-funding-rate): Perpetual futures explained: no expiry, index and mark price, who pays the funding rate, hypothetical examples, liquidation risk and rules in the US, UK and EU.

## Limits and checks in production

Kill switches, duplicate-order protection and reconciliation when the bot and the exchange disagree.

- [Trading bot risk management: limits and kill switches](https://fincodelabs.com/en/blog/trading-bot-risk-management): Trading bot risk management in practice: pre-trade checks, daily loss and drawdown limits, kill switch design, duplicate-order protection and reconciliation.
- [Trading bot kill switch: triggers, cancel-all and tests](https://fincodelabs.com/en/blog/trading-bot-kill-switch): Trading bot kill switch design: what RTS 6, FINRA and FIA describe, triggers, who resets it, cancel-all limits per venue, and tested Python with a mock.
- [Position reconciliation: when a bot and exchange disagree](https://fincodelabs.com/en/blog/position-reconciliation): Position reconciliation for trading bots: break types, what to query on Binance and Bybit, when to run it, what to do with a break, and tested Python.
- [Trading bot hosting: VPS, Docker, restarts and latency](https://fincodelabs.com/en/blog/trading-bot-hosting): Trading bot hosting without a sales pitch: when a VPS is worth it, what a ping measures, tested Docker files, graceful shutdown and restarts that reconcile.

## Calculators

- [Crypto position size calculator: risk, stop and lot step](https://fincodelabs.com/en/tools/crypto-position-size-calculator): Enter your balance, risk per trade, entry and stop prices, fee rate and lot step to see the fractional quantity that keeps a loss at the stop within your chosen amount. Free, no sign-up required.
- [Risk reward calculator: ratio, targets and break-even rate](https://fincodelabs.com/en/tools/risk-reward-calculator): Enter the side, entry, stop, target and fee per side to see risk and reward per unit, the ratio before and after fees, the stop and target distances and the win rate at which such trades break even. Free, no sign-up required.
- [Slippage calculator for trading: walk the order book](https://fincodelabs.com/en/tools/slippage-calculator): A trading slippage calculator: type the order book levels and your order size to see the average fill, the levels consumed and the slippage in basis points and money, or compare expected and actual prices from a fill log. Free, no sign-up required.
- [Crypto trading fee calculator: maker, taker and slippage](https://fincodelabs.com/en/tools/crypto-trading-fee-calculator): Enter the trade size, your maker and taker rates, the share of maker fills, slippage and round trips per month to see what trading costs per round trip and per month. Free, no sign-up required.
- [Crypto liquidation price calculator: isolated margin](https://fincodelabs.com/en/tools/liquidation-price-calculator): Enter the side, entry price, leverage and the maintenance margin rate from your exchange to estimate the liquidation price of an isolated-margin linear contract. Leverage can lose your entire margin. Free, no sign-up required.
- [Funding rate calculator: payments over a holding period](https://fincodelabs.com/en/tools/funding-rate-calculator): Enter the position size, side, funding rate per interval, interval length and holding period to see what a perpetual futures position pays or receives if the rate stays constant. Free, no sign-up required.
- [Crypto futures calculator: PnL, ROE, margin and fees](https://fincodelabs.com/en/tools/crypto-futures-calculator): Enter the side, entry, exit, quantity, leverage, fees and any funding to see the notional, initial margin, gross and net result, return on margin and break-even exit price of a linear futures position. Leverage can lose more than you expect. Free, no sign-up required.

## From Fincode

- [Custom crypto trading bot development, built from your written rules](https://fincodelabs.com/en/services/algorithmic-trading): Custom trading bots built from rules you have written, with risk limits, an emergency stop, logs and alerts. Backtested and paper traded before go-live.
- [Trading bot code review, audit and repair](https://fincodelabs.com/en/services/trading-bot-code-review): Trading bot audit: a review of existing code for API key handling, errors, rate limits, order state and logging, in a written report ranked by priority.
- [BIST strategy backtesting platform: example scenario](https://fincodelabs.com/en/projects/bist-strategy-backtesting-platform): Example scenario for a Borsa Istanbul backtesting platform: corporate action adjustments, commission and BSMV, tick sizes, price limits and walk-forward tests.
- [Read-only crypto portfolio risk dashboard: example scenario](https://fincodelabs.com/en/projects/crypto-portfolio-risk-dashboard): Example scenario for one dashboard of balances, positions, P&L, exposure and liquidation distance across crypto exchanges, built on read-only API keys.

## Frequently asked questions

### Is backtesting accurate?

Only as far as its data and assumptions go. Look-ahead bias, survivorship bias, overfitting through many trials and unrealistic fills and costs each make rules look more profitable on history than they can be in live trading, and a backtest does not guarantee future results.

### What should be tested before a bot trades live?

The rules on historical data with fees and slippage, then the software in paper trading, then a small staged live start.

### What is a kill switch in trading software?

A control that immediately cancels working orders and blocks new ones. It should work outside the strategy process and stay off until a person re-enables it.

> These guides are general information about software and markets, not investment, legal or tax advice. Automated trading can lose money, past or backtested performance does not guarantee future results, and the rules that apply depend on your jurisdiction and your exchange's terms. For readers in Turkey, Article 99/A of Capital Markets Law No. 6362 treats activity by foreign crypto-asset platforms directed at Turkish residents as unauthorized.

## Other guides

- [Trading bots: guides to how they work, cost and hiring](https://fincodelabs.com/en/blog/trading-bots): Guides to crypto trading bots and automated trading software: how bots work, rule types, AI claims, open-source frameworks, running costs and hiring checks.
- [Crypto exchange API guides: keys, limits, errors, Python](https://fincodelabs.com/en/blog/crypto-exchange-apis): Developer guides to crypto exchange APIs: API keys, request signing, REST and WebSocket, rate limits and error codes, with Python notes by exchange.
- [Algorithmic trading API guides: stocks, forex and FIX](https://fincodelabs.com/en/blog/stock-and-broker-apis): Developer guides to algorithmic trading APIs for stocks, forex and futures, from official documents: access, login, orders, paper trading, limits and FIX.
- [TradingView webhooks: guides to alerts and Pine Script](https://fincodelabs.com/en/blog/tradingview-webhooks): What a TradingView webhook is, which plans include it, its delivery limits, alert message format, why alerts fail, Pine Script and what the terms of use say.
- [Fintech software development guides: data, brokers, cost](https://fincodelabs.com/en/blog/fintech-software): Guides for teams building finance software: market data licenses, broker APIs and FIX, order management, portfolio tracking, Turkish payment rails and app cost.
- [All guides](https://fincodelabs.com/en/blog/): Every guide on trading software and on money and investing in Turkey, with search.

---

Published by Fincode (Fincode Yazılım ve Teknoloji A.Ş.), a software company in Istanbul, Turkey: https://fincodelabs.com/en/blog/backtesting-and-risk
