Actuary data for one age, for both sexes.
Number of people surviving to this age.
Probability of surviving one year (birthday to next birthday).
Life expectency from this birthday.
Age (usually of people)
An integer between 0 and 255, inclusive.
A specification of a length of time in units specified as CalendarUnit. e.g.:
const interval = {month: 3}; // 3 months
Measured length of time. This incorporates a {@link CalenderInterval} and adds a measured {@link CalendarLength.totalDays} that measures the exact number of days.
{link @Tagged} type for category names.
Colors are strings in the form #rrggbb.
Description of a table column
Parameters to pass to computeTax.
A number between 0 and 360, inclusive of 0, exclusive of 360.
Other values are mathematically valid, but are constrained here for implementation convenience and reliability. Use mod360 to coerce to this range.
Integer age (usually of people)
Common fields for item states.
Specs are prrovided as JSON. This describes the input form. See IncomeStreamBoundSpec for the bound form.
An integer.
The model implementation for each Type.
Additional fields found in specific implementation types.
Extract the Type keyword from an IITem-based type.
An item's full state.
Alias denoting ExtractorFns used to obtain keys
For aggregation, k
An amount of money.
The unit interval: a number between 0 and 1, inclusive.
Interest/growth rate as a fraction (not percent).
A reference to an asset, income, or loan.
Because names are not costrained, the compiler won't actually enforce this; it only serves to document it for humans.
Relax the type checking on tagged types. You can use typeguards and validators to convert back to the unrelaxed version by checking.
the type being relaxed.
the tag being removed. Defaults for simple types, must be supplied for recursive.
Sex for actuarial purposes.
A generator that produces updated item states,
Create a tag for a tagged type. A tagged type is a compile-time-only thing that limits the intensional use of a type, and traces type validations.
The tag (as a string literal type) of a tagged type.
Create a taggged type. A tagged type is is a compile-time-only thing that limits the intensional use of a type, and traces type validations.
The calculation for a TaxYearTable. The table is in this
.
A tax rate (as a fraction, not percentage).
Assert that the argument n is of the type Tagged<T,B>. The compiler's type inferencing is informed that the return value has been validated to be of that type.
A function that coerces to a specified type.
A type guard. Returns true
if the argument n satisfies the conditions to be of
type T, and informs the compiler's type inferencing engine.
The unit interval: a number between 0 and 1, inclusive.
The base type of T without the Tag.
Alias denoting ExtractorFns used to obtain values.
Year as an integer.
Zero Money.
For each CalendarUnit, the number of occurrances of that unit per year.
The default end date is 50 years from the start.
Date
a century in the future.
Year number a century in the future.
Default to 50 years.
Prepackaged formatters.
The length of each month, 0-origin, for non-leap and leap years.
The starting day of each month, 0-origin, for non-leap and leap years.
Our interface to the Observable world. This must be set before
Actuary data from the Social Security Administration based on mortality in calendar year 2017.
Source: Actuarial Life Table (Archive)
The default start date is the start of the next month.
US State postal codes, plus US = Federal
Collection of sort comparator functions.
A comparator that sorts according to the "natural" order. First by type, then by string or numerical ordering if a string, number, boolean, or symbol.
A comparator that does not alter the sort order. It regards everything as equal, and thus Javascript's stable sort leaves the ordering unchanged.
0
Tax tables by state.
This year as a Date
referring to January 1.
Today as a Date
, starting at midnite (UTC).
Information about this version.
This year as a 4-digit number.
The supplied color scheme.
Map of fields to converters to convert to the proper type (e.g. number, date, etc.)
Function that throws its argument.
a string or an Error
.
Parse a UTC date.
a string.
a Date
, constrained to 00:00:00.000 UTC
.
Construct a UTC Date
(0-11), default = 0 (January)
(1-31), default = 1
a Date
, constrained to 00:00:00.000 UTC
.
Obtain actuarial data for a person on a particular date.
Interpolates from the actuarial tables. (Linear interpolation for now, although that is not strictly correct),
The date on which the age is desired.
Obtain actuarial data for a specified age and sex.
Interpolates from the actuarial tables. (Linear interpolation for now, although that is not strictly correct),
Specification for the aggregation to be performed.
A type-inferred cast to a Tagged type. This is primarily intended for use with constants, where supplying the correct type can be determined by inspection
Generally the type parameters will be inferred.
let foo: Integer = as(1);
the tag type
the base (untagged) type.
a value in the base type
n
cast to be of the expected Tagged<T,B> type.
Assert that the argument n is of the type Tagged<T,B>. The compiler's type inferencing is informed that the return value has been validated to be of that type.
Assert that the argument n is of the type Tagged<T,B>. The compiler's type inferencing is informed that the return value has been validated to be of that type.
Assert that the argument n is of the type Tagged<T,B>. The compiler's type inferencing is informed that the return value has been validated to be of that type.
Assert that the argument n is of the type Tagged<T,B>. The compiler's type inferencing is informed that the return value has been validated to be of that type.
Assert that the argument n is of the type Tagged<T,B>. The compiler's type inferencing is informed that the return value has been validated to be of that type.
Assert that the argument n is of the type Tagged<T,B>. The compiler's type inferencing is informed that the return value has been validated to be of that type.
Coerce an unknown value to a number. Strings and other things coercible to numbers will be converted. An error will be thrown if the result does not satisfy isNumber.
a number, or something coerced to a number
Assert that the argument n is of the type Tagged<T,B>. The compiler's type inferencing is informed that the return value has been validated to be of that type.
Assert that the argument n is of the type Tagged<T,B>. The compiler's type inferencing is informed that the return value has been validated to be of that type.
Coerce an unknown value to a string. Numbers will be converted.
a number, or something coerced to a number
Assert that the argument n is of the type Tagged<T,B>. The compiler's type inferencing is informed that the return value has been validated to be of that type.
Assert that the argument n is of the type Tagged<T,B>. The compiler's type inferencing is informed that the return value has been validated to be of that type.
Assert that the argument n is of the type Tagged<T,B>. The compiler's type inferencing is informed that the return value has been validated to be of that type.
Assert that the call in the argument cannot return.
Check that the supplied {@link Row} is of the desired Type, returning it as that type, or throwing an exception if it is not.
The {@link Row} to check
NOP for the moment. Replaces:
html`<div style='border: 1px solid blue; padding: 5px; margin-right: 1px;'> ${content} </div>`
Calculate the difference between two dates, in fractional years.
Construct a CalendarRange.
A CalendarRange is a CalendarPeriod that is divided up by increments of time into
a series of CalendarStep segments. These segments can be iterated over in a for
loop:
for (const step in calendarRange) {
console.log(step.start, step.end, JSON.stringify(step.length));
}
The start Date
.
The end Date
.
The units of increment.
The number of units.
Check that the supplied {@link Row} is of the specified Type
The {@link Row} to check
the Type the row should be.
Construct a family of type functions: a type guard, a coersion, and a checked cast.
A class constructor
an optional coercion function to be tried in the to* (coercion) variant
Compute a set of color mappings for items in a given set of keys. A higher-order function. Supply color_scheme (and optionally unknown), and it will return a a function that accepts a list of keys
a list of colors in '#rrggbb' format.
the color to use for unknown keys
an object equivalent to a d3 ordinal interpolator.
Compute a set of color mappings for items in a given set of scenarios. A higher-order function. Supply color_scheme (and optionally unknown), and it will return a a function that accepts a list of scenarios
a list of colors in '#rrggbb' format.
the color to use for unknown keys
a d3 ordinal interpolator.
Construct an item from a row object
The type of item (defaulted from the item)
the constructed instance.
Convert interest rates between different compounding periods.
The rate per year in the original compounding period.
The number of periods per year for the original compounding period, or the corresponding CalendarUnit.
The number of periods per year for the new compounding period, or the corresponding CalendarUnit.
The effective rate per year at the new compounding period.
Convert interest rates between different compounding periods.
The rate per year in the original compounding period.
The number of periods per year for the original compounding period, or the corresponding CalendarUnit.
The number of periods per year for the new compounding period, or the corresponding CalendarUnit.
The effective rate per period at the new compounding period.
Get the beginning of the supplied day (using UTC for consistency).
The day of the year.
Obtain the day number of a given Date
The given Date
.
number of days since January 1
Decode a CalendarInterval into [
CalendarUnit, count]
.
Coerce a field name or ExtractorFn to an ExtractorFn.
field name or ExtractorFn
Format the date as year-mo-dd
Format the time as year-mo-dd HH:MM:SS
Format the date as year-mo
Format a number as a percentage.
Format a number as
0 or 2 (default = 2) positions for cents
Format the time as HH:MM:SS
Format a number as US currency.
a number as US currency
0 or 2 (default = 2) positions for cents
Format the date as year
Format the date as 'year
Format the date as 'year
Given a Heap
, give a generator to the (sorted) values in the heap.
Simple type-aware identity function.
a
Increment a time by a specified period of time.
The returned value is truncated to the beginning of the UTC day.
The date to be incremented
A CalendarInterval denoting how much to increment by.
Increment a time by a specified period of time.
The returned value is truncated to the beginning of the UTC day.
The date to be incremented
The number of units to increment by
Produce an index to a list of {@link Named objects.
A list of Named objects
An index of the objects by name.
A type guard. Returns true
if the argument n satisfies the conditions to be of
type T, and informs the compiler's type inferencing engine.
A type guard. Returns true
if the argument n satisfies the conditions to be of
type T, and informs the compiler's type inferencing engine.
Type guard that determines if the argument is a valid CalendarInterval.
The object under test
A type guard. Returns true
if the argument n satisfies the conditions to be of
type T, and informs the compiler's type inferencing engine.
A type guard. Returns true
if the argument n satisfies the conditions to be of
type T, and informs the compiler's type inferencing engine.
A type guard. Returns true
if the argument n satisfies the conditions to be of
type T, and informs the compiler's type inferencing engine.
Return true
iff the supplied year is a leap year.
The year as a number
Type guard to determine if the argument has a monetary .value
field.
A type guard. Returns true
if the argument n satisfies the conditions to be of
type T, and informs the compiler's type inferencing engine.
Type guard for numbers.
true
if the argument n is a number, not a NaN
, and finite.
A type guard. Returns true
if the argument n satisfies the conditions to be of
type T, and informs the compiler's type inferencing engine.
A type guard. Returns true
if the argument n satisfies the conditions to be of
type T, and informs the compiler's type inferencing engine.
Type guard for strings.
true
if the argument n is a string.
A type guard. Returns true
if the argument n satisfies the conditions to be of
type T, and informs the compiler's type inferencing engine.
A type guard. Returns true
if the argument n satisfies the conditions to be of
type T, and informs the compiler's type inferencing engine.
A type guard. Returns true
if the argument n satisfies the conditions to be of
type T, and informs the compiler's type inferencing engine.
Load data from the specified URL.
URL to load the data from
This looks up a tax in a classic federal-style tax table.
A higher-order function that returs a sort function.
a comparator
a sort function that sorts a list according to cmp
Higher-order function, that creates summing functions.
a function that takes an item and returns a number.
a function that validates that the result is of type V
.
a function that takes a list of items and returns the sum of the values returned by applying f.
Merge operator to merge to a list of values.
Key for the merged items. Ignored.
Merge object that merges to a list of values.
Higher order Merge operator. This takes a specification object and an optional onUnequal action.
The result is a Merge operator that performs each supplied merge in parallel, and producing a result object with the results of the sub-merges indicated by the specification object.
The specification object is an object with a field for each field of the result.
Each field value of the specification object is either a MergeFn, or a tuple of [extractor, MergeFn].
If an extractor is supplied, it is either a field to be extracted, or a function that takes the value supplied to the parent merge and produces the value to be merged by the sub-merge.
If the specification is an array, the result of the merge will be an array of the same size.
Merge operator to sum a set of numbers.
The merge key. Ignored
the sum of the numbers supplied
A comparator that sorts according to the "natural" order. First by type, then by string or numerical ordering if a string, number, boolean, or symbol.
A function that sorts according to natural order. See naturalCMP.
a copy of list in sorted order.
A comparator that does not alter the sort order. It regards everything as equal, and thus Javascript's stable sort leaves the ordering unchanged.
0
Create functions to test and assert membership in a tagged numerical range.
the type tag
the specification of the range to be enforced.
a DomainFns with the test and assert functions.
A higher-order function that takes a converter function and gives a higher-order function that takes a default, which returns a converter that uses the default when no value is supplied, instead of invoking the converter.
a converter function
A higher-order function that returns a @{link Converters} provides a default in cases where a value is not supplied in the input.
Default value
Parse a UTC date, in one of the following forms:
2021-08-13
2021-08
// Same as 2021-08-01
2021
// Same as 2021-01-01
Leading zeros on month and day are optional. Two-year year abbreviations are not allowed.
A string in the form YYYY-MMM-dd
a Date at 00:00:00.000 UTC
.
A higher-order-function that produces a rounding function that rounds to the nearest n.
scale of rounding
Format a row of values in a Markdown table.
Array of values for the cells in the row
a markdown-formatted string
Split a comma-separated field.
A function that coerces to a specified type.
A function that coerces to a specified type.
A function that coerces to a specified type.
A function that coerces to a specified type.
A function that coerces to a specified type.
A function that coerces to a specified type.
A function that coerces to a specified type.
A function that coerces to a specified type.
A function that coerces to a specified type.
A function that coerces to a specified type.
A function that coerces to a specified type.
Get the total value of a list of monetary items.
a list of IMonetaryItem items.
Rolls back time to the start of a year, quarter, month, or day. Higher-order function that returns a function for the specific time period to truncate to.
Unit of time to truncate to (must not be 'week').
(date: {@link Date}) => {@link Date}
Construct a family of type functions: a type guard, a coersion, and a checked cast.
A type guard.
A string for error messages, when the type guard fails
an optional coercion function to be tried in the to* (coercion) variant
Returns the unique values, as compared by ===
a list of strings or other values to be compared by ===
A specification of the validation/coercion to be performed.
Convert a TypeAssertion for type T into one for T | undefined
.
an existing typeguard.
Convert a TypeCoercion for type T into one for T | undefined
.
Return the Date
for January 1 in the year of the supplied date.
the date
The number of days in a particular year.
The year as a number
365 or 366
Generated using TypeDoc
Retirement Simulator
Retirement-simulator library. It is intended to be used in an exploratory manner in an ObservableHQ notebook.
Key Modelling Concepts
Balance Sheet
These concepts are what you have; together, they determine your net worth.
Cash Flow
Cash flow is money in or out. Together, they determine your net income, which can be positive or negative.
While technically, asset growth is reinvested investment income, we do not need to model it that way, as it would complicate the picture with details. With investments in a protected tax-deferred retirement account, with dividends and interest automatically reinvested, it is simpler to model as compound growth. However, nothing prevents you from modeling it as an income stream adding to the asset.
Other
Interfaces
The key modeling classes have corresponding interface types, to facilitate working with the raw data without instantiation as a class instance.
Other Facilities