okama.AssetList.tracking_difference
- AssetList.tracking_difference(rolling_window=None)
Return tracking difference for the rate of return of assets.
Tracking difference is calculated by measuring the accumulated difference between the returns of a benchmark and those of the ETF replicating it (could be mutual funds, or other types of assets). Tracking difference is measured in percents.
Benchmark should be in the first position of the symbols list in AssetList parameters.
- Parameters:
- rolling_windowint or None, default None
Size of the moving window in months. If None calculate expanding tracking difference.
- Returns:
- DataFrame
Tracking diffirence time series for each asset.
Examples
>>> import matplotlib.pyplot as plt >>> x = ok.AssetList(['SP500TR.INDX', 'SPY.US', 'VOO.US'], last_date='2021-01') >>> x.tracking_difference().plot() >>> plt.show()
To calculate rolling Tracking difference set rolling_window to a number of months (moving window size):
>>> x.tracking_difference(rolling_window = 24).plot() >>> plt.show()