Implied and Historical Volatility

The simulator provides key volatility metrics related to the underlying for every simulation run. These volatility metrics are made accessible to the user via the following variables:
  - underlying_hv
  - underlying_iv
  - underlying_iv_pct
  - underlying_iv_rank

All the calculated metrics are cross-checked and validated against key trading platforms (Interactive Brokers, TD Ameritrade and TastyTrade) respective values. The accuracy of our calculation matches over 95% of the time those trading platforms. 

Historical Volatility

Historical Volatility is calculated by looking back 30 calendar days and taking the log returns of the close prices on every given day. Using these prices, the standard deviation (square root of variance) is calculated and multiplied by the square root of trading days (252):

stdDev = Sqrt(logReturns.Sum(r => Pow(avg - r, 2)) / (logReturns.Count));
underlying_hv = Sqrt(252) *stdDev;

Please note, that as historical volatility is not updated intraday as it's using close prices.

Implied Volatility

The overall implied volatility for the underlying is calculated using the Options Contracts:

  • Option Types: Put Only
  • Expirations: Closest to 30 days out at any given time
  • Strikes: closest to underlying (ATM)

The calculation filters for bad data (outliers) and liquidity to have a realistic measure of implied volatility. 

Additionally, IV Rank and Percentile are calculated by looking back 1 calendar year as follows:

Find the period's high and low overall implied volatility. Count the number of total days and days where overall implied volatility is under (below) the current.

underlying_iv_rank = ((price.ImpliedVolatility - low) / (high - low)) * 100;
underlying_iv_pct = (under / total) * 100;

All implied volatility metrics are updated intra-day.

Crypto notes:
1) MesoSim's Implied Volatility is not sourced from Deribit's DVOL, but calculated internally. 
2) In case of Historical Volatility calculation, the End of Day is considered to be 00:00 UTC.