class_docstr: Constructs continuous forwards time series total return indices from underlying forwards contracts.
  
      
class_docstr_tok: ["Constructs","continuous","forwards","time","series","total","return","indices","from","underlying","forwards","contracts","."]
code: def fetch_continuous_time_series(
      self,
      md_request,
      market_data_generator,
      fx_forwards_trading_tenor=None,
      roll_days_before=None,
      roll_event=None,
      construct_via_currency=None,
      fx_forwards_tenor_for_interpolation=None,
      base_depos_tenor=None,
      roll_months=None,
      cum_index=None,
      output_calculation_fields=False,
      field=None,
  ):
      if market_data_generator is None:
          market_data_generator = self._market_data_generator
      if fx_forwards_trading_tenor is None:
          fx_forwards_trading_tenor = self._fx_forwards_trading_tenor
      if roll_days_before is None:
          roll_days_before = self._roll_days_before
      if roll_event is None:
          roll_event = self._roll_event
      if construct_via_currency is None:
          construct_via_currency = self._construct_via_currency
      if fx_forwards_tenor_for_interpolation is None:
          fx_forwards_tenor_for_interpolation = (
              self._fx_forwards_tenor_for_interpolation
          )
      if base_depos_tenor is None:
          base_depos_tenor = self._base_depos_tenor
      if roll_months is None:
          roll_months = self._roll_months
      if cum_index is None:
          cum_index = self._cum_index
      if output_calculation_fields is None:
          output_calculation_fields = self._output_calcultion_fields
      if field is None:
          field = self._field
  
      # Eg. we construct EURJPY via EURJPY directly (note: would need to have sufficient forward data for this)
      if construct_via_currency == "no":
          # Download FX spot, FX forwards points and base depos etc.
          market = Market(market_data_generator=market_data_generator)
  
          md_request_download = MarketDataRequest(md_request=md_request)
  
          fx_conv = FXConv()
  
          # CAREFUL: convert the tickers to correct notation, eg. USDEUR => EURUSD, because our data
          # should be fetched in correct convention
          md_request_download.tickers = [
              fx_conv.correct_notation(x) for x in md_request.tickers
          ]
          md_request_download.category = "fx-forwards-market"
          md_request_download.fields = field
          md_request_download.abstract_curve = None
          md_request_download.fx_forwards_tenor = (
              fx_forwards_tenor_for_interpolation
          )
          md_request_download.base_depos_tenor = base_depos_tenor
  
          forwards_market_df = market.fetch_market(md_request_download)
  
          # Now use the original tickers
          return self.construct_total_return_index(
              md_request.tickers,
              forwards_market_df,
              fx_forwards_trading_tenor=fx_forwards_trading_tenor,
              roll_days_before=roll_days_before,
              roll_event=roll_event,
              fx_forwards_tenor_for_interpolation=fx_forwards_tenor_for_interpolation,
              roll_months=roll_months,
              cum_index=cum_index,
              output_calculation_fields=output_calculation_fields,
              field=field,
          )
      else:
          # eg. we calculate via your domestic currency such as USD, so returns will be in your domestic currency
          # Hence AUDJPY would be calculated via AUDUSD and JPYUSD (subtracting the difference in returns)
          total_return_indices = []
  
          for tick in md_request.tickers:
              base = tick[0:3]
              terms = tick[3:6]
  
              md_request_base = MarketDataRequest(md_request=md_request)
              md_request_base.tickers = base + construct_via_currency
  
              md_request_terms = MarketDataRequest(
                  md_request=md_request
              )
              md_request_terms.tickers = terms + construct_via_currency
  
              # Construct the base and terms separately (ie. AUDJPY => AUDUSD & JPYUSD)
              base_vals = self.fetch_continuous_time_series(
                  md_request_base,
                  market_data_generator,
                  fx_forwards_trading_tenor=fx_forwards_trading_tenor,
                  roll_days_before=roll_days_before,
                  roll_event=roll_event,
                  fx_forwards_tenor_for_interpolation=fx_forwards_tenor_for_interpolation,
                  base_depos_tenor=base_depos_tenor,
                  roll_months=roll_months,
                  output_calculation_fields=False,
                  cum_index=cum_index,
                  construct_via_currency="no",
                  field=field,
              )
  
              terms_vals = self.fetch_continuous_time_series(
                  md_request_terms,
                  market_data_generator,
                  fx_forwards_trading_tenor=fx_forwards_trading_tenor,
                  roll_days_before=roll_days_before,
                  roll_event=roll_event,
                  fx_forwards_tenor_for_interpolation=fx_forwards_tenor_for_interpolation,
                  base_depos_tenor=base_depos_tenor,
                  roll_months=roll_months,
                  cum_index=cum_index,
                  output_calculation_fields=False,
                  construct_via_currency="no",
                  field=field,
              )
  
              # Special case for USDUSD case (and if base or terms USD are USDUSD
              if (
                  base + terms
                  == construct_via_currency + construct_via_currency
              ):
                  base_rets = self._calculations.calculate_returns(
                      base_vals
                  )
                  cross_rets = pd.DataFrame(
                      0,
                      index=base_rets.index,
                      columns=base_rets.columns,
                  )
              elif (
                  base + construct_via_currency
                  == construct_via_currency + construct_via_currency
              ):
                  cross_rets = -self._calculations.calculate_returns(
                      terms_vals
                  )
              elif (
                  terms + construct_via_currency
                  == construct_via_currency + construct_via_currency
              ):
                  cross_rets = self._calculations.calculate_returns(
                      base_vals
                  )
              else:
                  base_rets = self._calculations.calculate_returns(
                      base_vals
                  )
                  terms_rets = self._calculations.calculate_returns(
                      terms_vals
                  )
  
                  cross_rets = base_rets.sub(
                      terms_rets.iloc[:, 0], axis=0
                  )
  
              # First returns of a time series will by NaN, given we don't know previous point
              cross_rets.iloc[0] = 0
  
              cross_vals = self._calculations.create_mult_index(
                  cross_rets
              )
              cross_vals.columns = [tick + "-forward-tot." + field]
  
              total_return_indices.append(cross_vals)
  
          return self._calculations.join(
              total_return_indices, how="outer"
          )
  
file_path: finmarketpy/finmarketpy/curve/fxforwardscurve.py
imports: import numpy
  import pandas
  from pandas.tseries.offsets import CustomBusinessDay, CustomBusinessMonthEnd
  from findatapy.market import Market, MarketDataRequest
  from findatapy.timeseries import Calculations, Calendar, Filter
  from findatapy.util.dataconstants import DataConstants
  from findatapy.util.fxconv import FXConv
  from finmarketpy.curve.rates.fxforwardspricer import FXForwardsPricer
  from finmarketpy.util.marketconstants import MarketConstants
label_desc: Use image node_id 3 for calling the FXForwardsCurve obj's underlying member method code with example usage: obj.fetch_continuous_time_series(md_request, market_data_generator, fx_forwards_trading_tenor, roll_days_before, roll_event, construct_via_currency, fx_forwards_tenor_for_interpolation, base_depos_tenor, roll_months, cum_index, output_calculation_fields, field) and returns: self, self