class_docstr: Arranging underlying volatility market in easier to read format. Also provides methods for calculating various
  volatility metrics, such as realized_vol volatility and volatility risk premium. Has extensive support for estimating
  implied_vol volatility addons.
class_docstr_tok: ["Arranging","underlying","volatility","market","in","easier","to","read","format",".","Also","provides","methods","for","calculating","various","volatility","metrics",",","such","as","realized_vol","volatility","and","volatility","risk","premium",".","Has","extensive","support","for","estimating","implied_vol","volatility","addons","."]
docstr: Calculates volatility risk premium given implied and realized quotes (ie. implied - realized) and tenor
  
  Calculates both a version which is aligned (VRP), where the implied and realized volatilities cover
  the same period (note: you will have a gap for recent points, where you can't grab future implied volatilities),
  and an unaligned version (VRPV), which is the typical one used in the market
  
  Parameters
  ----------
  asset : str
      asset to calculate value for
  
  tenor_label : str
      tenor to calculate
  
  implied_vol : pd.DataFrame
      implied vol quotes where columns are of the form eg. EURUSDV1M.close
  
  realized_vol : pd.DataFrame
      realized vol eg. EURUSDH1M.close
  
  field : str
      the field of the data to use (default: 'close')
  
  Returns
  -------
  pd.DataFrame of vrp (both lagged - VRPV & contemporanous - VRP)
docstr_tok: ["Calculates","volatility","risk","premium","given","implied","and","realized","quotes","(","ie",".","implied","-","realized",")","and","tenor","Calculates","both","a","version","which","is","aligned","(","VRP",")",",","where","the","implied","and","realized","volatilities","cover","the","same","period","(","note",":","you","will","have","a","gap","for","recent","points",",","where","you","ca","n't","grab","future","implied","volatilities",")",",","and","an","unaligned","version","(","VRPV",")",",","which","is","the","typical","one","used","in","the","market","Parameters","--","--","--","--","--","asset",":","str","asset","to","calculate","value","for","tenor_label",":","str","tenor","to","calculate","implied_vol",":","pd.DataFrame","implied","vol","quotes","where","columns","are","of","the","form","eg",".","EURUSDV1M.close","realized_vol",":","pd.DataFrame","realized","vol","eg",".","EURUSDH1M.close","field",":","str","the","field","of","the","data","to","use","(","default",":","'close","'",")","Returns","--","--","--","-","pd.DataFrame","of","vrp","(","both","lagged","-","VRPV","&","contemporanous","-","VRP",")"]
code: def calculate_vol_risk_premium(
      self,
      asset,
      tenor_label="ON",
      implied_vol=None,
      realized_vol=None,
      field="close",
      adj_ON_friday=False,
  ):
      """Calculates volatility risk premium given implied and realized quotes (ie. implied - realized) and tenor
  
      Calculates both a version which is aligned (VRP), where the implied and realized volatilities cover
      the same period (note: you will have a gap for recent points, where you can't grab future implied volatilities),
      and an unaligned version (VRPV), which is the typical one used in the market
  
      Parameters
      ----------
      asset : str
          asset to calculate value for
  
      tenor_label : str
          tenor to calculate
  
      implied_vol : pd.DataFrame
          implied vol quotes where columns are of the form eg. EURUSDV1M.close
  
      realized_vol : pd.DataFrame
          realized vol eg. EURUSDH1M.close
  
      field : str
          the field of the data to use (default: 'close')
  
      Returns
      -------
      pd.DataFrame of vrp (both lagged - VRPV & contemporanous - VRP)
      """
  
      cal = Calendar()
      tenor_days = cal.get_business_days_tenor(tenor_label)
  
      if tenor_label == "ON" and adj_ON_friday:
          implied_vol = self.adjust_implied_ON_fri_vol(implied_vol)
  
      # Add x business days to implied_vol to make it equivalent to realized_vol (better than "shift")
      # approximation for options which are not ON or 1W
      # bday = CustomBusinessDay(weekmask='Mon Tue Wed Thu Fri')
      implied_vol = implied_vol.copy(deep=True)
  
      implied_unaligned = implied_vol.copy(deep=True)
      cols_to_change = implied_vol.columns.values
  
      new_cols = []
  
      for i in range(0, len(cols_to_change)):
          temp_col = list(cols_to_change[i])
          temp_col[6] = "U"
  
          new_cols.append("".join(temp_col))
  
      implied_vol.columns = new_cols
  
      ## Construct volatility risk premium such that implied covers the same period as realized
      # Add by number of days (note: for overnight tenors/1 week in FX we can add business days like this)
      # For because they are always +1 business days, +5 business days (exc. national holidays and only including
      # weekend). For longer dates like 1 month this is an approximation
      implied_vol.index = [
          pd.Timestamp(x) + pd.tseries.offsets.BDay(tenor_days)
          for x in implied_vol.index
      ]
  
      vrp = implied_vol.join(realized_vol, how="outer")
      vrp[asset + "VRP" + tenor_label + ".close"] = (
          vrp[asset + "U" + tenor_label + "." + field]
          - vrp[asset + "H" + tenor_label + "." + field]
      )
  
      ## Construct "traditional" volatility risk premium,
      # so implied does not cover the same period as realized volatility
      vrp = vrp.join(implied_unaligned, how="outer")
  
      vrp[asset + "VRPV" + tenor_label + ".close"] = (
          vrp[asset + "V" + tenor_label + "." + field]
          - vrp[asset + "H" + tenor_label + "." + field]
      )
  
      return vrp
  
file_path: finmarketpy/finmarketpy/curve/volatility/volstats.py
imports: import math
  import pandas
  from pandas.tseries.offsets import CustomBusinessDay
  from findatapy.timeseries import Calculations, Filter, Timezone
  from findatapy.timeseries import Calendar
label_desc: Use image node_id 3 for calling the VolStats obj's underlying member method code with example usage: obj.calculate_vol_risk_premium(asset, tenor_label, implied_vol, realized_vol, field, adj_ON_friday) and returns: vrp