## Hedging in the presence of transaction costs

As we shown earlier, increasing the number of portfolio adjustments leads to a decrease in the volatility of the hedging cost. As *Δt* approaches 0, the cost of hedging approximates the option price derived from the BS formula. Until now, we have disregarded the transaction costs, but here, we remove this assumption and analyze the effects of transaction costs on option hedging. As rebalancing becomes more frequent, transaction costs increase the cost of hedging, but at the same time, shorter rebalancing periods reduce the volatility of the hedging cost. Hence, it is worth examining this trade-off in more detail, and based on this, defining the optimal rebalancing strategy. An absolute (fixed for each transaction) or a relative (proportional to the transaction size) transaction cost can be added to the code by modifying the parameters when we define the function:

**cost_simulation = function(S0, mu, sigma, rf, K, Time, dt, periods, cost_per_trade...**