Skip to content

Commit d61f07d

Browse files
committed
2 parents 826a954 + 33d80da commit d61f07d

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

src/main/java/net/finmath/equities/marketdata/FlatYieldCurve.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public FlatYieldCurve(
2525
this.rate = rate;
2626
this.dayCounter = dayCounter;
2727
}
28+
29+
public FlatYieldCurve rollToDate(LocalDate date)
30+
{
31+
return new FlatYieldCurve(date, rate, dayCounter);
32+
}
2833

2934
public double getRate(double maturity)
3035
{

src/main/java/net/finmath/equities/models/BuehlerDividendForwardStructure.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public BuehlerDividendForwardStructure cloneWithNewDate(LocalDate newDate)
6565
return new BuehlerDividendForwardStructure(
6666
newDate,
6767
this.spot,
68-
this.repoCurve,
68+
this.repoCurve.rollToDate(newDate),
6969
this.dividendStream,
7070
this.dayCounter);
7171
}

src/main/java/net/finmath/equities/pricer/AnalyticOptionValuation.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ public double calculate(
5858
final var ttm = dcc.getDaycountFraction(forwardStructure.getValuationDate(), expiryDate);
5959
final var forward = forwardStructure.getForward(expiryDate);
6060
final var discountFactor = discountCurve.getDiscountFactor(expiryDate);
61-
//var repoRate = forwardStructure.getRepoCurve().getRate(expiryDate);
62-
final var repoRate = discountCurve.getRate(expiryDate);
61+
final var discountRate = discountCurve.getRate(expiryDate);
6362
final var adjustedForward = forwardStructure.getDividendAdjustedStrike(forward, expiryDate);
6463
final var adjustedStrike = forwardStructure.getDividendAdjustedStrike(option.getStrike(), expiryDate);
6564
final var volatility = volaSurface.getVolatility(
@@ -111,14 +110,7 @@ public double calculate(
111110
volatility,
112111
option.isCallOption(),
113112
discountFactor * adjustedForward,
114-
repoRate)
115-
- repoRate * Black76Model.optionPrice(
116-
1.0,
117-
adjustedStrike / adjustedForward,
118-
ttm,
119-
volatility,
120-
option.isCallOption(),
121-
discountFactor * adjustedForward);
113+
discountRate);
122114
default:
123115
throw new NotImplementedException("Calculation for " + calcType + " not implemented yet.");
124116
}

src/main/java/net/finmath/equities/pricer/PdeOptionValuation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ else if (i == j - 1 || i == j + 1)
401401
* dFdS / dFdX;
402402
final var gamma = discountFactor * (prices.getEntry(spotIndex + 1) + prices.getEntry(spotIndex - 1)
403403
- 2 * prices.getEntry(spotIndex)) / spaceStepSq * dFdS * dFdS / dFdX / dFdX;
404-
final var theta = (discountFactor * lastAtmPrice - price) / dt;
404+
final var discountFactorTheta = discountCurve.getDiscountFactor(expiryTime - dt);
405+
final var theta = (discountFactorTheta * lastAtmPrice - price) / dt;
405406
return new double[] {price, delta, gamma, theta};
406407
}
407408
else

src/test/java/net/finmath/equities/AnalyticOptionValuationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ public void Test_sensis() throws CalculationException
133133
final var anaTheta = pricer.getTheta(option, fwdStructure, discountCurve, flatVol);
134134
final var thetaDate = valDate.plusDays(1);
135135
final var thetaSpot = fwdStructure.getForward(thetaDate);
136+
final var thetaCurve = discountCurve.rollToDate(thetaDate);
136137
final var shiftedFwdStructure = fwdStructure.cloneWithNewSpot(thetaSpot).cloneWithNewDate(thetaDate);
137-
final var priceTheta = pricer.getPrice(option, shiftedFwdStructure, discountCurve, flatVol);
138+
final var priceTheta = pricer.getPrice(option, shiftedFwdStructure, thetaCurve, flatVol);
138139
final var fdTheta = (priceTheta - price) / dcc.getDaycountFraction(valDate, thetaDate);
139140

140141

src/test/java/net/finmath/equities/PdeOptionPricerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public void Test_europeanSensis() throws CalculationException
345345
assertEquals("Pde Vega deviates to much from analytic value for " + (isCall ? "Call" : "Put"),
346346
0.0, pdeVega/anaVega - 1.0, 0.02);
347347
assertEquals("Pde Theta deviates to much from analytic value for " + (isCall ? "Call" : "Put"),
348-
0.0, pdeSensis[3]/anaTheta - 1.0, 0.02);
348+
0.0, pdeSensis[3]/anaTheta - 1.0, 0.04);
349349
}
350350
}
351351

0 commit comments

Comments
 (0)