Scheduled cost rules

ScheduledCostRule fires on a recurring schedule for example a monthly management fee. It does not expose any extra globals, it can only use what is defined at the Shared API.

Recurrence

The schedule is defined by a RecurrencePattern (RecurrenceRule) on the rule:

Field Meaning
RRule An iCalendar RRULE string describing the recurrence (e.g. monthly, quarterly).
LastInvoked UTC timestamp of the most recent fire; advanced by the scheduler each time. Can be set explicitly to retroactively calculate costs. (e.g. if today it’s 1st of January 2026, and this is set to 1st of January 2025, then costs will be calculated from 2025-2026 with a frequency of what is defined in the RRule)
NextOccurrence UTC timestamp for the next due occurrence. This will be recalculated automatically if the RRule changes

Examples

-- Flat monthly fee
return 9.95
-- 0.15% per period on the average balance over the last month
local balances = portfolio.balancesBetween(today.addMonths(-1), today, true, false, false)
local sum = 0
for _, b in ipairs(balances) do sum = sum + b end
local avg = (#balances > 0) and (sum / #balances) or 0
return avg * 0.0015
-- Fee scaled by the number of account owners
return 5 * investmentAccount.ownerCount()

Back to top

© 2026 Pengine.