summaryrefslogtreecommitdiff
path: root/src/FundLab.Domain
diff options
context:
space:
mode:
Diffstat (limited to 'src/FundLab.Domain')
-rw-r--r--src/FundLab.Domain/Sip.fs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/FundLab.Domain/Sip.fs b/src/FundLab.Domain/Sip.fs
index 2db7fbd..28e0896 100644
--- a/src/FundLab.Domain/Sip.fs
+++ b/src/FundLab.Domain/Sip.fs
@@ -82,6 +82,25 @@ module SipPolicy =
let months = max 0 candidateMonths
rollToWeekday (addMonthsPreservingDay anchorDate months)
+ /// Due trade dates a plan must run through, from its current nextTradeDate up to and
+ /// including endDate. Calendar approximation: only weekends are skipped (Chinese fund
+ /// trading calendar approximated by weekdays; public holidays are not modeled here —
+ /// noted per the no-fabrication rule, holidays may be added to the calendar later).
+ let advancePlan
+ (frequency: SipFrequency)
+ (anchorDate: DateOnly)
+ (dueFrom: DateOnly)
+ (endDate: DateOnly)
+ : DateOnly list =
+ let rec loop (current: DateOnly) (acc: DateOnly list) =
+ if current > endDate then
+ List.rev acc
+ else
+ let following = nextTradeDate frequency anchorDate (current.AddDays 1)
+ loop following (current :: acc)
+
+ if dueFrom > endDate then [] else loop dueFrom []
+
/// Execution is out of scope for this slice. These pure helpers define the
/// due/settlement contract that the (future) executor will implement: when a
/// plan is due, the net amount debited equals the plan amount exactly, and no