<!--
This file is generated by a tool. Do not edit directly.
For open-source contributions the docs will be updated automatically.
-->

*Last updated: 2023-03-16.*

<div itemscope itemtype="http://developers.google.com/ReferenceObject">
<meta itemprop="name" content="tf_quant_finance.rates.analytics.swap.equity_leg_cashflows" />
<meta itemprop="path" content="Stable" />
</div>

# tf_quant_finance.rates.analytics.swap.equity_leg_cashflows

<!-- Insert buttons and diff -->

<table class="tfo-notebook-buttons tfo-api" align="left">
</table>

<a target="_blank" href="https://github.com/paolodelia99/tf-quant-finance/blob/main/tf_quant_finance/rates/analytics/swap.py">View source</a>



Computes cashflows for a batch of equity legs.

```python
tf_quant_finance.rates.analytics.swap.equity_leg_cashflows(
    forward_prices, spots, notional, dividends=None, dtype=None, name=None
)
```



<!-- Placeholder for "Used in" -->

Equity cashflows are defined as a total equity return between pay dates, say,
`T_1, ..., T_n`. Let `S_i` represent the value of the equity at time `T_i` and
`d_i` be a discrete dividend paid at this time. Then the the payment at time
`T_i` is defined as `(S_i - S_{i - 1}) / S_{i-1} + d_i`. The value of
the cashflow is then the discounted sum of the paments. See, e.g., [1] for the
reference.

#### Example
```python
notional = 10000
forward_prices = [[110, 120, 140], [210, 220, 240]]
spots = [100, 200]
dividends = [[1, 1, 1], [2, 2, 2]]
equity_leg_cashflows(forward_prices, spots, notional, dividends,
                     dtype=tf.float64)
# Expected:
#  [[1000.01, 909.1, 1666.675],
#   [ 500.01, 476.2, 909.1]]
```

#### Args:


* <b>`forward_prices`</b>: A real `Tensor` of shape `batch_shape + [num_cashflows]`,
  where `num_cashflows` is the number of cashflows for each batch element.
  Equity forward prices at leg reset times.
* <b>`spots`</b>:  A `Tensor` of the same `dtype` as `forward_prices` and of
  shape compatible with `batch_shape`. Spot prices for each batch element
* <b>`notional`</b>: A `Tensor` of the same `dtype` as `forward_prices` and of
  compatible shape. Notional amount for each cashflow.
* <b>`dividends`</b>:  A `Tensor` of the same `dtype` as `forward_prices` and of
  compatible shape. Discrete dividends paid at the leg reset times.
  Default value: None which maps to zero dividend.
* <b>`dtype`</b>: `tf.Dtype`. If supplied the dtype for the input and output `Tensor`s.
  Default value: None which maps to the default dtype inferred from
  `forward_prices`.
* <b>`name`</b>: Python str. The name to give to the ops created by this function.
  Default value: None which maps to 'equity_leg_cashflows'.


#### Returns:

A `Tensor` of the same `dtype` as `forward_prices` and of shape
`batch_shape + [num_cashflows]`.


#### References
[1] Don M. Chance and Don R Rich,
  The Pricing of Equity Swaps and Swaptions, 1998
  https://jod.pm-research.com/content/5/4/19