Simple Economic / Stock price model

In summary: I took a graduate financial modeling class, and it was just as BWV said. Geometric Brownian motion is known to be an imperfect model of real stocks, but it's a good start. It's also the model used to derive the famous Black-Scholes equation.If you want to write your own stochastic numerical solver, consider the Euler-Maruyama method. It's based on the Euler method for numerical integration. It has similar properties, too - it's relatively intuitive and easy to code, but its accuracy and stability are pretty bad.I know the standard practice is using the normal distribution for the returns, but extreme movements are much much rarer in that case that in reality.
  • #1
trollcast
Gold Member
282
13
I'm trying to program a simple game with a handful of fictious companies on a virtual stock exchange that is semi realistic with price variations and trends over time.

However I made a quick test using random functions and probabilities to produce the variations but I can't seem to strike a balance between stability (then the price just stays fairly constant and doesn't vary much) or instability where the price goes crazy.

Now its definitely a programming error but instead of guessing at what I need to change to get it to work I was wondering if there were any simple formulae or something that would be adequate to get a semi realistic price variation in the program?
 
Physics news on Phys.org
  • #2
You might want to pick, e.g. daily returns from a standard normal distribution, then apply these to a random starting price to generate realistic-looking returns. To make the returns more like actual market returns, you should alter the standard normal distribution to one with a skinnier bell and fatter tails.
 
  • #3
Use Cauchy distribution for the returns with a scale (gamma) of 1.7, it's the distribution Benoit Mandelbrot suggests.

By the way, will you simulate the volumes as well? I'd be very interested to see your program if you put it with volumes, since I guess then many differences will appear between the modeled prices and volumes and real ones.
 
  • #4
Tosh5457 said:
Use Cauchy distribution for the returns with a scale (gamma) of 1.7, it's the distribution Benoit Mandelbrot suggests.

By the way, will you simulate the volumes as well? I'd be very interested to see your program if you put it with volumes, since I guess then many differences will appear between the modeled prices and volumes and real ones.

How I'm planning to model it is:

I'm creating a class called Company that has a shareprice, buyprice and sellprice (I was going to just work out the buy and sell by going say 1% above for the buy and 1% below the shareprice for sell.

So the program will create a couple of instances of Company and set them a share price.

Now I want to work out how is the best way to move the shareprice on each time step to simulate how share prices vary in real life.

Not sure how I could include volumes into that simplistic model, maybe if I set each company a fixed number of shares?
 
  • #5
Not sure how I could include volumes into that simplistic model, maybe if I set each company a fixed number of shares?

Yes, and if you want it more realistically, put a small chance (like 0.001%) in each timestep that the numbers of share duplicate. I don't know how to model volumes though, I never looked at their distribution...
 
  • #6
The standard methodology is log normal returns/ geometric Brownian motion

http://en.wikipedia.org/wiki/Geometric_Brownian_motion

No one really uses levy stable distributions as the fat tails have an auto correlating component. Stochastic, trending volatility such as GARCH is most typically uemployed
 
  • #7
I think I'll keep updating this thread to show the progress I'm making with this.

Just playing around with a random uniform distribution to start with has produced some quite good trends but its not very consistent:

eg.
attachment.php?attachmentid=57229&stc=1&d=1364518939.jpg


attachment.php?attachmentid=57230&stc=1&d=1364518939.jpg


But the prices are far too volatile and well random to be honest, also there's quite a few runs of it that doesn't produce a good trend as the price just tends to zero.

Its just a quick mock up in python with matplotlib and the 2 different libs just represent 2 different runs of the generator.
 

Attachments

  • eg.jpeg
    eg.jpeg
    27 KB · Views: 742
  • eg2.jpeg
    eg2.jpeg
    24.6 KB · Views: 731
  • #8
BWV said:
The standard methodology is log normal returns/ geometric Brownian motion

http://en.wikipedia.org/wiki/Geometric_Brownian_motion

No one really uses levy stable distributions as the fat tails have an auto correlating component. Stochastic, trending volatility such as GARCH is most typically uemployed

I took a graduate financial modeling class, and it was just as BWV said. Geometric Brownian motion is known to be an imperfect model of real stocks, but it's a good start. It's also the model used to derive the famous Black-Scholes equation.

If you want to write your own stochastic numerical solver, consider the Euler-Maruyama method. It's based on the Euler method for numerical integration. It has similar properties, too - it's relatively intuitive and easy to code, but its accuracy and stability are pretty bad.
 
  • #9
I know the standard practice is using the normal distribution for the returns, but extreme movements are much much rarer in that case that in reality. In an era where we can use powerful computing and our knowledge of Mathematics is vast, I don't see the point in insisting of using a wrong model. The only reason it's still used for option valuation it's because of the properties of the normal distribution, that others don't have, such as finite variance.
Indeed the autocorrelation of the fat tails is a problem about using Cauchy distribution, but you could introduce that autocorrelation when extreme movements happen.
 

1. What is a simple economic/stock price model?

A simple economic/stock price model is a mathematical representation of the relationship between economic factors and stock prices. It is used to predict the future movements of stock prices based on key economic indicators, such as inflation, interest rates, and GDP growth.

2. How does a simple economic/stock price model work?

A simple economic/stock price model works by analyzing historical data and identifying patterns and relationships between economic factors and stock prices. It then uses this information to make predictions about future stock prices based on changes in the economy.

3. What are the limitations of a simple economic/stock price model?

One limitation of a simple economic/stock price model is that it does not account for unpredictable events, such as natural disasters or political changes, that can significantly impact stock prices. Additionally, it may not be accurate in predicting long-term trends as economic conditions and stock prices can be affected by a multitude of factors.

4. How accurate is a simple economic/stock price model?

The accuracy of a simple economic/stock price model depends on the quality of the data used and the assumptions made in the model. While it can provide valuable insights and predictions, it should not be relied upon as the sole source of information for making investment decisions.

5. Can a simple economic/stock price model be used for all types of stocks?

A simple economic/stock price model can be used for most stocks, but it may be more effective for certain industries or sectors. Some stocks may be more influenced by economic factors, while others may be more affected by company-specific factors. It is important to consider the individual characteristics of a stock before applying a simple economic/stock price model.

Similar threads

Replies
24
Views
2K
  • General Discussion
Replies
4
Views
3K
  • General Discussion
Replies
31
Views
8K
  • Programming and Computer Science
Replies
13
Views
2K
  • General Discussion
Replies
2
Views
3K
  • STEM Academic Advising
Replies
4
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
2K
Replies
6
Views
3K
Replies
3
Views
4K
  • STEM Academic Advising
Replies
13
Views
2K
Back
Top