class_docstr: Represents an interest rate curve.
docstr: Initializes the interest rate curve.
  
  Args:
    maturity_dates: A `DateTensor` containing the maturity dates on which the
      curve is specified.
    rates: A `Tensor` of real dtype specifying the rates (or yields)
      corresponding to the input maturities. The shape of this input should
      match the shape of `maturity_dates`.
    valuation_date: A scalar `DateTensor` specifying the valuation (or
      settlement) date for the curve.
    compounding: Optional scalar `Tensor` of dtype int32 specifying the
      compounding frequency of the input rates. Use compounding=0 for
      continuously compounded rates. If compounding is different than 0, then
      rates are converted to continuously componded rates to perform
      interpolation.
      Default value: If omitted, the default value is 0.
    interpolator: Optional Python callable specifying the desired
      interpolation method. It should have the following interface: yi =
      interpolator(xi, x, y) `x`, `y`, 'xi', 'yi' are all `Tensors` of real
      dtype. `x` and `y` are the sample points and values (respectively) of
      the function to be interpolated. `xi` are the points at which the
      interpolation is desired and `yi` are the corresponding interpolated
      values returned by the function.
      Default value: None in which case linear interpolation is used.
    dtype: `tf.Dtype`. Optional input specifying the dtype of the `rates`
      input.
    name: Python str. The name to give to the ops created by this function.
      Default value: `None` which maps to 'rate_curve'.
docstr_tok: ["Initializes","the","interest","rate","curve",".","Args",":","maturity_dates",":","A","`","DateTensor","`","containing","the","maturity","dates","on","which","the","curve","is","specified",".","rates",":","A","`","Tensor","`","of","real","dtype","specifying","the","rates","(","or","yields",")","corresponding","to","the","input","maturities",".","The","shape","of","this","input","should","match","the","shape","of","`","maturity_dates","`",".","valuation_date",":","A","scalar","`","DateTensor","`","specifying","the","valuation","(","or","settlement",")","date","for","the","curve",".","compounding",":","Optional","scalar","`","Tensor","`","of","dtype","int32","specifying","the","compounding","frequency","of","the","input","rates",".","Use","compounding=0","for","continuously","compounded","rates",".","If","compounding","is","different","than","0",",","then","rates","are","converted","to","continuously","componded","rates","to","perform","interpolation",".","Default","value",":","If","omitted",",","the","default","value","is","0.","interpolator",":","Optional","Python","callable","specifying","the","desired","interpolation","method",".","It","should","have","the","following","interface",":","yi","=","interpolator","(","xi",",","x",",","y",")","`","x","`",",","`","y","`",",","'xi","'",",","'yi","'","are","all","`","Tensors","`","of","real","dtype",".","`","x","`","and","`","y","`","are","the","sample","points","and","values","(","respectively",")","of","the","function","to","be","interpolated",".","`","xi","`","are","the","points","at","which","the","interpolation","is","desired","and","`","yi","`","are","the","corresponding","interpolated","values","returned","by","the","function",".","Default","value",":","None","in","which","case","linear","interpolation","is","used",".","dtype",":","`","tf.Dtype","`",".","Optional","input","specifying","the","dtype","of","the","`","rates","`","input",".","name",":","Python","str",".","The","name","to","give","to","the","ops","created","by","this","function",".","Default","value",":","`","None","`","which","maps","to","'rate_curve","'","."]
code: def __init__(
      self,
      maturity_dates,
      rates,
      valuation_date,
      compounding=None,
      interpolator=None,
      dtype=None,
      name=None,
  ):
      """Initializes the interest rate curve.
  
      Args:
        maturity_dates: A `DateTensor` containing the maturity dates on which the
          curve is specified.
        rates: A `Tensor` of real dtype specifying the rates (or yields)
          corresponding to the input maturities. The shape of this input should
          match the shape of `maturity_dates`.
        valuation_date: A scalar `DateTensor` specifying the valuation (or
          settlement) date for the curve.
        compounding: Optional scalar `Tensor` of dtype int32 specifying the
          compounding frequency of the input rates. Use compounding=0 for
          continuously compounded rates. If compounding is different than 0, then
          rates are converted to continuously componded rates to perform
          interpolation.
          Default value: If omitted, the default value is 0.
        interpolator: Optional Python callable specifying the desired
          interpolation method. It should have the following interface: yi =
          interpolator(xi, x, y) `x`, `y`, 'xi', 'yi' are all `Tensors` of real
          dtype. `x` and `y` are the sample points and values (respectively) of
          the function to be interpolated. `xi` are the points at which the
          interpolation is desired and `yi` are the corresponding interpolated
          values returned by the function.
          Default value: None in which case linear interpolation is used.
        dtype: `tf.Dtype`. Optional input specifying the dtype of the `rates`
          input.
        name: Python str. The name to give to the ops created by this function.
          Default value: `None` which maps to 'rate_curve'.
      """
      self._name = name or "rate_curve"
      with tf.compat.v1.name_scope(self._name):
          self._dtype = dtype
          if interpolator is None:
  
              def default_interpolator(xi, x, y):
                  return linear.interpolate(xi, x, y, dtype=dtype)
  
              interpolator = default_interpolator
  
          if compounding is None:
              compounding = 0
  
          self._dates = dates.convert_to_date_tensor(maturity_dates)
          self._valuation_date = dates.convert_to_date_tensor(
              valuation_date
          )
  
          self._times = self._get_time(self._dates)
          self._rates = tf.convert_to_tensor(
              rates, dtype=self._dtype, name="curve_rates"
          )
  
          if compounding > 0:
              self._rates = tf.where(
                  self._times > 0.0,
                  tf.math.log(
                      (1.0 + self._rates / compounding)
                      ** (compounding * self._rates)
                  )
                  / self._times,
                  self._rates,
              )
          self._interpolator = interpolator
  
file_path: tf-quant-finance/tf_quant_finance/experimental/instruments/rate_curve.py
imports: import tensorflow.compat.v2
  from tf_quant_finance import datetime
  from tf_quant_finance.math.interpolation import linear
label_desc: Use image node_id 1 to create a new RateCurve object from inherited base classes: object with example: obj = RateCurve(maturity_dates, rates, valuation_date, compounding, interpolator, dtype, name)