Sunday, June 30, 2013

Portfolio Optimization

Can you consistently beat the S&P 500 by ranking all of the stocks in the index from 1-500, then trading only those stocks that are ranked in the top 50?

That question has been on my mind for a long time...

So I went ahead and wrote a program that ranks all of the stocks in the index from 1-500, using the same algorithmic trend-following system that I've been using for 10+ years to generate my buy and sell signals.

I ran the system on all of the stocks in the index over that same 10-year time period, and then ranked them by Sortino Ratios. That ratio is calculated as the average weekly return divided by the standard deviation of returns below the minimum required rate of return (I chose 12% as my rate).

I like Sortino over Sharpe (the average weekly return divided by the standard deviation of all returns) because it views risk as being asymmetrical. In other words, downside risk is very important. Upside risk? Not really a problem.

In all honesty, my rankings didn't change much (one or two places here and there) whether I used Sharpe or Sortino or even Drawdown Analysis, so it's just a question of personal preference.

I use weekly data inputs in my (long-term) system, so the rankings update automatically at the end of every week.

And of course, if I'm going to rank everything in the index, it also makes sense to rank the stocks within their sectors and sub-industries, so I did that too.

But before we talk about ranking the 6 stocks in the Oil & Gas Equipment & Services sub-industry of the Energy sector, I have some house-cleaning to do.

On Friday I closed out 5 positions that do not meet my criteria for trading going forward:

Salesforce.com (CRM)
With an average weekly return of +0.72% and a standard deviation of 5.04% across 372 totals weeks (5 trades) since 2004, CRM has a very respectable Sortino Ratio of +0.1423. That's easily good enough to crack my top 50. But... it's only good enough for 5th place within the Internet Software & Services sub-industry of the Information Technology sector. NetFlix (NFLX), Mastercard (MA), Visa (V), and Akamai Technologies (AKAM) all rank higher. So I closed out this trade at $38.18 (+6.3%).

Crocs (CROX)
It's simple: this stock isn't in the S&P 500. Too bad. An average weekly return of +1.64% with a standard deviation of 7.44% over 208 totals weeks (4 trades) give CROX a Sortino Ratio of +0.2202. That would solidly rank in my top 10... if it were in the S&P 500. So I sold this position for $16.50 (+6.9%).

Deckers Outdoor (DECK)
Again, not a part of the S&P 500. And again, this would be a top 50 stock based on the average weekly returns of +0.97% and standard deviation of 5.58% across 284 total weeks (4 trades). That's a Sortino Ratio of +0.1731. But these boots are made for walkin', so I sold this position at $50.51 (+16.0%).

LinkedIn (LNKD)
Same story. And I really did not want to close out this trade. Average weekly returns of +1.90% to go with a standard deviation of only 4.37%... a +0.4338 Sortino Ratio... I was just 24 weeks into this trade, and it would have been ranked in my top 5... instead I sold it for $178.30 (+51.1%).

Zynga (ZNGA)
At the other of the spectrum, I'm very happy to get rid of this one. No matter how you slice it, this has been just a lousy trade. Through 20 weeks, average weekly returns of -0.89% paired up with a standard deviation of 5.55% yields a Sortino Ratio of -0.1608. Game over. I closed this trade out at $2.78 (-19.0%).

But I did keep 2 other trades open (this can serve as my official Disclaimer).

Mastercard (MA)
My current trade has been open since October 2010 (+136.8%), and over 275 total weeks (5 trades) since 2006, MA has an average weekly return of +0.81% and standard deviation of just 4.33%. That Sortino Ratio of +0.1863 is in my top 20 overall, and is 2nd only to NetFlix (NFLX) in the Internet Software & Services sub-industry of the Information Technology sector.

Precision Castparts (PCP)
Is this the best stock in the Industrial Conglomerates sub-industry of the Industrials sector? We'll get into that another time. Truth be told, it doesn't boast great average weekly returns. Only +0.72% per week through 432 total weeks (3 trades). But what it does have is a very low standard deviation. Just 3.58%. That Sortino Ratio of +0.2013 is just good enough to crack my top 10. By the way, my current open trade stands at +78.4%.

To be completely honest, I actually do have 9 other long trades open, but at this point I'm only covering the trades that have already made their way into this blog. I'll provide disclaimers for each of those trades as they are covered in future posts. For example, when we're talking about LyondellBasell (LYB) and the other stocks that make up the Diversified Chemicals sub-industry of the Materials sector.  

Sunday, June 2, 2013

Zynga (ZNGA)

BUY signal the week of 2.4.13 at $3.43. My first stop was $2.20, so my risk (R)/share was $1.23. 

Closed Friday at $3.40 with a $2.56 stop. My new stop for this week is $2.63.  

The percentage loss on this trade is -0.9%, and the reward-to-risk ratio is -$0.03/$1.23 = -0.02.

History (beginning in 2013):
Winning Trades: 0 | 0.0% | +$0.00/share avg.
Losing Trades: 1 | 100.0% | -$0.03/share avg.
Average Trade: -0.9% | -$0.03/share | Reward-to-Risk (R): -0.02
Compound Annual Growth Rate (CAGR): -2.8% 
Alpha% (weekly): -0.26%
Sharpe Ratio (weekly): +0.0091

Alpha% and Sharpe Ratio calculations:
Total # of weeks (1 trade): 16
Mean Trade Returns (weekly): +0.04%
Mean S&P 500 Returns (weekly): +0.46%
Standard Deviation (weekly): +4.52%
Risk-Free Rate (baseline assumption): 0.0%
Beta (calculation): +0.66
Alpha (calculation): -0.26%
Sharpe Ratio (calculation): +0.0091

Precision Castparts (PCP)

BUY signal the week of 9.13.10 at $126.68. My first stop was $103.19, so my risk (R)/share was $23.49. 

Closed Friday at $213.92 with a $187.91 stop. My new stop for this week is $188.73. 

The percentage gain on this trade is +68.9%, and the reward-to-risk ratio is +$87.24/$23.49 = +3.71.

History (beginning in 2003):
Winning Trades: 3 | 100.0% | +$73.43/share avg.
Losing Trades: 0 | 0.0% | -$0.00/share avg.
Average Trade: +218.9% | +$73.43/share | Reward-to-Risk (R): +13.89
Compound Annual Growth Rate (CAGR): +33.0%
Alpha% (weekly): +0.46%
Sharpe Ratio (weekly): +0.1987

Alpha and Sharpe Ratio calculations:
Total # of weeks (3 trades): 427
Mean Trade Returns (weekly): +0.71%
Mean S&P 500 Returns (weekly): +0.22%
Standard Deviation (weekly): +3.58%
Risk-Free Rate (baseline assumption): 0.0%
Beta (calculation): +1.16
Alpha (calculation): +0.46%
Sharpe Ratio (calculation): +0.1987

Mastercard (MA)

BUY signal the week of 10.18.10 at $242.64. My first stop was $202.75, so my risk (R)/share was $39.89. 

Closed Friday at $570.25 with a $519.79 stop. My new stop for this week is $522.37.  

The percentage gain on this trade is +135.0%, and the reward-to-risk ratio is +$327.61/$39.89 = +8.21.

History (beginning in 2006):
Winning Trades: 4 | 80.0% | +$117.35/share avg.
Losing Trades: 1 | 20.0% | -$35.79/share avg.
Average Trade: +57.8% | +$86.72/share | Reward-to-Risk (R): +3.02
Compound Annual Growth Rate (CAGR): +32.0%
Alpha% (weekly): +0.67%
Sharpe Ratio (weekly): +0.1638

Alpha and Sharpe Ratio calculations:
Total # of weeks (5 trades): 271
Mean Trade Returns (weekly): +0.82%
Mean S&P 500 Returns (weekly): +0.13%
Standard Deviation (weekly): +4.98%
Risk-Free Rate (baseline assumption): 0.0%
Beta (calculation): +1.15
Alpha (calculation): +0.67%
Sharpe Ratio (calculation): +0.1638

LinkedIn (LNKD)

BUY signal the week of 1.7.13 at $118.00. My first stop was $96.40, so my risk (R)/share was $21.60. 

Closed Friday at $167.53 with a $139.69 stop. My new stop for the coming week is $141.22.

The percentage gain on this trade is +42.0%, and the reward-to-risk ratio is +$49.53/$21.60 = +2.29.

History (beginning in 2013):
Winning Trades: 1 | 100.0% | +$49.53/share avg.
Losing Trades: 0 | 0.0% | -$0.00/share avg.
Average Trade: +42.0% | +$49.53/share | Reward-to-Risk (R): +2.29
Compound Annual Growth Rate (CAGR): +148.7%
Alpha% (weekly): +1.14%
Sharpe Ratio (weekly): +0.3039

Alpha% and Sharpe Ratio calculations:
Total # of weeks (1 trade): 20
Mean Trade Returns (weekly): +1.95%
Mean S&P 500 Returns (weekly): +0.52%
Standard Deviation (weekly): +6.42%
Risk-Free Rate (baseline assumption): 0.0%
Beta (calculation): +1.56
Alpha (calculation): +1.14%
Sharpe Ratio (calculation): +0.3039

Deckers Outdoor (DECK)

BUY signal the week of 2.4.13 at $43.56. My first stop was $29.97, so my risk (R)/share was $13.59. 

Closed Friday at $53.68 with a $45.81 stop. My new stop for the coming week is $46.52.

The percentage gain on this trade is +23.2%, and the reward-to-risk ratio is +$10.12/$13.59 = +0.74.

History (beginning in 2005):
Winning Trades: 3 | 75.0% | +$29.55/share avg.
Losing Trades: 1 | 25.0% | -$16.82/share avg.
Average Trade: +117.3% | +$17.96/share | Reward-to-Risk (R): +3.44
Compound Annual Growth Rate (CAGR): +34.2%
Alpha% (weekly): +0.83%
Sharpe Ratio (weekly): +0.1539

Alpha and Sharpe Ratio calculations:
Total # of weeks (4 trades): 280
Mean Trade Returns (weekly): +1.00%
Mean S&P 500 Returns (weekly): +0.11%
Standard Deviation (weekly): +6.49%
Risk-Free Rate (baseline assumption): 0.0%
Beta (calculation): 1.60
Alpha (calculation): +0.83%
Sharpe Ratio (calculation): +0.1539

Crocs (CROX)

BUY signal the week of 2.19.13 at $15.43. My first stop was $12.46, so my risk (R)/share was $2.97. 

Closed Friday at $17.64 with a $14.08 stop. My new stop for this week is $14.50. 

The percentage gain on this trade is +14.3%, and the reward-to-risk ratio is +$2.21/$2.97 = +0.74.

History (beginning in 2006):
Winning Trades: 3 | 75.0% | +$14.34/share avg.
Losing Trades: 1 | 25.0% | -$5.43/share avg.
Average Trade: +159.5% | +$9.40/share | Reward-to-Risk (R): +2.88
Compound Annual Growth Rate (CAGR): +46.2%
Alpha% (weekly): +1.35%
Sharpe Ratio (weekly): +0.1778

Alpha% and Sharpe Ratio calculations:
Total # of weeks (4 trades): 204
Mean Trade Returns (weekly): +1.70%
Mean S&P 500 Returns (weekly): +0.21%
Standard Deviation (weekly): +9.57%
Risk-Free Rate (baseline assumption): 0.0%
Beta (calculation): +1.68
Alpha (calculation): +1.35%
Sharpe Ratio (calculation): +0.1778

Salesforce.com (CRM)

BUY signal the week of 2.21.12 at $35.91 (adjusted for 4.18.13 4:1 stock split). My first stop was $27.13, so my risk (R)/share was $8.78. 

Closed Friday at $42.33 with a $38.00 stop. My new stop for the coming week is $38.10.  

The percentage gain on this trade is +17.9%, and the reward-to-risk ratio is +$6.42/$8.78 = +0.73.

History (beginning in 2004 and adjusted for 4.18.13 4:1 stock split):
Winning Trades: 4 | 80.0% | +$8.12/share avg.
Losing Trades: 1 | 20.0% | -$0.17/share avg.
Average Trade: +66.9% | +$6.46/share | Reward-to-Risk (R): +1.96
Compound Annual Growth Rate (CAGR): +28.2%
Alpha% (weekly): +0.52%
Sharpe Ratio (weekly): +0.1312

More bells and whistles! 

I added alpha% calculations the last time around because I want to compare the weekly performance of my trades against the benchmark S&P 500 Index.

Now I'm adding a weekly Sharpe Ratio (which I've actually calculated for years) because I like to objectively rank all of the stocks that I trade and/or follow from first to worst in terms of reward and risk. Basic portfolio optimization.

I've started to factor Sortino Ratios into the mix as well (differs from Sharpe in that it only calculates standard deviation below a minimum required rate of return), but let's stick with one new thing at a time for the sake of this blog.

Here are my calculations for alpha% and the Sharpe Ratio:

Total # of weeks (5 trades): 368
Mean Trade Returns (weekly): +0.75%
Mean S&P 500 Returns (weekly): +0.16%
Standard Deviation (weekly): 5.74%
Risk-Free Rate (baseline assumption): 0.0%
Beta (calculation): +1.39
Alpha% (calculation): +0.52%
Sharpe Ratio (calculation): +0.1312