Hello! Welcome to the first lesson in your course to become a quantitative developer.
This initial module, "Mathematical Foundations for Quant Finance," will equip you with the essential mathematical and computational building blocks you'll need. Today, we're starting with the most fundamental concept in finance: the time value of money.
By the end of this lesson, you will be able to explain why money today is worth more than the same amount in the future and use this principle to calculate the present and future values of cash flows using discount factors. As a developer, your focus will be on implementing these calculations efficiently, so we'll dive straight into how this is done in Python using NumPy.
1. The Core Concept: Why Time is Money
Before we get into formulas and code, let's build the intuition. Would you rather have $1,000 today or $1,000 one year from now? You'd almost certainly choose to have it today. Why?
- Opportunity Cost: You could invest the $1,000 today and have more than $1,000 in a year.
- Inflation: The purchasing power of $1,000 is likely to be lower in a year due to rising prices.
- Certainty: Having the money now is a sure thing; a promise of future payment carries risk.
This simple preference is the essence of the time value of money. To formalize this, we need a way to quantify the relationship between money at different points in time.
To get a quick and clear overview of this idea, please watch the first two minutes of the following video.
This video from The Finance Storyteller provides a great intuitive explanation of the time value of money.
Watch from the beginning until the 2:06 mark. Focus on how the narrator establishes an 'equivalence' between money today and money in the future.
2. Compounding and Future Value (FV)
If money today is worth more than money in the future, how much more will today's money be worth in the future? This is calculated through compounding. When you invest money, you earn interest. The next period, you earn interest on your initial principal and on the accumulated interest.
The general formula for the Future Value (FV) of a single sum is:
Where:
- is the Present Value (the initial amount)
- is the interest rate per period
- is the number of periods
Let's continue with the video you started, which now introduces these formulas.
The same video now breaks down the mathematics of compounding and discounting.
Watch from 2:06 to 4:16. Pay attention to how the FV and PV formulas are just rearrangements of each other.
Implementation in Python
As a developer, you'll rarely calculate these values with a pen and paper. Your expertise in Python and numerical libraries is a huge advantage here. Let's see how to calculate future value over several years using NumPy. This approach avoids explicit for loops, which is a core principle in high-performance scientific computing.
This guide from a Duke University FinTech course shows how to perform time value of money calculations using NumPy's vectorized operations.
Read the section titled 'Single Interest Rate Compounding'. Focus on how np.cumprod() is used to calculate the balance year-over-year in a single, vectorized operation.
The key insight from that code is that instead of looping through each year, you can create an array of growth factors ([1.05, 1.05, ...]) and use np.cumprod() (cumulative product) to get the compounded growth factor at each step ([1.05, 1.1025, ...]). This is far more efficient for large calculations.
Test your understanding!
You invest $10,000 in a project that promises an annual return of 6%. Using NumPy, calculate the investment's value at the end of each year for the next 5 years.
Show answer
import numpy as np
initial_amount = 10000
interest_rate = 0.06
num_years = 5
# Create an array of growth factors for each year
growth_factors = np.full(num_years, 1 + interest_rate)
# Calculate the cumulative growth over the years
cumulative_growth = np.cumprod(growth_factors)
# Calculate the value at the end of each year
yearly_amounts = initial_amount * cumulative_growth
print("Value after each year:", np.round(yearly_amounts, 2))
# Expected output:
# Value after each year: [10600. 11236. 11910.16 12624.77 13382.26]
3. Discounting and Present Value (PV)
Discounting is the reverse of compounding. It answers the question: "How much is a future cash flow worth to me today?" This is arguably the most important concept in valuation. To value a stock, a bond, or an entire company, you project its future cash flows and "discount" them back to the present.
The formula for Present Value is a simple rearrangement of the FV formula:
The Discount Factor
You can think of this calculation in two parts. The term is called the Discount Factor. It's the value today of $1 received in periods at a discount rate of .
Once you have the discount factor, calculating the present value is straightforward: .

Application: Discounted Cash Flow (DCF)
A common application is a Discounted Cash Flow (DCF) analysis, where you sum the present values of all expected future cash flows from a project or company to determine its worth today.
This next video shows this in action, introducing the idea of a "discount rate" and applying discount factors to a series of cash flows to find their Net Present Value (NPV).
What is Discounted Cash Flow (DCF)?
This video from AssistKD demonstrates the practical application of discounting in a business context.
Watch from 1:56 to 4:05. Notice how a different discount factor is applied to each year's cash flow to find its present value, and then these are all summed up.
Implementation in Python
Now, let's implement the discounting of multiple cash flows in Python. Similar to the FV calculation, we can use NumPy to perform this efficiently.
Discounted Cash Flow Analysis - DCF with Python
This article on 'Tidy Finance with Python' provides an excellent function for performing a DCF calculation.
Read the section 'Computing Enterprise Value'. Study the Python function compute_dcf. Focus on this line in particular: present_value_fcf = free_cash_flow / ((1 + wacc) ** np.arange(1, years + 1)).
That single line of code is incredibly powerful. Let's break it down:
free_cash_flowis a NumPy array of future cash flows, e.g.,[100, 110, 120].np.arange(1, years + 1)creates an array of time periods, e.g.,[1, 2, 3].- The
**operator raises(1 + wacc)to the power of each element in the time period array. - Finally, the division is performed element-wise.
This is a perfect example of the "vectorized" thinking common in quantitative finance. Instead of writing a loop, you operate on entire arrays at once.
Conclusion
In this lesson, we established the foundational principle of finance: the time value of money. We've seen that compounding calculates a future value, while discounting calculates a present value.
Key Takeaways:
- Money has a time value due to opportunity cost and inflation. A dollar today is worth more than a dollar tomorrow.
- Future Value (FV) is calculated by compounding a present amount forward in time: .
- Present Value (PV) is calculated by discounting a future amount back to the present: .
- The Discount Factor is the term , which represents the present value of $1 received in the future.
- As a quant developer, you can use NumPy's vectorized operations to perform these calculations efficiently on entire series of cash flows, which is much faster and cleaner than writing explicit loops.
This concept is the bedrock for almost everything that follows. Whether pricing a bond, valuing an option, or assessing a trading strategy's returns, you are always, in some form, discounting future expectations to make a decision today.
Preview of the Next Lesson:
We got a taste of NumPy's power today. In the next lesson, we will formalize our understanding of the data structures we'll be using. We'll explore how to represent asset prices and portfolio weights as vectors and perform basic vector operations. This is the next essential skill for handling financial data computationally.