Skip to content

Commit 7a57066

Browse files
Changing funding cost approximation and MC accrual.
1 parent bd094ba commit 7a57066

File tree

2 files changed

+77
-193
lines changed

2 files changed

+77
-193
lines changed

src/main/java/net/finmath/smartcontract/simulation/SDCCollateralizedHistoricalSimulation.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public static void main(String args[]) throws Exception {
7979
double accrualFactor, valueCurrent, valueChange, cappedValueChange, gapAmount;
8080
double gapAccount = 0.0;
8181
double realizedCashFlows = 0.0;
82-
double fundingCosts = 0.0;
8382
// If trade has initially a non-zero value -> collateral needs to be set up by an up-front payment
8483
double collateralAccount = valuePrevious;
8584

@@ -115,10 +114,7 @@ public static void main(String args[]) throws Exception {
115114
collateralAccount = collateralAccount + accrualFactor * cappedValueChange;
116115
// D_i = D_{i-1}*(1+rt) + Z_i
117116
gapAccount = gapAccount * accrualFactor + gapAmount;
118-
}
119-
120-
// Sum up funding costs. Margin buffer and funding spread can be time dependent
121-
fundingCosts += marginFloor * fundingSpread * FloatingpointDate.getFloatingPointDateFromDate(valuationDatePrevious, valuationDateCurrent);
117+
}
122118
// Reuse current values as previous ones for next iteration
123119
valuationDatePrevious = valuationDateCurrent;
124120
valuePrevious = valueCurrent;
@@ -130,6 +126,8 @@ public static void main(String args[]) throws Exception {
130126
// Add increment results to result array
131127
margin.add(marginFloor);
132128
cashFlow.add(realizedCashFlows);
129+
// Constant Margin buffer and funding spread, but can be time dependent
130+
double fundingCosts = marginFloor * (1.0 - Math.exp(-fundingSpread * FloatingpointDate.getFloatingPointDateFromDate(startDate, forwardCurveSnapshots.get(valuationEndIndex - 1).getValuationDate())));
133131
funding.add(fundingCosts);
134132
}
135133

0 commit comments

Comments
 (0)