SFI Bulletin Articles

Modeling Markets

by Cosma Rohilla Shalizi

Published, tweaked, in the Santa Fe Institute Bulletin, vol. 15, no. 1 (Winter 2000).
The great paradox of financial markets is this: trade is largely driven by experienced guesswork and simple rules, when not driven by confusion, error and nonsense, supplemented by (as one financial journalist puts it) "testosterone and cocaine." A process less likely to deliver a reasonable evaluation of what something is worth could hardly be imagined, yet it's exceedingly hard to beat the market over any substantial length of time. How can this be?

This is the puzzle addressed by SFI resident faculty member J. Doyne Farmer in his recent research, summarized in his paper "Market Force, Ecology, and Evolution"and in an informal short course this March. The latter was part of a new NSF-funded program for which the Institute is a pilot, designed to take physics graduate students and expose them to interdisciplinary research. During the presentation, John Geanakoplos, a professor of economics at Yale and a collaborator of Farmer's played the role of devil's advocate.

Farmer comes to this work from a background in nonlinear dynamics (he was a member of the Dynamical Systems Collective at UC Santa Cruz in the late 1970s), a long association with the Institute (he participated in the well-known conference on "The Economy as an Evolving Complex System" in 1987), and a number of years at the Prediction Company, which uses time-series analysis techniques on very large volumes of data to predict market movements. Farmer's current research has moved into yet new realms; he's working to understand how markets work, which probably won't help anyone make a killing, but might give us a better handle on these beasts which play such an important role in the world.

First some background to help understand the context for the talks: Neo-classical economics has very definite ideas about what traders and markets should look like. Economic agents have beliefs about the world and desires about how the world (or at least their part of it) should be. Their guesses about what will happen are the best that can be formed on the basis of what they believe ("rational expectations"), and their actions are the ones most likely to satisfy their desires, again given their beliefs. If all their desires are purely self-interested, and they are allowed to trade everything they have initially, and a few more technical conditions are met, then after one round of trading, markets will be at equilibrium, meaning that everyone will have made all the trades they want to, and nobody will want to make any more trades. Markets at equilibrium are said to allocate efficiently, since goods wind up with those for whom they have the highest utility, i.e., those who are willing and able to pay the most to have them. (The good allocated in financial markets is, essentially, capital.)

Equilibrium markets are not necessarily static; in fact generally they change, and do so unpredictably. After all, agents are rational people; the price they are willing to pay for a good reflects all the available information which has any bearing on the good's value. Suppose new relevant information appears. Either this could have been predicted from the old data, in which case, because of rational expectations, it would have been, and prices adjusted accordingly, or it could not, in which case the movement of prices is unpredictable and random. This property --- the unpredictability of prices --- is also called "efficiency," and in equilibrium, with rational agents, prices are efficient if and only if allocation is efficient.

There are several reasons why financial markets make good testbeds for theories of economic behavior. Lots of reliable, fine-grained data is available for these markets over long stretches of time. Agents interact only in tightly-constrained, almost ritualized ways. Similarly, financial markets themselves have only tightly limited and constrained interactions with other parts of the economy (no suppliers, no customers, etc.), so quite crude represnetations of the real economy may suffice for financial modeling. Finally, determining the value of securities is in some ways actually easier than determining the value of, say, machine parts, haircuts, or software, since most financial agents treat them as investments, rather than as things with intrinsic utility (if you want a car, you buy a car, not stock in Ford). For instance, the price you should pay for a share of stock is how much you would get in exchange for your money, that is, the value of the dividends the stock will pay, discounted for risk and the fact that we generally prefer money now rather than later --- the "net present value" --- of the dividend stream. Other kinds of securities can be priced similarly.

How well do standard economic ideas hold up? At first sight, surprisingly, pretty well. After removing trends which reflect the long-term growth of the real economy, securities prices do indeed appear to be random --- more exactly the logarithms of prices fit very closely to the stochastic process physicists call a "random walk." (In fact much of the mathematics of random walks was first developed to model market movements, and only subsequently applied to physical problems.) So prices are very nearly efficient, which means that it's extremely hard to do better than the market average in the long run, and why nobody now remembers investment gurus from 10 years ago, and why nobody will remember today's gurus in 2010.

On the other hand, if financial markets really were in equilibrium, they would be immensely less active than they are. Agents would trade only when they received genuinely new data, or their desires changed --- otherwise their existing positions would be sub-optimal. But the volume of trading, at least in modern markets, is orders of magnitude too large to be due to new information or new wants; the volume of daily currency trading, for instance, is (roughly) 50 times the daily output of the world economy (and most of that output doesn't involve international trade anyway). Similarly, large price movements often display no real connection to any sort of news which might rationally influence prices. (The inhabitants of Korea, Indonesia, etc., recently had an all-too-convincing demonstration of this phenomenon.) So evidently traders do not rationally evaluate all available evidence, with potentially very important effects.

This is consistent with empirical observations of the way traders actually make decisions, with which we began. Their procedures run from trying to value securities according to fundamental information, through attempting to find patterns in the movements of prices ("technical trading"), to numerology, and astrology.

So now we can be a bit more precise about the puzzle. Traders in the markets aren't rational, but prices in the markets are efficient. A good theory of markets should explain how this trick is turned. It should also explain why prices aren't completely efficient --- why traders who crunch enough data can out-perform the market --- and two very robust statistical features of securities prices. The first is the existence of "fat tails," which is a situation where there are more very large changes in prices than a simple random walk can account for. The other is "clustered volatility": the amounts by which the price of a security changes on different days are correlated, and the correlation decays only slowly, as a power-law (but we've seen that, according to rational expectations, there should be no correlations in price changes at all). What Farmer is attempting is to come up with a simple theory that can accommodate all these facts --- the near-efficiency of markets, the irrationality of traders, fat tails, and clustered volatility, among others.

Farmer's model works as follows: There are two assets, one of which is riskless but pays no dividends, which we can think of as cash; the other fluctuates in price, and can be thought of as a stock that pays no dividends. There are a number of agents engaged in trading. In a rational-expectations model, we would need to specify the utility function of each agent, and from that we could deduce what position it wants to hold --- how many shares of stock it wants to own --- in any given state of the world. Here instead we specify for each agent a behavioral rule, which computes a position as a function of certain data about the world. There is no particular reason for this rule to be optimal. Behavioral rules have to be stated in terms of positions and not orders, simply because no sane agent wants to take an unbounded position in any given security. (Neo-classical models would represent this as a risk-aversion term in the agent's utility function; Farmer has to put it in by hand, as it were.)

At each time-step, every agent computes what it wants its position to be, and then calculates the order it wants to place as the difference between what it wants and what it has. Orders are then submitted to a special agent, the market maker. In Farmer's models, the market marker has two roles: it matches supply and demand, and it determines the new price of securities. Many real markets, such as the Chicago Board of Trade, feature people who take on this job; we'll see why they might presently; for now, let's look a little closer at each role.

Markets are said to "clear" when supply equals demand; in this case, when the sum of the buy orders equals the sum of the sell orders. Equilibrium markets always clear; and a common assumption in modeling is that no trades happen until a market-clearing price is found. This is not how markets work nowadays (though it was how some financial markets worked in the late 19th century, when the foundations of modern economics were laid). One of the jobs of the market maker is to ensure clearing, by either buying up shares when there is an excess of supply, or by selling off shares when there is an excess of demand. (The latter can force the market-maker to take a negative or "short" position.) The other function the market maker performs is to adjust the price at which the stock changes hands. This is, again, modeled as just a behavioral rule (rather than a reasoned consideration of what would benefit the market maker)-the "market-impact" or "price-impact" function, which says how the new price depends on the current price and the net demand for the stock. Even if the rule isn't optimal for the market maker, it's still plausible that the price should rise when demand exceeds supply, and fall under the opposite circumstances. A convenient, but not particularly realistic, price-impact function is that the logarithm of the ratio of the new price to the old price should be proportional to the size of the net demand. This is called the "log-linear pricing rule."

Once we have a price-impact function, and once we assign a strategy function to every trader, we've essentially specified the model, and can watch its dynamics unfold. Three kinds of strategies have been studied in depth so far. The first and simplest are "users" : they buy the stock at one time and sell it at a fixed later time, regardless of price. (Think of people saving for future expenses.) Next are "value investors" : they have some estimate of what the stock is really worth, and want to hold a positive position in it when it is under-priced, and a short position when it is overpriced. The simplest such strategy tells them to take a position proportional to the value minus the price; surprisingly, in a market consisting of value investors of this type, price does not track value. There are value strategies which do so, especially ones where only changes in the mis-pricing above some threshold lead to changes in position. These strategies also lead to fat tails, and to clustered volatility.

The third class of strategies are trend-based rules or "technical trading" strategies, which set their position based on the recent history of price changes.

A market containing a plausible mix of value and trend investors, fed realistic value data, produces mis-pricing reminiscent of what's seen in actual markets, and the main statistical features --- the fat tails and the clustered volatility --- are also in at least qualitative agreement with reality. This model is, however, much too crude to be used for forecasting, or for further efforts at parameter estimation to be worthwhile; the point is not to predict what the Nasdaq will do next week, but to gain at least some insight into how markets work in general.

Now that we have several kinds of strategy in the model, it's natural to wonder how well they do relative to one another. It turns out that, given log-linear pricing, the (average) profits of each strategy can have a "pairwise decomposition," meaning they can be found from calculating how much money the strategy makes from all the other strategies in the market (including itself), and adding. That is, if there are three strategies, A, B, and C, A's profits are a sum of how it would do playing against itself alone, how it would do playing against B alone, and how it would do playing against C alone. For other pricing rules, pairwise decomposition is in general not possible, though it may still be a good approximation. (That is, the effects of interactions of three or more strategies may be small.) Within each pair, A will profit from B if it disagrees with B, or anticipates what B will do, or, preferably, both. (More exactly, the profits are proportional to the correlation between A's position now and B's position at the next time-step, minus the correlation between A's position now and B's position now.) It is not enough to be contrarian; you must also be right. This means that a strategy will not make money playing against itself; rather the market-maker will. (In these models, the market maker almost always turns a profit in the long run.) Notice that all this has to do with the profits or losses of a strategy; an agent following that strategy will take a share of that profit proportional to the size of its position, its capital.

Given the pairwise decomposition, we can write down equations for how the capital of different strategies will change over time. Remarkably, these equations have exactly the same form as the Lotka-Volterra equations of ecology, which describe how the populations of interacting species will change. The flow of money from one strategy to another corresponds to that of energy and resources in ecology, and one can arrange strategies in a trophic web, showing which ones "feed" on which others as one can do with species. "User" strategies, not surprisingly, tend to be at the bottom of the food chain.

One of the features of the Lotka-Volterra dynamics is what biologists call density-dependence, and economists non-constant returns to scale. For any strategy, there comes a point where the extra profit made from scaling up one's position is more than offset by the reduction in profit due to your own order's effect on prices --- "market friction." That is, profit increases with capital up to a certain point (analogous to the carrying capacity in ecology), after which it declines towards zero (i.e., returns to scale are diminishing). Blindly reinvesting your profits actually diminishes them in the long run; ideally, agents would limit the size of their position to that which gave maximum profit and would try to hold themselves just at carrying capacity. As Farmer notes, "In my experience as a practitioner, understanding market impact well enough to accurately limit capital is a difficult statistical estimation problem that even the best traders have a difficult time solving," and it's extremely implausible that real traders do maximize their profits, much as they might like to. If several agents follow the same strategy, total profits would be maximized by holding the total capital invested at the carrying capacity, but this is not to be expected either in Farmer's models or in a rational-expectations equilibrium.

In a rational-expectations model, any pattern in prices will be noticed by the agents, and if they can make money by exploiting it they will, tending to eliminate the pattern in the process; this is part of what leads to efficient pricing. In Farmer's models, it's perfectly possible for a pattern to persist, just because none of the agents has a strategy which can detect that pattern. If there are strategies that are sensitive to it, then whether or not it will be exploited away depends on how many agents have the right strategies, and how much capital they devote to trading. A single profit-maximizing agent will generally cut the size of the pattern in half, but not eliminate it; only if the number of agents is large will the pattern disappear.

The idea that market economies resemble ecosystems has been around for a long time, but Farmer's work is one of the first (if not the first) to make the analogy detailed and concrete. One current direction of his research is to add evolution on top of this ecology, to allow the strategies followed by agents in the market to change over time, connecting this work to the extensive traditions of research on evolutionary game theory and evolutionary economics. Other open directions include modeling more realistic strategies, the effects of including a more detailed "real" economy as a determinant of value and cash-flow (currently the real value is simply another random walk), and questions of efficiency. Farmer estimates that the real time-scale for efficiency in allocation (as opposed to pricing) is on the order of several years.

Since we've given the financial markets a great deal of power over our lives, it would be comforting to think them incapable of erring, or at least of making large errors in which they persist for a long time. But once we give up the belief in rational expectations and equilibrium, we loose any reason to think that markets are _optimal_, that they do their jobs perfectly, or even close to perfectly. What the research of Farmer and others shows is that the actual facts about markets can be explained by the far-from-equilibrium behavior agents "of very little brain". But the justification for markets should never have been that they are the best of all possible mechanisms of allocation. Rather, given that all that's available to make decisions are human beings, creatures inevitably driven by some amalgam of greed, guesswork, haste, half-digested experience, inaccurate theories, fixed ideas, misunderstandings, knee-jerk reactions, superstition and, of course, testosterone and cocaine, letting them haggle works better than we have any right to expect. What research like Farmer's promises is an understanding of the real causes both of market success and of market failure. Whether the new knowledge will give us ways to eliminate causes of failure, or will just give us a better idea of how these vitally important creations of ours work, nobody has the least idea, but finding out will be, at the least, interesting.