<!--
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.cashflows.present_value" />
<meta itemprop="path" content="Stable" />
</div>

# tf_quant_finance.rates.analytics.cashflows.present_value

<!-- 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/cashflows.py">View source</a>



Computes present value of a stream of cashflows given discount factors.

```python
tf_quant_finance.rates.analytics.cashflows.present_value(
    cashflows, discount_factors, dtype=None, name=None
)
```



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


```python

  # 2 and 3 year bonds with 1000 face value and 4%, 6% semi-annual coupons.
  # Note that the first four entries in the cashflows are the cashflows of
  # the first bond (group=0) and the next six are the cashflows of the second
  # bond (group=1).
  cashflows = [[20, 20, 20, 1020, 0, 0],
               [30, 30, 30, 30, 30, 1030]]

  # Corresponding discount factors for the cashflows
  discount_factors = [[0.96, 0.93, 0.9, 0.87, 1.0, 1.0],
                      [0.97, 0.95, 0.93, 0.9, 0.88, 0.86]]

  present_values = present_value(
      cashflows, discount_factors, dtype=np.float64)
  # Expected: [943.2, 1024.7]
```

#### Args:


* <b>`cashflows`</b>: A real `Tensor` of shape `batch_shape + [n]`. The set of
  cashflows of underlyings. `n` is the number of cashflows per bond
  and `batch_shape` is the number of bonds. Bonds with different number
  of cashflows should be padded to a common number `n`.
* <b>`discount_factors`</b>: A `Tensor` of the same `dtype` as `cashflows` and of
  compatible shape. The set of discount factors corresponding to the
  cashflows.
* <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
  `cashflows`.
* <b>`name`</b>: Python str. The name to give to the ops created by this function.
  Default value: None which maps to 'present_value'.


#### Returns:

Real `Tensor` of shape `batch_shape`. The present values of the cashflows.
