What transaction costs should I assume in historical tests?

CREATED BY
March 24, 2025
MICHAŁ ZAREMBA
Transaction costs are an extremely important topic for every trader, especially short-term and algorithmic ones.

What transaction costs should I assume in backtests?
I first approached analyzing transaction costs using Alpaca & Algocloud in mid-2024 with a sample of about 1,000 real transactions for the period 11.2023-07.2024.
In February 2025, I returned to analyze the costs again, this time with a sample of over 6,000 transactions on both Alpaca accounts (real and demo) for the period 11-2023/02-2025.
Now, I can answer with much greater confidence the crucial question: What are the real trading costs using Alpaca and Algocloud?
In the second part of this article, you will receive specific setting guidelines that I use in my backtests, but let's start with what and how I investigated.
Objective and Method of the Study
The study aimed to determine the actual slippage and spread for market orders placed at the end of the day (ON BAR CLOSE). These orders are placed about 3-4 minutes before the market closes and are compared to the close prices recorded on daily candles used for backtesting.
My study included 2,227 LONG transactions on a real account and 3,548 transactions on a demo account.
I use the broker Alpaca, so I do not incur any commission costs except for REG/TAF fees, which are marginal (I write about the details here).
I base my analysis on the closing transaction prices recorded in Algocloud (csv export). The sample concerns strategies operating on companies from the S&P500 and Nasdaq100 indices.
I compared this "close" price to a reference source, i.e., the official Close price of that day, according to Nasdaq Financial, Economic and Alternative Data. I used this source due to the unadjusted close. In a previous study, I used the price provided by GoogleFinance, but the Nasdaq data are better for this study because it does not include dividend adjustments.
Obtained Results
Here is a summary of the obtained results:
A screen of the Real account sheet. The full data can be found below.
Histogram showing the distribution of price differences based on Real account data. Positive difference - unfavorable. Negative - favorable.
Full research results are available in the Google Sheet:
How about dividends?
To ensure the accuracy of this study over the long term, we need to use the unadjusted close, which is the actual price of the day without considering splits and dividends. If we don't, the study might be too optimistic because the adjusted close tends to decrease over time, skewing the results.
However, this approach means the study doesn't include dividends paid if we hold a position on the Ex-Dividend Date. I view dividends as a bonus, like the cherry on top, reducing our costs, but this is not included in the study.
Summary of results
The result obtained on the real account, i.e., 0.015%, is several times better than the 0.05%-0.1% I most often assumed in backtests.
Interestingly, the results from the real account are better than from the demo account, suggesting responsible simulation of order execution by Alpaca.
The timing used by Algocloud, which operates on bar close with about a 3-minute delay, is cost-effective.
While total transaction costs can be higher depending on how a position is opened, most of my strategies use Limit orders. This approach helps avoid the spread from the beginning. Although Limit orders have their own "limitations", that's not the focus of this article.
In my opinion, we live in beautiful times because transaction costs have never been so low for individual investors!
Safe assumptions in backtesting
Here is MY standard historical test setup, with strategy settings:
Type 1:
Entry - Limit
Exit - Market, On Bar Close

The costs we assume are 0.05%, which is over 3x more than what came out in the real account study 0.015%.
Type 2:
Entry - Market On Bar Close
Exit - Market On Bar Close

The costs we assume in backtests are 0.1%, which is almost 7x more than what came out in the real account study.
In this case, slippage occurs 2x (on entry and exit), so it requires in my opinion at least double consideration. I currently have too little data to assess the market order entries themselves, but I plan to expand my research in the future.
All strategy tests conducted by us in Algohubb have such or similar cost settings during the strategy testing phase.
You can find more on the topic of broker evaluation and costs in this article.
BEST STRATEGIES
Week Explorer Strategy
For last 40 years, the best day of the week on the US stock market has been Tuesday. The next day with the highest return is Wednesday. We present a strategy that skillfully exploits this market behavior by opening positions only on Mondays and cashing in profits in almost 70% of cases over the following days.
●
KO Christmas Rally Strategy
The seasonal holiday pattern on Coca-Cola is one fantastic example of how seasons affect stocks. The pattern has a logical justification, which is the association of the brand with holidays built over decades. This consequently influenced consumer and investor behavior before this period.
●
BA Flight to Growth Strategy
Each year, the shares of the aerospace giant The Boeing Company (BA) statistically see an increase from the end of October to the beginning of January. What might drive this trend? Increased air traffic during the holiday season, which reminds investors of the company? Or perhaps government purchases at the end of the year cause Boeing's shares to gain strength?