Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alecloudenback committed Oct 28, 2023
1 parent 947e842 commit b5b4b9c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ A collection of common functions/manipulations used in Actuarial Calculations.
- Calculate the `Macaulay`, `Modified`, or `DV01` durations for a set of cashflows
- Calculate the `KeyRate(time)` (a.k.a. `KeyRateZero`)duration or `KeyRatePar(time)` duration
- `convexity` for price sensitivity
- Flexible interest rate options via the [`Yields.jl`](https://github.com/JuliaActuary/Yields.jl) package.
- Flexible interest rate models via the [`FinanceModels.jl`](https://github.com/JuliaActuary/FinanceModels.jl) package.
- `internal_rate_of_return` or `irr` to calculate the IRR given cashflows (including at timepoints like Excel's `XIRR`)
- `breakeven` to calculate the breakeven time for a set of cashflows
- `accum_offset` to calculate accumulations like survivorship from a mortality vector
Expand All @@ -52,14 +52,14 @@ A collection of common functions/manipulations used in Actuarial Calculations.

### Typed Rates

- functions which return a rate/yield will return a `Yields.Rate` object. E.g. `irr(cashflows)` will return a `Rate(0.05,Periodic(1))` instead of just a `0.05` (`float64`) to convey the compounding frequency. This uses (and is fully compatible with) Yields.jl and can be used anywhere you would otherwise use a simple floating point rate.
- functions which return a rate/yield will return a `FinanceCore.Rate` object. E.g. `irr(cashflows)` will return a `Rate(0.05,Periodic(1))` instead of just a `0.05` (`float64`) to convey the compounding frequency. This is compatible across the JuliaActuary ecosystem and can be used anywhere you would otherwise use a simple floating point rate.

A couple of other notes:

- `rate(...)` will return the untyped rate from a `Yields.Rate` struct:
- `rate(...)` will return the scalar rate value from a `Rate` struct:

```julia-repl
julia> r = Yields.Rate(0.05,Yields.Periodic(1));
julia> r = Rate(0.05,Periodic(1));
julia> rate(r)
0.05
Expand All @@ -70,22 +70,20 @@ julia> rate(r)
```julia
discount(0.05,cashflows)

r = Yields.Rate(0.05,Yields.Periodic(1));
r = Rate(0.05,Periodic(1));
discount(r,cashflows)
```

- convert between rates with:

```julia
using Yields
r = Rate(0.05,Periodic(1));

r = Yields.Rate(0.05,Yields.Periodic(1));

convert(Yields.Periodic(2), r) # convert to compounded twice per timestep
convert(Yields.Continuous(2),r) # convert to compounded twice per timestep
convert(Periodic(2), r) # convert to compounded twice per timestep
convert(Continuous(2),r) # convert to compounded twice per timestep
```

For more, see the [Yields.jl](https://github.com/JuliaActuary/Yields.jl) which provides a rich and flexible API for rates and curves to use.
For more on Rates, see [FinanceCore.jl](https://github.com/JuliaActuary/FinanceCore.jl). [FinanceModels.jl](https://github.com/JuliaActuary/FinanceModels.jl) also provides a rich and flexible set of yield models to use.

## Documentation

Expand All @@ -99,8 +97,6 @@ See [JuliaActuary.org for instructions](https://juliaactuary.org/tutorials/cashf

[![Simple cashflow analysis with ActuaryUtilities.jl](https://user-images.githubusercontent.com/711879/95857181-d646a280-0d20-11eb-8300-a4c226021334.gif)](https://juliaactuary.org/tutorials/cashflowanalysis/)



## Useful tips

Functions often use a mix of interest_rates, cashflows, and timepoints. When calling functions, the general order of the arguments is 1) interest rates, 2) cashflows, and 3) timepoints.
30 changes: 18 additions & 12 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
```julia
cfs = [5, 5, 105]
times = [1, 2, 3]

discount_rate = 0.03

present_value(discount_rate, cfs, times) # 105.65
duration(Macaulay(), discount_rate, cfs, times) # 2.86
duration(discount_rate, cfs, times) # 2.78
Expand All @@ -20,7 +22,7 @@ A collection of common functions/manipulations used in Actuarial Calculations.
- Calculate the `Macaulay`, `Modified`, or `DV01` durations for a set of cashflows
- Calculate the `KeyRate(time)` (a.k.a. `KeyRateZero`)duration or `KeyRatePar(time)` duration
- `convexity` for price sensitivity
- Flexible interest rate options via the [`Yields.jl`](https://github.com/JuliaActuary/Yields.jl) package.
- Flexible interest rate models via the [`FinanceModels.jl`](https://github.com/JuliaActuary/FinanceModels.jl) package.
- `internal_rate_of_return` or `irr` to calculate the IRR given cashflows (including at timepoints like Excel's `XIRR`)
- `breakeven` to calculate the breakeven time for a set of cashflows
- `accum_offset` to calculate accumulations like survivorship from a mortality vector
Expand All @@ -43,14 +45,15 @@ A collection of common functions/manipulations used in Actuarial Calculations.

### Typed Rates

- functions which return a rate/yield will return a `Yields.Rate` object. E.g. `irr(cashflows)` will return a `Rate(0.05,Periodic(1))` instead of just a `0.05` (`float64`) to convey the compounding frequency. This uses (and is fully compatible with) Yields.jl and can be used anywhere you would otherwise use a simple floating point rate.
- functions which return a rate/yield will return a `FinanceCore.Rate` object. E.g. `irr(cashflows)` will return a `Rate(0.05,Periodic(1))` instead of just a `0.05` (`float64`) to convey the compounding frequency. This is compatible across the JuliaActuary ecosystem and can be used anywhere you would otherwise use a simple floating point rate.

A couple of other notes:

- `rate(...)` will return the untyped rate from a `Yields.Rate` struct:
- `rate(...)` will return the scalar rate value from a `Rate` struct:

```julia-repl
julia> r = Yields.Rate(0.05,Yields.Periodic(1));
julia> r = Rate(0.05,Periodic(1));
julia> rate(r)
0.05
```
Expand All @@ -59,20 +62,25 @@ julia> rate(r)

```julia
discount(0.05,cashflows)
r = Yields.Rate(0.05,Yields.Periodic(1));

r = Rate(0.05,Periodic(1));
discount(r,cashflows)
```

- convert between rates with:

```julia
using Yields
r = Yields.Rate(0.05,Yields.Periodic(1));
convert(Yields.Periodic(2), r) # convert to compounded twice per timestep
convert(Yields.Continuous(2),r) # convert to compounded twice per timestep
r = Rate(0.05,Periodic(1));

convert(Periodic(2), r) # convert to compounded twice per timestep
convert(Continuous(2),r) # convert to compounded twice per timestep
```

For more, see the [Yields.jl](https://github.com/JuliaActuary/Yields.jl) which provides a rich and flexible API for rates and curves to use.
For more on Rates, see [FinanceCore.jl](https://github.com/JuliaActuary/FinanceCore.jl). [FinanceModels.jl](https://github.com/JuliaActuary/FinanceModels.jl) also provides a rich and flexible set of yield models to use.

## Documentation

Full documentation is [available here](https://JuliaActuary.github.io/ActuaryUtilities.jl/stable/).

## Examples

Expand All @@ -82,8 +90,6 @@ See [JuliaActuary.org for instructions](https://juliaactuary.org/tutorials/cashf

[![Simple cashflow analysis with ActuaryUtilities.jl](https://user-images.githubusercontent.com/711879/95857181-d646a280-0d20-11eb-8300-a4c226021334.gif)](https://juliaactuary.org/tutorials/cashflowanalysis/)



## Useful tips

Functions often use a mix of interest_rates, cashflows, and timepoints. When calling functions, the general order of the arguments is 1) interest rates, 2) cashflows, and 3) timepoints.
3 changes: 0 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ const FC = ActuaryUtilities.FinanceCore

include("risk_measures.jl")

#convenience function to wrap scalar into default Rate type
p(rate) = Yields.Periodic(rate, 1)

@testset "Temporal functions" begin
@testset "years_between" begin
@test years_between(Date(2018, 9, 30), Date(2018, 9, 30)) == 0
Expand Down

0 comments on commit b5b4b9c

Please sign in to comment.