Stock Market AI
The other method is to simulate the end result of the stock price, based on a set of input parameters. The simplest equation you would define in this scenario would be a random walk that is independent of the inputs. Essentially though, you might find it easier to simulate the first derivative of the market and then use that to adjust the current price. For example, having lots of sellers and few buyers tends to drive prices down, so you could add a negative factor to the market derivative. However, if the company just announced a merger with a blue chip company, that might drive their share price up. Although, if the merger was a weak attempt to shore up prices of the blue chip, which have been falling rapidly of later, then that might actually pull the price down. Get the picture?
If you want to look at investments besides shares, like options for example, then you can actually model them with known equations. The Black-Scholles equation is a good stochastic differential equation for modelling options prices, although it does have it''s downside... it actually caused the stock market crash of 1987 because of its erroneous pricing estimation!
There are several people within the forum here who can offer you advice based on games they have written/are writing that involve these ideas. InnocuousFox is one that comes to mind.
If you want more detailed mathematical descriptions, let us know. I would be happy to give further details if you want them.
Cheers,
Timkin
1. Generate random walks for each of the following: the whole market, each industry, each company.
2. Generate a stock''s price by computing a weighted sum of the market, industry, and company walk values. The weights are different for each company.
I think you could make your idea work, but I it would be very difficult to make it work well, and it would be very difficult to control. How often is there good and bad news? How does the news affect the traders decisions to buy and sell? What makes prices move in the absence of news? How do you control how much a trader buys and sells?
If you want to accurately model the conditions that cause price movements, forget it. People have yet to figure that one out.
Still there are a number of factors which can make a share worth to buy. One factor is the real value of the company divided by the number of shares. Another factor is if the company is growing, because it can lead to increased future profits. Of course this is not as simple, the human factor is the greatest one. The market can behave with a totally irrational flocking behaviour, once the price of a small company start moving upwards. Nothing might justify a higher share price, still it may sky-rocket in couple of days due to speculation.
I am myself going to make an attempt on an economic simulation sooner or later. I just need to narrow down the model first, I can''t possibly simulate the whole world accurately. Even though it is that I want to do .
What I would suggest is either a 3 tiered approach or a 2-tiered one. In either one, each company would have a collection of 1-n weights of indicators that it is affected by or relies on as well as an industry that it is a part of. You would create random EVENTS that would appear in the news. Each event would carry with it a collection of positive or negative effets on one or more of the indicators. When an event is generated, it would then affect the related companies in a rainbow of different ways. For example, news that crude oil prices are going up would affect the oil and gas companies to some extent, and affect the airlines, the transportation industry and even manufacturing and retail because of higher fuel costs. If it gets too out of hand, it may even affect the tourist industry because less people are traveling.
In the 2 tier one, you would create random news events that affect the company stock prices directly. In the 3 tier model, you model traders that have different perceptions and preferences and manage portfolios of your stocks. The events trigger their perceptions and reactions, then they buy and sell the stocks accordingly. In the former, the price is directly affected. In the latter, the price is indirectly affected - and is much more of a bitch to debug and balance... however, it has the potential to be more realistic.
If the stock market is in the forefront of this game, you can justify going to these lengths. If it is just a background part of the game, model it on simpler things like the random numbers.
Dave Mark - President and Lead Designer
Intrinsic Algorithm - "Reducing the world to mathematical equations!"
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
this is a 2 tier system in a 3 tier system I would simply have "agents" which take the news and then distribute it differently throughout the effected companies.
did I understand your method? it sounds interesting.
thanks,
I must''ve told you a million times, don''t over-exaggerate.
InnocuousFox, your description of a 3-tier model was exactly what I was planning on handling. One of the major concerns I have was how to handle the news. Exactly how far should the simulated stock market go? For example, you said a raise in crude oil prices. In turn gas stations may reflect this by raising the price of gas/liter. Now is that to say the news should go so far as to specifying the new prices for goods and services which in turn effect people’s spending and in turn effecting company revenue or can the market itself be simulated by other simpler means? Preferably where one does not need to go as far as specifying the goods and services.
Also, is it wise to use a GA with an ANN to model the trader agents? I was thinking about training some agents with various differences. Like make some wealthier than others or have some agents think, where thinking is handled at the GA level. Their fitness scores will return better results (through applying statistical mathematics) versus others (without any special mathematics) that would obtain better trade results slower, if any at all. Could this make for a proper, realistic environment?
Thanks for any tips/info.
Nathaniel Meyer
http://www.nutty.ca
In the 3-tier model, the actual price change would be done by the traders, so that the news figures would only be a suggestion that would be filtered by the traders'' perceptions. Some may underestimate, some may panic. Each of their input will affect their position on buing, selling and holding. In turn, as the price changes, it would tend to triger other traders. For example, a particular trader may not perceive the value of a news item, but would later be spurred into action by the falling price - and perhaps extend a slide of that stock on a sell-off. In turn, another trader may now perceive the stock as a good value as the price gets lower and decided to buy. The news items are only spurs to kick things around a bit... a lot of the trader reactions are going to be to other traders.
Dave Mark - President and Lead Designer
Intrinsic Algorithm - "Reducing the world to mathematical equations!"
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play
"Reducing the world to mathematical equations!"
You would have three REAL numbers that would indicate the health of a particular stock. Market stregth, as in the strength of the economy as a whole, Industry strength, as in the strength of the industry, and company strength. These numbers would reflect current economic conditions.
You would also have duplicate SPECULATIVE numbers. The speculative numbers would be a semi-random indication of what the future may bear.
The real set of values would only be changed by random events. ie: your news events, quaterly reports, mergers, etc... The speculative set of numbers would actually be affected by the market itself. ie: if lots of people buy stock a, then the speculative value of a would increase. If lots of people are buying tech stocks, then the speculative value for the tech industry would increase. etc..
Stock prices would be in no way tied to either the real or speculative values. They would be determined just like in the real world: asking price. The catch is that asking price would be determined by a function of the real and speculative numbers.
By this way you could create certain types of investors. For example, a conservative bank may not pay much attention to speculative figures, but would love to buy a company who is under valued based on it''s real figures. Conversley, a high-risk mutual fund might be interested only in the speculative value of a stock, and invest accordingly.
Depending on how your write you app, speculative bubbles would hopefully emerge, and your stock market would be very interesting. If not, you could always hard-code them in.
Good luck,
Will
> simulating a stock market.
What role does the gamer take in the game? Entrepreneur? Marketer? Trader? Banker? Does it need multiplayer capabilities?
I played a few of those games, and stock prices played a different role in them and thus were computed differently.
MarkStrat (by StratX) used a market share approach to determine sales and profits correlated with an artificial stock price index. A pre-canned inflation index shook the COGS a bit, and the market segments had initial vectors on the MDS map; the market dynamics moved them around. The simulation ''game'' is used as a teaching tools for marketers. It is a turn-based game where the simulation took a few hours to compute between turns because it used a few million buyers spread on a few hundred retail outlets and each had varying tastes and budgets.
Startup2000 (by MonteCristo Simulation Games) used a pre-canned set of events that drove the market segments, and it also used a market share approach. The stock prices had little influence on the gameplay except in later stages of the game where a strong stock price helped to reduce the financing costs.
Capitalism II (by Ubisoft/Trevor Chan) is using some form of complex dependency graph where technology improvements change the rate of consumption and quality, and each manufacturing / retailing node has a weighted set of inputs that were connected to other nodes; ultimately, the graph''s terminal nodes ended up being natural resources or imports. That determined the costs of goods sold and then each node''s profit. In this game, you not only control manufacturing and retail, but you can also invest in the stock market and thus influence stock prices. Stock prices seemed to correlate with profits, stock trading and some random speculation factor.
-cb