Wednesday, May 06, 2020

CB Prosperity Diaries #7 - If you can't afford to buy, build !

Here's a short update.

I've been busy preparing for classes this weekend and I've been so busy that I was not even able to promote my webinar later with a useful article on the Dr. Wealth Blog.

In spite of my lack of articles, I have been getting really decent progress on my coding and I can claim that I managed to recover some functionality of a Bloomberg terminal that I lost when COVID-19 closed all libraries down last month. Here's a background, when the libraries closed, I wanted to purchase a backtesting terminal from Factset and was quoted a ridiculous $48,000 USD annual fee. As I am just a humble investment trainer and not some high flying hedge fund manager, this idea was thrown out of the window quickly.

If I can't afford to buy, maybe I can afford to build instead!

So one of my major missions is to see whether I can write enough code to replace the backtesting functionality I used to enjoy when the libraries were open.

And just today, after weeks of experimenting with Python, I am finally able to do simple backtests with code that I wrote myself that invole APIs that download datasets from Yahoo Finance. 

This screen-shot is the result of a few weeks of attending online Python coding classes and reading programming guides. This program creates an equal-weighted portfolio of STI component REITs and compares its performance against the STI ETF.

It confirms a lot of my suspicions about the markets.

  • A large proportion of gains in the STI over the past 2 years came from REITs that are now slowly being injected into the index in the future to maintain its relevance. So much so that a simple subset of REITs could have a ridiculous Sharpe Ratio over 1. Of course, as some of the REITs were only injected the index recently, a lot of these gains are due to index inclusion. 
  • Another surprise is that the correlation of the REITs from the greater index is also surprisingly low at only 0.37. 

Naturally, my program is inferior to Bloomberg in many ways. It does not account for survivorship bias and I need another program to screen stocks based on stock fundamentals.

But the potential of what a simple Python program can do now quite significant - I can now select any meaningful subset of stocks and compare the performance across different eras limited only by data availability on Yahoo Finance.

Sadly, I only finished my program today after struggling with some coding differences behind geometric and arithmetic means of daily returns. Combining insights from multiple domains like statistics, finance and computer science is hard but I think this is where I can really add value over the next few weeks.

As such, I am unable to integrate this program to my presentation tonight.

If you are free, come and attend my webinar anyway by clicking on this link!

Anyway, I know some engineers are reading my blog, I include a screen-shot of the first few lines of code as some software developers will ask how I invoke the command to fetch prices from Yahoo.

No comments:

Post a Comment