# simulation

For simulating stock prices, Geometric Brownian Motion (GBM) is the de-facto go-to model. It has some nice properties which are generally consistent with stock prices, such as being log-normally distributed (and hence bounded to the downside by zero), and that expected returns don't depend on the magnitude of price. Of course, GBM is just a model and no model is a perfect representation of reality. In particular, GBM uses constant volatility, which is clearly at odds with reality. It also doesn't account for jumps, such as those caused by news. In spite of those limitations, GBM is a useful starting point for modeling the behaviour of stock prices. In particular, it's great for building intuition about various finance concepts - notably, options pricing. Normally when we're modeling stock prices, our use case requires running a large number of simulations in order to generate a distribution of possible outcomes. Since such a use-case requires running a GBM simulator numerous times, it can pay to think about optimising code for speed. A small amount of forethought can save a ton of time...

This is Part 2 in our Practical Statistics for Algo Traders blog series—don't forget to check out Part 1 if you haven't already. Even if you've never heard of it, the Law of Large Numbers is something that you understand intuitively, and probably employ in one form or another on an almost daily basis. But human nature is such that we sometimes apply it poorly, often to great detriment. Interestingly, psychologists found strong evidence that, despite the intuitiveness and simplicity of the law, humans make systematic errors in its application. It turns out that we all tend to make the same mistakes - even trained statisticians who not only should know better, but do! In 1971, two Israeli psychologists, Amos Tversky and Daniel Kahneman,[footnote]Readers of the Robot Wealth blog will know that I'm a big fan of the work of Tversky and Kahneman. In fact, I'd go as far to call it the most important body of work related to understanding errors made by the human mind - something that is of obvious interest to traders. Check out Kahneman's "Thinking...

This is the first in a two-part series. Be sure to read part 2 - Practical Statistics for Algo Traders: The Law of Large Numbers How do you feel when you see the word "statistics"? Maybe you feel that it's something you should be really good at but aren't. Maybe the word gives you a sense of dread, since you've started exploring its murky depths, but thrown your hands up in despair and given up - perhaps more than once. If you read lots of intelligent-sounding quant blogs displaying their use of "practical statistics", you might even feel like your lack of statistical sophistication is what's standing between you and algo trading success. If you are confused, you're not alone. The reality is that classical statistics is difficult, time-consuming and downright confusing. Fundamentally, we use statistics to answer a question - but when we use classical methods to answer it, half the time we forget what question we were seeking an answer to in the first place. even sparkles don't soften the knee-jerk angst But guess what? There's another way...