IntroducingHow to illustrate log returns vs simple returns

How to illustrate log returns vs simple returns

In this blog post we are going to introduce the concepts of log returns vs simple returns and realized volatility.

To illustrate the log returns and more complex concepts we are going to demonstrate the concepts with the help of python libraries: pandas and numpy.

Simple returns vs log returns

To begin with, the key benefit of using financial returns instead of prices is normalization which allows us to measure and compare all financial instruments and assets. This is also a requirement for many multidimensional statistical analysis and machine learning techniques.

The simple return on an asset is the amount we receive or lose after holding an asset for a certain time frame.

simple returns formula

Meanwhile we calculate log returns as

log returns formula

where P is price of an asset and t is a time period.

In pandas we calculate the simple returns with an in-built pandas function pct_change that calculates percentage change and use numpy log to calculate log returns in addition to pandas diff that differences the series.

data['simple_returns'] = data.close.pct_change()
def log_return(list_stock_prices):
    return np.log(list_stock_prices).diff()
data['log_return'] = log_return(data.close)

The main advantage of log returns is that we can easily aggregate them across time unlike simple returns. For instance, the log return for a year is the sum of the log returns of the days within the year. Additionally, log returns are symmetric around 0 and log return values can range from minus infinity to plus infinity. Whereas, simple returns' downside is limited at -100% and a negative movement of -25% (movement from 100$ to 75$) does not reverse the losses by going +25% (75$ to 93.75$).

Realized Volatility

Volatility plays an important role in trading and financial model forecasting. Next to directly modeling high–frequency returns, intra–day returns are also used to construct lower–frequency daily volatility measures, known as realized volatility. The application of volatility has tremendously risen due to the availability of high-frequency data and computational resources.

Layman’s definition:  Realized volatility is the magnitude of daily price movements, regardless of direction, of some underlying, over a specific period.

Technical definition:  Realized volatility is the daily standard deviation of log returns of an underlying asset, index, instrument, security, or ETF, over a defined period, with an assumed mean of zero.

Traders and data scientist use realized volatility to assess the predictive performance and adequacy of existing models and strategies due to our ability to observe the metric (non-latent character). Realized volatility is a particularly powerful indicator of the price risk and its dynamics.

The formula for realized volatility:

formula for realized volatility

In Python we create a function that calculates realized volatility with the help of numpy functions sqrt and sum and pandas groupby and agg.

Realized Variance

Andersen and Bollerslev (1998) have suggested an ex-post intra-daily volatility measure based on the sum of the squared intra-day returns. This concept is now known as realized variance, and this is an ex-post observable measure.

Realized variance formula