Chapter 10
IN THIS CHAPTER
Seeing strategies
Preparing to program
Backtesting, Backtesting, Backtesting
Building on some standard strategies
Arbitraging your way to new opportunities
In a way, day trading is simple. You see an indicator showing that a trend is starting. You place a trade. Then, when the trend is over or you hit your loss limit, you close out the trade.
Ah, but there are two challenges. The first is identifying an indicator or trend in enough time to trade on it. The second is fighting your emotions so that you actually execute the trade and then close it out – and not execute a completely different trade, or be too overcome with doubt to place the trade, or wish and hope that the loss will magically reverse itself.
Many traders find that the way to make trading work is to do it automatically. They set up their accounts to scan for indicators, and then they place the trades for them. Some traders trust their systems enough to have them do it all for them, whereas others prefer to place the trades themselves but appreciate the reminders.
Think of this chapter as a continuation of Chapter 9. A trading program, also known as an algorithm, an expert advisor, or a trading robot — works off of the indicators discussed there. Whether or not you actually use programs, understanding how they work can help you approach the markets better.
This chapter doesn’t provide you with a magic money-making machine. In fact, be suspicious of anyone who offers to sell you a trading program that’s a sure thing. This chapter does give you some ideas for when to trade and how to take your emotions out of the game.
Developing a trading algorithm can help you distill your strategy, and it can execute even when you’re nervous about pulling the trigger. However, the program is only as good as the programmer. If you write a bad program, you’ll get bad trading. Also, market conditions change — a program that worked for a while may need to be tweaked or even scrapped all together.
Before you start programming, you want to spend time with the markets looking at indicators and seeing how the assets that you want to work with trade. And before I get into the soft chewy center of this chapter, make sure you do two hard things: have a plan and know the limitations.
Take out a sheet of paper and a pen, and write out the steps of your ideal trade from start to finish. Answer the following:
Answering these questions can move you toward making your trading more systematic, whether or not you decide to turn to a robot to execute the trades for you.
Here’s an example:
You can’t write a program until you can write out step by step what you want to do. And, really, you shouldn’t trade at all until you can do that.
Robots only do what they’re programmed to do. A robot designed to clean carpets can’t wash dishes. A robot programmed to trade badly can’t trade well. Trading algorithms are only as good as they were designed to be, and they can’t respond to changes in market conditions by themselves. You can’t set the program to run and then walk away from it.
Yes, the big hedge funds and brokerage firms rely on algorithmic trading. They also hire people with PhDs in computer science to help them. Some hedge funds do such things as locate their servers on the floors of the exchange to speed execution, and they program in artificial intelligence to adapt to changes. You can’t keep up.
Most modern day traders find that they need to program their trades. In other words, they need to determine what they’re trading, identify the signals they use to buy and sell securities, and set their trading platform to execute the orders automatically. Instead of working on your reflexes, you do the work of planning and testing.
You don’t need to be a software engineer to develop trading programs. Many of the charting services offer program templates that you can follow or adapt; the brokerage firms that work with day traders offer trading platforms that can be programmed without too much effort, usually by clicking on icons or inserting widgets of prewritten code.
Start by writing out your process step by step with a pen on paper before you attempt to convert it to code. Then look at what may be available from your broker or different trading platforms before moving on to programming your trades yourself.
The next sections give you some sense of what products are on the market and how they can be used to help automate your trading and take emotion out of the game.
Most brokers who cater to day traders offer automating scanning and signaling. These services allow you to specify parameters that you want to know about for your trading. You’ll receive a notice whenever the system detects your parameter in the market so that you can trade. These services can speed up your trading, but they still rely on you to execute the suggested trade.
You can use stop and limit orders, which I discuss in Chapter 3, to help with automating your trading, especially in enforcing loss limits.
Beyond that, some brokerage firms offer the ability to develop simple algorithms using their scanning and signaling services. These services are usually basic “if, then” commands, but they can go a long way to help you get started.
In addition, your broker may offer tutorials and other tools to help you figure out how to use its platform to trade more effectively.
If you have a complex algorithm in mind, you may want to work with a trading platform that works with your brokerage firm’s order entry system and allows you to do some serious programming.
Many of these systems use Python or a proprietary programming language to help you create algorithms that work for you. They can allow you to do almost anything you want.
The key, of course, is that you know what you want to do. Having more programming power isn’t going to help you trade better unless you know how to trade and how to program.
Not everyone writing day trading programs is an expert computer programmer. They get help! Some vendors sell completed programs and promise that you can make money from them. That’s possible. Other traders create modules for different trading platforms that they give away or sell, and you can use them to build out your own programs. Each module is a chunk of code that lets you do one thing, and if you put a few together, you end up with a complete trade.
Finally, plenty of videos and tutorials are available online that have instructions on how to program for your trading. They can help you hone your skills. All of them need to be tested, which is what leads into the next section.
I bring up a lot of trading maxims in this book, but this time, here is a popular programming maxim to remember:
Garbage in, garbage out.
Having a program doesn’t necessarily mean that you’re going to trade well, and a program that works for a while may not work forever. That’s why you have to test it.
You can also run your program on current market conditions without trading actual money, a process known as paper trading or simulation trading. It’s a way to see how your program works in current conditions.
Ultimately, though, the true test will be putting it to work in actual trading with actual dollars. You may find some additional glitches and have to start over again.
Trade programming is iterative. To some people, the opportunity to test and refine is part of the fun. Chapter 13 goes into this process in more detail, but for now, know that it’s a necessary component of algorithmic trading.
Day trading, whether done by person or machine, relies on some basic strategies. Trading algorithms build off charts, technical indicators, and common strategies; they don’t bring some new secret sauce to the table.
In this section, I review the strategies that traders use to play off the information they receive from their different signals.
Range trading, sometimes called channel trading, starts with an understanding of the recent trading history of a given security. Getting this history involves looking at the charts (see Chapter 8) to identify typical highs and lows during the day as well as the typical difference between these two prices. With this information, you simply buy low and sell high. When the security dips in price, you place the order to buy; when the security rises, you place the order to sell.
Most range traders use stops and limits to keep their trading in line with what they see. A stop limits the loss if the security keeps dropping below your entry point, and the limit order gets you out at a profit if the security moves to the top of the range (refer to Chapter 3 for more information).
Momentum traders buy securities when prices are rising and sell when prices are falling. These traders figure that something that goes up in price will continue to go up and something going down will continue to go down. Momentum trading (refer to Chapter 9) is one strategy, and it works well for many traders, especially in a strong bull market.
Contrarian trading, on the other hand, is just the opposite of momentum trading, and it can work well, too. The logic behind a contrarian strategy is that nothing goes up forever; for that matter, nothing falls forever, either. The contrarian trader looks for assets that have been rising in price and sells them; she prefers to buy things that have been falling. The point is to sell what seems to be overpriced and buy what seems to be a bargain. Contrarian traders may just be quick to spot when a trend ends. For example, they may buy on a rumor and sell on the news, jumping out right when everyone else is ready to jump in.
The people I’ve known who use this strategy well tend to be bargain hunters in every aspect of their lives. They stock up on frozen vegetables when the grocery store has a once-a-year loss leader, and they sell their apartment if their neighborhood’s real estate gets too hot. They have a nose for value and put that to work during the trading day.
Contrarian traders are fighting the trend, which can work against them sometimes. This style favors people who know a market inside and out so that they know when to move against it.
News trading is possibly the most traditional form of day trading. This type of trader doesn’t pay much attention to charts. Instead, he waits for information that will drive prices. This information may come in the form of a company announcement about earnings or new products, a general economic announcement about interest rates or unemployment, or just a lot of rumors about what may or may not be happening in a given industry.
Traders who do well with news trading usually have some understanding of the markets they’re working in. They’re not hard-core fundamental researchers, but they know enough to know what kind of news would be taken well by the markets and what would be taken poorly. They also have the attention span needed to pay attention to a few different news sources simultaneously, as well as the ability to place the order when the time comes.
The downside of news trading is that really good events may be few and far between; more often, the hype is already built into the price by the time you see it. Also, news trading is difficult to automate, although more and more computer programs draw signals from news and social media feeds. You can’t place a limit order to buy when a price level is hit; you have to wait until you see the news and then place the order yourself. Thus, news trading works well only for traders who can commit to placing the order.
With pair trading, a pairs trader looks for two related assets and goes long on the stronger one and short on the weaker. Many pairs traders work with stocks and look for two companies in the same industry, but a pairs strategy can be worked in futures and currency markets, too — going long on metals and short on interest-rate futures, for example, or long on the dollar and short on the euro. The idea is to get the maximum return possible from a trend that affects both assets. For example, if one retail stock does really well, it may be because the company is taking market share from a weaker one. These trades are a little more complex because you have to plan both sides.
The key to success in any investment is buying low and selling high. But what’s low? And what’s high? Who knows?
In the financial markets, the general assumption is that, at least in the short run, the market price is the right price. Only investors, those patient, long-suffering accounting nerds willing to hold investments for years, see deviations between the market price and the true worth of an investment. For everyone else, especially day traders, what you see is what you get.
Program trading offers huge advantages for arbitrage trading (trading in order to achieve a riskless profit) because the robot can see a price discrepancy and act on it before many humans would be able to.
The law of one price holds as long as markets are efficient. Market efficiency is a controversial topic in finance. In academic theory, markets are perfectly efficient, and arbitrage simply isn’t possible. That makes a lot of sense if you are testing different assumptions about how the markets would work in a perfect world. A long-term investor would say that markets are inefficient in the short run but perfectly efficient in the long run, so they believe that if they do their research now, the rest of the world will eventually come around, allowing them to make good money.
Traders are in between. The market price and volume are pretty much all the information they have to go on. The price may be irrational, but that doesn’t matter today. The only thing a trader wants to know is whether an opportunity exists to make money given what’s going on right now.
In the academic world, market efficiency comes in three flavors, with no form allowing for arbitrage:
Those efficient-market true believers are convinced that arbitrage is imaginary because someone would’ve noticed a price difference between markets already and immediately acted to close it off. But who are those mysterious someones? They are day traders! Even the most devout efficient markets adherent would, if pressed, admit that day traders perform a valuable service in the name of market efficiency.
Those folks with a less-rigid view of market activity admit that arbitrage opportunities exist but that they are few and far between. A trader who expects to make money from arbitrage had better pay close attention to the markets to act quickly when a moment happens.
Finally, people who don’t believe in market efficiency believe that market prices are usually out of sync with asset values. They do research in hopes of learning things that other people don’t know. This mindset favors investors more than traders because it can take time for these price discrepancies to work themselves out.
So how can you as a day trader take advantage of what you know about the one-price rule? Suppose that what you see in New York is not what you see in London, or that you notice that futures prices are not tracking movements in the underlying asset. How about if you see that the stock of every company except one in an industry has reacted to a news event?
Well, then, you have an opportunity to make money, but you’d better act fast because other people – and other robots - will probably see the discrepancy, too. What you do is simple: You sell as much of the high-priced asset in the high-priced market as you can, borrowing shares if you need to, and then you immediately turn around and buy the low-priced asset in the low-priced market.
If you start with a high price of $8 and a low price of $6 and then buy at $6 and sell at $8, your maximum profit is $2 — with no risk. Until the point where the two assets balance at $7, you can make a profit on the difference between them.
Of course, most price differences are on the order of pennies, not dollars, but if you can find enough of these little pricing errors and trade them in size, you can make good money.
The law of one price is all well and good, but prices change constantly during the day. They go up a little bit, they go down a little bit, and they move every time an order is placed.
Once upon a time, day traders could profit from these movements. The process, known as scalping, is not exactly arbitrage. Especially active in commodities markets, scalpers look to take advantage of changes in a security’s bid-ask spread. This spread is the difference between the price that a broker will buy a security for from those who want to sell it (the bid) and the price that the broker will charge those who want to buy it (the ask — also called the offer in some markets).
In normal trading, the bid-ask spread tends to be more or less steady over time because the usual flow of supply and demand stays in balance. After all, under market efficiency, everyone has the same information, so their trading is consistent and allows the broker-dealers to generate a steady profit. Sometimes, however, the spread is a little wider or narrower than normal, not because of a change in the information in the market but because of short-term imbalances in supply and demand.
A basic scalping strategy looks like this:
The scalper has to work quickly to make many small trades. He may buy at $20.25, sell at $20.50, and buy again at $20.30. He has to have a low trade cost structure in place (discussed later in this chapter) or else he’ll pay out all his profits and more to the broker. He also has to be sure that the price changes aren’t driven by real information, because that makes market prices too volatile to make scalping profitable. Scalping is akin to “picking up nickels in front of a steamroller,” some traders say, because of the risk of focusing on small price changes when bigger changes are underway.
In its purest form, arbitrage is riskless because the purchase of an asset in one market and the sale of the asset in another happen simultaneously — you just let those profits flow right into your account. This situation does occur, but not often, and not in a way that lets most day traders compete with algorithmic traders.
Because so few opportunities for true arbitrage exist, most day traders looking at arbitrage strategies actually practice risk arbitrage. Like true arbitrage, risk arbitrage attempts to generate profits from price discrepancies, but like the name implies, risk arbitrage involves taking some risk. Yes, you buy one security and sell another in risk arbitrage, but it’s not always the same security and not always at the same time. For example, a day trader may buy the stock of an acquisition target and sell the stock of an acquirer in the hopes of making a profit as the deal nears the closing date.
In risk arbitrage, a trader is buying and selling similar securities. Much of the risk draws from the fact that the securities are not identical, so the law of one price isn’t absolute. Nevertheless, it forms the guiding principle, which is this: If you have two different ways to buy the same thing, then the prices of each purchase should be proportional. If the prices aren’t proportional, there’s an opportunity to make money. And what day trader doesn’t want to make money?
Arbitrageurs use a mix of different assets and techniques to create these different ways of buying the same thing. The following sections describe some of their favorites.
Derivatives are options, futures, and related financial contracts that draw or derive their value from the value of something else, such as the price of a stock index or the current cost of corn. Derivatives offer a lower-cost, lower-obligation method of getting exposure to certain price changes. In the case of agricultural and energy commodities, derivatives are the only practical way for a day trader to own them. Because they are so closely tied to the value of the underlying security, derivatives form a useful, almost-but-not-quite asset for traders looking for arbitrage situations. A trader may see a price discrepancy between the derivative and the underlying asset, thus noticing a profitable trading opportunity.
Using a derivative in tandem with its underlying security, traders can construct a range of risk arbitrage trades (and you can read more about them later in this section). For example, a trader looking to set up arbitrage on a merger could trade options on the stocks of the buying and selling companies rather than trading the stocks themselves. The more arbitrage opportunities there are, the greater the likelihood of making a low-risk profit.
Leverage is the process of borrowing money to trade in order to increase potential returns. The more money the trader borrows, the greater the return on capital that she can earn. Leverage is commonly used by day traders, because most trades with a one-day time horizon carry low returns unless they are magnified through borrowing. (Go to Chapter 5 for detailed coverage of leverage.)
That magic of magnification becomes especially important in arbitrage, because the price discrepancies between securities tend to be really small. The primary way to get a bigger return is to borrow money to do it.
Short selling (another topic from Chapter 5) creates another set of alternatives for setting up an arbitrage trade — one that’s almost necessary to the process. Short selling allows a day trader to profit when a security’s price goes down. The short seller goes to her broker, borrows the security that she thinks will decline in price, sells it, and then buys it back in the market later so that she has the shares to repay the loan. In essence, the trader is selling high (with borrowed money) and buying back low. Assuming she’s right and the price does indeed fall, she pockets the difference between the price where she sold the security and the price where she bought it back. Of course, that difference is her loss if the price goes up instead of down. The arbitrageur can use this to bet on assets that are likely to go down in price when another asset goes up.
By adding short selling to the bag of tricks, an arbitrageur can find a lot more ways to profit from a price discrepancy in the market. New combinations of cheap and expensive assets — and more ways to trade them — give a day trader more opportunities to make trades during the day.
Feeling creative? Well, then, consider creating synthetic securities when looking for arbitrage opportunities. A synthetic security is a combination of assets that have the same profit-and-loss profile as another asset or group of assets. For example, a stock is a combination of a short put option, which has value if the stock goes down in price, and a long call option, which has value if the stock goes up in price. By thinking up ways to mimic the behavior of an asset through a synthetic security, a day trader can find more ways for an asset to be cheaper in one market than in another, leading to more potential arbitrage opportunities.
A typical arbitrage transaction involving a synthetic security, for example, involves shorting the real security and then buying a package of derivatives that match its risk and return. Many of the risk-arbitrage techniques covered later in this chapter involve the creation of synthetic securities.
You can use the tools of arbitrage — derivatives, leverage, short selling, synthetic securities — in all sorts of ways to generate potentially profitable trades, and that’s what this section of the chapter covers. If you decide to do arbitrage, you may discover a few useful strategies to follow. Beware of picking too many: The trader who tries to do too much is the trader who will soon be looking for a new job! Instead, look for an arbitrage strategy that matches your approach to the market and make it your own.
The varieties of arbitrage transactions are listed here in alphabetical order. Some are more complex than others, some generate more opportunities than others, and some work best if you are willing to swing trade (hold for a few days) rather than day trade (close out all positions at the end of the day). Keep in mind that this list is not exhaustive; you can find plenty of other ways to exploit price differences in the market, but some involve more time than a day trader is willing to commit.
Other types of arbitrage are certainly out there. Wherever people pay close attention to the markets and price changes, they find small price differences to turn into large, low-risk profits. If you think you’ve found an arbitrage strategy not listed here, by all means, go and test it to see whether it will work for you.
As part of designing their capital structure, some companies issue convertible bonds (sometimes called a convertible debenture) or convertible preferred stock. These securities are a cross between stocks and bonds. Like an ordinary bond, convertibles pay regular income to those who hold them (interest for convertible bonds and dividends for convertible preferred stock), but they also act a little like stock because the holders have the right to exchange the convertible security for ordinary common stock.
Here’s an example: A $1,000 convertible bond pays 7.5 percent interest and is convertible into 25 shares of stock. If the stock is less than $40 per share, the convertible holder will prefer to cash the interest or dividend checks. If the company’s stock trades above $40, the convertible holder would make more money giving up the income in order to get the stock cheap. Because of the benefit of conversion, the interest rate on a convertible security is usually below that on a regular corporate bond.
Consider this case: A day trader notices that a convertible bond is selling at a lower price than it should be, given the current level of interest rates and the price of the company’s common stock. So he buys the convertibles and sells the common stock short (see Chapter 9 for more on short selling). When the stock’s price moves back into line, he collects a profit from both sides of the trade.
An exchange-traded fund, or ETF, is a security based on a stock market index. It may be a recognized index or one that has been invented by the company that created the ETF to track a particular investment strategy.
ETFs have been designed with a built-in mechanism to keep the price of the funds in line with the underlying securities. A typical ETF has two classes of shareholders. The first are authorized participants, which are large trading firms that agree to buy the securities in the ETF. The authorized participants then give the securities to the ETF company in exchange for creation units, which are shares of the fund that the authorized participant can hold, sell on the open market, or trade back to the ETF company for the shares. The authorized participant will do whatever had the greatest profit potential, some built-in arbitrage designed to keep the ETF’s value in line for the second class of shareholders, the regular ETF traders.
Despite this mechanism, an ETF’s value may swing out of line with the underlying index or the underlying fundamentals of the sector that it represents. When this happens, a trader can look for an arbitrage opportunity between the ETF and an index future, between two different ETFs, or between an ETF and a representative stock.
Fixed-income securities are bonds, notes, and related securities that give their owners a regular interest payment. They are popular with conservative investors, especially retirees, who want to generate a regular income from the quarterly interest payments. They are considered to be safe, predictable, long-run investments, but they can fluctuate wildly in the short term, which makes them attractive to arbitrageurs.
Interest rates are the price of money, and so they affect the value of many kinds of securities. Fixed-income securities have a great deal of interest-rate exposure because they pay out interest. Some stocks have interest-rate exposure, too. Trading in foreign exchange is an attempt to profit from the changing price of one currency relative to another, and that’s usually a function of the difference in interest rates between the two countries. Derivatives have a regular expiration schedule, so they have some time value, and that’s measured through interest rates.
With so many different assets affected by changes in interest rates, arbitrageurs pay attention. With fixed-income arbitrage, the trader breaks out the following:
If one of the numbers is out of whack, the trader constructs and executes an arbitrage trade to profit from it.
How would such a trade work? Think of a day trader monitoring interest rates on U.S. government securities. He notices that two-year treasury notes are trading at a lower yield than expected — especially relative to five-year treasury notes. He sells futures on the two-year treasury notes and then buys futures on the five-year treasury notes. When the difference between the two rates falls back where it should be, the futures trade will turn a profit.
Market observers talk a lot about the performance of the S&P 500 Index and the Dow Jones Industrial Average. These market indexes represent the activity of the market and are widely published for market observers to follow. The performance of the index is based on the performance of a group of securities, ranging from the 3,000 largest companies in the market (the Russell 3,000) to a mere 30 large companies (the Dow Jones Industrial Average).
Sure, an arbitrageur could buy all the stocks, and some hedge funds do just that. But very few people can afford to pursue that strategy. Instead, they get exposure to index performance through the many different securities based on the indexes. Buy-and-hold mutual fund investors can buy funds that hold all the same stocks in the same proportion as the index. Those with shorter-term profits in mind can buy exchange-traded funds, which are baskets of stocks listed on organized exchanges, or they can trade futures and options on the indexes.
Arbitrageurs love the idea of an asset — like an index — that has lots of different securities based on its value because it creates lots of opportunities for mispricing. Unless the index, the futures, the options, and the exchange-traded funds are all in line, some canny day trader can step in and make some money.
Suppose, for example, that the S&P 500 futures contract is looking mighty cheap relative to the price of the S&P 500 Index. A trader can short an exchange-traded fund on the index and then buy futures contracts to profit from the difference.
Every day, companies get bought and sold, and that creates arbitrage opportunities. In fact, one of the better-known arbitrage strategies out there is merger arbitrage, in which traders try to profit from the change in stock prices after a merger has been announced. This kind of trade starts with the trader looking at the following details in the merger announcement:
Until the date that the merger actually closes, which may be different from the date in the merger announcement, any and every one of the announced details can change. The acquiring company may learn new information about the target company and change its mind. A third company may jump in and make an offer for more money. The shareholders may agree to support the deal only if they get cash instead of stock. All that drama creates opportunity, both for traders looking for one-day opportunities and for those willing to hold a position until the merger closing date.
Here’s an example. Say that Major Bancorp offers to buy Downtown Bank for $50 per share in cash. Major Bancorp’s shares will probably fall in price because its shareholders will be concerned that the merger will be a lot of trouble. Downtown Bank’s shares will go up in price, but not all the way to $50, because its shareholders understand the risk that the deal won’t go through. An arbitrageur would short Major Bancorp and buy Downtown Bank to profit from the concerns. If Overseas Banque decides to step in, the trader may think it a profitable idea to buy Major Bancorp and short Overseas Banque. (If another bidder steps in and places a higher offer for Downtown Bank, then the whole arbitrage unravels — hence, the risk.)
Options, which I discuss in more detail in Chapter 4, form the basis of many arbitrage strategies, especially for those day traders who work the stock market. First, many different types of options are available, even on the same security. The two main categories are puts, which bet on the underlying security price falling, and calls, which bet on the underlying security price rising. Puts and calls on the same security come in many different strike prices, depending on where you want to bet the price goes. Some options, known as American options, can be cashed in at any time between the date of issue and the expiration date, and you can exercise others, known as European options, only at the expiration date. (To complicate matters, American and European options can be issued anywhere.) With all those choices, the alert arbitrageur is bound to notice a few price discrepancies.
Maybe a day trader notices that on a day when a company has a big announcement, the options exchanges seem to be assuming a slightly higher price for the stock than where the stock is actually trading. He decides to buy the underlying stock as well as a put; he also sells a call with the same strike price and expiration date as the put. This strategy creates a synthetic security (refer to the earlier section “Creating synthetic securities”) that has the same payoff as shorting the security, meaning that the trader has pulled off a riskless arbitrage transaction. He effectively bought the security cheap in the stock market and sold it at a higher price in the options market.
Pure arbitrage works best in a world where trading is free. In reality, trading costs good money. Sometimes you may notice a price discrepancy that seems to last forever, but you can’t work it because the profit wouldn’t cover your costs. And that actually may be true for everyone else out there.
In the real world, trading costs money. Consider all the costs of getting started: buying equipment, paying for Internet access, learning how to trade. Add to those costs the costs of doing business that vary with each transaction: commissions, fees, interest, the bid-ask spread, and taxes. You don’t make a profit on a trade unless it covers those costs.
Add up those trading costs, and you can find yourself in a frustrating situation: You can see the opportunity staring you in the face, but you can’t take it. So the opportunity either sits there, taunting you, or it gets picked off by a trader who has lower costs than you do.