Spread, commission, swap and slippage in a backtest

GuidesDeutsch

Spread, commission, swap and slippage in a backtest

Backtest costs are the charges a broker takes on every trade: the spread between bid and ask, a commission per lot, the swap for holding a position overnight, and the slippage between the price you asked for and the price you got. A realistic backtest charges all four, because a small edge per trade can vanish in costs alone.

Updated · Orion Quant Technologies

Why do costs matter so much in a backtest?

Costs matter in a backtest because they are charged on every trade, while the edge is only earned on average. A strategy that makes 5 pips gross per trade on EURUSD and pays 1.7 pips in spread and commission keeps 3.3 pips, a third less. Halve the gross edge to 2.5 pips and the same costs take about two thirds of it.

CostWhen it is chargedHow to model it
SpreadOn every round trip, as the gap between bid and askReal bid and ask ticks, or a fixed or variable spread on bars
CommissionPer lot and per side, on entry and on exitA fixed amount per lot per side
SwapFor every night a position is open at the rolloverA signed amount per lot per night, triple on Wednesday for most forex pairs
SlippageWhen the fill differs from the requested priceTick fills for stops and market orders, plus a margin around news

How do you calculate spread cost in a backtest?

Spread cost in a backtest is the spread in pips times the pip value times the number of lots. On EURUSD one standard lot is 100,000 euros, so one pip (0.0001) is worth 10 USD. A spread of 1.0 pip costs 10 USD per lot on every round trip, whether the trade wins or loses.

Spreads are not constant. They widen around the daily rollover, at the weekly open and on news. A fixed spread in a bar backtest is an average, while real bid and ask tick data charges the spread as it was at the moment of each entry and exit. For more on that, see tick data backtesting.

How is commission charged per lot and side?

Commission in a backtest is usually charged per lot and per side, so a round trip pays it twice. At 3.50 USD per lot per side, one round trip of 1 lot costs 7 USD, which on EURUSD equals 0.7 pips. Add a 1.0 pip spread and every trade starts 1.7 pips, or 17 USD, behind.

Over a year the small numbers add up. A strategy with 400 round trips a year on 1 lot of EURUSD pays:

Cost itemPer round tripPer year (400 trades)
Spread, 1.0 pip10 USD4,000 USD
Commission, 3.50 USD per side7 USD2,800 USD
Total17 USD6,800 USD

Some brokers quote commission per round turn instead of per side, which halves the number on the price list but not the cost. Check which one your broker means before you type it in.

What is swap and how do you backtest it?

Swap is the overnight financing charge or credit for holding a position past the broker's daily rollover, for forex usually 5 pm New York time. Swap is quoted per lot per night, can be negative or positive, and usually differs between long and short. For most forex pairs the Wednesday rollover charges three nights, to cover the weekend.

Example: a long position of 1 lot with a swap of minus 6 USD per night, opened on Monday and closed on Friday before the rollover, pays for Monday, Tuesday, Wednesday (three nights) and Thursday. That is six nights, or 36 USD.

A backtest without swap overstates every strategy that holds positions for days. The triple Wednesday charge matters most for strategies that often hold over the middle of the week.

How do you model slippage in backtesting?

Slippage in backtesting is the difference between the price an order asked for and the price it was filled at. Market orders and stop orders slip, because they fill at whatever price is available next. Limit orders do not slip in price, but they may not fill at all. A conservative backtest assumes slippage on every market and stop fill.

  • Fill stops on ticks: a stop filled on bid and ask ticks takes the first price beyond the level, which already includes the jump in a fast market.
  • Add a fixed amount on bars, for example 0.5 pip per stop fill. On 1 lot of EURUSD that is 5 USD per fill.
  • Watch the size: an order larger than the volume at the best price fills partly at worse prices.
  • Stress the costs: run the backtest again with doubled costs. A strategy that only works at the lowest costs has no room for error.

How are costs charged in the Orion Quant Technologies Engine?

The Orion Quant Technologies Engine treats costs as fields of a run: a spread band, commission per lot and per side, and a signed swap per night with the triple rollover on Wednesdays. Cost schedules can change over time, the way a broker's did, so a long backtest does not charge today's prices for the past.

On the tick tier, fills use institutional bid and ask, so the spread is the one that was quoted. Bid and ask size come with every tick, and the engine flags an entry larger than the size at the touch. An order the account cannot margin is refused and counted, not filled. L2 order book depth, where a market order walks the visible book and pays the price of every level it takes, is built into the fill model, and the depth data arrives during early access. The engine is in early access through the waitlist.

Frequently asked questions

How much does the spread cost per lot on EURUSD?

One standard lot of EURUSD is 100,000 euros, and one pip is worth 10 USD at that size. A spread of 1.0 pip therefore costs 10 USD per round trip, and a spread of 0.5 pip costs 5 USD. Multiply by the number of trades: 400 trades a year at 1.0 pip is 4,000 USD on 1 lot, before any commission.

Should I include swap in a day trading backtest?

Include swap whenever a position can stay open past the daily rollover. A day trading strategy that always closes before 5 pm New York time pays no swap, but one that now and then holds a losing trade overnight does, and on Wednesdays it pays three nights. Leaving swap out is only safe when the rules force every position flat before the rollover.

What is a realistic slippage assumption for a backtest?

There is no single number, because slippage depends on the market, the time of day and the order type. A common conservative approach is to fill stop and market orders on tick data with real bid and ask, and to add a small fixed amount, such as half a pip on forex majors, in bar backtests. Around news, expect much more.

Why is my backtest profitable but my live account is not?

Missing or understated costs are a common reason. Check that the backtest charges the real spread, commission on both sides, swap with the triple Wednesday and some slippage on stops. Then look for lookahead bias and overfitting, which inflate a result in a different way. The guide on overfitting and lookahead bias shows how to test for both.

Research and testing only. A backtest shows how rules behaved in the past, not what they will earn. Nothing here is investment advice.

Orion Quant Technologies