Bias & Intuition Paradox

Last week I called my mom to say hi, and she said they are on their way to the hospital as my step-father has had a suspected heart-attack.

depression-cause-heart-attack-1

Ian had been suffering from a coughing virus for the last 2 weeks and was feeling pretty lousy. My mother was insisting that he go to the doctor for an unbiased examination. The issue is Ian is a doctor and often when you are an expert in a field you think you know best. However an expert doesn’t always sufficiently factor in the bias that comes when personal involvement is present. Subjectivity can override common sense and good judgement, it is for this reason doctors don’t usually operate on or make serious diagnoses on their own family. Back to the drama……….

After my mothers nagging which I can assure you is enough to give you a heart-attack Ian agreed to see his local doctor who ran some blood work. He called back shortly to say that the enzymes indicating a heart-attack were present and he needs to be admitted immediately with a suspected heart-attack. The cardiologist on call was concerned enough to put him in intensive care and ordered a series of further testing. All this time, Ian was convinced he never suffered a heart-attack, and everyone was overreacting. Ian had concocted a complex endocrine story of how his body was producing excessive enzymes due to a virus attacking the lining of the heart muscles. So Ian has spent 6 days in hospital twiddling his thumbs convinced he was well and statistical science was producing a misdiagnosis.

The message I wanted to convey with this experience was how as a trader we bring our own personal bias’s to our trading decisions and this is part of all facets of life, even doctors experience it. Therefore at times like these even if you are an expert (the best “Elliott Wave Trader” or the best “Swing Trader”) you need to lean on other experts in your team to help you gain perspective.

However, the final message of this story had a completely opposite ending with perhaps an even more powerful message than the one that personal involvement brings bias to ones judgment. Today Ian had an angiogram to make a final diagnosis, and thankfully his complex theory which his cardiologist dismissed as fanciful turned out to be spot on. So almost in complete contradiction to my original message, the very personal bias that we sometimes try to avoid by consulting other experts ignores the incredible gift of intuition that sits somewhere on the cusp of science and a mystical gift of the divine.

I am relaxing on holiday and enjoying playing around with these observations – Good night!.

Grown Ups

My sisters house on the left and my house on the right.

My sisters house on the left and my house on the right.

As a young person growing up you try and picture what your life will look like when you grow up. I grew up in a close family and always had a close relationship with my sister who is 14 months older than me.

In December 2000 my mom, sister and her family emigrated to Melbourne with me staying on in Johannesburg, South Africa. I moved with my family to Sydney in December 2007, and every year we come on a short holiday to Melbourne where we stay with my mom.

This year my sisters best friend from grade 1 offered us to stay in her house while she is on holiday. The house is amazing it has everything, it’s massive with swimming pool and tennis court and every game a child could dream of. But it is even more amazing because it is next door to my sisters home with my mother a few streets away.

So I write this post while living next door to my 44 yr old sister. Even though it’s for a couple of weeks I feel tremendously blessed to have this almost child like experience with my kids living next door to their first cousins and me and my mom and sister popping in to each other’s house. I grew up living a few houses away from my great gran, gran and grandpa, great aunt, and two of my moms sisters with my cousins, so the feeling of living next to my sister has brought back so many fond childhood memories.

How wonderful to have friends that open their home like Lauren and Manfred. Yours truly is unwinding and recharging looking forward to a big 2015 and feeling so grateful.

Bond Timer for S&P500 (Part 2)

As I said the other day when posting Part 1, I was tired. I also don’t wish to delete older posts that may be of little value, rather I want to keep my workings and progress. Maybe a symbolic way of dealing with my “Shadow”. For those readers not into geekish financial maths, give this post a miss.

Let us have another look at the results, this time with some tweaks to the approach and then we will go into some more depth trying to establish whether this method truly adds value to the Buy and Hold approach.

We start by downloading S&P500 and US 10yr Treasury data from Quandl going back to 1962 so we have 53 years of data. I would actually like to use a lot more data as I fear that the secular bond bull cycle may be distorting our results. We create a ratio by dividing the S&P500 by the bond yield (I think working with nominal index and not using log returns may be an issue worth looking into). Once we have a ratio we then smooth it out with a 50 and 200 day moving average. The signal trigger in our model then is to buy the market whenever the 50 day moving average of the ratio is greater than the 200 day. It is quite hard to see on this chart but you can at least see the shape of the ratio relative to the S&P500 (black):

Rplot

So lets look at the results:

2014-12-25_1612

According to the results from 1962 the Sharpe Ratio of the Ratio Cross vs Buy&Hold is better 0.50 vs 0.32. You can also see a superior Max DrawDown ratio, we do not focus on absolute return where buy and hold outperforms as our stated objective is to always focus on risk adjusted returns. I include the tail(sig_ratio) so that you can see that the system is invested at the moment.

Rplot07

 

We now try a different study and look at the Sharpe Ratio on a yearly basis and then look at the mean of the 53 years. Here I get a confusing result which I don’t know how to explain, it seems to say that the Ratio Cross has a Sharpe Ratio of 0.60 vs 0.70 hmmm???. So to take this one step further I tested the market timing ability of my Bond Timer with the Treynor-Mazuy quadratic regression approach, and you can see below that the system produces alpha, which seems to suggest that the Bond Timer is providing market timing value add. Btw, the MarketTiming() function isn’t in the Performance Analytics package on CRAN so I have included the function in my code below.

2014-12-25_1618

Conclusion:

This is still very much a work in progress but I believe the ratio timing method adds value to a buy and hold approach, however I need to explain why I am getting a conflicting result when looking at Sharpe Ratio’s of 1 year at a time.

require(quantmod)
require(PerformanceAnalytics)
require(Quandl)
 
start<- "1962-01-02"
#get the data (S&P500 and US 10yr Treasury)
spy<- Quandl("YAHOO/INDEX_GSPC", authcode="kvYEqCqKCTyL4anWz5Zv", type="xts")
bond<- Quandl("FRED/DGS10", authcode="kvYEqCqKCTyL4anWz5Zv", type="xts")
 
data<- merge(spy[,6],bond[,1])
data<- data["1999::"]
 
# This is the magic signal or is it? It is the Nominal Price of the S&P500 / bond yield. 
# The fact that it is nominal worries me. 
ratio<- data[,1]/data[,2]
ratio<- na.omit(ratio)
# moving averages of the ratio
ratio_short<- rollmean(ratio, k=50, align= "right")
ratio_long<- rollmean(ratio, k=200, align= "right")
 
# I like visual references ignore the red errors in the output console I am too lazy to fix up the axis.
plot(data[,1], main="Mike's Bond Timer")
par(new=TRUE)
plot(ratio_long, col ='red')
axis(4)
par(new=TRUE)
plot(ratio_short, col ='green')
par(new=TRUE)
plot(ratio, col ='blue')
 
#our baseline, unfiltered results
ret <- ROC(data[,1])
 
#our comparision, filtered result. The idea being to trade the short ratio while it is above the long ratio.
sig_ratio <- Lag(ifelse(ratio_short > ratio_long, 1, 0))
sig_ret <- ret * sig_ratio
 
btimer<- cbind(sig_ret, ret)
colnames(btimer) = c('Ratio Cross', 'Buy&Hold')
 
table.AnnualizedReturns(btimer, Rf= 0)
charts.PerformanceSummary(btimer, Rf = 0, main="Bond Timer",geometric=FALSE)
maxDrawdown(btimer)
tail(sig_ratio)
 
# This looks at the Sharpe Ratio on an annual basis as opposed to the whole period.
years <- apply.yearly(btimer, SharpeRatio.annualized)
 
# In order to get rid of NaN's this function I found on StackFlow helps convert them to zero.
is.nan.data.frame <- function(x)
  do.call(cbind, lapply(x, is.nan))
years[is.nan(years)] <- 0
years
sapply(years, mean)
 
# Market Timing Function which is not part of the CRAN release.
MarketTiming <- function (Ra, Rb, Rf = 0, method = c("TM", "HM"))
{ # @author Andrii Babii, Peter Carl
 
  # FUNCTION
 
  Ra = checkData(Ra)
  Rb = checkData(Rb)
  if (!is.null(dim(Rf))) 
    Rf = checkData(Rf)
  Ra.ncols = NCOL(Ra)
  Rb.ncols = NCOL(Rb)
  pairs = expand.grid(1:Ra.ncols, 1)
  method = method[1]
  xRa = Return.excess(Ra, Rf)
  xRb = Return.excess(Rb, Rf)
 
  mt <- function (xRa, xRb)
  {
    switch(method,
           "HM" = { S = xRb > 0 },
           "TM" = { S = xRb }
    )
    R = merge(xRa, xRb, xRb*S)
    R.df = as.data.frame(R)
    model = lm(R.df[, 1] ~ 1 + ., data = R.df[, -1])
    return(coef(model))
  }
 
  result = apply(pairs, 1, FUN = function(n, xRa, xRb) 
    mt(xRa[, n[1]], xRb[, 1]), xRa = xRa, xRb = xRb)
  result = t(result)
 
  if (ncol(Rb) > 1){
    for (i in 2:ncol(xRb)){
      res = apply(pairs, 1, FUN = function(n, xRa, xRb) 
        mt(xRa[, n[1]], xRb[, i]), xRa = xRa, xRb = xRb)
      res = t(res)
      result = rbind(result, res)
    }
  }
 
  rownames(result) = paste(rep(colnames(Ra), ncol(Rb)), "to",  rep(colnames(Rb), each = ncol(Ra)))
  colnames(result) = c("Alpha", "Beta", "Gamma")
  return(result)
}
print(MarketTiming(years[,1],years[,2],Rf=0))

Created by Pretty R at inside-R.org

Sefirot Capital Freestyle Portfolio

I think it is too easy to make market calls and never hold oneself accountable to how these suggestions perform. This site is not about providing investment advice, it is about sharing knowledge, wisdom and providing some entertainment. In order for me to feel engaged with the markets directly, as I no longer manage money for people directly but rather invest in other traders like a fund of fund, I will be running the Sefirot Capital Freestyle paper portfolio. To ensure that this portfolio is free of hindsight bias all trades will be posted via the blog to ensure a real time time-stamp with the portfolio updated on the Portfolio page. The objective of this portfolio is to outperform the S&P 500 on a risk adjusted basis.

Note: I don’t intend for this portfolio to trade too often.

On the 23rd December 100 VXX shares were boughts @$28.55

 

 

The Dark Side – Shadow

This is a strange topic to be writing about on the eve of Christmas where the western world is gripped in a mood of good cheer; yet here I am writing about evil. I woke up to the Dow closing above 18,000 for the first time and the S&P500 making new all time highs, and I felt compelled to share some wisdom.

Yes I am bearish the markets at the moment, and yes it is a source of irritation, annoyance and confusion so with that bit of background lets dig a little deeper. In order to do so we need to start with a quote from Jung’s Collective Works:

Unfortunately there can be no doubt that man is, on the whole, less good than he imagines himself or wants to be. Everyone carries a shadow, and the less it is embodied in the individual’s conscious life, the blacker and denser it is. If an inferiority is conscious, one always has a chance to correct it. Furthermore, it is constantly in contact with other interests, so that it is continually subjected to modifications. But if it is repressed and isolated from consciousness, it never gets corrected.

“Psychology and Religion” (1938). In CW 11: Psychology and Religion: West and East. P.131

In layman language, just like the name “shadow” implies the Jungian idea is that each persons psyche develops both positive and negative characteristics with each lived experience. The negative ones embarrass us, and we prefer not to deal with these emotions so we cast them into the shadows, i.e. into our unconscious minds where we try not confront them and try and forget about it.

I am touching on a central Jungian motif, coincidentia oppositorum – unity of opposites, which many dialectical philosophical models work with, but is an idea I am familiar with and is central to the Jewish Kabbalistic approach to creation and existence. The sitra achra means the “other side” that is from the sitra kedusha “side of holiness” and everything in the world can be seen from these polar opposites.

Ok lets get back to the subject of this note, that is the dark side our shadow. It is very important when working with the Jungian model to see psycho-dynamics in terms of energy flow. As we create positive energy so too we equally create negative energy, this is actually a very difficult concept to grasp. Here is an example; I act in a very “kind” way to Dean this creates positive energy, but there is an equal dark “mean” force created in my psyche towards Dean. That is a horrible theory you are probably saying, but that is probably your shadow acting up 😦 .

So you are probably saying assuming you accept this line of thinking – so what? The problem is that when emotions are left unconscious they form a life of their own and this is where we get ourselves into trouble. A typical manifestation of the shadow complex is for it to find expression via projection. The reason why we don’t want to allow projection to play out is due to the completely irrational / random nature of projected behaviour. Here is an example of how this plays out:

Its the holiday season and we live in beautiful Sydney a highly desirable location. Friends contact me and ask if they can stay with us for a few days as they are passing through town. I accept and I am the perfect host. I use every bit of my energy to make sure that our guests have a great time. I am attentive, I am resourceful I am all things good what I am unaware of is I am building shadow material. The guests leave having had the best stay ever, and I am just about to kick up my feet and peace out in quiet watching some cricket, and the missus says, “Mike will you go past the shops and pick up some bagels”. What do I do, I go friggin mad and scream and shout how ungrateful she is and launch into a completely irrational tirade. Do any of you recognize this pattern, I suspect so LOL :).

We have all heard that saying, “the bigger you are the harder you fall”. This is very common with politicians or other people who occupy positions of power. I think of Elliott Spitzer as a classic example of someone who clamped down on crime and prostitution only to fall for this very activity. Or think of religious people perpetrating sexual misconduct, acting precisely against what the religion they represent stands for.

Does this mean we are destined to be ruled by our shadow? No not at all, the secret is to bring our shadow into consciousness. This secret formulae has the potential to diffuse the negative energy. What is even more amazing is that our psyche can be “tricked” through symbolic ritual/activity. Marie Louis von Franz one of Jung’s greatest disciples, used to always recommend to friends and colleagues experiencing hubris to go and take out the trash or some such “lowly” activity to symbolically balance the libido/energy from the shadow.

With many stock indexes at all time highs, it is easy to develop shadow material. It is times like these when markets climb and we profit to fall into the fooled by randomness trap and think it is all us. This shadow material will eventually want to express itself, it may be through excessive risk taking due to our inflated sense of Self or it may manifest in us buying a Porsche that we cannot really afford. Remember the psyche is open to symbolic gestures, if you have benefited from the bullish markets, think of a creative way of bringing the shadow material associated with it to consciousness or less energy potent. Perhaps it may be something as simple as this:

I made 25% in my investment portfolio this year, when I take the market beta into account I actually only added about 2% through my stock picking ability. This is a simple way of acknowledging and diffusing the shadow that likes to think that all 25% was my doing.

Bond Timer for S&P500

It is late and I am tired, but I wanted to quickly explore an idea, where I use the ratio of the S&P500 divided by the US 10yr Treasury note yield as the trigger for when to get in and out of the S&P500. I have lots of things to check to see if this spurious or not, but none the less this is the code I came up with.

But before we look at the code you can see some nice out performance of the index. I haven’t factored in transaction costs or spread. Will check and amend if this is likely to be material.

2014-12-22_2245

Rplot01

Some visuals of the indicators

Rplot2

Finally the code:  [Post script: On the 25th of December I improved on the findings originally posted here. I don’t like to delete my workings as I like to have a source of reference for the progression of my thinking.]

require(quantmod)
require(PerformanceAnalytics)
require(Quandl)
 
start<- "1962-01-02"
#get the data (S&P500 and US 10yr Treasury)
spy<- Quandl("YAHOO/INDEX_GSPC", authcode="kvYEqCqKCTyL4anWz5Zv", type="xts")
bond<- Quandl("FRED/DGS10", authcode="kvYEqCqKCTyL4anWz5Zv", type="xts")
 
data<- merge(spy[,6],bond[,1])
data<- data["1962::"]
 
# This is the magic signal or is it? It is the Nominal Price of the S&P500 / bond yield. 
# The fact that it is nominal worries me. 
ratio<- data[,1]/data[,2]
ratio<- na.omit(ratio)
# moving averages of the ratio
ratio_short<- rollmean(ratio, k=20, align= "right")
ratio_long<- rollmean(ratio, k=100, align= "right")
 
# I like visual references ignore the red errors in the output console I am too lazy to fix up the axis.
plot(data[,1], main="Mike's Bond Timer")
par(new=TRUE)
plot(ratio_long, col ='red')
axis(4)
par(new=TRUE)
plot(ratio_short, col ='green')
par(new=TRUE)
plot(ratio, col ='blue')
 
 
#our baseline, unfiltered results
ret <- ROC(data[,1])
 
#our comparision, filtered result. The idea being to trade the ratio while it is above the long term m.average
sig_long <- Lag(ifelse(ratio > ratio_long, 1, 0))
sig_short <- Lag(ifelse(ratio > ratio_short, 1, 0))
sig_long <- ret * sig_long
sig_short <- ret * sig_short
 
 
btimer<- cbind(sig_long, sig_short, ret)
colnames(btimer) = c('BT Long', 'BT Short','Buy&Hold')
 
table.AnnualizedReturns(btimer, Rf= 0.02/252)
charts.PerformanceSummary(btimer, Rf = 0.02, main="Bond Timer",geometric=FALSE)
maxDrawdown(btimer)
tail(ma_sig)

Created by Pretty R at inside-R.org

 

Projection (Part 4)

School holidays started 2 days ago, and I have been preaching more than usual how important it is for the kids to put their dishes away and put their clothes in the wash. When I get on my high horse and tell my wife and kids about their untidiness I feel 100% justified in my actions, in fact I think I am near perfect (or do I).

Over the last 24 hrs my wife keeps coming at me with “Preacher” mistakes, in other words the very thing I am demanding from the family I am guilty of to some degree as well. This is a classic example of my “shadow” that I am projecting onto the family. It turns out I am not as perfect as I think I am 😦 and my lecturing to the family about neatness is rather something about myself that I am not too comfortable with, and it has found its expression through projection.

Don’t get me wrong as a parent I have every right to insist on the kids and my wife keeping the house neat and tidy; however the same applies to me! Following a Jungian approach, the first step to wholeness is identifying consciously with the shadow.