Simple Return, Log Return and Volatility easy intro

Following $100k Optiver Realized Volatility Prediction Competition on Kaggle, interest in financial time-series and concepts has drastically increased. Besides, in this website we have not travelled past the very introductory concepts in time-series ecnnometrics. Therefore in this blog post we are going to introduce the concepts of simple returns, log returns and realized volatility.

In the following article we have already explored time-series and simple operations in pandas and numpy.

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

Simple returns vs log returns

To begin with, 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.

Meanwhile we calculate log returns as

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.

https://www.realvol.com/Realizedvolatilitydefinition.htm

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:

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

def realized_volatility(series):
    return np.sqrt(np.sum(series**2))
df.groupby(df.index.date).agg(realized_volatility)

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.

def realized_variance(series):
    return np.sum(series**2)
df.groupby(df.index.date).agg(realized_variance)

References


You can contact me for professional inquires via my social media:

8 thoughts on “Simple Return, Log Return and Volatility easy intro”

  1. whoah this blog is fantastic i love reading your articles. Keep up the great work! You know, a lot of people are looking around for this information, you could aid them greatly.

    Reply
  2. Nice blog! Is your theme custom made or did you download it from somewhere? A design like yours with a few simple adjustements would really make my blog jump out. Please let me know where you got your design. Bless you

    Reply
  3. I know this if off topic but I’m looking into starting my own blog and was wondering what all is needed to get setup? I’m assuming having a blog like yours would cost a pretty penny? I’m not very internet savvy so I’m not 100 certain. Any recommendations or advice would be greatly appreciated. Many thanks

    Reply
  4. Nice post. I learn something totally new and challenging on websites I stumbleupon every day. It will always be interesting to read content from other authors and use a little something from other websites.

    Reply
  5. I truly love your website.. Great colors & theme.
    Did you develop this web site yourself? Please reply back as I’m looking
    to create my very own site and would like to learn where you got this
    from or just what the theme is named. Kudos!

    Reply
  6. I’m gone to say to my little brother, that he should also go to see this blog on regular basis to obtain updated from hottest news.

    Reply

Leave a comment