About this question

Slippage & Transaction Cost Modeling

Medium · market_microstructure · Quant Researcher interview question · backtesting, transaction-costs, pnl-calculation, numpy

Accurate backtesting requires modeling transaction costs, often decomposed into linear components like bid-ask spreads and quadratic components representing market impact. These costs significantly affect the realized Profit and Loss (PnL) of a trading strategy, necessitating precise calculation methods for realistic performance evaluation. Task Implement the function solution(prices, positions, linear_impact, quadratic_impact) to calculate the cumulative Net PnL and Total Transaction Costs for