π
Scheduled Investment Provider (scheduled_investment)
A synthetic, deterministic provider that calculates the value of an asset based on a predefined interest schedule. It makes no external calls and requires no DB access for calculation. It is one of the Asset Providers.
π User Guide: Scheduled Investment β User Manual
βοΈ Configuration Schema
The asset's value is determined entirely by provider_params, which follow the FAScheduledInvestmentSchedule schema:
| Field | Type | Required | Description |
|---|---|---|---|
initial_value |
Currency |
β | Principal / face value (e.g., {"code": "EUR", "amount": 10000}) |
interest_type |
SIMPLE \| COMPOUND |
β | Global interest method (default: SIMPLE) |
day_count |
ACT/365 \| ACT/360 \| ACT/ACT \| 30/360 |
β | Day count convention (default: ACT/365) |
schedule |
FAInterestRatePeriod[] |
β | List of interest rate periods (non-overlapping, contiguous) |
late_interest |
FALateInterestConfig |
β | Optional penalty rate after maturity |
asset_events |
FAAssetEventPoint[] |
β | Manually defined asset events |
π Interest Rate Period (FAInterestRatePeriod)
| Field | Type | Default | Description |
|---|---|---|---|
start_date |
date |
β | Period start (inclusive) |
end_date |
date |
β | Period end (inclusive) |
annual_rate |
Decimal |
β | Annual rate as decimal (e.g., 0.05 for 5%) |
maturation_frequency |
MaturationFrequency |
DAILY |
Emission granularity: DAILY, WEEKLY, MONTHLY, QUARTERLY, SEMIANNUAL, ANNUAL |
generate_interest |
bool |
false |
Auto-generate INTEREST events at each maturation date |
π Calculation Engine
Price formula:
- SIMPLE:
I = Pβ Γ r Γ Ξtβ interest always on initial principal - COMPOUND:
I_day = V_{t-1} Γ r Γ Ξtβ interest on running accumulated value
Emission: Price points are emitted only at maturation dates (not every day), matching the maturation_frequency. Start and end dates of each period always produce a point regardless.
π Auto-Generated Events (generate_interest)
When generate_interest = True on a period:
- At each maturation date, the engine checks if accrued interest is positive
- If positive, generates an π΅ INTEREST event:
value = current_value - initial_value - After the event:
total_interest = 0,event_adjustment = 0β value resets toinitial_value - Interest accrual restarts from zero on the next day
Coupon Reset Behavior
The INTEREST event represents a "coupon payout" β the accumulated interest is crystallized and paid out, resetting the running value back to the original principal.
π MATURITY_SETTLEMENT Event
Auto-generated when:
- The last schedule period has
generate_interest = Trueand nolate_interestis configured - Or
late_interesthasgenerate_interest = True(settlement at the last late maturation date)
After settlement, the engine is "off" β get_current_value() returns the settlement value for all future dates.
See Asset Events for the full event type reference.
β° Late Interest (FALateInterestConfig)
Applied after the asset's maturity date (last period end_date):
| Field | Type | Default | Description |
|---|---|---|---|
annual_rate |
Decimal |
β | Annual late interest rate |
grace_period_days |
int |
0 |
Days after maturity before late interest starts |
interest_type |
SIMPLE \| COMPOUND |
COMPOUND |
Late interest compounds by default (penalties grow) |
maturation_frequency |
MaturationFrequency |
DAILY |
Emission frequency for late period |
generate_interest |
bool |
false |
Auto-generate INTEREST + MATURITY_SETTLEMENT events |
Skip Formula Optimization
SIMPLE late interest uses a closed-form calculation for efficiency. COMPOUND late interest uses day-by-day accumulation only within the late sub-period, not from asset start.
β‘ Caching & Invalidation
The engine caches the full schedule computation as a tuple[dict, list[FAAssetEventPoint]]:
- Key: Hash of the entire
provider_paramsJSON. - Invalidation: Cache is invalidated when
provider_paramschanges (i.e., the user reconfigures the schedule via the frontendScheduledInvestmentEditor). - Hit behavior: On cache hit,
get_history_value()slices the pre-computed dict to the requested date range β O(1) per point. - Miss behavior: Full schedule recomputation from
initial_valuethrough all periods. This is deterministic and fast (no I/O), typically < 10ms even for multi-year schedules.
The cache lives in the provider instance (in-memory, per-process). It survives across multiple sync calls but is cleared on server restart.
π§ Internal State Variables
During computation, the engine tracks these internal variables per day:
| Variable | Description | Reset behavior |
|---|---|---|
total_interest |
Cumulative accrued interest since last coupon/start | Reset to 0 after INTEREST event |
event_adjustment |
Net sum of PRICE_ADJUSTMENT events | Reset to 0 after INTEREST event |
running_value |
initial_value + total_interest + event_adjustment |
Computed per-day |
These variables are NOT persisted β they exist only during computation.
π Use Cases
- P2P/Crowdfunding Loans: Model a loan with fixed interest rate and periodic coupon payouts.
- Fixed-Rate Bonds: Calculate bond value including accrued interest and coupon payments.
- Any asset with predictable, deterministic cash flows.
π Example
A P2P loan of β¬10,000 with 5% simple annual interest, monthly coupons (generate_interest: true):
- Day 1β30: value grows from β¬10,000 to ~β¬10,041
- Month end (maturation): π΅ INTEREST event of β¬41 β value resets to β¬10,000
- Month 2: value grows again from β¬10,000
- Maturity: π MATURITY_SETTLEMENT event β engine stops
π§ Technical Notes
financial_math.pyeliminated: All financial math functions (calculate_day_count_fraction,calculate_simple_interest,_compute_maturation_dates) are now insidescheduled_investment.pyas a# Financial Mathsection.identifier_type: AlwaysAUTO_GENERATEDβ the engine generates its own UUID identifier.params_schema: Exposes a complex schema with_ui_component: "ScheduledInvestmentEditor"hint for the frontend to render a dedicated editor component.supports_events = True: The provider returns both price points and events viaFAHistoricalData.
π Related Documentation
- π Scheduled Investment β User Guide β End-user configuration guide
- π Asset Events β Event types, dedup strategy, MATURITY_SETTLEMENT
- π Day Count Conventions β ACT/365, ACT/360, 30/360, ACT/ACT
- π Asset Types β CROWDFUND_LOAN, BOND, etc.
- π° Asset Architecture β Sync pipeline and event persistence
- π¦ Providers Overview β All available providers