Archived

This topic is now archived and is closed to further replies.

medovids

Stock market AI

Recommended Posts

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?

Share this post


Link to post
Share on other sites
the stock market is very complex... even the "experts" who invest and talk about it don''t really have a clue. if they did, they''d all be rich and the stick market would lose it''s blackjack appeal (at least as far as i am concerned). so, no matter how deep into the subject you delve, there will still be a big chunk of random thrown in there.

--- krez (krezisback@aol.com)

Share this post


Link to post
Share on other sites
Scientific American had an article a couple of years back related to mandelbrot sets and stock market patterns. Depending on exactly what you want to do with the data, you might be able to generate data using some of these techniques (?)

Share this post


Link to post
Share on other sites
hmm, this is probably off topic, but i recall hearing about a person who used neural nets, or perhaps another type of AI, to analyze the stock market and try to predict what will happen next (in order to make money). from what ive heard (and we should all know about rumors) he did pretty well.

anyway, just a story i heard, i dont even know if its true. lol


 - jeremiah
 http://fakemind.com

Share this post


Link to post
Share on other sites
To sum up, the stock price will change based on what people are willing to pay for it. If people want it, they will be willing to buy it for more than it is currently listed... assuming someone is willing to unload it. If you want to sell, and no one is buying, you may have to sell it for less and the price would then fall. How much? That depends on the who is willing to pay/part with what amount. It''s all an excercise in human psychology and perception. Model it? Woo hoo... that''s a rough one. Feel free to contact me (my email is dead until Wed. 16th) if you would like some more input on this.

Dave Mark
Intrinsic Algorithm Development

Share this post


Link to post
Share on other sites
I suspect we would need to ask the questions...

Are the players going to be involved in buying and selling? If so, how many players? Do you want their transactions to affect the price? Are you going to be creating outside stimuli like economic indicators or company press releases? Those certainly affect the perception of a company''s future and therefore its price. We need more info on what it is you are trying to do.

Dave Mark
Intrinsic Algorithm Development

Share this post


Link to post
Share on other sites
Just thinking aloud:

I wonder how closely the game AI should model the real stock market... In the real world, you worry about real money and the consequences of your actions. This does at least two things.

1. You''re probably much more conservative than you would be in a game. (Even if you''re high risk, you''re probably higher risk in the game)

2. You''re willing to read/study a lot more than you would be willing to in a game. Reading press releases is generally fairly boring. Reading fake press releases would be extremely boring (at least for me).

Having said that, perhaps the AI should be much more wild than real economic theory. Perhaps the dynamics of market activity and price would be completely different if you were aiming for fun vs. reality.

Again, just thinking out loud...

Share this post


Link to post
Share on other sites
quote:
Original post by Torn Space
If you just want the price to move up and down, you can do something like this for each stock:

For every day, roll d100:
0-30: stock starts a downward trend (-1% to -5% per day)
31-70: the trend continues
71-99: stock starts upward trend (+1% to +5% per day)

That''s overly simple, but it''s a good start.


Unfortunately, that would not create stock price movement which mimics the way real stock prices move. Your method would have little chance of creating double bottoms and double tops, or trendlines.

A double bottom is where a price bounces off of a particular price level where the index or stock bounced before, say three weeks ago. Such patterns look like a ''W''. The psychology of the markets create these patterns. Investors see that investors were not willing to let the price drop below a certain price before. They believe that price is a ''fair'' price. They refuse to purchase at a higher price so let it drop. It does, and then the crowd rushes in to buy where it bounced before, creating a self fulfilling bounce.

Trendlines are weird but very common. A stock price advances, and then drops about two thirds of its advance and then advances again to a new high. This will repeat for several times. At each time the price dips and advances again, you can connect these dips with a diagonally advancing straight edge. It is really uncanny.

New highs indicate strength in a stock. When a stock breaks an old high, it has destroyed the psychology of what it was previously thought to be its maximum value. Investors often buy stocks making new highs, because they have ''cleared'' the way for advancement.



___________________________________

Share this post


Link to post
Share on other sites
A familiarity with the internal mechanisms of the markets would go a long way towards setting up a simulation of one. The NASDAQ uses a market maker system. Some reading on NASDAQ market makers will facilitate your understanding of them. The big board (NYSE) uses specialists. Regardless, an understanding of the bid & ask is necessary.

___________________________________

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Don''t let these guys fool you. The stock market is very simple. It''s extremely random. Stocks will move up or down randomly every day, with a slight bias toward moving up, since stocks generally gain in value over time (At a rate of about 8 or 9 percent or year on average)

You should treat most of it as random data, though. Most of the ''patterns'' in the stock market are just human attempts to impose patterns on a random phenom.

Success of fundamental anaylsis, the neural net kind of thing mentioned above, and the other tricks in the bag are just a consequence of the upward trend of the stock market. I could let a blind monkey with asthma choose my stock purchases and get a good return.

Share this post


Link to post
Share on other sites
I guess it''s important to remember the purpose of the stock market: as a way for companies to raise capital - generally to fund things like expansion & therefore increase the the capital value of the firm & [hopefully] your stake.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Don''t let these guys fool you. The stock market is very simple. It''s extremely random. Stocks will move up or down randomly every day, with a slight bias toward moving up, since stocks generally gain in value over time (At a rate of about 8 or 9 percent or year on average)

You should treat most of it as random data, though. Most of the ''patterns'' in the stock market are just human attempts to impose patterns on a random phenom.

Success of fundamental anaylsis, the neural net kind of thing mentioned above, and the other tricks in the bag are just a consequence of the upward trend of the stock market. I could let a blind monkey with asthma choose my stock purchases and get a good return.


Run along, son. The boy has a serious question... let''s give him a serious answer. As for your theory? Imagine all of the independant, random events that lined up all in a row for Enron to go from $90 to 35 cents in a year. Wow... that''s like flipping tails 3000 times in a row. Aparently the sightless asthamtic simians were on strike this past year.



Dave Mark
Intrinsic Algorithm Development

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
I could let a blind monkey with asthma choose my stock purchases and get a good return.


Sure. The stock market was great in late ''99. That''s why I realized a 1100% return in 6 months with a portfolio of about 8 stocks making new highs. Undoubtedly anyone anywhere (including your blind monkey) would have realized the same return.



___________________________________

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
How do you explain the general failures of mutual fund managers, then. Surely some trained professional, somewhere, would be as good an investor as you, and generate those kinds of returns reliably?

That doesn''t happen. Why? Because the stock market is impossible to predict. Sure you got great returns, but you are a statistical outlier, not the norm. Keep investing long enough and your returns will regress to the mean.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Because the stock market is impossible to predict.

Just because it seems to go over YOUR head doesn''t mean that it is impossible.

quote:
Keep investing long enough and your returns will regress to the mean.


If that were the case, all of the major market indexes would be exactly where they were 20, 30, 40... even 70 years ago. Your statement is foolish. Methinks you better retreat back to threads that are in your area of expertise... whatever that may be.


Dave Mark
Intrinsic Algorithm Development

Share this post


Link to post
Share on other sites
There is absolutely no need for ANYONE to make personal comments about another member of this forum. I''m not singling out anyone in particular, but this thread is degenerating fast. Either clean it up or I will close it.

Timkin

Share this post


Link to post
Share on other sites
Here is an idea for a simple stock market simulation, since that was what was asked for in the original post...

The buying and selling of stocks works on an open market place principle. People are free (there are some restrictions but we wont go into them here) to bid and ask whatever they like for stocks. An broker places stocks into the market and asks for a price per share. Other brokers bid to buy the share. Many modern stock exchanges today run on computers, like the ASX in Australia. The computer matches buyers and sellers in a time critical order (so oldest bids are matched with oldest asks. Usually what you see if you look at a days trading of the stocks of a particular company is that most people buying are bidding less than the stated market price, while most people selling are asking more than the stated market price. There is another option to buying or selling of shares (no pun intended) and that is to bid or ask at the current market price. This normally results in a quick trade as the market price (usually) falls between the average bid and ask prices. The market price is an estimate of the value of each share based on all bids and asks to date.


So, you could make a stockmarket simulation by creating 100 agents and giving them all some cash (don''t give them all the same amount). Have just 1 stock for them to trade in. Create for each agent a different buying and selling strategy (or have groups of investors with similar strategies) and then set them free in the market to buy and sell shares according to their strategies. Watch what happens to the value of the stock as the simulation runs. You''ll notice that either a) the moves to a fixed value and stays there; or b) the price oscillates between several values; or c) the price fluctuates apparently randomly between many states. How the market performs depends on how you tune it and the complexity of the bid and ask strategies. You''ll need to play with it a little to get it into state ''c''.

Holler if you need more suggestions.

Cheers,

Timkin

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by InnocuousFox


If that were the case, all of the major market indexes would be exactly where they were 20, 30, 40... even 70 years ago. Your statement is foolish. Methinks you better retreat back to threads that are in your area of expertise... whatever that may be.



You misunderstood. I said that the _return_ will regress to the mean. This is different than saying stock prices do not move. The average return on the S&P is 9 or 10% per year. Keep investing long enough, and your life time returns will approximate the average stock market return more and more.

With that in mind, do you have a non-hostile response to my argument? I''d really love for someone to prove me wrong, since I would then have access to a system better than the buy-and-hold and index fund strategies I currently use.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
How do you explain the general failures of mutual fund managers, then?


Easy. They offer a service 365 days a year to invest your money in investments which follow the guidelines of their prospectus. On the other hand, I leave the stock market for large periods at a time and dive in fast and furious with heavy margin risk for short periods of times.

___________________________________

Share this post


Link to post
Share on other sites
THANKS GUYS,

I got some very good answers! Although I think I have some understanding of how a stock market works in real. I wanted to know how do I program the way it works in real and I didn''t really get much help with that.(Allthough a few suggestions were very interesting!)

Share this post


Link to post
Share on other sites
quote:
Original post by medovids
I wanted to know how do I program the way it works in real and I didn''t really get much help with that.(Allthough a few suggestions were very interesting!)


Well, isn''t understanding the mechanisms of the market, the motivations of its participants, and the appearance of the market 90% of your battle?



___________________________________

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
With that in mind, do you have a non-hostile response to my argument? I''d really love for someone to prove me wrong, since I would then have access to a system better than the buy-and-hold and index fund strategies I currently use.

I''m just trying to figure out how your opinion that the stock market is not unlike a random number generator will help the poor chap who is asking the question.


Dave Mark
Intrinsic Algorithm Development

Share this post


Link to post
Share on other sites
quote:
Original post by medovids
Well yes, but I still need the other 10%.I want to find a simple yet effective way of doing this!

THAT you won''t find. At the very least, you would need to simulate hundreds if not hundreds of THOUSANDS of individual perceptions and personalities... for THAT is what moves the market.


Dave Mark
Intrinsic Algorithm Development

Share this post


Link to post
Share on other sites