Day of month effect on Bond Equity portfolio

In this post we will:

  1. Take a look at a simple, momentum based, monthly rebalanced Equity/Bond portfolio.
  2. Search for what has been the optimal dates in the month to rebalance such a portfolio.

Each month we allocate to two ETFs: SPY and TLT.

If SPY has outperformed  TLT we rebalance to 60% SPY – 40% TLT.

If TLT has outperformed  SPY we rebalance to 20% SPY – 80% TLT.

For the first run we will re-balance on the first of the month and close at the last day of the month.


Now will try different combinations of entry and exit days. We will try to purchase x days before or after the month and instead of exiting at the end of the month we will exit after y days.



The top chart is optimized for Net Profit while the second one for annual return/max drawdown. They are similar in this case but will will use the second one.

According to the chart the best combinations have been:

Buy 3-7 days after the month and hold for around 10-18 days.

The BuyDayRefToMonth variable refers to when we buy relative to the turn of the month. For example -5 means we buy five days after the turn of the month (i.e., the 6th trading day). +5 means we buy 5 days before the month ends. The BarsnStop variable  refers to how many days later we sell the positions.

Looking at the charts more closely we see that buying after (not before) the 1st of the month gives consistently better results when set between 2 and 7 days.635995120684418456


How many days we hold the investment is less obvious and seems to work across the given range:


Let’s run this again but now only for 2012-May 2016:


Similar results. The only difference is that the holding times are shorter.

Let’s now input the optimized numbers and run the backtest. Obviously we will get something that looks good since it has been fit to the data. We buy 6 days after the month and hold 10 trading days.

Buy 6 days aftre hold 10



There are many variables that affect how we run a dynamic Equity/Bond portfolio. We optimized only two of them, namely when to rebalance relative to the turn of the month and how many days to hold the investment.

In terms of entry it was  better to wait 3-6 days after the month changes to enter the trade. When it comes to this bond/equity portfolio, rebalancing late is better.

Looking for a smart bond/equity portfolio?  Read  about the Universal Investment Strategy @ Logical-Invest.

The end of EOM? – Strategy and Rebalancing

Historically and up to 2013, equities have exhibited a positive bias during the end of the month.
Here is an example of buying the SPY etf on the first down-day after the 23rd and selling on the first up-day of the next month. Trading is at the same day close.


This has been well documented in academic papers as well as blogs. The main reason quoted for this persistent bias has been end-of-month window dressing.

As one of my favorite author/blogger/trader, Mr. Grøtte, has also recently blogged the EOM bias is no more.


Why is this important to know?

A lot of investors re-balance monthly. The day of the re-balance used to be somewhat important as there was an EOM bias. So it was better to ‘buy’ at the end of the month rather than at the beginning of the month. As of late (2013) this is less true.

What this means in practice is that the specific timing for re-balancing monthly strategies may be less important than it used to be.

//Amibroker code:
Buy=Day()>=23 AND C<Ref(C,-1) ;//AND C>MA(C,100);
Sell= (Day()<11 AND C>Ref(C,-1));
posqty=Param("nUMBER OF pOSITIONS",1,1,30,1);
PositionSize=- 98/posqty;
bars = 10; // exit after 10 bars
ApplyStop( stopTypeNBar, stopModeBars, bars, True );


Will We Ever Kill The Bug?

There is something very attractive about vintage items that just won’t die.

They just keep coming back. Same philosophy but better up-to-date technology.

It’s not just cars. It’s investment strategies, too.

Vintage strategies are often simple, easy to execute and provide amble ‘out-of-sample’ data. In other words one can see how they performed in real life years after they have been proposed. And like the VW bug, they are “safe” choices. Tried and true.

Can you imagine a 1965 VW running in the Autobahn? 
Although the essence counts for a lot, for the car to survive at today’s highway speeds the tech needs to be up to date.

So let’s take my favorite oldie and bring it up to speed: Harry Browne’s Permanent Portfolio investment strategy.

From Investopedia:

… Browne believed that each of the aforementioned four asset classes would thrive in one of the four possible macroeconomic scenarios that exist.

  • Stocks would thrive during periods of economic prosperity.
  • Bonds would do well in deflation and acceptably well during periods of prosperity.
  • Gold during periods of high inflation would rapidly increase in value as the only true defense against a deteriorating currency.
  • Cash would act as a buffer against losses during a routine recession or tight-money episode, and would act well in deflationary times.

So let’s see how it has performed.

The original rules:
25% in a stock market Index (SP500)
25% in Treasuries.
25% in Gold.
25% in Cash or similar.

Not bad. Annual return is 7.1% and maximum draw-down comes in at 17.84% since 1992.

For a far more detailed analysis of the so called “PP” you can see Gestaltu’s excellent “PP Shakedown” series as well as Scott’s Investments analysis. There are many other articles and analysis that serve as inspiration to this article.

Building a new strategy.

So let’s update this strategy by using some recent tactics. All further rules assume monthly rebalance.


Continue reading Will We Ever Kill The Bug?

SanzP joins Logical-Invest

I joined the team at Logical-Invest.

Together with Frank, Alex and Scott (our info) we hope to create a place where we can develop strategies and actually offer them to the public for a low subscription.

This is something new. At least I think so.

If you have followed my blog you may have guessed that I support empowering the private investor to take investing into their own hands and use tools as good or better than the ‘big guys’ use. But I also understand that not everyone can become a full-time trader, learn programming or research the market for hours on end. Luckily there are quite a few management firms that are intelligent, publish their research, have good track records and are fairly priced.

We are taking a different route. We are providing strategies that someone can follow for a low fee.
What’s new about that? Services like that have been around for quite some time.

This is what we are doing different:

1. We explain how the strategy works.

 In detail! Is there a danger that someone can replicate it and use it?
Sure, more power to them. We believe most people would rather pay a small fee and have us track, monitor and notify them when changes are due than having to create their own back-end from scratch. As Scott says, someone can go online and learn how to rewire his whole house. It doesn’t mean they ‘ll want to do it themselves. Maybe they just want understand how it’s done and then to pay someone to do it.

2. We put a face behind the strategy

A lot of strategies are ‘face-less’. We are not sure who runs them. Is it a mature investor thinking about retirement? An aggressive young guru in his teens?
We have faces. We have e-mails. You know who we are and you can talk to us. We even have a forum!

3. Mix & Match

We are developing a portfolio tool where you can combine strategies and see how the resulting portfolio would perform.

4. We are experimenting. 

We don’t know everything right from the start. We are already running some strategies but we all have our own opinions and preferences. And there are many paths to take.

So please visit us and let us know what you think. All suggestions are welcome.

From Regime Switching to Fuzzy Logic -SP500

In the previous post I showed how one can implement “regime” switching to create a strategy that switches between a mean-reverting and a momentum sub-strategy.

Can we do something similar (or better) using Fuzzy Logic?

  Here’s the setup: (here for some Fuzzy Logic backround)

We create a basic membership function for the RSI(2) indicator: “Low”, Medium” and “High”
We create a basic membership functions for the Correlation* indicator: “Low”,”High”.

We implement these rules:
1.//mean revert – LOW Autoccorelation
IF “rsi” is  “Low” AND “autocorrel” is “Low”, “Action”, 1 ; //Buy
IF “rsi” is “High” AND  “autocorrel” is “Low”, “Action”, -1 ; //Sell

//MOM – HIGH Autocorrelation
IF “rsi” is “Low” AND “autocorrel” is “High”, “Action”, -1 ; //Sell
IF “rsi” is “High” AND “autocorrel” is “High”, “Action”, 1 ;  //Buy

Here’s the Equity:

As with Regime switching we can use Fuzzy Logic to solve the problem of using one strategy for trading pre- and post-2000 SP500. Furthermore, we have more robust and less specific rules to deal with (buy on “Low” RSI rather than Buy=RSI2<30).

*By “Correlation Indicator” I am referring to the  22-day Correlation (see previous post) between the current return and the previous day’s return. In Amibroker Code: 

Simple Regime Switching for SP500

image from

Let us consider two possible ways to trade the SP500.

1. If the index falls today, we buy tomorrow at the open. This is a “mean-reversion” strategy.
2. If the index rises today, we buy tomorrow at the open. A “follow-through” strategy.

From the graphs below, we can see that neither of these strategies worked well from 1960 to today.


Mean Reversion Trading On SP500
Follow-Thru (momentum) trading on SP500

Let’s introduce a qualifier that will tell us which strategy to trade at what time.

We will try the most basic one: The correlation between today’s return (close to yesterday’s close) to the previous day’s return. If it is negative we ‘ll use a contrarian logic. If the correlation is positive we ‘ll use a momentum logic.

The indicator of choice is the 2-period Relative Strength Index (RSI).

So if correlation between yesterday’s and today’s return is less than zero we buy on a correction. Otherwise we buy on strength. We trade at the next Open.

Here’s the Amibroker Code:

Strategies on The Cloud: TAA on Google Docs

Did you want to have a strategy on the cloud that monitors the market and updates you on new Buy/Sell signals (as well as number of shares, etc)  by email. Did you want to run it on best of breed “always ON” servers with free and accurate data?
How much would that set you back?Well, Nada! Courtesy of Google.This post will guide you through coding a simple Tactical Asset Allocation on Google’s Docs.
You need:
1. A Google account.
2. Google Docs.The system is similar to Faber’s TAA model using 5 Etfs.: SPY,TLT,VNQ,EEM,DBC
We buy or sell at the beginning of the month ONLY.
If Close > 200-moving Average then we buy the ETF.
If Close < 200-moving Average then we sell the ETF.

Pseudo Code:
If TodayIsNewMonth AND CloseETF>MA(200) Then Buy
If TodayIsNewMonth AND CloseETF<MA(200) Then Sell

Let’s get started. Go to Google Docs and create a new SpreadSheet. Call it TAA_5.
Once the spreadsheet is open in your browser, go up to the menu and select Tools–>Script Editor…
This should open a new script Editor. Select “SpreadSheet” as your project.


Lets start coding.
Google Docs scripting uses a version of JavaScript which seems fairly easy for non programmers.

Continue reading Strategies on The Cloud: TAA on Google Docs

You don't need a prophet to trade your account