Monthly Archives: January 2012

Pathetic Model Using VIX To Predict S&P 500, Part 1

The Chicago Board Options Exchange Market Volatility Index (the “VIX”) is often referred to in the financial press as the fear index. Even casual observers of the VIX will notice that it increases (sometimes substantially) during times of extreme uncertainty and has a strong negative relationship with the overall market — the VIX increases when the overall market decreases.

The past few months I have been getting acquainted with R, a programming environment for statistical computing and graphics. It also has a robust collection of user-written packages, including many related to algorithmic trading. It is open source and used by a large number of amateur and professional traders.

Some readers may be interested in my personal background. My day job involves data analysis, modeling, and regression analysis using SAS and Stata (also programming environments for statistical computing). I come from an econometrics background (working under the guidance of economists), and this is the approach that I hope to take with my pathetic attempts at algorithmic trading. Progress on learning R has been slower than I expected due to a heavy workload at my day job and because I have started studying for the CFA Level 2 exam.

Algorithmic trading is a term so broad that it may be helpful for me to define the scope of what I am hoping to accomplish. I am interested in identifying predictive indicators and building models to generate buy and sell decisions using end-of-day data with holding periods of several days to months or longer. This definition is important because algorithmic trading can refer to a number of things. A number of algorithms are focused on best execution (VWAP, for example). These algorithms seek to find the best price when a fund wishes to purchase or sell a large block of shares where the actual buying or selling will move the market. On the other hand, there are a number of algorithms that are designed to sniff out when a big player wishes to move a lot of shares — these algorithms are in constant battle with the best execution algorithms. Other algorithms are focused on exploiting small inefficiencies in market microstructure. These algorithms can involve analysis of each individual tick of data (each tick being the smallest possible increment a security’s price can move) and analysis of the limit order book. Most algorithms also have a degree of automation which involves interfacing with a broker’s API or through some other fashion.

It is worth noting that I intend to trade manually on any buy or sell signals that my models generate. In this sense I can keep a discretionary component in my trading and focus on trading strategy instead of  a broker’s API.

The Data

As this is my initial foray into the world of algorithmic trading and R, this post explores some of the most basic functionality of R using end of day prices of VIX and SPY, an ETF that tracks the S&P 500. I use SPY instead of the actual S&P 500 index to preserve the applicability of any signals the model generates. SPY is a trade-able security while the S&P 500 is not. Nonetheless, I use the terms SPY and the S&P 500 interchangeably throughout this post and my code.

First, let’s see a plot of the data using the ggplot2 package:

Plotting the data is an essential starting point for any kind of statistical analysis. The genesis of any model is disciplined observation of the world around you and attempting to quantify and predict the phenomenon or relationship that you observe. In time series regression analysis, it is also essential for determining model selection and whether all the numerous assumptions of regression analysis holds. These include detecting whether the following problems are present: whether the data should be transformed in some way (natural log transformation, first differencing, or some kind of non-linear transformation), heteroskedasticity (sub-populations of the data have different variance than other sub-populations), serial correlation (correlation of an observation with previous observations), whether the data is covariance stationary (constant mean and variance over time), and the integrity of the data (outliers and missing observations).

In this case, the transformation we use is taking the natural log of the daily returns. For a discussion of why academics and practitioners of quantitative finance use log returns, I refer you to an excellent post by Quantivity here.

Plots of the log returns seem much more appropriate for time series regression analysis:

I have been meaning to write more on this post, but my work schedule has been extremely demanding. Will continue writing in part two when I have a chance. In the meantime, please follow Curated Alpha via Email,RSS, or Twitter.

What I’m Reading – January 22, 2012

Amazing Chart: Alan Greenspan’s Laugh Is the Best Housing Bubble Indicator [The Atlantic]

In the infamous transcript of the Federal Reserve’s first meeting in 2006, the word “[Laughter]” appeared at least 45 times. In once case, Fed Chair Alan Greenspan mocked his fellow economists’ ability to predict the future, and the board laughed. Two years later, the global economy fell apart due to a housing meltdown that many Fed economists noted, but discounted. I counted the top ten most ironic laugh lines of the meeting here.

How U.S. Lost Out on iPhone Work [New York Times]

An eight-hour drive from that glass factory is a complex, known informally as Foxconn City, where the iPhone is assembled. To Apple executives, Foxconn City was further evidence that China could deliver workers — and diligence — that outpaced their American counterparts. That’s because nothing like Foxconn City exists in the United States. The facility has 230,000 employees, many working six days a week, often spending up to 12 hours a day at the plant. Over a quarter of Foxconn’s work force lives in company barracks and many workers earn less than $17 a day. When one Apple executive arrived during a shift change, his car was stuck in a river of employees streaming past. “The scale is unimaginable,” he said. Foxconn employs nearly 300 guards to direct foot traffic so workers are not crushed in doorway bottlenecks. The facility’s central kitchen cooks an average of three tons of pork and 13 tons of rice a day. While factories are spotless, the air inside nearby teahouses is hazy with the smoke and stench of cigarettes.

Who exactly are the 1%? [The Economist]

The richest 1% earn roughly half their income from wages and salaries, a quarter from self-employment and business income, and the remainder from interest, dividends, capital gains and rent. According to an analysis of tax returns by Jon Bakija of Williams College and two others, 16% of the top 1% were in medical professions and 8% were lawyers: shares that have changed little between 1979 and 2005, the latest year the authors examined (see chart). The most striking shift has been the growth of financial occupations, from just under 8% of the wealthy in 1979 to 13.9% in 2005. Their representation within the top 0.1% is even more pronounced: 18%, up from 11% in 1979.

Now Reporting: Earnings [The Wall Street Journal]

In Praise of Cheap Labor [Slate]

Such moral outrage is common among the opponents of globalization–of the transfer of technology and capital from high-wage to low-wage countries and the resulting growth of labor-intensive Third World exports. These critics take it as a given that anyone with a good word for this process is naive or corrupt and, in either case, a de facto agent of global capital in its oppression of workers here and abroad. But matters are not that simple, and the moral lines are not that clear. In fact, let me make a counter-accusation: The lofty moral tone of the opponents of globalization is possible only because they have chosen not to think their position through. While fat-cat capitalists might benefit from globalization, the biggest beneficiaries are, yes, Third World workers.

Get used to living with Mom and Dad [Salon]

It’s a growing trend: More and more adults are living with their parents. According to the Census Bureau, the number of 25- to 34-year-old adults in the U.S. living at home rose from 14 percent in 2005 to 19 percent in 2011. The trend is present in other developed countries across the globe too: In Italy, 37 percent of men 30 years of age and older have never left home; in Japan, men living under their parents’ care are pushing their 40s. Such individuals are easily disparaged as lazy, overgrown babies, content to mooch off their aging parents rather than strike it out on their own. (Remember all those biting jokes Archie Bunker would throw to his “meathead” of a son-in-law.) But are they really?

The Graduates [The Atlantic]

Crowded Out [New York Times]

 

What I’m Reading: January 15, 2012

The Top 1 Percent: What Jobs Do They Have? [New York Times]

What Percent Are You? [New York Times]

Among the Wealthiest One Percent, Many Variations [New York Times]

Why Are Smart People Usually Ugly? [Slate]

The Rise of the New Groupthink [New York Times]

Ex-Investment Banker Shares All and A Kinder, Gentler, Philosophy Of Success

“As a young banker in M&A, you have no social life, I mean, none. A work week has seven days. There’s no time for friends, and when you have a few hours off, you try to maximise it. Drink really hard, party wild, and you get confronted with drugs – which seems to be a taboo although many do it. You need to feel in those few moments that you’re still alive. On Sundays, following one of these binges, I would wake up feeling so rotten, so empty.

“I used to be the kind of person who enjoys life, who gets up in the morning eager for another day. The past two years I found myself changing. I lost my interest in politics, in sports … I began to wonder: what’s happening to me?

“My flatmate is in finance too. I’ve seen him coming home crying, from exhaustion, from something that happened to him. Why are we doing this to ourselves? My sense is that the majority of the people in finance have an urge to prove themselves. And banks offer a platform where they can do so. I feel there’s a particular kind of insecurity to many bankers, a form of neediness and a deep desire to compensate. Love?

“Many people in banking try to project an image of perfection, and banks play to that, trying to make you look perfect and feel invulnerable. It’s very easy to get hooked to that life, to become addicted to work and the money. I am sure it would have happened to me, had I done this work for too long.

“Imagine. 25 years old, and in my first year I made £45k plus a 70% bonus. So over 75k, one year out of university. That is quite something, let me tell you. But within six months you get used to it. I would spend £250 on a night out, and think nothing of it, spend £100 on dinner and genuinely think to myself: well, that was not too expensive.

“This was a lesson: it doesn’t really matter how much you make, because your lifestyle and expectations move up with your income.

Continue reading here. This article is part of the Voices of Finance series from The Guardian. Reminds me a lot of Reddit IAmA’s which I have curated here.

Many people who wish to enter the financial services industry have a strong desire to prove themselves. Given this investment banker’s illusion with the industry, I think Alain de Botton’s TED speech, “A Kindler, Gentler, Philosophy Of Success” is relevant. I highly recommend this speech to readers:

Popular Posts Page

I removed my previous “Trading Resources” page and replaced it with a “Popular Posts” page. This page contains a short selection of posts based on my traffic statistics from Google Analytics and some personal curation. You can go to the page here. Will update the popular posts page periodically.

Nassim Taleb: Journalism May Be The Greatest Plague We Face Today

Nassim Taleb, in no uncertain words, shares his opinion on journalism in Fooled by Randomness: The Hidden Role of Chance in Life and in the Markets:

Try the following experiment. Go to the airport and ask travelers en route to some remote destination how much they would pay for an insurance policy paying, say, a million tugrits (the currency of Mongolia) if they died during the trip (for any reason). Then ask another collection of travelers how much they would pay for insurance that pays the same in the event of death from a terrorist act (and only a terrorist act). Guess which one would command a higher price? Odds are that people would rather pay for the second policy (although the former includes death from terrorism). The psychologists Daniel Kahneman and Amos Tversky figured this out several decades ago. The irony is that one of the sampled populations did not include people on the street, but professional predictors attending some society of forecasters’ annual meeting. In a now famous experiment they found that the majority of people, whether predictors or nonpredictors, will judge a deadly flood (causing thousands of deaths) caused by a California earthquake to be more likely than fatal flood (causing thousands of deaths) occurring somewhere in North America (which happens to include California). As a derivatives trader I noticed that people do not like to insure against something abstract; the risk that merits their attention is always something vivid.

This brings us to a more dangerous dimension of journalism. We just saw how the scientifically hideous George Will and his colleagues can twist arguments to sound right without being right. But there is a more general impact by information providers in biasing the presentation of the world one gets from the delivered information. It is a fact that our brain tends to go for superficial clues when it comes to risk and probability, these include being largely determined by what emotions they elicit or the ease with which they come to mind. In addition to such problems with the perception of risk, it is also scientific fact, and a shocking one, that both risk detection and risk avoidance are not mediated in the “thinking” part of the brain but largely in the emotional one (the “risk as feelings” theory). The consequences are not trivial: It means that rational thinking has little, very little, to do with risk avoidance. Much of what rational thinking seems to do is rationalize one’s actions by fitting some logic to them.

In that sense the depiction coming from journalism is certainly not just an unrealistic representation of the world but rather the one that can fool you the most by grabbing your attention via your emotional apparatus – the cheapest to deliver sensation. Take the mad cow “threat” for example: Over a decade of hype, it only killed people (in the highest estimates) in the hundreds as compared to car accidents (several hundred thousands!) — except that the journalistic description of the latter would not be commercially fruitful. (Note that the risk of dying from food poisoning or in a car accident on the way to a restaurant is greater than dying from mad cow disease.) This sensationalism can divert empathy toward wrong causes: cancer and malnutrition being the ones that suffer the most from the lack of such attention. Malnutrition in Africa and Southeast Asia no longer causes the emotional impact — so it literally dropped out of the picture. In that sense the mental probabilistic map in one’s mind is so geared toward the sensational that one would realize informational gains by dispensing with the news. Another example concerns the volatility of markets. In people’s minds lower prices are far more “volatile” than sharply higher moves. In addition, volatility seems to be determined not by the actual moves but by the tone of the media. The market movements in the eighteen months after September 11, 2001, were far smaller than the ones that we faced in the eighteen months prior — but somehow in the mind of investors they were very volatile. The discussions in the media of the “terrorist threats” magnified the effect of these market moves in people’s heads. This is one of the may reasons that journalism may be the greatest plague we face today — as the world becomes more and more complicated and our minds are trained for more and more simplification.

All great investors consider themselves contrarian investors. Rather than avoiding journalism and the mainstream media (as Taleb recommends in a post I wrote earlier), I think profitable trading ideas can be sourced by systematically analyzing the news and measuring investor sentiment. When investors become too negative on a company, that often is a good entry point.

One thing I tend to look for is analyzing how a stock reacts to unambiguously good or bad news. Stocks should act as you expect — positive returns in response to positive news and negative returns in response to negative news. It’s when this relationship doesn’t hold that presents interesting opportunities. An anecdotal example: Several days ago, the latest industry reports stated that Research in Motion’s smartphone market share has declined again. Yet the stock price barely declined as a result. The interpretation is clear — this particular piece of bad news has already been priced into the stock. Buying at this entry point would have resulted in a quick 20 percent return.

Interested readers can buy Fooled by Randomness: The Hidden Role of Chance in Life and in the Markets on Amazon.

Luck vs. Skill In Financial Markets

Nassim Taleb on mistaking luck as skill in financial markets:

There is one world in which I believe the habit of mistaking luck for skill is most prevalent – and most conspicuous – and that is the world of markets. By luck or misfortune, that is the world in which I have operated most of my adult life. It is what I know best. In addition, economic life presents the best (and most entertaining) laboratory for the understanding of these differences. For it is the area of human undertaking where the confusion is greatest and its effects the most pernicious. For instance, we often have the mistaken impression that a strategy is an excellent strategy, or an entrepreneur a person endowed with “vision,” or a trader a talented trader, only to realize that 99.9% of their past performance is attributable to chance, and chance alone. Ask a profitable investor to explain the reasons for his success; he will offer some deep and convincing interpretation of the results. Frequently, these delusions are intentional and deserve to bear the name “charlatanism.”

Contrast participants in financial markets to another group of people with similar characteristics: professional poker players. Poker games, like financial markets, are zero-sum in that one participant cannot do better without making another player worse off. Poker players and investors must make decisions under situations of incomplete and imperfect information. And most importantly, there is a tremendous amount of short-term luck involved in poker — often times one can make the right decision but end up losing money.

Consider the best starting hand in Texas Hold’Em versus one of the statistically worst starting hands: pocket aces versus seven two off-suit. Even in this most favorable situation possible, the pocket aces has only a 87 percent chance of winning the hand. And these are one of the easiest hands to play correctly! Most situations involve considerable uncertainty: top pair versus a flush draw, for example. The role of luck in poker is so large that paradoxically, both players can be making the right move (in that they have positive expected value) by staying in the hand. Thus, the consensus among poker players is that anyone reaching the final table in a tournament has had a great deal of short-term luck. Often times, due to the increasing blind structure, the remaining players in a tournament must survive multiple all-in, coin flip situations.

Acknowledging that poker has a great deal of short-term luck, why is it that poker is generally recognized as a game of skill? From my own personal study of the game, I can confidently conclude that, at least for low-limit games, poker can be beat through dedicated study.

So why can’t the same be said about financial markets? Economists generally agree that investors cannot achieve consistent market-beating returns and recommend an indexing approach instead.

Daniel Kahneman, recipient of the Nobel Prize in Economics, presents a plausible explanation in a @Google Talk. Watch (at the very least) 14:00 to 18:00.

Kahneman suggests that only in the regular world — a world defined by rules and similar, repeated experiences — can intuitive expertise be developed. He presents an interesting example: an anesthesiologist versus a radiologist. An anesthesiologist often sits by a patient’s head throughout a surgery, constantly monitoring a wide variety of patient vital signs. The anesthesiologist gets excellent and clear feedback when something goes wrong or right. The radiologist, on the other hand, lives in what Kahneman describes as the chaotic world. When diagnosing whether a patient has a tumor, for example, the radiologist does not know whether he was right in his diagnosis until much later. In other words, the radiologist isn’t faced with enough repeated experiences to develop intuitive expertise.

Kahneman goes on to say that he believes participants in financial markets live in the chaotic world and thus skill in stock picking cannot be developed. Could it be that financial markets are so dynamic that there aren’t enough repeated experiences for market participants to truly gain expertise?

When Will China Overtake The United States?

The Economist presents an interesting way of visualizing data in this graphic:

Economic power is best gauged by looking at absolute size rather than per-person measures. On a few indicators, such as steel consumption, ownership of mobile phones and beer-guzzling (a crucial test of economic superiority), the milestone was reached as long as a decade ago. Several more have been passed since. In 2011 China exported about 30% more than the United States and spent some 40% more on fixed capital investment. China is the world’s biggest manufacturer, and partly as a result it burns around 10% more energy and emits almost 40% more greenhouse gases than America (although its emissions per person are only one-third as big). The Chinese also buy more new cars each year than anybody else.

The chart shows our predictions for when China will overtake America on several other measures. Official figures show that China’s consumer spending is currently only one-fifth of that in America (although that may be understated because of China’s poor statistical coverage of services). Based on relative growth rates over the past five years it will remain smaller until 2023. Retail sales are catching up much faster, and could exceed America’s by 2014. In that same year China also looks set to become the world’s biggest importer—a huge turnaround from 2000, when America’s imports were six times those of China.

I’m a fan of data visualization and I have never quite seen a visualization like this. It seems like the latest estimates indicate China’s GDP overtaking the US’s GDP sooner than I thought. What I didn’t know is that in several other important indicators, the Chinese economy overtook the US long ago.

Having traveled to Shanghai in October 2010 and in October 2011, I have strong anecdotal evidence that the growth is very real and noticeable.

Read the full article at The Economist here.

Is Finance Governed By Physics, Biology, Or Perltzman?

Quantivity asks is finance governed by physics, biology, or Perltzman? Which one you believe is true can guide your view of markets and development of trading strategies.

The traditional answer of market hypothesis, provided by financial economics via microeconomic principles of equilibrium and efficiency: causality flows from market to investor. This explanation comes in two variants, known by their colloquial analogical fields:

Physics: market is governed by immutable mathematical principles and can be formalized into coherent predictive models, either in favor or contradiction of excess returns; exemplified by classic weak/strong EMH theory

Biology: market is governed by evolutionary principles ala Darwin, as exemplified by Lo’s 2004 AMH article: “Very existence of active liquid financial markets implies that profit opportunities must be present. As they are exploited, they disappear. But new opportunities are also constantly being created as certain species die out, as others are born, and as institutions and business conditions change.” (p. 24)

Yet, both these explanations suffer from implicitly begging the question: conjure “a market” with desired attributes and then derive conclusions. The physics perspective assumes immutability, conceivability, and mathematical expressiveness for its hypothesized market. While the biology perspective endows the hypothesized market with even more sophisticated Darwinian traits, presumably driven by underlying physical principles so inscrutable as to defy mathematical formalization.

An alternative explanation is to apply the self-fulfilling Peltzman effect to financial markets, and reverse causality: markets behave as they do because of investor sociology, rather than arising emergent from implicit cooperation of equilibrium-seeking rational microeconomic agents.

Read the full blog post at Quantivity, a blog that Curated Alpha looks up to. Quantivity has excellent discussion on quantitative finance and algorithmic trading from an academic perspective.

2011 Portfolio Review: 23% and 27%

I finished this year near the highs of this year with a 23 percent return for my individual account and a 27 percent return for my Roth IRA versus zero percent for the S&P 500. In the third quarter of this year, I decided to change my focus from an absolute return perspective to maximizing my sharpe ratio (i.e. minimizing my volatility for a given level of return). I still have quite a large cash position which I am unwilling to commit due to the high volatility of my portfolio. In this case, I am willing to accept lower levels of return if my volatility is lowered. By focusing on minimizing my volatility, I may be comfortable in committing more capital in my trades. The overall effect of this would be to increase my absolute returns on a dollar basis even if my return on a percentage basis decreases.

My efforts to reduce my portfolio can be partially seen in my Roth IRA — the orange line in the chart located above. I initiated a small position in TZA, a 3x levered short ETF that tracks the Russell 2000, and increased my use of covered calls. I think I will continue to use this strategy to reduce my volatility going forward.

New positions initiated this quarter include a small position in Bank of America which I believe is at an attractive valuation now. I have also conducted research into Research in Motion and Netflix but have not yet initiated any positions.

I don’t anticipate 2012 to be a good year for me because many of my positions are reaching full valuation. My focus for the first half of next year will be to initiate various defensive option positions (ex: covered calls, vertical call spreads) since I don’t anticipate large gains in the short term.

For the next year, I hope to supplement my strategy of fundamental analysis with a more systematic and algorithmic approach to trading. Progress has been slow on this front, but I hope to show readers some preliminary models soon.

I thank the small collection of readers who frequent this pathetic blog, and I encourage readers to continue to comment on reach out to me through e-mail.