Skip to content

Commit

Permalink
Merge pull request #10 from Thorium/doc-fix
Browse files Browse the repository at this point in the history
Minor improvements to docs and api-docs
  • Loading branch information
simontreanor authored Nov 4, 2024
2 parents 0707841 + 88e6a1e commit 9a9921c
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Initial features:
> amortisation
This library operates partially in area where business is regulated by various regulators.
Though every care has been taken to ensure the accuracy of the results, please independently validate figures produced by it.
This library operates partially in areas where business is regulated by various regulators.
Though every care has been taken to ensure the accuracy of the results, please independently validate the figures produced by it.
It is not audited or validated by any of the regulators.

If you have any suggestions or corrections, please feel free to comment or create a pull request.
Expand Down
6 changes: 3 additions & 3 deletions docs/algorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ necessary to bring the final principal balance to zero.

There is no formula to calculate this as it requires recursion - the interest due depends on the principal balance, the amount you pay affects
how much interest is paid off (this is paid off first) and the remainder goes towards the principal, and the remaining principal determines
how must interest is due on the next payment.
how much interest is due on the next payment.

So we start with a rough payment: ```(principal + interest) / paymentCount```

Expand Down Expand Up @@ -58,7 +58,7 @@ We now have our initial payment schedule detailing the days and amounts to be pa
### Interest caps

The only other consideration in generating this initial schedule is to respect any interest caps imposed, both daily and total. For this reason
we maintain aggregate interst limits and aggregate interest amounts and compare them throughout the generation process, capping the interest where
we maintain aggregate interest limits and aggregate interest amounts and compare them throughout the generation process, capping the interest where
necessary.

## Applying actual payments to the initial schedule
Expand All @@ -80,7 +80,7 @@ When creating the amortisation schedule, we tie all of this information together

> There are a lot of variables and the order of calculation is critical, which is what makes F# such a good choice for implementing this. Some
variables are maintained in their original and modified form (typically suffixed by an apostrophe or two to make it easy to track the modifications),
and either form may be necessary throughout the algorithm. It is therefore recommended to examine the code itself if you need to see the detail.
and either form may be necessary throughout the algorithm. It is therefore recommended to examine the code itself if you need to see the details.

By way of overview though, the following are performed:

Expand Down
2 changes: 1 addition & 1 deletion docs/exampleAprUk.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ solution
(*** include-it ***)

(**
This result is of a `Array.Solution` type. `Found` means that it was able to find a solution.
This result is of an `Array.Solution` type. `Found` means that it was able to find a solution.
The APR, expressed as a decimal, is returned as the first item of the tuple. The APR is more usefully shown as a percentage,
which can easily be done as follows:
*)
Expand Down
2 changes: 1 addition & 1 deletion docs/exampleAprUs.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ solution
(*** include-it ***)

(**
This result is of a `Array.Solution` type. `Found` means that it was able to find a solution.
This result is of an `Array.Solution` type. `Found` means that it was able to find a solution.
The APR, expressed as a decimal, is returned as the first item of the tuple. The APR is more usefully shown as a percentage,
which can easily be done as follows:
*)
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# F# Finance - Personal

FSharp.Finance.Personal is a set of functions for calculating Annual Percentage Rates (APRs) and amortisation schedules on products such as personal loans, mortgages, etc.
FSharp.Finance.Personal is a set of functions for calculating Annual Percentage Rates (APRs) and amortisation schedules for products such as personal loans, mortgages, etc.

## APRs

Expand Down Expand Up @@ -32,4 +32,4 @@ This library is able to generate amortisation schedules based on a highly custom

### The `FSharp.Finance` family

`FSharp.Finance.Personal` covers personal finance, whereas `FSharp.Finance.Corporate` and `FSharp.Finance.Public` could potentially cover other areas of finance - anyone interested!?
`FSharp.Finance.Personal` covers personal finance, whereas `FSharp.Finance.Corporate` and `FSharp.Finance.Public` could potentially cover other areas of finance - anyone interested!?
4 changes: 2 additions & 2 deletions src/Amortisation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ module Amortisation =
type Schedule = {
/// a list of amortisation items, showing the events and calculations for a particular offset day
ScheduleItems: Map<int<OffsetDay>, ScheduleItem>
/// the offset day of the final cheduled payment
/// the offset day of the final scheduled payment
FinalScheduledPaymentDay: int<OffsetDay>
/// the final number of scheduled payments in the schedule
FinalScheduledPaymentCount: int
Expand Down Expand Up @@ -651,7 +651,7 @@ module Amortisation =
// post-process missed payments or underpayments
|> markMissedPaymentsAsLate

/// wraps the amortisation schedule in some statistics, and optionally calculate the final APR (optional because it can be processor-intensive)
/// wraps the amortisation schedule in some statistics, and optionally calculates the final APR (optional because it can be processor-intensive)
let calculateStats sp settlementDay (items: Map<int<OffsetDay>, ScheduleItem>) =
let finalItemDay, finalItem = items |> Map.maxKeyValue
let items' = items |> Map.toArray |> Array.map snd
Expand Down
10 changes: 5 additions & 5 deletions src/Scheduling.fs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ module Scheduling =
MaxDuration: Duration
}

/// the type of the scheduled; for scheduled payments, this affects how any payment due is calculated
/// the type of the schedule; for scheduled payments, this affects how any payment due is calculated
[<RequireQualifiedAccess; Struct>]
type ScheduleType =
/// an original schedule
Expand Down Expand Up @@ -363,7 +363,7 @@ module Scheduling =

/// parameters for creating a payment schedule
type Parameters = {
/// the date on which the schedule is inspected, typically today, but can be used to inspect it at any point (affects e.g. whether schedule payments are deemed as not yet due)
/// the date on which the schedule is inspected, typically today, but can be used to inspect it at any point (affects e.g. whether scheduled payments are deemed as not yet due)
AsOfDate: Date
/// the start date of the schedule, typically the day on which the principal is advanced
StartDate: Date
Expand Down Expand Up @@ -470,7 +470,7 @@ module Scheduling =
|> Cent.fromDecimalCent sp.InterestConfig.InterestRounding
|> Cent.min totalInterestCap
| _ -> 0L<Cent>
// calculate the approximate level payment value
// calculate the approximate level-payment value
let calculateLevelPayment interest = if paymentCount = 0 then 0m else (decimal sp.Principal + decimal feesTotal + interest) / decimal paymentCount
// create the initial item for the schedule based on the initial interest and principal
// note: for simplicity, principal includes fees
Expand Down Expand Up @@ -570,7 +570,7 @@ module Scheduling =
| Solution.Bypassed ->
// for the add-on interest method, now the schedule days and payment values are known, iterate through the schedule until the final principal balance is zero
// note: this step is required because the initial interest balance is non-zero, meaning that any payments are apportioned to interest first, meaning that
// the principal balance is paid off more slowly than it would otherwise be; this, in turn, generates higher interest, which leads to a higher intitial interest
// the principal balance is paid off more slowly than it would otherwise be; this, in turn, generates higher interest, which leads to a higher initial interest
// balance, so the process must be repeated until the total interest and the initial interest are equalised
match sp.InterestConfig.Method with
| Interest.Method.AddOn ->
Expand Down Expand Up @@ -680,7 +680,7 @@ module Scheduling =
previousRescheduleDay <- rescheduleDays |> Array.tryFind(fun d -> offsetDay >= d) |> toValueOption |> ValueOption.orElse previousRescheduleDay
// create the modified scheduled payment
match original, latestRescheduling with
// if there are any rescheduled payments, add the latest as well as the list of previously rescheduled payments on the day (also include original if any on the day)
// if there are any rescheduled payments, add the latest as well as the list of previously rescheduled payments on the day (also include the original if any on the day)
| _, ValueSome r ->
Some (offsetDay, {
Original = original |> ValueOption.bind _.Original
Expand Down
2 changes: 1 addition & 1 deletion src/UnitPeriod.fs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ module UnitPeriod =
| _ ->
0m

/// unit period combined with start date and multiple where appropriate
/// unit period combined with a start date and multiple where appropriate
[<Struct>]
type Config =
/// single on the given date
Expand Down

0 comments on commit 9a9921c

Please sign in to comment.