The Importance of Factoring in Commission

What is Commission?

Commission refers to the fee charged by a broker or financial intermediary for executing a trade on behalf of a client. In the context of trading, commissions are costs incurred when buying or selling securities like stocks, options, futures, or other financial instruments. These fees are a primary way that brokers generate revenue.

Importance in Algorithmic Trading

  • Impact on Profitability: Commissions directly affect the net profitability of an algorithmic trading strategy. Intraday trading strategies, which make a large number of trades, can see significant portions of their profits eroded by commissions.
  • Strategy Design: Understanding commission structures is crucial in the design and backtesting of trading algorithms. Strategies need to be profitable after accounting for all trading costs.
  • Broker Selection: Traders may select brokers based on commission structures that best suit their trading strategies. For example, traders that execute large numbers of trades per day may prefer brokers with low per-trade fees or tiered commission structures.

Overview

This Python script is designed to backtest a trading strategy based on the Moving Average Convergence/Divergence (MACD) and the Stochastic Oscillator technical indicators. It connects to the Interactive Brokers (IB) API to fetch historical data, computes the technical indicators, executes the trading strategy and evaluates its performance using key financial metrics. Commission fees are factor into this strategy.

Information regarding this trading strategy can be found here.

Main Script

Case Study

Here we look into a case study regarding Apple (AAPL).

Above: Strategy’s performance without commissions factored in

Above: Strategy’s performance with commissions factored in

In the context of this specific case, a total of 872 trades were executed over the course of a year. This high trading volume led to a significant reduction in the returns generated by the strategy. Before accounting for commission fees, the strategy achieved a Sharpe ratio of 15.85, indicating extremely strong returns. However, after factoring in the commission fees, the Sharpe ratio plummeted to -0.16, reflecting a net loss when adjusted for commission fees.

This stark difference underscores the importance of incorporating commission fees into the evaluation of trading strategies. For algorithmic traders, optimizing the trade frequency and selecting brokers with favorable commission structures are essential steps to ensure that the strategy remains profitable after all costs are considered.

More results here for MSFT, NVDA, GOOG and AMZN:

Feel free to use the codes shared for your own tickers!

Back to Algorithmic Trading page