Market Making

“Money is only a tool. It will take you wherever you wish, but it will not replace you as the driver.”

— Ayn Rand

How do you simulate price change? How do you make prices go up and down the way that markets do? Answering this question was my first great task before I could even start building a game that included a market.

It can seem like a trivial question if you start with the assumption that the answer is simple: the market is random. If it wasn’t, then everyone would be rich. Sometimes it’s up, sometimes it’s down. You never know. And while this is true, it’s not the whole truth. To view the market this way is to forget that it is not made up of products or services or even money. That’s just the stuff passed back and forth. The market, on the other hand, is created by, and continues to exist because of, and consists 100% of… people. And people, all people, unless making a concerted effort, exerting great focus to stay random, making randomness their full-time job in fact, will slip into a pattern, a routine. And even then, most of what they do would still be fairly predictable. We are all on autopilot for an alarming percentage of our waking hours.

This became immediately obvious when I used random numbers to be my first “version” of a stock market. It was insane. One year it was up 50%, the next down 80%, then back up 90%, then down another 70%! A roller coaster ride that would rattle even Warren Buffett to his core. Investors would run screaming. Entire market segments would be unemployed. Wall Street would be losing its mind.

So how does a programmer simulate a market? That’s easy, just grab historical prices from the internet, plug, and go. But here was the rub: even a simulated market is still made of real people. The real people in this case are the players. It wouldn’t be long before they figured out the pattern, checked it against history, figured out where it was headed, and let everyone else know.

I slept on the question for a few nights. The mechanism behind a price is so incredibly complex. It’s instantly updated by innumerable factors just as fast as information passes between participants. I could code for years and not create a truly realistic market. Then one morning it occurred to me: I don’t have to. I’m not an economist or financial genie. I’m just a programmer. And it’s just a simulation. It needs no brilliant predictive calculation. A simple approximation would suffice. So I settled on a balance between the two: random and pattern.

We as programmers need to start at the end: our goal needs to be known before we can design a solution to reach it. So I made the assumption that the market would, on average, go up, say, 7% per year? This seemed kinda right. I’d heard some stat like that before. Then I injected some randomness, and made each year a random number that could go above or below that 7% by a fixed limit, say, 30% above or below that. I called that upper and lower limit “volatility”. So, it could go as high as 37%+ or as low as 23%-. But over the long run, it would “average” close to the “actual” market, of 7% per year.

But I didn’t stop there. Programmers and mathematicians use a tool every day that is so incredibly powerful. The first time I used it I reveled at the–literally endless possibilities (within the laws of physics, of course): the variable. You can punch ANY number in and the computer will just go with it. And remembering that a game is for its players and software for its users, I decided to hand over the tool to the People: to let the user decide what the market would do. Why should I be the one to decide? So when the game host sets up a new game, he or she decides the “rules of the market” and plugs them into these variables, with some helpful-but-not-ironclad suggestions if they want some semblance of realism, of course.

Thus, a market was made.

Leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website at
Get started
%d bloggers like this: