Skip to content

Commit

Permalink
Add Futures::Type Custom (#1915)
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Feb 21, 2024
2 parents 72012a7 + 1917baf commit 012754d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion ql/instruments/futures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ namespace QuantLib {
return out << "IMM";
case Futures::ASX:
return out << "ASX";
case Futures::Custom:
return out << "Custom";
default:
QL_FAIL("unknown futures type (" << Integer(f) << ")");
return out << "Unknown(" << Integer(f) << ')';
}
}

Expand Down
3 changes: 2 additions & 1 deletion ql/instruments/futures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ namespace QuantLib {
enum Type {
IMM, /*!< Chicago Mercantile Internation Money Market, i.e.
third Wednesday of March, June, September, December */
ASX /*!< Australian Security Exchange, i.e. second Friday
ASX, /*!< Australian Security Exchange, i.e. second Friday
of March, June, September, December */
Custom /*!< Other rules */
};
};

Expand Down
9 changes: 5 additions & 4 deletions ql/termstructures/yield/ratehelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ namespace QuantLib {
case Futures::ASX:
QL_REQUIRE(ASX::isASXdate(date, false), date << " is not a valid ASX date");
break;
case Futures::Custom:
break;
default:
QL_FAIL("unknown futures type (" << Integer(type) << ')');
QL_FAIL("unknown futures type (" << type << ')');
}
}

Expand Down Expand Up @@ -133,7 +135,7 @@ namespace QuantLib {
[](const Date date) -> Date { return ASX::nextDate(date, false); });
break;
default:
QL_FAIL("unknown futures type (" << Integer(type) << ')');
QL_FAIL("unsupported futures type (" << type << ')');
}
earliestDate_ = iborStartDate;
yearFraction_ = DetermineYearFraction(earliestDate_, maturityDate_, dayCounter);
Expand Down Expand Up @@ -180,11 +182,10 @@ namespace QuantLib {
QL_REQUIRE(termStructure_ != nullptr, "term structure not set");
Rate forwardRate = (termStructure_->discount(earliestDate_) /
termStructure_->discount(maturityDate_) - 1.0) / yearFraction_;
Rate convAdj = convAdj_.empty() ? 0.0 : convAdj_->value();
// Convexity, as FRA/futures adjustment, has been used in the
// past to take into account futures margining vs FRA.
// Therefore, there's no requirement for it to be non-negative.
Rate futureRate = forwardRate + convAdj;
Rate futureRate = forwardRate + convexityAdjustment();
return 100.0 * (1.0 - futureRate);
}

Expand Down

0 comments on commit 012754d

Please sign in to comment.