Skip to content

Commit 06f754c

Browse files
committed
QPR-11744 ensure non-negative variances
1 parent c9743e7 commit 06f754c

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

ql/termstructures/volatility/equityfx/blackvariancecurve.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,12 @@ namespace QuantLib {
6262
}
6363

6464
Real BlackVarianceCurve::blackVarianceImpl(Time t, Real) const {
65-
if (t<=times_.back()) {
66-
return varianceCurve_(t, true);
65+
if (t <= times_.back()) {
66+
return std::max(varianceCurve_(t, true), 0.0);
6767
} else {
6868
// extrapolate with flat vol
69-
return varianceCurve_(times_.back(), true)*t/times_.back();
69+
return std::max(varianceCurve_(times_.back(), true), 0.0) * t / times_.back();
7070
}
7171
}
72-
7372
}
7473

0 commit comments

Comments
 (0)