code: def equity_swap_price(
      rate_leg_coupon_rates,
      equity_leg_forward_prices,
      equity_leg_spots,
      rate_leg_notional,
      equity_leg_notional,
      rate_leg_daycount_fractions,
      rate_leg_discount_factors,
      equity_leg_discount_factors,
      equity_dividends=None,
      is_equity_receiver=None,
      dtype=None,
      name=None,
  ):
      """Computes prices of a batch of equity swaps.
  
      The swap consists of an equity and interest rate legs.
  
      #### Example
      ```python
      rate_leg_coupon_rates = [[0.1, 0.2, 0.05], [0.1, 0.05, 0.2]]
      # Two cashflows of 4 and 3 payments, respectively
      forward_prices = [[110, 120, 140, 150], [210, 220, 240, 0]]
      spots = [100, 200]
      notional = 1000
      pay_leg_daycount_fractions = 0.5
      rate_leg_daycount_fractions = [[0.5, 0.5, 0.5], [0.4, 0.5, 0.6]]
      rate_leg_discount_factors = [[0.95, 0.9, 0.85], [0.98, 0.92, 0.88]]
      equity_leg_discount_factors = [[0.95, 0.9, 0.85, 0.8],
                                     [0.98, 0.92, 0.88, 0.0]]
  
      equity_swap_price(
          rate_leg_coupon_rates=rate_leg_coupon_rates,
          equity_leg_forward_prices=forward_prices,
          equity_leg_spots=spots,
          rate_leg_notional=notional,
          equity_leg_notional=notional,
          rate_leg_daycount_fractions=rate_leg_daycount_fractions,
          rate_leg_discount_factors=rate_leg_discount_factors,
          equity_leg_discount_factors=equity_leg_discount_factors,
          is_equity_receiver=[True, False],
          dtype=tf.float64)
      # Expected: [216.87770563, -5.00952381]
      forward_rates(df_start_dates, df_end_dates, daycount_fractions,
                    dtype=tf.float64)
      ```
  
      Args:
        rate_leg_coupon_rates: A real `Tensor` of shape
          `batch_shape + [num_rate_cashflows]`, where `num_rate_cashflows` is the
          number of cashflows for each batch element. Coupon rates for the
          interest rate leg.
        equity_leg_forward_prices: A `Tensor` of the same `dtype` as
          `rate_leg_coupon_rates` and of shape
          `batch_shape + [num_equity_cashflows]`, where `num_equity_cashflows` is
          the number of cashflows for each batch element. Equity leg forward
          prices.
        equity_leg_spots: A `Tensor` of the same `dtype` as
          `equity_leg_forward_prices` and of shape compatible with `batch_shape`.
          Spot prices for each batch element of the equity leg.
        rate_leg_notional: A `Tensor` of the same `dtype` as `rate_leg_coupon_rates`
          and of compatible shape. Notional amount for each cashflow.
        equity_leg_notional: A `Tensor` of the same `dtype` as
          `equity_leg_forward_prices` and of compatible shape.  Notional amount for
          each cashflow.
        rate_leg_daycount_fractions: A `Tensor` of the same `dtype` as
          `rate_leg_coupon_rates` and of compatible shape.  Year fractions for the
          coupon accrual.
        rate_leg_discount_factors: A `Tensor` of the same `dtype` as
          `rate_leg_coupon_rates` and of compatible shape. Discount factors for each
          cashflow of the rate leg.
        equity_leg_discount_factors: A `Tensor` of the same `dtype` as
          `equity_leg_forward_prices` and of compatible shape. Discount factors for
          each cashflow of the equity leg.
        equity_dividends: A `Tensor` of the same `dtype` as
          `equity_leg_forward_prices` and of compatible shape. Dividends paid at the
          leg reset times.
          Default value: None which maps to zero dividend.
        is_equity_receiver: A boolean `Tensor` of shape compatible with
          `batch_shape`. Indicates whether the swap holder is equity holder or
          receiver.
          Default value: None which means that all swaps are equity reiver swaps.
        dtype: `tf.Dtype`. If supplied the dtype for the input and output `Tensor`s.
          Default value: None which maps to the default dtype inferred from
          `rate_leg_coupon_rates`.
        name: Python str. The name to give to the ops created by this function.
          Default value: None which maps to 'equity_swap_price'.
  
      Returns:
        A `Tensor` of the same `dtype` as `rate_leg_coupon_rates` and of shape
        `batch_shape`. Present values of the equity swaps.
      """
      name = name or "equity_swap_price"
      with tf.name_scope(name):
          rate_leg_coupon_rates = tf.convert_to_tensor(
              rate_leg_coupon_rates,
              dtype=dtype,
              name="rate_leg_coupon_rates",
          )
          dtype = dtype or rate_leg_coupon_rates.dtype
          equity_leg_forward_prices = tf.convert_to_tensor(
              equity_leg_forward_prices,
              dtype=dtype,
              name="equity_leg_forward_prices",
          )
          equity_leg_spots = tf.convert_to_tensor(
              equity_leg_spots, dtype=dtype, name="equity_leg_spots"
          )
          rate_leg_daycount_fractions = tf.convert_to_tensor(
              rate_leg_daycount_fractions,
              dtype=dtype,
              name="rate_leg_daycount_fractions",
          )
          equity_dividends = equity_dividends or 0
          equity_dividends = tf.convert_to_tensor(
              equity_dividends, dtype=dtype, name="equity_dividends"
          )
          rate_leg_notional = tf.convert_to_tensor(
              rate_leg_notional, dtype=dtype, name="rate_leg_notional"
          )
          equity_leg_notional = tf.convert_to_tensor(
              equity_leg_notional,
              dtype=dtype,
              name="equity_leg_notional",
          )
          rate_leg_discount_factors = tf.convert_to_tensor(
              rate_leg_discount_factors,
              dtype=dtype,
              name="rate_leg_discount_factors",
          )
          equity_leg_discount_factors = tf.convert_to_tensor(
              equity_leg_discount_factors,
              dtype=dtype,
              name="equity_leg_discount_factors",
          )
          if is_equity_receiver is None:
              is_equity_receiver = True
          is_equity_receiver = tf.convert_to_tensor(
              is_equity_receiver,
              dtype=tf.bool,
              name="is_equity_receiver",
          )
          one = tf.ones([], dtype=dtype)
          equity_receiver = tf.where(is_equity_receiver, one, -one)
          equity_cashflows = equity_leg_cashflows(
              forward_prices=equity_leg_forward_prices,
              spots=equity_leg_spots,
              notional=equity_leg_notional,
              dividends=equity_dividends,
          )
          rate_cashflows = rate_leg_cashflows(
              coupon_rates=rate_leg_coupon_rates,
              notional=rate_leg_notional,
              daycount_fractions=rate_leg_daycount_fractions,
          )
          return equity_receiver * swap_price(
              rate_cashflows,
              equity_cashflows,
              rate_leg_discount_factors,
              equity_leg_discount_factors,
          )
  
file_path: tf-quant-finance/tf_quant_finance/rates/analytics/swap.py
imports: import tensorflow.compat.v2
  from tf_quant_finance.rates.analytics import cashflows
label_desc: Use image node_id 6 for calling a global function with example usage: equity_swap_price(rate_leg_coupon_rates, equity_leg_forward_prices, equity_leg_spots, rate_leg_notional, equity_leg_notional, rate_leg_daycount_fractions, rate_leg_discount_factors, equity_leg_discount_factors, equity_dividends, is_equity_receiver, dtype, name) and returns: unknown