Sunday, August 11, 2013

Deconstructing 10 Years of Apple Trades

Earlier this week, I read over my Apple post from last weekend and decided that just about all of the information was basically useless.
And my first thought as I started writing this post was to explain in detail what I thought was wrong with it.

But on second thought, I don't really want to write a post like that, and I'm pretty sure nobody wants to read a post like that. 

What's the point?

Instead, let's take the small amount of information that actually is valuable, deconstruct it a little bit, add a few new things, and see if we can make it more useful.  

1). Total # of weeks (5 trades): 432
  • What number/percentage of those weeks resulted in either positive or negative returns?
  • # of weeks with positive returns: 248 (57.41%)
  • # of weeks with negative returns: 184 (42.59%)
  • One thing to keep in mind: I'm using a minimum required rate of return of +12% annually (+0.22% weekly), so positive returns are defined as >0.22% weekly, and negative returns as <0.22% weekly.

2). Average Weekly Trade Returns: +1.08% 
  • +465.73% total return / 432 weeks = +1.08%

3). Average Weekly S&P 500 Returns: +0.20% 
  • +86.10% total return / 432 weeks = +0.20%

4). Average Weekly Excess Returns: +0.88%
  • +1.08% - +0.20% = +0.88%
  • As you can see, I subtract the weekly S&P 500 Index returns from my trade returns to determine my weekly excess returns. I could certainly use the risk-free rate as a benchmark instead of the index, but this is not a decision between buying Apple stock or a 10-year US bond. On top of that, I think using the index raises the bar considerably.

5). Cumulative Gains %: +894.47% 
  • What the huh? This is the useless information I was talking about at the start. But actually, it just needs a little bit of work.
  • Our average positive weekly excess return is +894.47% / 248 = +3.61%
  • Adjusting for the probability of a positive weekly return vs. a negative weekly return: 57.41% * +3.61% = +2.07%

6). Cumulative Losses %: -514.16%
  • Average weekly excess negative return: -514.16% / 184 = -2.80% 
  • Adjusting for probabilities: 42.59% * -2.80% = -1.19%

7). Average Weekly Excess Returns: +0.88%
  • +2.07% + -1.19% = +0.88%
  • I could call this 4a since we're back at the results calculated in step 4 above, but I think we've found some additional information that is very useful by adding steps 5 and 6

Before we get to the Omega Ratio, let's take a quick look at risk. I evaluate the risk to a position with 3 numbers (the following numbers, without digging into the equations, are my current calculations):
  • Value at Risk (VaR): -10.10%
  • Maximum Actual/Historical Drawdown: -19.43% (the week of 1.22.08)
  • my Volatility-Based Trailing Stop: -12.95% (Apple closed Friday at $454.45, and my new stop for the coming week is $395.62, so ($454.45 - $395.62) / $454.45 = 12.95%.
I'll generally take the middle number of the 3 as the best estimate of my risk. 

In Apple's case, that would be my stop. 

But for a stock with a limited history/limited data set like TripAdvisor (TRIP), which has the following set of calculations:
  • Value at Risk (VaR): -10.71%
  • Maximum Actual/Historical Drawdown: -6.93% (the week of 4.1.2013)
  • my Volatility-Based Trailing Stop: -19.79% (($80.94 - $64.92) / $80.94)
I'd pay more attention to the VaR calculation.

Okay, so back to the... 

8). Omega Ratio: 1.74 
  • +2.07% / -1.19% (absolute value) = 1.74
  • Is that good or bad? It's good, but we obviously need some context here.
I rank all of the stocks in the S&P 500 by several ratios (Omega, Sharpe, Sortino, Upside Potential, etc.), and I like the Omega Ratio in particular because it factors all of the specific returns into it's calculations. It does not assume anything. 

So how does Apple rank?

This is my current Top 10 (by Omega Ratio):

1. TripAdvisor (TRIP): 2.74
2. LyondellBasell (LYB): 1.88
3. Apple (AAPL): 1.74
4. Marathon Petroleum (MPC): 1.70
5. Mastercard (MA): 1.63
6. NetFlix (NFLX): 1.63
7. Intuitive Surgical (ISRG): 1.59
8. Precision Castparts (PCP): 1.57
9. (PCLN): 1.52
10. Discover Financial Services (DFS): 1.51

FYI - I planned to include a table with all of the Average Weekly Positive and Negative Returns, Probabilities, and resulting Omega Ratios... but it wouldn't fit.

Alright, so if the idea was to make this information more useful, then how are we going to use it?

My first thought, with 20 weeks left in 2013, is to project, based on the numbers we've calculated above, how much a share of Apple will cost at the end of 2013. 

I never do this kind of thing (until right now apparently), and I generally don't like predictions of any kind, so I'm going to call this a falsifiable hypothesis:
  • The closing price Friday was $454.45, and ((1+0.0088)^20)-1) = +19.12%, so $454.45 plus an additional 19.12% = $541.35.

Yes, I realize that new information will render that number useless a week from now. The irony is not lost on me. But this is still fun.

Where do you think Apple will be at the end of 2013? 

Or at the end of August for that matter?

Disclaimer: I currently own shares of LyondellBasell, Apple, Mastercard, NetFlix, and Precision Castparts.   

Sunday, August 4, 2013

Apple (AAPL)

New BUY signal the week of 7.29.13 (Friday) at $462.54. My initial stop is $393.59, so my risk (R)/share is $68.95 (14.91%).

That probably seems like a very wide stop, but my Value at Risk (VaR) calculation (at a 99% confidence level) is -10.10% ($46.74), and my Worst Actual/Historical Weekly Drawdown is -19.43% ($89.87), so 14.91% ($68.95) actually sounds about right.

At least to me it does.

History (beginning in 2003):
Winning Trades: 3 | 75.0% | +$203.20/share avg.
Losing Trades: 1 | 25.0% | -$12.10/share avg.
Average Trade: +274.8% | +$149.38/share | Reward-to-Risk (R): +11.14
Compound Annual Growth Rate (CAGR): +55.0%
Sortino Ratio (annualized): +2.36
Omega Ratio: 1.74 

Sortino and Omega Ratio calculations:
Total # of weeks (4 trades): 431 
Mean Trade Returns (weekly): +1.08%
Mean S&P 500 Returns (weekly): +0.20%
Excess Trade Returns (weekly): +0.88%
Downside Deviation (weekly): +2.70%
Sortino Ratio (calculation): +2.36
Cumulative Gains %: +894.47%
Cumulative Losses %: -514.16%
Omega Ratio (calculation): 1.74

The Best Bang For Your Buck

In the General Merchandise Stores industry of the Consumer Goods sector is...

...either Dollar General (DG) or Dollar Tree (DLTR).

You see, if we rank the stocks using the Sortino Ratio...

RankSymbolCompanyAverage Weekly Excess Return %Downside Deviation %Sortino Ratio
1 DG Dollar General+0.28%1.73%+0.1603
2 DLTR Dollar Tree+0.34%2.80%+0.1218
3 FDO Family Dollar Stores+0.15%2.74%+0.0538
4 TGT Target Corp.-0.07%1.66%-0.0408
5 KSS Kohl's Corp.-0.34%2.12%-0.1606

...Dollar General comes out on top.

But if we rank them by Omega Ratio...

RankSymbolCompanyCumulative Gains %Cumulative Losses %Omega Ratio
1 DLTR Dollar Tree607.38%-470.63%1.29
2 DG Dollar General198.56%-158.59%1.25
3 FDO Family Dollar Stores439.77%-395.86%1.11
4 TGT Target Corp.325.82%-350.26%0.93
5 KSS Kohl's Corp.275.55%-370.33%0.74

...then Dollar Tree is the winner.

How are we going to break the tie?

Let's see what happens when we rank them by Upside Potential Ratio:

RankSymbolCompanyUpside Deviation %Downside Deviation %Upside Potential Ratio
1 DG Dollar General1.38%1.98%0.6979
2 DLTR Dollar Tree1.51%2.59%0.5852
3 FDO Family Dollar Stores1.48%2.69%0.5476
4 TGT Target Corp.0.90%1.80%0.5026
5 KSS Kohl's Corp.0.99%2.38%0.4167

It looks like Dollar General is the best bang for your buck in the General Merchandise Stores industry after all.

Just as a side note: my Downside Deviation % calculations differ between the Sortino and Upside Potential Ratios because the Upside Potential Ratio takes the Upside (>0.22% required weekly return) and Downside (<0.22% required weekly return) Deviation %'s and multiplies them by their respective probabilities.

Sortino uses the full Downside Deviation % (all returns below the required +0.22% weekly return).

Disclaimer: I do not own any of the stocks mentioned in this post nor do I intend to open any positions in any of these stocks in the next 72 hours.

Sunday, July 28, 2013

The Stock That Pays You Back

In the Consumer Finance sub-industry of the Financials sector is... you guessed it:

Discover Financial Services (DFS).

Otherwise, I'd probably be saying "Don't Leave Home Without This Stock" or "What's In Your Portfolio?" or... I don't know what H&R Block's slogan is!?!

Moving on.

All of the ratios that I use to rank the stocks within the S&P 500 Index and then their respective sectors and sub-industries are saying the same thing for this group, so I'm only going to publish one of the ratios today.

The Sortino Ratio

RankSymbolCompanyAverage Weekly Excess Return %Downside Deviation %Sortino Ratio
1 DFS Discover Financial Services+0.49%2.22%+0.2216
2 HRB Block H&R+0.32%2.55%+0.1240
3 AXP American Express Co+0.15%1.53%+0.1008
4 COF Capital One Financial-0.02%2.34%-0.0082

And just so we're clear, when I say that Discover Financial Services is "The Stock That Pays You Back," I am not talking about dividends.

I'm talking about increasing stock prices.

To that end, let's take a look at my current trading signals for each of these 4 stocks:

SymbolCompanyBuy Signal DateBuy Signal PriceClosing Price 7/26/2013Current Trade Return %
DFS Discover Financial Services4/19/2010$15.75 $49.45 213.97%
HRB Block H&R7/9/2012$15.91 $30.49 91.64%
AXP American Express Co1/30/2012$51.38 $75.34 46.63%
COF Capital One Financial5/6/2013$59.51 $68.76 15.54%

That's right, you would have had to buy DFS 3+ years ago to get all of that that roughly 214% gain...

Does anybody (besides Warren Buffett) actually hold stocks that long anymore?

I do.

Personally, I think less trading is better trading.

I like long-term capital gains.

I don't like transaction costs and I really don't like paying taxes.

But that's just me. 

Disclaimer: I do not own any of the stocks mentioned in this post nor do I plan to open any positions in any of these stocks in the next 72 hours.

Sunday, July 21, 2013

The Best Oil & Gas Exploration & Production Stock in the S&P 500

Is Range Resources (RRC).

And if it's all the same to everyone, I think I'm just going to let the numbers do the talking from now on.

Let's start with the Omega Ratio, which is a risk measure that divides the Cumulative Weekly Gain % over the past 10 years of trades by the Cumulative Weekly Loss %.

RankSymbolCompanyCumulative Weekly Gains %Cumulative Weekly Losses %Omega Ratio
1 RRC Range Resources Corp.+1201.52%-864.68%1.39
2 EOG EOG Resources+959.53%-691.68%1.39
3 SWN Southwestern Energy+971.12%-708.67%1.37
4 PXD Pioneer Natural Resources+1058.07%-777.25%1.36
5 OXY Occidental Petroleum+872.22%-658.58%1.32
6 BTU Peabody Energy+733.28%-564.31%1.30
7 CNX CONSOL Energy Inc.+796.07%-633.13%1.26
8 APC Anadarko Petroleum Corp+775.38%-627.05%1.24
9 COG Cabot Oil & Gas+993.40%-805.69%1.23
10 WMB Williams Cos.+343.27%-279.55%1.23
11 MRO Marathon Oil Corp.+587.00%-478.99%1.23
12 NBL Noble Energy Inc+608.82%-504.71%1.21
13 DNR Denbury Resources Inc.+802.69%-678.90%1.18
14 APA Apache Corporation+308.12%-266.46%1.16
15 DVN Devon Energy Corp.+784.40%-708.89%1.11
16 NFX Newfield Exploration Co+724.32%-695.67%1.04

Next up is the Sortino Ratio. It divides the Average Excess Return % by Downside Deviation % (<0.22% weekly).

RankSymbolCompanyAverage Weekly Excess Return %Downside Deviation %Sortino Ratio
1 RRC Range Resources Corp.+0.66%2.94%+0.2226
2 SWN Southwestern Energy+0.64%3.11%+0.2053
3 EOG EOG Resources+0.54%2.67%+0.2034
4 PXD Pioneer Natural Resources+0.54%2.85%+0.1906
5 OXY Occidental Petroleum+0.37%2.27%+0.1635
6 BTU Peabody Energy+0.53%3.58%+0.1489
7 CNX CONSOL Energy Inc.+0.49%3.69%+0.1324
8 APC Anadarko Petroleum Corp+0.32%2.54%+0.1263
9 COG Cabot Oil & Gas+0.39%3.14%+0.1252
10 MRO Marathon Oil Corp.+0.25%2.22%+0.1141
11 NBL Noble Energy Inc+0.24%2.24%+0.1092
12 WMB Williams Cos.+0.22%2.09%+0.1073
13 DNR Denbury Resources Inc.+0.31%3.26%+0.0944
14 APA Apache Corporation+0.20%2.65%+0.0750
15 DVN Devon Energy Corp.+0.15%2.45%+0.0631
16 NFX Newfield Exploration Co+0.07%3.22%+0.0224

This is obviously a closer race than the Biotechnology sub-industry, where Gilead Sciences was (and still is) clearly the best stock in the group.

Range Resources is neck and neck with EOG Resources based on their Omega Ratios, but EOG Resources slides to third behind Southwestern Energy when it comes to the Sortino Ratio, so I think we can safely call Range Resources as the winner.

Disclaimer: I do not own any of the stocks mentioned in this post nor do I intend to open any positions in any of these stocks in the next 72 hours.

Sunday, July 14, 2013

What's the best Biotechnology stock to trade in the S&P 500?

I'll just go ahead and get my disclaimer out of the way up front and say that I do not have any open positions in any of the stocks mentioned in this blog, nor do I intend to open any any of these stocks in the next 72 hours.

Glad that's out of the way.

So, until about 3 months ago, I never asked myself which Biotechnology stock in the S&P 500 would be the best to trade.

The universe was just too big. So many stocks to research and trade, so little time.

But now I know how to write code.

And the universe just got a lot smaller.

Or my head got a lot bigger...

Either way, I wrote a program in Python that ranks (at the push of one button) all of the stocks in the S&P 500, plus all of the sectors and sub-industries within the S&P 500, from top to bottom using historical return/risk ratios.

Sure, I probably could have bought a program to do what I wanted, but where's the fun in that? I like to re-invent the wheel whenever I get the chance.

My program uses the long-term trend-following algorithm for which this blog is named to generate buy and sell signals, and I've been trading for 10 years, so I run my tests back to the beginning of 2003. That seems like enough time/data to create some statistical significance. 

It will compute 10+ ratios so far, and for this post I planned to include tables for Sharpe, Sortino, and Omega Ratios, thinking the comparisons would be interesting.

But on second thought, that's probably too much information.

For now, let's just look at the results using the Omega Ratio.

To be honest, the Omega Ratio is kind of new to me, but I think it's interesting because the calculation (Cumulative Weekly Gains above the required rate of return / Cumulative Weekly Losses below the required rate of return) includes all of the returns in the distribution, which means it can account for the high risk/low probability fat tails that are not part of a normal distribution.

FYI - I'm using a 12% annual (0.22% weekly) required rate of return.

In any case, if anyone wants to see the results in Sharpe, Sortino, or any other ratio that you can think of, just let me know. I'll be happy to run and send that along.

Okay, so which Biotechnology stock in the S&P 500 is the best trade?

RankSymbolCompanyCumulative Weekly Gains %Cumulative Weekly Losses %Omega Ratio
1 GILD Gilead Sciences+615.26%-485.39%1.27
2 ALXN Alexion Pharmaceuticals+768.97%-621.65%1.24
3 CELG Celgene Corp.+242.25%-196.02%1.24
4 AMGN Amgen Inc+193.75%-157.01%1.23
5 LIFE Life Technologies+335.65%-312.81%1.07
6 BIIB Biogen IDEC Inc.+514.90%-486.40%1.06

Gilead Sciences?

That surprised me too. 

But there's a reason I research and trade with algorithms and quantitative data and not my gut.

My gut is not very smart.

So... anybody out there trading Gilead Sciences?  

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: (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.