🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Stock market AI

Started by
53 comments, last by medovids 22 years, 5 months ago
quote: Original post by medovids
Thanks,
But how would I generate so many dif. personalities?


I would think the creation of the different personalities to be as simple as creating simulated people with emotional, sociological and intellectual attributes; similar to what is done in the game The Sims but on a larger scale.

I have started working on something similar and in this I have created a few C++ classes to create my simulated people (from now on referred to as Citizens). In my simulation, the first 4 citizens are created from scratch and the remainder are paired up and created from the first 4. This allows for mutations. I am using the MercTwist to generate random numbers for the attributes but I have found the creation of citizens from a set to be a better representation of society (in my game the citizens also have political attributes and studies have shown that parents impact the child’s political viewpoints).

After you create some citizens you would then update their ‘feelings’. When would you do it? Good question – some fixed interval might work, but in a stock market simulation why not just randomize when everyone’s ‘feelings’ change. Better yet, if you divided the citizens into regions and selected a region that would drive the other regions (like NY and LA drive middle America) that would be more realistic.

I hope I have given you some ideals – and if you need some example code I might consider showing you how I create my citizens but the rest would be up to you.



Dave "Dak Lozar" Loeser
Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
Advertisement
quote: Original post by Anonymous Poster
Hmm? Seems pretty obvious to me, but then I was writing it. If the stock market acts liks a random number generator to all appearances, then a good way to simulate it will be by moving the previous day''s stock prices by some small random percentage up or down. You slightly bias your random numbers toward moving upward, and you''ll produce a decent approximation of the stock market.

Of course, this presupposes that you want to model the stock market accurately, and realism may not strictly be the best choice for a stock market game, as opposed to a stock market simulator.


That''s the point. It is NOT random. In fact, if you were creating the supposed stock market game based on random numbers, then there would not be a significant difference from creating a game where you guess the next random number that the computer will display. If, however, you are wanting the player to have to interpret the factors that go into the stock prices (and therefore the entire market) rising and falling, you have to have criteria that affect the prices and provide them with the information on those criteria.

If the stocks were not a major part of the game but rather something of background interest, your approach would be valid since you are creating something that LOOKS like the market. I think what he is trying to accomplish is to create something that ACTS like the market.

Dave Mark
Intrinsic Algorithm Development

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!"

quote: Original post by medovids
But how would I generate so many dif. personalities?

I think it would not be so important to have the different personalities as it would be to start with the list of criteria that affect the market prices. Each of your stocks (as someone above illustrated) would be affected by one or more of those criteria in a variety of ways. Then, the personalities can be defined by a collection of various scaled reactions to those criteria - that is, what is hypotheticall important to them. If you have 10 different criteria, each with 3 different reactions (pos., neg., neutral) then figure out all the combinations of reactions, you have that many different personalities. (3^10 = 59049)

The tricky part would be defining the curves you use for each criteria affecting each type of stock and the curves for how much changes in criteria affect the different personalities. Game balancing would involve a lot of hypotheticals to see how the various stocks move and people react.

Of course, now I want to design this myself ... (it''s what I specialize in!).




Dave Mark
Intrinsic Algorithm Development

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!"

I Liked the solution of making 100 dif. personalities and let them buy stocks.

I am trying to think of a way to code this simply....

Different personalities will simply be that different people take different things into account. For example one person might really follow and believe the news so if he were to see that a company made a new gadget he might right away buy lots of stocks. Another person wouldn't care about that he would concentrate more on the stock's pattern. Before I start I throw in a few factors like the above news report. Than my people will go out and buy stocks. I will get a rating rated 1-100 of this stock from each person then I will adjust prices accordingly.

What do you think?

Edited by - medovids on January 16, 2002 11:03:03 PM
It seems to me that the argument about whether the market can be modelled by a random number generator issues from a difference of perspective. On the one hand the AP is suggesting that a random sequence would look like a stock price sequence while on the other hand InnocuousFox is suggesting that the market is not random. You''re both wrong and you''re both right!

Certainly, the market is not random. The market price is the result of actual trades of shares and some specific rules. The market price is one factor in the decision making process of buyers and sellers. Countless other factors drive these decisions so that to predict the market exactly one would need to know EVERY causal influence between system variables and the value of every variable in the a model of the market and its players, as well as encode the rules upon which buyers and sellers make their decisions.

This is not possible. Indeed, it''s not possible for most dynamic systems in the real world. We can however approximate the system with a model that attempts to explain the approximate motions of the market price. If the model is a good one, then the unexplained residual variability in the market price may approximate a zero mean random process. In which case, we could use the deterministic model and a sample from this zero mean random process to model the stock price. Alternatively, the variance in the random process gives us an estimate of the uncertainty in the value returned by the deterministic process.

So, given this, it could be said that the stock price is driven by a stochastic process (rather than a random process, which is subtely different). This is what the AP was suggesting.

So, rather than argue over whether the stockmarket is truly random, lets argue over whether the market could be successfully modelled by a stochastic process. At least that argument would have some value!

Cheers,

Timkin
It appears that Medovids wants a little more meat in his stock market meal! Okay then, here some ideas about HOW to model the investors in a stockmarket.

Let''s assume that there is just one stock being traded. The ideas here trivially extend to n stocks.

Each investor must have a perception about the current market value of the stock. Their perception will be that the market price of the stock is: 1) over-valued , 2) fair , or 3) under-valued .

Secondly, each investor will have a risk based strategy for acting in the market. Some investors will be risk-seeking , others will be risk-neutral and finally others will be risk-averse . Most people are risk-neutral with small amounts of money; are risk-averse with larger amounts when they have a positive wealth pool; and are risk-seeking when they are in debt. A good example of the latter is people with gambling addiction. They are prepared to keep throwing good money away on the slight chance of a big win to clear their debts.

I''ll leave it up to you to think about how you might work these ideas into a simulation of investors in a market. I might offer some more ideas about this tomorrow.

Cheers,

Timkin
Another characteristic of the "artificial trader" (perhaps "AT" from here on out?) would be that of how quickly and often he would trade. Someone with less likelyhood to pull the trigger would be one who is in it for income... a long term investor. One who would be more likely to take his 10% gain and switch to another "hot stock" would be termed the "day trader" type.

One thing I am concerned about prior to proceeding further is what the actual function is that Meds is looking for. Is he looking for something that simulates the stock market fluctuations so that the player can buy and sell in the hopes of making money or is he looking to simulate what we are discussing... that is, the AI that would go into choosing stocks, etc. We may be taking the wrong approach and doing a lot of very granular work for nothing.

Dave Mark
Intrinsic Algorithm Development

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!"

quote: InnocuousFox wrote:
One thing I am concerned about prior to proceeding further is what the actual function is that Meds is looking for. Is he looking for something that simulates the stock market fluctuations so that the player can buy and sell in the hopes of making money or is he looking to simulate what we are discussing... that is, the AI that would go into choosing stocks, etc. We may be taking the wrong approach and doing a lot of very granular work for nothing.


You''re quite right. I''m not sure what it is that he is looking for myself. Medovids'' original post of:
quote: I want to make a stock market game but I am not sure how to make the AI for it. When do the prices go up and when do they go down, how much do they go up by or how much do they go dowm by?
is a 50,000+ feet statement... What is it that you really want to do with the AI medovids?




Dave "Dak Lozar" Loeser
Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
I am looking too make a stock market game where you buy the stocks you want and you try too make money!

What I wnat is too make the stock market prices realistic. From what I understood that is exactly what we are trying to figure out.

sorry for the misunderstanding.
quote: Original post by Torn Space
You could also just connect to yahoo or something and download the prices. Can''t get much more accurate than that.


Unless you want it to move at a rate quicker than day to day trading. If you want to simulate all that can happen in a quarter, you need to come up with your own simulation. Otherwise, a 15 minute delayed quote would provide real prices and real news via real events. Your job would then be to provide a simulated trading field for your players.



___________________________________

_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.

This topic is closed to new replies.

Advertisement