# Is it possible to build a computer model to simulate a market to prove whether efficient theory is true or not?

I know this may sound stupid. But I had this idea and wanted to try it out for a college project. Has this been done before? If and what's wrong with this idea?

• There are things called "agent based (or multi-agent) simulations of the stock market", but they generally try to reproduce other interesting features of markets, not just seeing whether the market turns out to be efficient or not, which may be a little too trivial (too easy to make it come out efficient or inefficient depending how you do it, so it doesn't really tell you much). Some early work on such models was done by Prof. Blake LeBaron of Brandeis University. Generally the question "are markets efficient or inefficient" is seen as too simple nowadays... reality is more complicated. Apr 19, 2020 at 19:37
• Generally speaking, the financial literature seems to have converged on the idea that markets are relatively efficient. When people talk about behavioral biases, it usually comes hand in hand with a limit to arbitrage argument. The answer to "why" isn't stupidity weeded out is that it's not always worth it to eliminate it all the way to zero. And, yes, it's more interesting to think about the consequences of deviations from exact efficiency than about how far from exact efficiency we stand. Apr 19, 2020 at 19:57

Let's begin from the start.

At its core, market efficiency is a statement about the compensation for risk embedded in asset prices. So, you can think of this issue as involving 3 quantities: (1) the price that you observe, (2) the price that you should observe and (3) the distance between them. The fundamental problem with trying to test for market efficiency is that you only have (1), so you need to build (2) to check if (3) is zero as the theory predicts. That point was made by Eugene Fama back in 1965. He said that a test of market efficiency always is a joint test of an asset pricing model (what gives you (2)) and of market efficiency (the fact that (3) should be zero).

You're sort of a facing a Duhem-Quine type of problem here. If you run your tests and reject the hypothesis of efficiency, is it because markets are inefficient, because your asset pricing model is wrong or a little bit of both? In essence, when you say that a market is inefficient, what you're saying is that there doesn't exist any model, current or future, that could possibly rationalize the data while respecting the hypothesis of market efficiency... That's hell of a strong statement to make given how little of the possible space of models we have explored so far. The reason I bring this up is that no matter how you approach this issue, you will run into that problem. The best response I have seen thus far comes from Giglio and Kelly (2018): they show how a large class of models for a wide range of derivative instruments is strongly rejected by the data, that a relatively wide array of potential "excuses" we could make to rescue the absence of arbitrage fail while a behavioral model does match observed statistical patterns. It's not a perfect way around it, but going beyond just noting that an asset pricing model is rejected by the data is a good step in the right direction.

Now, let's turn to your idea.

Yes, this has been done in one way or another by many people, although the point isn't to prove or disprove the efficient market hypothesis. There is an entire literature in financial economics on agent based simulations where traders, market makers and other players are assumed to follow simple rules, as opposed to responding optimally. It can create extremely intricate dynamics. In those types of simulations, we generally have no idea if arbitrage opportunities exist.

One thing you could do for a quick project is to find the simulation codes of someone else that would allow you to simulate the price of a stock. Any code will do. Now, you go find stock market data: pick, say, 10 stocks and the S&P500 at daily or monthly frequency. Then, what you want to do is to run a test of the CAPM and collect diagnostics of how well or poorly it fits the data. Then, you will do the same, but using simulations. You run the simulations to create 10 artificial stock price series and you can naively assume that your artificial S&P500 is a simple average of them. On those 11 simulated time series, you run exactly the same tests and model diagnostics. You repeat that say, 10 000 times. Once you've done this, you can check how well your artificial market mimmicks the real market. This is a very naive way to do something like you want to do, but it's not bad to start simple. Unless you're writting a PhD thesis or are looking to publish a paper on this, you don't necessarily want to spend the time it would take to make all of this as kosher as possible.

• Stephane: Interesting answer and take on things. But, if one could build a model that profits ( above the risk free rate ) after transaction costs consistently, isn't this a proof of market inefficiency ? I agree that proving market efficiency is difficult but it doesn't seem terribly difficult to prove market inefficiency. Apr 19, 2020 at 21:28
• Efficiency is a statement about the compensation for risk. The issue is not whether you can expect to profit above a riskless benchmark after transaction costs, but whether you could do it WITHOUT taking more risk. The whole issue here is that you don't know how much risk is tied to a trading strategy. You can estimate it if you make assumptions about the data generating process, but you don't see it. By the way, read your statement again: ALL theories that impose the absence of arbitrage allow you to profit above the risk free rate... just hold the S&P500. Apr 19, 2020 at 21:50
• right but there's risk in the SAP500. I should have said little to zero risk but I kind of implied by using the word "consistently". risk is a funny thing though right. Suppose someone consistently beats the SAP500 year in and year out and somehow we compute that he-she did it with less risk. Then, this pandemic rolls around and he-she gets killed just like the SAP500. Does that really mean that the market is efficient ? I don't think so. I'd say that the market is inefficient but even market inefficiencies can get beaten down because of tail events. Apr 20, 2020 at 3:10

Yes. It's possible to simulate markets. It's called Agent based model and you can read more about it on wikipedia:

https://en.wikipedia.org/wiki/Agent-based_model

Basically you assign simple rules to the agents (in our case market participants) and simulate to try to re-create and predict how the markets behave.

An example: By modeling a complex system of analysts based on three distinct behavioral profiles – imitating, anti-imitating, and indifferent – financial markets were simulated to high accuracy. Results showed a correlation between network morphology and the stock market index.

Stefan, F., & Atman, A. (2015). Is there any connection between the network morphology and the fluctuations of the stock market index? Physica A: Statistical Mechanics and Its Applications, (419), 630-641.