Capital Asset Pricing Model

This post describes a feature of the v1 engine. As of March 2023, the v2 engine does not have this feature yet. However, we are planning to port it over asap.

We just finished implementing a new indicator for TuringTrader: The Capital Asset Pricing Model, namely calculation of Alpha and Beta. These are very useful functions to have for creating efficient portfolios.

The calculation is based on exponentially-weighted statistics, making it very fast. See Tony Finch’s fabulous paper for further explanation. Our own contribution to the methods outlined in chapter 9 is the calculation of the co-variance, based on the calculation of variance given in the paper. See our repository for a peek at the code.

The indicators can be calculated on instruments, or time series. Here is a simple demo project, plotting rolling 3-months betas for a set of sector ETFs. I hope you enjoy how sweet and concise this is, thanks to the new indicators:

The demo produces the plot below. On the left side of the chart, all betas begin with an initial value of 1.0, until they slowly approach their correct values:

We hope you find the addition of this indicator useful.

Happy coding!