Book Image

Python for Finance

By : Yuxing Yan
Book Image

Python for Finance

By: Yuxing Yan

Overview of this book

Table of Contents (20 chapters)
Python for Finance
About the Author
About the Reviewers

The power function, floor, and remainder

For our FV=PV(1+R)^n, we use a power function. The floor function would give the largest integer smaller than the current value. The remainder is the value that remains after an integer division. Given a positive discount rate, the present value of a future cash flow is always smaller than its corresponding future value.

The following formula specifies the relationship between a present value and its future value:

In this formula, PV is the present value, FV is the future value, R is the cost of capital (discount rate) per period, and n is the number of periods. Assume that we would receive $100 payment in two years and that the annual discount rate is 10 percent. What is the equivalent value today that we are willing to accept?


Here, ** is used to perform a power function. The % operator is used to calculate the remainder. Refer to the following example for the implementation of these operators: