Wednesday, June 29, 2016

Pruitt, The Ultimate Algorithmic Trading System Toolbox

I am in the process of learning to code in Python and am, I must admit, no programming genius. So I was delighted to see that George Pruitt, best known for his book on TradeStation’s EasyLanguage (Building Winning Trading Systems with TradeStation) had written a new book that covered not only the TradeStation platform but also AmiBroker, Excel (with VBA), and Python. The Ultimate Algorithmic Trading System Toolbox: Using Today’s Technology to Help You Become a Better Trader (Wiley, 2016) is a how-to manual for the non-quant who wants to incorporate algorithms into his trading.

Pruitt’s focus in this book is not so much on system development per se as it is on popular programming tools for building and back testing technical trading systems. Yes, he has chapters on “Genetic Optimization, Walk Forward, and Monte Carlo Start Trade Analysis” and “An Introduction to Portfolio Maestro, Money Management, and Portfolio Analysis,” but what will most likely draw traders to Pruitt’s book is his extensive array of clearly explained sample code.

His examples of input into technical trading systems are drawn from the usual suspects, such as Bollinger bands, Keltner channels, MACD, RSI, stochastics, and various moving average indicators. More important, he shows traders who don’t use comprehensive platforms how to write system testers. He developed his own bare-bones Python and Excel testing engines. A website accompanying the book includes this software, with all its source code, as well as source code that can be run in TradeStation and AmiBroker. Unlike much of the Python code that is available online, Pruitt’s actually seems to be error-free. I didn’t test his other code.

One of Pruitt’s aims in this book was to offer “the most important and simplest programming techniques to transform a non-quant into a not-so-non-quant.” He has, I believe, succeeded admirably.

Sunday, June 26, 2016

Roze, Tensile Trading

Tensile Trading: The 10 Essential Stages of Stock Market Mastery by the father-son team of Gatis N. Roze and Grayson D. Roze (Wiley, 2016) is a wide-ranging book that will be of particular value to those who are fairly new to active investing. Or those who have not been as successful as they would have liked and want to start over.

The book is organized around a ten-step process: money management, the business of investing, the investor self, market analysis, routines, stalking your trade, buying, monitoring, selling, and—finally—revisit, retune, refine.

One imperative that gets repeated in many contexts is: Put it in writing! The authors stress that in business (and investing should be treated as a business) “documentation is the centerpiece of effective organization and operation.” The investor should document and regularly update his business plan. He should also keep a daily journal. Another suggestion is to take observational notes (on notepads or via smartphone). “Opportunities surround us in abundance if we open ourselves up to them…. [S]mall, brilliant little gems present themselves in the most unlikely situations. It is uncanny how often these observations translate into profitable investment decisions somewhere down the line.”

Once an investor has identified a stock in which he is interested (and the authors suggest a process for making this identification) and is prepared to execute a buy order, he should not go all in. Rather, he should use the strategy of pyramid trading, buying only a percentage of the desired total investment and letting the market prove him right before he buys more. The authors’ recommendation is to pyramid into long positions using 25%-35%-40% progression and to pyramid out using a reversed 40-35-25 sequence, “which reflects the fact that prices tend to fall faster than they rise.” Using this buy strength, sell weakness method, “if the trend pushes higher, the market has reinforced your good judgment and handed you some profit as a reward. If the trend reverses, your stop is executed, your risk is limited, and you book a small loss on only 25 percent of your full intended position rather than a larger loss on its entirety.”

Tensile Trading frequently drills down into specifics. For instance, it describes a personal selling paradigm that monitors price relative, trend, volume, momentum, bearish patterns, and personal money management rules and that is illustrated with color charts from, where Grayson Roze serves as business manager.

But at its core Tensile Trading sets out to delineate a framework in which to thrive as an active investor, no matter what particular strategies and tactics the investor develops and pursues. And this it does very well.

Wednesday, June 22, 2016

Kirchner, Merger Arbitrage

Engaging in merger arbitrage—that is, entering a position after a definitive agreement has been signed between the target and the acquirer—is akin to selling options. The most an arbitrageur can make is the payment received when the merger closes. The downside is unlimited: in a worst-case scenario a complete loss of capital is possible if a merger collapses.

Thomas Kirchner, in this second edition of Merger Arbitrage: How to Profit from Global Event-Driven Arbitrage (Wiley, 2016), describes the ins and outs of mergers in easily understandable prose. He also addresses the risks and returns of the merger arbitrage strategy as well as its role in a diversified portfolio.

A couple of points about the risk:return profile of this strategy.

Quantifying the probability and severity of potential losses involves a lot of guesswork. In fact, the author writes, “even if quantitative methods are used to determine probabilities, it is difficult to say for sure how much credibility they have. Mergers are subject to a large number of variables that behave very differently under varying economic circumstances. Moreover, most arbitrage portfolios tend to have a limited number of positions, because only a limited number of companies merge at any one time. An overreliance on probabilities in such portfolios can be dangerous.” (p. 140)

The typical return on a merger arbitrage position is 2 to 4 percent achieved over, on average, four months. Annualized, the return would be 6 to 12 percent. Using the IQ Index and the S&P Merger Arbitrage Index as (admittedly flawed) proxies for the performance of this strategy as well as indices of hedge funds that specialize in merger arbitrage, we see that their “median return is comparable to that of the S&P 500 index, whereas volatility is more akin to that of bonds.” (p. 465)

Investors who are considering adding a merger arbitrage component to their portfolio should read this well-crafted book, as should students of finance. Cobbling together knowledge about mergers from the financial press simply leaves too many gaping holes.

Sunday, June 19, 2016

Wachenheim, Common Stocks and Common Sense

Common Stocks and Common Sense: The Strategies, Analyses, Decisions, and Emotions of a Particularly Successful Value Investor (Wiley, 2016) by Edgar Wachenheim III, chairman and chief portfolio manager of Greenhaven Associates, is a delightful book. Part memoir, part case study, part advice, it sheds light on a stellar investing career. Over the past 25 years Greenhaven, which currently has about $5.5 billion in assets under management, has achieved average annual returns of nearly 19 percent.

Eleven case studies—IBM, Interstate Bakeries, U.S. Home Corporation, Centex, Union Pacific, American International Group, Lowe’s, Whirlpool, Boeing, Southwest Airlines, and Goldman Sachs—form the core of the book, some wildly successful investments, others less so. Wachenheim tersely describes the fate of one of his disasters (AIG): “I went to bed with Miss America and woke up with a witch.”

Although Wachenheim is a value investor, and as such necessarily a number cruncher, he doesn’t dwell unduly on valuation. For instance, in assessing a potential investment in Whirlpool, he decided that it “would be an exciting investment regardless of whether [the shares] were worth 15 times earnings or 12 times earnings or even 10 times earnings. … When you think you are hitting a home run, you need not dwell on whether the ball is likely to end up in the lower deck, the upper deck, or out of the ball park.”

In connection with Greenhaven’s Whirlpool investment, Wachenheim continues: “If one in five of our holdings triples in value over a three-year period, then the other four holdings only have to achieve 12 percent average annual returns in order for our entire portfolio to achieve its stretch goal of 20 percent. For this reason, Greenhaven works extra hard trying to identify potential multibaggers.”

The book closes with a letter to a younger investment manager who had asked for advice. It includes such wonderful lines as this one, which invokes Samuel Johnson: “Be wary of stock recommendations made by others, especially by those in the media who may sound articulate and authoritative, but who lack the resources to be successful professional investors. A horse that can count to 10 is a wonderful horse, but not a wonderful mathematician.”

Wachenheim might write that “all [his] life, he struggled with verbal skills,” but you wouldn’t know it from this book. It’s a page turner.

Wednesday, June 15, 2016

Gervasi, East-Commerce

Marco Gervasi, a management consultant (founder of The Red Synergy) and technology blogger who lives in Shanghai, believes that China will develop advanced models in both e-commerce and the internet of things that will inspire the world. He is also convinced that the growth of its super-connected world will happen faster than anywhere else in the world.

East-Commerce: A Journey through China E-Commerce and the Internet of Things (Wiley, 2016) is interesting, however, not so much for its predictions but for its description of the ways in which the typical Chinese online experience differs from its western counterpart. “In the West, people use the Internet to search for information and learn about things. In China, however, people use it primarily to entertain themselves. … Boredom was, and still is, what drives most people to the Internet in China.”

Toine Rooijmans, a market researcher, would ask his subjects how they discovered his website. “He learned that the users were finding the site through word of mouth or blogs. He would then ask if users were searching online for things they did not know. The answer was always the same: ‘When we do not know something, we ask our friends.’” And if their friends didn’t know? “’Then nobody knows,’ they would answer.”

Gervasi claims that the Chinese also shop differently from westerners. They prefer bazaars over individual brand sites. “The digital bazaar—the online souk—has many of the same advantages of the ancient bazaar: it creates competition among vendors, thus driving down prices. It also allows people to engage merchants in conversation, providing them with feedback on pricing and quality. … Bazaars are perceived as highly social entities whereas individual brand websites in China seem ‘antisocial’ and therefore untrustworthy.” I’m not sure that the difference between East and West is so stark in this regard, Amazon being a case in point.

Chinese consumers use social networks to interact with brands, even if they don’t buy from brand websites. They “want to know what the brands are doing, whether they are creating new products etc.” And their purchasing behavior is very social. “Chinese like to share and tell people what they have bought.”

Gervasi’s book is anecdotal, not the product of serious sociological research. But it goes a long way toward explaining why so many western businesses have failed to engage the Chinese consumer.

Sunday, June 12, 2016

Benello et al., Concentrated Investing

We are often told that diversification is the closest thing to a free lunch in investing. And yet some of the most successful investors have politely declined this free lunch. Instead, they have opted to, in Warren Buffet’s words, “keep all [their] eggs in one basket, but watch that basket closely.”

Concentrated Investing: Strategies of the World’s Greatest Concentrated Value Investors by Allen C. Benello, Michael van Biema, and Tobias E. Carlisle (Wiley, 2016) re-visits “the subject of bet sizing [the Kelly Criterion] and portfolio concentration as a means to achieve superior long-term investment results.” In eight chapters it analyzes the techniques of investors Lou Simpson; John Maynard Keynes; John Kelly, Claude Shannon, and Edward Thorp; Warren Buffett; Charlie Munger; Kristian Siem; Grinnell College; and Glenn Greenberg.

Holding a concentrated portfolio is not for the faint of heart and certainly not for the dabbler. It requires an extraordinary amount of skill, intense research, and preferably deep pockets since a concentrated portfolio can have large drawdowns. As a strategy, it goes in and out of fashion. “When times are good, portfolio concentration is popular because it magnifies [or can magnify] gains; when times are bad, it’s often abandoned—after the fact—because it magnifies [or can magnify] volatility. Concentration has been out of favor since 2008, when investment managers began in earnest to avoid what they perceive as a risky business practice.”

Central to most concentrated investing, and not just value investing, is the application of some version of the Kelly Criterion. Keynes was a “Kelly-type bettor” in that he bet big when he had an edge and wagered nothing when he didn’t. Keynes, however, “shied away from attempting mathematical precision because ‘our existing knowledge does not provide a sufficient basis for a calculated mathematical expectation.’”

Kelly, simplifying Shannon’s rate of transmission theorem used in his information theory paper, offered an equation for the optimal bet size, one that maximized the exponential rate of growth of the gambler’s capital. (By the way, he looked at the case of betting on baseball teams, not horse racing.) The formula was f* = (bp – q)/b = (p(b+1) -1)/b, where f* is the fraction of the current bankroll to wager, b is the net odds received on the wager, p is the probability of winning, and q is the probability of losing. The equation can be further simplified to edge/odds. Kelly’s formula assumes “the possibility of reinvestment of profits and the ability to vary the amount of money invested or bet.”

The Kelly Criterion is a very aggressive position sizing strategy and can experience wrenching volatility in the short term. Some investors therefore halve its recommended position size, achieving “three-quarters of the compound return of Kelly with half the volatility.” Or opt for some other fractional variation.

Value investors don’t always use the Kelly Criterion, and those investors who use some variation of the Kelly Criterion aren’t always value-oriented, Thorp being a case in point. But somewhere in the matrix of value investing and position sizing there is a sweet spot. As the authors conclude, “The lesson of this book condensed into a single sentence is: ‘Bet seldom, and only when the odds are strongly in your favor, but when you do, bet big, hold for the long term, and control your downside risk.’”

Wednesday, June 8, 2016

Pachamanova & Fabozzi, Portfolio Construction and Analytics

Portfolio Construction and Analytics by Dessislava A. Pachamanova and Frank J. Fabozzi (Wiley, 2016) is written for portfolio managers, institutional investors, and students of finance, not for the average retail investor. Nonetheless, it is a worthwhile read for anyone who is looking for an overview of basic quantitative principles although, at nearly 600 pages, it is not a fast read.

The book is divided into six parts: statistical models of risk and uncertainty, simulation and optimization modeling, portfolio theory, equity portfolio management, fixed income portfolio management, and derivatives and their application to portfolio management. The authors assume that the reader has practically no knowledge of financial markets or quantitative concepts; everything is described from scratch. The reader does, however, have to be quite mathematically literate. The authors’ only concession on this score is an appendix explaining basic linear algebra concepts.

Many of the problems the book introduces can be addressed, although often with severe limitations, using either R or Excel (for instance, basic optimization with Excel Solver, a task the authors explain in step-by-step detail). Although most portfolio managers will undoubtedly opt for more user-friendly specialized software packages, for teaching purposes it makes sense to rely on readily available free (or nearly free) software.

Just to give a taste of the book, let’s look briefly at the problem of optimization under uncertainty. There are three approaches to dealing with this problem: dynamic programming, stochastic programming, and robust optimization.

With dynamic programming, “the optimization problem is solved recursively, going backwards from the last state, and computing the optimal solution for each possible state of the system at a particular stage. In finance, dynamic programming is used in the context of pricing of some derivative instruments, in investment strategies such as statistical arbitrage, and in long-term corporate financial planning.”

Stochastic methods “rely on representing the uncertain data with scenarios and focus on finding a strategy so that the expected value of the objective function over all scenarios (sometimes, penalized for some measure of risk) is optimal. Stochastic algorithms have been successfully applied in a variety of financial contexts, such as management of portfolios of fixed income securities, corporate risk management, security selection, and asset/liability management….”

The problem with both of these methods is that, in most real-world applications, “the dimensions … are too large, and the problems are difficult to handle computationally. Often, approximation algorithms are used; some such algorithms employ Monte Carlo simulation and sample the state space efficiently.”

Robust optimization, introduced to the world of finance more recently, “takes a worst-case approach to optimization formulations.” It “makes optimization models robust with respect to uncertainty in the input data of optimization problems by solving so-called robust counterparts of these problems for appropriately defined uncertainty sets for the random parameters. The robust counterparts contain no uncertain coefficients; they are deterministic optimization problems.”

As you can see from these snippets, Portfolio Construction and Analytics isn’t exactly a James Patterson thriller, but for the quantitatively oriented student of finance or portfolio manager it is a useful text.

Sunday, June 5, 2016

Duckworth, Grit

Grit is one of those books I thought had been published long before it actually appeared in print. The idea central to Angela Duckworth’s book (Scribner, 2016)—that grit, a combination of passion and perseverance, is the best predictor of high achievement—was popularized before she herself could properly explain it to laymen and defend it against criticism. Duckworth, a psychology professor at the University of Pennsylvania, got a MacArthur “genius” award in 2013, and by 2014 school reformers were already clamoring to teach kids to have grit, citing her research.

Finally we have the book, an instant New York Times bestseller, and it was worth the wait. The thesis may be straightforward, but Duckworth is quick to qualify it where necessary. She admits that talent is a plus and that we aren’t all equally talented. But, she argues, “as much as talent counts, effort counts twice.” Here’s how. Talent x effort = skill, and skill x effort = achievement. That is, “talent is how quickly your skills improve when you invest effort. Achievement is what happens when you take your acquired skills and use them.” Of course, having a great coach or teacher matters, as does sheer luck. But “when you consider individuals in identical circumstances, what each achieves depends on just two things, talent and effort. Talent—how fast we improve in skill—absolutely matters. But effort factors into the calculations twice, not once.”

Duckworth illustrates her points with anecdotes, some from her own life. For instance, as a second term freshman at Harvard she enrolled in neurobiology, a course for which she was obviously not qualified. Despite studying “madly,” she got an F on her first exam and another F on the midterm. Her TA strongly urged her to drop the course so she wouldn’t have a failing grade on her transcript. But, with only the final exam remaining, she resolved to stick it out—and, in fact, to become a biology major with a concentration in neurobiology. She writes: “For the rest of the semester, I not only tried harder, I tried things I hadn’t done before. I went to every teaching assistants’ office hours. I asked for extra work. I practiced doing the most difficult problems under time pressure—mimicking the conditions under which I needed to produce a flawless performance. I knew my nerves were going to be a problem at exam time, so I resolved to attain a level of mastery where nothing could surprise me. By the time the final exam came around, I felt like I could have written it myself. I aced the final. My overall grade in the course was a B—the lowest grade I’d get in four years, but, ultimately, the one that made me the proudest.” Talk about grit!

Throughout her book Duckworth describes in some detail research that, though sometimes tangential to her own, supports her thesis. She writes about Carol Dweck’s work on fixed vs. growth mindsets. She cites the claim of her colleague Philip Tetlock in Superforecasting that “The strongest predictor of rising in the ranks of superforecasters is perpetual beta, the degree to which one is committed to belief updating and self-improvement. It is roughly three times as powerful a predictor as its closest rival, intelligence.”

Grit is an inspiring book that blends solid research with good storytelling. I couldn’t put it down.

Wednesday, June 1, 2016

May, Winning the Brain Game

Matthew E. May’s Winning the Brain Game: Fixing the 7 Fatal Flaws of Thinking (McGraw-Hill, 2016) is “a mindful guide … for using our minds to win the games our brains are hardwired to play on us, the patterns of tricks that while effective in handling routine problems and quick-fix situations, become traps when we need to invoke our best thinking.” (p. xii)

May, a former professional facilitator at Toyota’s U.S.-based corporate university, glides over a lot of hard problems in this book. As he confesses up front, he is neither scientist nor scholar. He instead sees himself as having written a repair manual. As repair manuals go, this is quite a decent one.

The seven fatal flaws of thinking, as May sees them, are leaping, fixation, overthinking, satisficing, downgrading, not invented here (NIH), and self-censoring. The deadliest of these (though presumably by virtue of being fatal they’re all deadly) is self-censoring, so it’s the one I’ll focus on here.

Self-censoring is succumbing to our inner critic. We come up with a great idea, we may even think it is great, but we kill it anyway. “Self-Censoring is rooted in a kind of personal fear that can not only silence whatever creative instinct we may have, but also render us mindless: exaggerating, catastrophizing, doomsdaying. Welsh novelist Sarah Waters sums it up quite eloquently: ‘Midway through writing a novel, I have regularly experienced moments of bowel-curdling terror, as I contemplate the drivel on the screen before me and see beyond it, in quick succession, the derisive reviews, the friends’ embarrassment, the failing career, the dwindling income, the repossessed house, the divorce…’” (p. 152)

How do we fix this self-censoring? May recommends self-distancing. Self-distancing involves mindfulness—“a higher-order attention, noticing moment-to-moment changes around you.” (p. 161) And it involves invoking the impartial spectator, first introduced by Adam Smith in The Theory of Moral Sentiment and defined as “the ability to observe our behavior as an objective onlooker does, while remaining fully aware of our thoughts, emotions, and circumstances.” (p. 162)

One “trick” to self-distancing is to address yourself in the third person (presumably without being ridiculed like Bob Dole was). For instance, in one study experimenters gave college students five minutes to prepare to speak in front of judges, without notes. A stress-inducing experiment. “One group was told to use first-person pronouns to work through their stress; for example, ‘I shouldn’t be so nervous,’ and ‘I will be fine.’ The other group was told to use their name or a third-person pronoun; for example, ‘Matt, don’t be nervous,’ or ‘You’ll do great.’” (Actually, a second-person pronoun in this example.) “Not only did the judges find the latter group’s performances to be more confident and persuasive, but the participants themselves reported far less shame and rumination than the first-person group.” (p. 163)

If you’re wondering about the reference to rumination here, the author quotes Pamela Weintraub: “By toggling the way we address the self—first person or third—we flip a switch in the cerebral cortex, the center of thought, and another in the amygdala, the seat of fear, moving closer to or further from our sense of self and all its emotional intensity. Gaining psychological distance enables self-control, allowing us to think clearly, perform competently. The language switch also minimizes rumination, a handmaiden of anxiety and depression after we complete a task. Released from negative thoughts, we gain perspective, focus deeply, and plan for the future.” (pp. 163-64)

Although I doubt that the solution to self-censoring is so simple, self-distancing might well be part of the solution. I suspect that the power of shifting away from the first person comes from our perceived need for external validation. We’ve been programmed from our school days (grades) and work experience (evaluations from colleagues and bosses) to be judged by outsiders. If at some meta-level we become that outsider—an encouraging, validating one, of course—we might short circuit our own self-doubts.