Python for Finance: Are stock returns normally distributed?

Sdílet
Vložit
  • čas přidán 5. 09. 2024

Komentáře • 32

  • @weirdcuteai
    @weirdcuteai Před 3 lety +8

    Hi, thanks for the video! I just want to add that when you using stats.kstest, by default it compares with standard normal distribution (std=1 and mean =0), however your stock returns has different std & mean, so you might want to add args in your function, then the stock return might fit normal distribution better
    for example: ks_stat, p_value = kstest(log_returns, 'norm', args = (mean, std))

  • @yeuyang5551
    @yeuyang5551 Před 5 měsíci +2

    Before doing ks /sw test, did I need to standardize the log return?

  • @vladislavpyatnitskiy
    @vladislavpyatnitskiy Před rokem +1

    Thank you for a great content! I would like to add that there is one more test for normality which is Jarque-Bera test that should be familiar to students who have done econometrics. Therefore, I might suppose that you have completed non-economic major. However, I think it is nice to know other normality tests as well!

  • @sahilharidas4747
    @sahilharidas4747 Před rokem +1

    Great video! Just a bit of nit-picking though: at 13:00 when you subtract the mean and divide by standard deviation, you say that will 'normalise' the best and worst case scenarios when they are instead being 'standardised'

  • @MA-oj8zk
    @MA-oj8zk Před rokem

    For those running into issues plotting the diagrams, replace
    df.Close.plot().update_layout(autosize=False,width=500,height=300).show(renderer="colab")
    with
    df.Close.plot().update_layout(autosize=False,width=500,height=300).show()
    Same for
    log_returns.plot(kind='hist').update_layout(autosize=False,width=500,height=300).show(renderer="colab")
    and
    log_returns.plot(kind = 'box').update_layout(autosize=False,width=350,height=500).show(renderer="colab")

  • @joaopedrorocha5693
    @joaopedrorocha5693 Před rokem

    Wow, great class! Thanks! Was thinking that the mean of the simple return was a good to have a first idea of returns over time but it can overshoot a lot! Will be able to estimate better now! And learned what the heck a ks test is about hehe Thanks a lot!
    Just a tip ... I think that you could have just sum 1 to simple_returns instead of doing a list comprehension, it's cleaner and more efficient (on cell 57 of the notebook)

  • @konturgestalter
    @konturgestalter Před 3 lety +3

    excellent as always!

  • @AkashChauhan-rw1qh
    @AkashChauhan-rw1qh Před 3 lety +1

    Thanks for sharing with us........

  • @DimitarDobrinov
    @DimitarDobrinov Před 10 měsíci

    Great explanation! I have a question. If arithmetic average of simple returns does not yield a correct measure of mean and we need to use geometric mean instead, what do we do with standard deviation? How will we compute standard deviation in a manner that deals with the fact that simple returns are not additive?

  • @kaiwang2924
    @kaiwang2924 Před rokem

    Simple and beautiful.

  • @sdsagdfd117
    @sdsagdfd117 Před 3 lety +2

    Perfect

  • @ncheymbamalu4013
    @ncheymbamalu4013 Před 2 lety

    Stock returns and log returns can be modeled more accurately with the t-distribution.

    • @sahilharidas4747
      @sahilharidas4747 Před rokem

      More generally, the t-distribution is better suited when the underlying population variance is unknown, as is usually the case in practice. However, the t-distribution becomes the standard normal distribution as the number of degrees of freedom approaches infinity.

  • @joshuaGmartin2023
    @joshuaGmartin2023 Před 8 měsíci

    Great stuff

  • @FRANKWHITE1996
    @FRANKWHITE1996 Před 3 lety +1

    Thanks 🙌

  • @gian_piano
    @gian_piano Před rokem

    awesome content thank you so much!

  • @modeocheng2190
    @modeocheng2190 Před rokem

    fantastic!

  • @omololaomotalade8105
    @omololaomotalade8105 Před 2 lety

    Hello,
    I got the same figure when adding log or simple return to the beginning price to get the ending price.
    My code:
    For log_return:
    data.Price[0] * np.exp(data['log_return'].mean() * len('log_return'))
    This code did not give me the price at the end of the timeseries
    For simple_return :
    data.Price[0] * (1 + data['simple_return'].mean()) ** len('simple_return') .
    Is there something I am doing wrong?
    Kindly respond.

  • @wilsongomes3360
    @wilsongomes3360 Před rokem

    good job. tks

  • @jure4835
    @jure4835 Před 2 lety +1

    Doesn't this basically show that log returns are normally distributed and therefore the stock returns have a lognormal distribution?

    • @QuantPy
      @QuantPy  Před 2 lety

      Log returns could be normally distributed, depends on your data. Yes modelling stock returns with a lognormal distribution is a strong assumption, but one that is made often

  • @carlosarrieta1145
    @carlosarrieta1145 Před 3 lety +2

    in which IDLE are you runing your code?

    • @QuantPy
      @QuantPy  Před 3 lety +1

      This is Jupyter Lab (notebooks) for python. If you’re using straight IDE, I like to use Visual Studio Code 👍

  • @steez54321
    @steez54321 Před 2 lety

    So what's the solution to this? Most all of theoretical finance assumes a normal distribution (Markowitz theory, CAPM, Black-Scholes). What do quants do in the real world when returns are not normally distributed?

    • @QuantPy
      @QuantPy  Před 2 lety

      Excellent question, obviously there is no one answer that solves all problems.
      However things for you to research, a way to model different distributions for various assets is through copulas. This could be incorporated through Monte Carlo simulations for either “real” world risk or portfolio optimisation or “risk-neutral” world derivative valuation

    • @steez54321
      @steez54321 Před 2 lety

      @@QuantPy do you have any materials or information you could point me to that talk about how to deal with non normal data in finance? I'm aware of copulas but am definitely not an expert and haven't see how they can help with non normal data. My understanding was that copulas are used for risk management. When you say use monte carlo is it just a matter of making random draws from an empirical distribution rather than the normal distribution and seeing how that affects an option price for example?

  • @MA-oj8zk
    @MA-oj8zk Před rokem

    For those running into issues with the yahoofinance pandareader, here's the fix:
    import yfinance as yf
    yf.pdr_override()

  • @vladk9152
    @vladk9152 Před 3 lety

    In a lot of engineering projects we ignore >3sigma events. Is it the same for finance projections? Let's say i want to make an ARIMA projection, or a monte carlo simulation. Should i keep these rare events as useful data?

    • @TheMLPRyan
      @TheMLPRyan Před 2 lety

      Yes keep the rare events, have a look at what happened to LTCM when they didn’t include large deviations from their models.

  • @ooddy24
    @ooddy24 Před 2 lety

    I would appreciate if you would move your picture outside of the script...it is hard enough to see the blurred script because its small scale. And your photo makes it worst...

    • @QuantPy
      @QuantPy  Před 2 lety +1

      Thanks Manit, all code on my website in the link in the description if you’ve missed anything 👍

  • @shaaf9817
    @shaaf9817 Před 3 lety

    Do some videos on crypto