Aan de slagGa gratis aan de slag

Third moment: Skewness

To calculate the third moment, or skewness of a returns distribution in Python, you can use the skew() function from scipy.stats.

Remember that a negative skew is a right-leaning curve, while positive skew is a left-leaning curve. In finance, you would tend to want positive skewness, as this would mean that the probability of large positive returns is unusually high, and the negative returns are more closely clustered and predictable.

StockPrices from the previous exercise is available in your workspace.

Deze oefening maakt deel uit van de cursus

Introduction to Portfolio Risk Management in Python

Cursus bekijken

Oefeninstructies

  • Import skew from scipy.stats.
  • Drop missing values in the 'Returns' column to prevent errors.
  • Calculate the skewness of clean_returns.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import skew from scipy.stats
from ____ import ____

# Drop the missing values
clean_returns = ____

# Calculate the third moment (skewness) of the returns distribution
returns_skewness = ____
print(returns_skewness)
Code bewerken en uitvoeren