-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathFinancialMarketsFormulas.cs
30 lines (29 loc) · 1.35 KB
/
FinancialMarketsFormulas.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
namespace srbrettle.FinancialFormulas
{
/// <summary>
/// A collection of methods for solving Financial-Markets-focused Finance/Accounting equations.
/// </summary>
public static class FinancialMarketsFormulas
{
/// <summary>
/// Calculates Rate of Inflation from Initial Consumer Price Index and Ending Consumer Price Index
/// </summary>
/// <param name="initialConsumerPriceIndex">Initial Consumer Price Index</param>
/// <param name="endingConsumerPriceIndex">Ending Consumer Price Index</param>
/// <returns>Decimal value for Rate of Inflation</returns>
public static decimal CalcRateOfInflation(decimal initialConsumerPriceIndex, decimal endingConsumerPriceIndex)
{
return (endingConsumerPriceIndex - initialConsumerPriceIndex) / initialConsumerPriceIndex;
}
/// <summary>
/// Calculates Real Rate of Return from Nominal Rate and Inflation Rate
/// </summary>
/// <param name="nominalRate">Nominal Rate</param>
/// <param name="inflationRate">Inflation Rate</param>
/// <returns>Decimal value for Real Rate of Return</returns>
public static decimal CalcRealRateOfReturn(decimal nominalRate, decimal inflationRate)
{
return ((1 + nominalRate) / (1 + inflationRate)) - 1;
}
}
}