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 rolling realized vol with daily cutoffs either using daily spot data or intraday spot data
  (which is assumed to be in UTC timezone)
  
  Parameters
  ----------
  asset : str
      asset to be calculated
  
  spot_df : pd.DataFrame
      minute spot returns (freq_min_mult should be the same as the frequency and should have timezone set)
  
  tenor_label : str
      tenor to calculate
  
  freq_min_mult : int
      frequency multiply for data (1 = 1 min)
  
  hour_of_day : closing time of data in the timezone specified
      eg. 10 which is 1000 time (default = 10)
  
  minute_of_day : closing time of data in the timezone specified
      eg. 0 which is 0 time (default = 0)
  
  field : str
      By default 'close'
  
  returns_calc : str
      'simple' calculate simple returns
      'log' calculate log returns
  
  timezone_hour_minute : str
      The timezone for the closing hour/minute (default: 'America/New_York')
  
  Returns
  -------
  pd.DataFrame of realized volatility
docstr_tok: ["Calculates","rolling","realized","vol","with","daily","cutoffs","either","using","daily","spot","data","or","intraday","spot","data","(","which","is","assumed","to","be","in","UTC","timezone",")","Parameters","--","--","--","--","--","asset",":","str","asset","to","be","calculated","spot_df",":","pd.DataFrame","minute","spot","returns","(","freq_min_mult","should","be","the","same","as","the","frequency","and","should","have","timezone","set",")","tenor_label",":","str","tenor","to","calculate","freq_min_mult",":","int","frequency","multiply","for","data","(","1","=","1","min",")","hour_of_day",":","closing","time","of","data","in","the","timezone","specified","eg",".","10","which","is","1000","time","(","default","=","10",")","minute_of_day",":","closing","time","of","data","in","the","timezone","specified","eg",".","0","which","is","0","time","(","default","=","0",")","field",":","str","By","default","'close'","returns_calc",":","str","'simple","'","calculate","simple","returns","'log","'","calculate","log","returns","timezone_hour_minute",":","str","The","timezone","for","the","closing","hour\/minute","(","default",":","'America\/New_York","'",")","Returns","--","--","--","-","pd.DataFrame","of","realized","volatility"]
code: def calculate_realized_vol(
      self,
      asset,
      spot_df=None,
      returns_df=None,
      tenor_label="ON",
      freq="daily",
      freq_min_mult=1,
      hour_of_day=10,
      minute_of_day=0,
      field="close",
      returns_calc="simple",
      timezone_hour_minute="America/New_York",
  ):
      """Calculates rolling realized vol with daily cutoffs either using daily spot data or intraday spot data
      (which is assumed to be in UTC timezone)
  
      Parameters
      ----------
      asset : str
          asset to be calculated
  
      spot_df : pd.DataFrame
          minute spot returns (freq_min_mult should be the same as the frequency and should have timezone set)
  
      tenor_label : str
          tenor to calculate
  
      freq_min_mult : int
          frequency multiply for data (1 = 1 min)
  
      hour_of_day : closing time of data in the timezone specified
          eg. 10 which is 1000 time (default = 10)
  
      minute_of_day : closing time of data in the timezone specified
          eg. 0 which is 0 time (default = 0)
  
      field : str
          By default 'close'
  
      returns_calc : str
          'simple' calculate simple returns
          'log' calculate log returns
  
      timezone_hour_minute : str
          The timezone for the closing hour/minute (default: 'America/New_York')
  
      Returns
      -------
      pd.DataFrame of realized volatility
      """
  
      if returns_df is None:
          if spot_df is None:
              if freq == "daily":
                  spot_df = self._market_df[asset + "." + field]
              else:
                  spot_df = self._intraday_spot_df[asset + "." + field]
  
          if returns_calc == "simple":
              returns_df = self._calculations.calculate_returns(spot_df)
          else:
              returns_df = self._calculations.calculate_log_returns(
                  spot_df
              )
  
      cal = Calendar()
      tenor_days = cal.get_business_days_tenor(tenor_label)
  
      if freq == "intraday":
          # Annualization factor (1440 is number of minutes in the day)
          mult = int(1440.0 / float(freq_min_mult))
  
          realized_rolling = self._calculations.rolling_volatility(
              returns_df, tenor_days * mult, obs_in_year=252 * mult
          )
  
          # Convert to NYC time (or whatever timezone hour is specified in)
          realized_rolling = self._timezone.convert_index_aware_to_alt(
              realized_rolling, timezone_hour_minute
          )
  
          realized_vol = self._filter.filter_time_series_by_time_of_day(
              hour_of_day, minute_of_day, realized_rolling
          )
          realized_vol = self._timezone.convert_index_aware_to_UTC_time(
              realized_vol
          )
          realized_vol = self._timezone.set_as_no_timezone(realized_vol)
      elif freq == "daily":
          realized_vol = self._calculations.rolling_volatility(
              spot_df, tenor_days, obs_in_year=252
          )
  
      # Strip the time off the date
      realized_vol.index = realized_vol.index.date
      realized_vol = pd.DataFrame(realized_vol)
  
      realized_vol.columns = [asset + "H" + tenor_label + ".close"]
  
      return realized_vol
  
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 2 for calling the VolStats obj's underlying member method code with example usage: obj.calculate_realized_vol(asset, spot_df, returns_df, tenor_label, freq, freq_min_mult, hour_of_day, minute_of_day, field, returns_calc, timezone_hour_minute) and returns: realized_vol