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 debtFunctionality: - 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: - `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. - `max_period (int)`: The total number of months over which the time value calculation will be performed. - `inflation (float)`: The annual inflation rate as a decimal, used to adjust the future value calculations. - `amount (float)`: The initial amount of money to be evaluated. - `calculation_type (str)`: A string indicating whether the calculation is for 'debt' or 'stock'. - `interest_rate_or_return (float)`: The annual interest rate for debt or the annual return rate for stocks, provided as a decimal.
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 --fred_str=env:FRED
Installation
dagger install github.com/EmmS21/daggerverse/CalculateTimeValue@v0.0.2
Entrypoint
Return Type
CalculateTimeValue !
Example
dagger -m github.com/EmmS21/daggerverse/CalculateTimeValue@b690a69b263902262741393552b29042c7bd7087 call \
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
Name | Type | Default Value | Description |
---|---|---|---|
fredStr | Secret ! | - | A reference to a secret value, which can be handled more safely than the value itself. |
Example
dagger -m github.com/EmmS21/daggerverse/CalculateTimeValue@b690a69b263902262741393552b29042c7bd7087 call \
calculate --fred-str env:MYSECRET
func (m *myModule) example(ctx context.Context, fredStr *Secret) string {
return dag.
CalculateTimeValue().
Calculate(ctx, fredStr)
}
@function
async def example(fred_str: dagger.Secret) -> str:
return await (
dag.calculate_time_value()
.calculate(fred_str)
)
@func()
async example(fredStr: Secret): Promise<string> {
return dag
.calculateTimeValue()
.calculate(fredStr)
}