Skip to content

Commit e6d34c9

Browse files
authored
Merge pull request #831 from smucclaw/thomasgorissen/update-libs-and-actus-docs
Update core libraries and add ACTUS documentation
2 parents 5610c4b + 3e2f357 commit e6d34c9

File tree

9 files changed

+145
-27
lines changed

9 files changed

+145
-27
lines changed

doc/reference/GLOSSARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ For complete documentation, see **[Libraries Reference](libraries/README.md)**.
253253
| ----------------- | ------------------------------------ |
254254
| **prelude** | Standard functions (always imported) |
255255
| **daydate** | Date calculations and temporal logic |
256+
| **actus** | ACTUS financial contract standards |
256257
| **excel-date** | Excel date compatibility |
257258
| **math** | Mathematical functions |
258259
| **currency** | ISO 4217 currency handling |

doc/reference/libraries/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Core libraries are located in the [jl4-core/libraries/](https://github.com/smucc
1414
- **[legal-persons](legal-persons.md)** - Legal entity types and capacity
1515
- **[jurisdiction](jurisdiction.md)** - Jurisdiction definitions
1616
- **[holdings](holdings.md)** - Holdings and ownership
17+
- **[actus](actus.md)** - ACTUS financial contract types and evaluation
1718
- **[date-compat](date-compat.md)** - Legacy DATE syntax compatibility
1819
- **[llm](llm.md)** - LLM API integration
1920

doc/reference/libraries/actus.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# ACTUS Library
2+
3+
Algorithmic Contract Types Unified Standards ([actusfrf.org](https://www.actusfrf.org)) implementation in L4. Provides types and functions for modelling standardised financial contracts.
4+
5+
Import with `IMPORT actus` to get all modules, or import individual modules selectively.
6+
7+
### Location
8+
9+
| File | Purpose |
10+
| ------------------------------------------------------------------------------------------------------ | ----------------------------------------- |
11+
| [actus.l4](https://github.com/smucclaw/l4-ide/blob/main/jl4-core/libraries/actus.l4) | Main entry point (re-exports all modules) |
12+
| [actus-core.l4](https://github.com/smucclaw/l4-ide/blob/main/jl4-core/libraries/actus-core.l4) | Core types (contract types, roles, enums) |
13+
| [actus-terms.l4](https://github.com/smucclaw/l4-ide/blob/main/jl4-core/libraries/actus-terms.l4) | Contract term definitions |
14+
| [actus-state.l4](https://github.com/smucclaw/l4-ide/blob/main/jl4-core/libraries/actus-state.l4) | Contract state variables |
15+
| [actus-events.l4](https://github.com/smucclaw/l4-ide/blob/main/jl4-core/libraries/actus-events.l4) | Event types and operations |
16+
| [actus-daycount.l4](https://github.com/smucclaw/l4-ide/blob/main/jl4-core/libraries/actus-daycount.l4) | Day count conventions and year fractions |
17+
| [actus-schedule.l4](https://github.com/smucclaw/l4-ide/blob/main/jl4-core/libraries/actus-schedule.l4) | Schedule generation |
18+
19+
### Core Types (`actus-core`)
20+
21+
**Contract Type Taxonomy** (~32 ACTUS contract types organised into families):
22+
23+
- `Basic Contract Type` — PAM, LAM, NAM, ANN, CLM, CSH, STK, UMP, COM
24+
- `Exotic Basic Contract Type` — LAX, NAX, ANX
25+
- `Combined Contract Type` — SWAPS, SWPPV, OPTNS, FUTUR, FXOUT, CAPFL, BCS
26+
- `Credit Enhancement Contract Type` — CEG, CEC, MAR
27+
28+
**Contract Role** — RPA, RPL, CLO, CNO, COL, LG, ST, BUY, SEL, RFL, PFL, RF, PF
29+
30+
- `` `role sign` `` — sign multiplier for payoff calculations (+1 or -1)
31+
32+
**Contract Performance** — PF (performant), DL (delayed), DQ (delinquent), DF (default), MA (matured), TE (terminated)
33+
34+
- `` `is non-performing` ``, `` `is active` `` — performance predicates
35+
36+
**Day Count Convention** — AA, A360, A365, `30E360`, `30E360ISDA`, BUS252
37+
38+
**Other Enums:**
39+
40+
- `End of Month Convention` — EOM, SD, EOMP
41+
- `Business Day Convention` — SCR, SCRF, SCRP, SCRMF, SCRMP
42+
- `Calendar Type` — NoCalendar, MondayToFriday, Calendar
43+
- `Period Unit` — Days, Weeks, Months, Quarters, Years
44+
- `Stub Convention` — Long/Short Initial/Final
45+
- `Interest Payment Convention` — PayInterest, CapitalizeInterest
46+
- `Penalty Type` — NoPenalty, AbsolutePenalty, RelativePenalty, InterestPenalty
47+
- `Option Type` / `Option Exercise Type` — Call, Put, Straddle / European, American, Bermudan
48+
- `Scaling Effect` — NoScaling, InterestScaling, PrincipalScaling, BothScaling
49+
- `ACTUS Currency` — USD, EUR, GBP, JPY, CHF, CAD, AUD, CNY, HKD, SGD, or custom via `ACTUS Other`
50+
51+
**Cycle** — record with `period`, `periodUnit`, `stub`; convenience constructors: `` `Monthly Cycle` ``, `` `Quarterly Cycle` ``, `` `Semi-Annual Cycle` ``, `` `Annual Cycle` ``
52+
53+
### Contract Terms (`actus-terms`)
54+
55+
- `ACTUS Contract Terms` — core contract parameters (ID, type, role, dates, principal, rate, day count convention)
56+
- `FXOUT Terms` — FX outright transaction parameters
57+
- `` `implied exchange rate` `` — derive rate from FX term amounts
58+
59+
### Contract State (`actus-state`)
60+
61+
- `Contract State` — runtime state (statusDate, contractPerformance, notionalPrincipal, accruedInterest, nominalInterestRate, feeAccrued)
62+
- `` `is fully paid` ``, `` `is in default` ``, `` `outstanding balance` `` — state predicates
63+
- `` `empty state` `` — default initial state
64+
65+
### Contract Events (`actus-events`)
66+
67+
**Event Types:** IED, PR, PP, MD, IP, IPCI, RR, RRF, FP, PY, TD, XD, STD, DV, CE, AD
68+
69+
- `Contract Event` — record with eventType, eventDate, payoff, currency, notionalPrincipal, nominalInterestRate, accruedInterest
70+
- `` `make event` `` — event constructor
71+
- `` `event sequence` ``, `` `event name` ``, `` `event acronym` `` — event metadata
72+
- `` `is principal event` ``, `` `is interest event` ``, `` `has cash flow` `` — event predicates
73+
- `` `total payoff` `` — sum payoffs across a list of events
74+
75+
### Day Count Conventions (`actus-daycount`)
76+
77+
- `` `year fraction` `` — Y(S,E) calculation dispatching on convention
78+
- `` `year fraction A365` ``, `` `year fraction A360` `` — specific convention implementations
79+
- `` `days between` `` — raw day count between two dates
80+
- `` `accrued interest for period` `` — interest accrual given principal, rate, dates, and convention
81+
82+
### Schedule Generation (`actus-schedule`)
83+
84+
- `` `add months` ``, `` `add days` `` — date arithmetic with month-end clamping
85+
- `` `monthly schedule` `` — generate a list of monthly dates from a start date
86+
- `` `schedule length` `` — count dates in a schedule
87+
88+
### Evaluation Engine (`actus`)
89+
90+
**Payoff Functions (POF):**
91+
92+
- `` `POF_IED` `` — Initial Exchange Date payoff
93+
- `` `POF_IP` `` — Interest Payment payoff
94+
- `` `POF_MD` `` — Maturity payoff
95+
- `` `POF_PR` `` — Principal Redemption payoff
96+
97+
**State Transition Functions (STF):**
98+
99+
- `` `STF_IED` `` — initialise state after initial exchange
100+
- `` `STF_IP` `` — reset accrued interest after payment
101+
- `` `STF_MD` `` — contract reaches maturity
102+
- `` `STF_PR` `` — reduce notional by redemption amount
103+
104+
**Interest Accrual:**
105+
106+
- `` `accrue interest to` `` — accrue interest from current state date to a target date
107+
108+
**FX Transaction (FXOUT):**
109+
110+
- `` `FXOUT pay event` ``, `` `FXOUT receive event` `` — generate FX cash flow events
111+
112+
**Cash Flow Projection:**
113+
114+
- `` `net cash flow` `` — sum all cash flows from a list of events
115+
116+
**See the [actus.l4](https://github.com/smucclaw/l4-ide/blob/main/jl4-core/libraries/actus.l4) source and sub-modules for full details.**

doc/reference/libraries/date-compat.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@ Provides the uppercase DATE constructor for code that used the old record-based
1212

1313
**Legacy syntax:** DATE 15 3 1990
1414
**Modern syntax:** Date 15 3 1990
15+
16+
### Field Accessor Helpers
17+
18+
Named functions to extract date components:
19+
20+
- `` `Day of` `` / `` `day of` `` — extract day from date (`DATE_DAY`)
21+
- `` `Month of` `` / `` `month of` `` — extract month from date (`DATE_MONTH`)
22+
- `` `Year of` `` / `` `year of` `` — extract year from date (`DATE_YEAR`)
23+
24+
Each accessor has a capitalised primary name and a lowercase `AKA` alias.

doc/reference/libraries/daydate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Daydate Library
22

33
Date arithmetic and temporal logic for legal deadlines and time-based rules. Follows ISO 8601 conventions.
4-
Can be imported into L4 files with `IMPORT daydate`.
4+
Can be imported into L4 files with `IMPORT daydate`. Automatically imports `date-compat` for backwards-compatible DATE accessors.
55

66
### Location
77

doc/reference/libraries/prelude.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The prelude can be imported into every L4 program with `IMPORT prelude` and prov
2121

2222
- `map` - Apply function to each element
2323
- `filter` - Keep elements matching predicate
24+
- `count` - Count number of elements in a list
2425
- `take` - First n elements
2526
- `drop` - All but first n elements
2627
- `takeWhile` / `dropWhile` - Conditional take/drop

jl4-core/libraries/date-compat.l4

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
--
1515
-- If you need the old field accessor style, use the helpers below.
1616

17-
IMPORT prelude
18-
IMPORT daydate
19-
2017
§§ `DATE Constructor Alias`
2118

2219
-- Provides DATE as an alias for Date for backwards compatibility
@@ -34,32 +31,14 @@ GIVETH A DATE
3431

3532
§§ `Field Accessor Helpers`
3633

37-
-- These provide named functions to replace the old field accessor syntax
38-
-- Usage: `day of` someDate (instead of someDate's day)
39-
40-
GIVEN date IS A DATE
41-
GIVETH A NUMBER
42-
`day of` MEANS DATE_DAY date
43-
44-
GIVEN date IS A DATE
45-
GIVETH A NUMBER
46-
`month of` MEANS DATE_MONTH date
47-
48-
GIVEN date IS A DATE
49-
GIVETH A NUMBER
50-
`year of` MEANS DATE_YEAR date
51-
52-
-- Alternative postfix style accessors
53-
-- Usage: someDate's `the day`
54-
5534
GIVEN date IS A DATE
5635
GIVETH A NUMBER
57-
`the day` date MEANS DATE_DAY date
36+
`Day of` AKA `day of` MEANS DATE_DAY date
5837

5938
GIVEN date IS A DATE
6039
GIVETH A NUMBER
61-
`the month` date MEANS DATE_MONTH date
40+
`Month of` AKA `month of` MEANS DATE_MONTH date
6241

6342
GIVEN date IS A DATE
6443
GIVETH A NUMBER
65-
`the year` date MEANS DATE_YEAR date
44+
`Year of` AKA `year of` MEANS DATE_YEAR date

jl4-core/libraries/daydate.l4

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
-- A week begins on Monday
66
-- Check the test/daydate.l4 file to see examples
77

8-
8+
IMPORT `date-compat`
99

1010

1111
§§ `Constants`
@@ -322,7 +322,6 @@ GIVETH A NUMBER
322322

323323

324324

325-
326325
§§ `Weekday Functions`
327326

328327

jl4-core/libraries/prelude.l4

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ filter f list MEANS
9696
THEN x FOLLOWED BY filter f xs
9797
ELSE filter f xs
9898

99+
GIVEN a IS A TYPE
100+
list IS A LIST OF a
101+
GIVETH A NUMBER
102+
count list MEANS
103+
go 0 list
104+
WHERE
105+
go acc l MEANS
106+
CONSIDER l
107+
WHEN EMPTY THEN acc
108+
WHEN x FOLLOWED BY xs THEN go (acc + 1) xs
109+
99110
GIVEN
100111
a IS A TYPE
101112
list IS A LIST OF a

0 commit comments

Comments
 (0)