Saturday, April 25, 2020

Write some code, improve your life

Learn Python 3 the Hard Way: A Very Simple Introduction to the ...

I thought I should do an article on my adventures with Python programming.

This CB is a great time to develop new skills, so I decided to pick up some Python programming. I took the following steps to pick up my skills :

  • To get the basics right, I used Learn Python 3 the Hard Way by Zed Shaw. The book was fairly detailed and coding about 90% of the exercises gave me the proper foundation to get started.
  • The second book I used was Python for Finance by Yuxing Yan. This was challenging as some APIs no longer worked and I had to use some web surfing to correct the code contained in the book. Still, it was great as it tied Python programming to real-world finance problems.
  • Finally, I signed with Data Camp and paid for a year's subscription. I completed a 4-hour program on Introductory Python for Finance module and now undergoing training on Data Frames which is a foundation for further Python data science problem-solving. 
For the engineers who are curious, I installed Python 3.8 on my PC and use the ATOM IDE to do my coding. 

As I have some legacy C++ and R background, picking up Python was fairly straight-forward but I had to contend with some difficulties many new developers face at work :
  • New age programming has a lot of problems with versions. Some old code I used worked for Python 2 would not work for Python 3 and my Mac has both versions installed. This is a serious obstacle for beginners. 
  • Worse, the data science packages also get obsolete quickly so learning from a physical book is painful as your code needs an added level of troubleshooting even if you copied the lines properly. Even after getting my code working, my program is always warning about the deprecation of code meaning that my code will fail one day. 
  • The online documentation has too much information and sometimes you just want a piece of code that solves the problem you are facing. Fortunately, there is Stack Overflow but it is a crapshoot as to whether you can find the code you want.
  • Sadly, I spent more time positioning data on a chart to make it look good than to process numbers to come up with excellent financial insights.
After a short week or so, here's a great result I can add this to my training slides. 

Image may contain: text

Right now, I figured out how to fetch some data from Yahoo Finance and reduce it to daily stock gains. With that information, I can build a histogram to compare the volatility of local stock ETFs and put up some serious information on correlations. 

The above slide allows a student to visualise risk-returns and illustrates why correlations matter in portfolio design. 

What this slide tries to demonstrate is that for the past 2 years or so, the ABF Bond ETF is negatively correlated to the STI ETF and correlation between REITs and blue-chips is approximate 0.7 which makes both ETFs excellent diversification tools for STI ETF investors. You can also, by visual inspection, observe just how stable a bond ETF can be when stacked against an equity ETF. 

Image may contain: text

This slide illustrates the yield to maturity corresponding to different AstreaIIV bond prices and outputs the price-level that is feasible for leveraged investors. You can see that the visualizations closely mirror my course objectives.

Both code fragments are not too complex, all of which are about the length of just one page. With a little bit of coding skill and domain knowledge, a trainer can jazz up with slides to improve his pedagogy. 

For the folks who know a bit more finance, you should be able to guess that machine-driven asset allocation should not be too far from reach, once I attain this level of programming. 

You can expect my future webinars to be influenced by Python Matplotlib visualizations. The question is how hardcore can my presentations become before people start complaining that it has become too difficult or technical. 

My next major project beyond my previews is based on the cancelled Seedly Talk on the FIRE movement. I fully intend to exploit my Python programming skills to jazz up my slides which will be expanded to a one-hour discussion. 

I guess to remain relevant, we have to keep pushing the boundaries to maintain an edge over our competitors. 

Thanks to CB,  I can now bring three edges to the competitive training landscape: 
  • I have my finance domain knowledge;
  • visualization and data science skills with Python which can be upgraded to machine or deep learning. 
  • and a decade of public speaking.



2 comments:

  1. Napoleon would have said, "But are you lucky?!?" LOL.

    My gut feel is that this recession, while deep, will be relatively short ... similar to 08/09, oh say lasting about a year. This is thanks to the wholesale embrace of MMT by any & all govts with the capacity to print or borrow without causing hyperinflation in the short to medium term.

    Hence I would say the situation is lucky for you as Wall St recovers fairly faster than Main St. People in your target market i.e. earning above the median wage, will tend to be able to hold on to their jobs if the downturn is not multi-years.

    ReplyDelete
  2. I hope you are right, even though I probably don't have half your optimism.

    Gotta hustle this COVID-19 season so I hope I get to make some luck when everybody else is down right now.

    ReplyDelete