Tracking error is a measure of how closely a portfolio follows the index against which it is benchmarked. The larger the tracking error, the more the portfolio diverges from the market index, indicating an active management style. Tracking error can be measured ex-post or ex-ante. Ex-post tracking error is calculated as standard deviation of excess returns.

Rp – portfolio return
Rb – benchmark return
n – number of periods