Friday, September 8, 2017

Dividend yield trend during GFC using R

Done with writing another R script! Instead of correlating different counters together, this time round my script will be used to visualize the trend in dividend yield across time. I'm particularly curious as to the yield of some counters during the great financial crisis (GFC). It's more for planning how I could prioritize my available funds.

The function takes in three arguments: (a) the counter symbol, (b) the start date, and (c) the end date.

The function consists of the following steps:
1). Use quantmod to import the historical data for a given counter into R, with the start date and the end date specified by the user.
2). Retain only the closing price for said counter
3). Use quantmod to download the dividend data, and their corresponding payout dates, into R. The start date and the end date are the same as that in step 1.
4). Sum up the dividends received across the time period.
5). For each day, divide the sum of dividends received by the closing price to produce the daily dividend yield.
6). Plot the data as a line graph using ggplot, where the x-axis and y-axis are date and daily dividend yield, respectively.
7). As a cautionary measure, produce a data frame of the data. If there is any error in the data manipulation/data presentation, I will be able to drill-down to the source of the error rapidly.

The good thing about writing your own functions is that you know what goes into it. Different firms adopt different fiscal years in their reporting. To simplify comparisons across counters, I defined total annual dividends in my function as the total amount received when the counter goes ex-dividend (because Yahoo Finance tracks the ex-dividend date, and not the payment date) during the calendar year. To better illustrate what I am saying, please refer to the visualization below.

Consider a company that ends their fiscal year in June. By right, annual dividends are computed based on total dividends paid out between Q3 2007 to Q2 2008. However, my function will only consider total dividends, for the same counter, based on the counter going ex-dividend between Q1 2008 to Q4 2008.


I'll reserve my thoughts to the end of the post.

Let's start with some STI constituents k?

DBS


UOB

Capitaland Mall Trust

Capitaland Commercial Trust

Ascendas REIT

Singtel

ComfortDelGro

ST Engineering

SGX

Hong Kong Land

Thai Beverage


Enough with STI constituents. Let's take a look at other equally interesting counters.

Dairy Farm

Frasers Commercial Trust

Fraser and Neave

AIMS AMP Capital Industrial REIT

Parkway Life REIT

Hong Leong Finance

Lippo Malls Trust


Thoughts
1). Thai Beverage yielded more than 100% during the GFC?!?!?!? Is that accurate? The raw data looks fine when I checked it though. However, according to SGX's Corporate Action section, the dividends paid during the 2008 calendar year was in thai baht while the stock price was in Singapore Dollars. Okay, that explains the supposed crazy results.


2). On the internet, I have encountered a particular type of hearsay stating that ST Engineering would yield 7% during recessions. Apparently, my chart does not corroborate that particular hearsay. When I created another chart (not shown above) for ST Engineering from 01 January 2009 to 31 December 2009, the maximum yield is still around 3.5%.

I initiated my position in ST Engineering on February 2016. According to other online yield trackers, I got into the counter at 5+% yield. When I tried to compute the yield at around February 2016 with my function, the result showed that I got the counter at around 3.60% yield.

I shall attribute this to the difference between calendar year and ST Engineering's fiscal year.

3). When I look at these yield charts, it clearly reminded me of my inexperience in the market. How was a particular company like in, let's say, 2007? What direction was the management taking then? What was their attitude towards cheap money? Name some major corporate actions that the company took. What could be gleaned from these actions, their pros and their cons? How are their competitors faring? What about the overall shape of the industry? Is there a structural decline in the industry? What were investors' sentiment back then? Obviously, I can't even provide a comprehensive enough answer to the questions I have set for myself.

Experience is built up through time spent as an investor, coupled with active reflection on the ins and outs of the market, their various industries, and the individual companies that make up those industries. At this juncture, I have but only 2.5 years' worth of experience in the market. Textbook-learning aside, I just have to progress, open my eyes wide, and breathe in the "feel" of the markets.

8 comments:

  1. Hi UN,

    Wow. A very informative case study of the various counters during the period of GFC. Most commonly, a practical lesson will be able to explain a thousand theory lesson.

    Let's wait for the GSS for these counters to come :p

    ReplyDelete
    Replies
    1. Hi Sleepydevil,

      Need to save a lot of money first :P

      Delete
  2. Haha. This is the kind of post that makes me feel unintelligent >.< but I like it! Ever thought of sharing your script over git or something?

    ReplyDelete
    Replies
    1. Hi KPO,

      Thinking of doing that, but people will know my true identity. :(

      Do you use R?

      Delete
  3. Haha. Create a separate git account to stay hidden. lol. I have not use it but I use Python in my workplace. Programming languages same same one..

    ReplyDelete
    Replies
    1. Hi KPO,

      A tempting proposition. Shall consider it. :P

      Born in the year of the snake? :P

      Delete
  4. IMHO if you have the skills and capabilities, you should advertise your projects sufficiently to benefit off it (advertising in your blog). A public github will definitely benefit you in the long run.

    Some of the more successful bloggers marketed their skills and blogs to earn side income of social media. It benefits both parties if you don't mind the hard work provided for free on your part

    ReplyDelete
    Replies
    1. Hi INTJ,

      I'm still a novice in my craft. In the long run, I share your sentiments exactly. :)

      Cheers

      Delete