Saturday, 30 August 2014

Markets, stocks simulations and Markov chains

This article is some sort of continuation from this one.

Our previous model for stock simulations did not take in account the following idea:
when a stock (or the market) is going up, then it should be (intuitively) at least, more likely that it will continue to go up. Or at the very least, as it is the case for a football game, it does not feel right to believe that the probability of either of the two possible outcomes is exactly 50%.

The idea behind Markov chains is really versatile, we can apply it also to the markets.
With a “bit” of study (I’m being sarcastic here), you can come up with something pretty complicated like this, however, the model I’m going to show here is much more naive and easier.

Suppose a Markov chain with two states, market up and market down. Once you found the probabilities of each state, you can easily simulate a random walk (based on a Markov chain of course).

Here is the code for this model:

The graphs below represent respectively, 2, 200 and 500 random paths.


2 random walks
2_random_waks


200 random walks


200_random_waks


500 random walks


500_random_waks


Hope this was interesting.





Disclaimer
This article is for educational purpose only. The numbers are invented. The author is not responsible for any consequence or loss due to inappropriate use. It may contain mistakes and errors. You should never use this article for purposes different from the educational one.

1 comment:

  1. Buy Speakers at Cheapest Price with Amazing Quality
    https://seventysevenstyle.com/collections/wireless-products/products/touch-bedside-lamp-night-light-bluetooth-speaker-rechargeable

    ReplyDelete