Dagger
Search

CalculateTimeValue

Overview: This module provides functionality to calculate the time value of money for either debt or stock investments over a specified period, factoring in inflation. It uses data from the Federal Reserve Economic Data (FRED) API to obtain the current inflation rate and incorporates this information into the calculations. This module is used to help an autonomous agent decide how to more efficiently prioritize paying back a debt

Functionality: - Fetches the annual inflation rate from the FRED API based on the Consumer Price Index (CPI). - Calculates the future value of a given amount of money, either as debt or as a stock investment, over a specified period with monthly compounding. - Adjusts the calculation for inflation to provide a more accurate representation of the time value of money.

Args: - `period (int)`: The total number of years over which the time value calculation will be performed. - `amount (str)`: The initial amount of money to be evaluated. - `rate (str)`: The annual interest rate for debt or the annual return rate for stocks, provided as a decimal. - `fred_str (Secret)`: The API key required to authenticate requests to the FRED API. This key should have the necessary permissions to access the required data.

Return: - The function returns a JSON formatted string. For each month in the specified period, it provides the future value of the amount as either debt or stock, adjusted for inflation. The JSON string represents an array of monthly future values, where each entry is a dictionary with the month and the calculated future value.

Example Call: dagger call calculate --period=2 --amount=10000 --rate=0.04 --fred_str=env:FRED

Installation

dagger install github.com/EmmS21/daggerverse/CalculateTimeValue@v0.0.4

Entrypoint

Return Type
CalculateTimeValue !
Example
func (m *myModule) example() *CalculateTimeValue  {
	return dag.
			CalculateTimeValue()
}
@function
def example() -> dag.CalculateTimeValue:
	return (
		dag.calculate_time_value()
	)
@func()
example(): CalculateTimeValue {
	return dag
		.calculateTimeValue()
}

Types

CalculateTimeValue 🔗

calculate() 🔗

Returns a container that echoes whatever string argument is provided

Return Type
String !
Arguments
NameTypeDefault ValueDescription
periodInteger !-No description provided
amountString !-No description provided
rateString !-No description provided
fredStrSecret !-A reference to a secret value, which can be handled more safely than the value itself.
Example
func (m *myModule) example(ctx context.Context, period int, amount string, rate string, fredStr *Secret) string  {
	return dag.
			CalculateTimeValue().
			Calculate(ctx, period, amount, rate, fredStr)
}
@function
async def example(period: int, amount: str, rate: str, fred_str: dagger.Secret) -> str:
	return await (
		dag.calculate_time_value()
		.calculate(period, amount, rate, fred_str)
	)
@func()
async example(period: number, amount: string, rate: string, fredStr: Secret): Promise<string> {
	return dag
		.calculateTimeValue()
		.calculate(period, amount, rate, fredStr)
}