Update of /cvsroot/quantlibaddin/QuantLibAddin/qlo
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv25354/qlo
Modified Files:
ratehelpers.cpp ratehelpers.hpp
Log Message:
Added "Include Depos after front Futures" parameter to qlRateHelperSelection
Index: ratehelpers.hpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/ratehelpers.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** ratehelpers.hpp 14 Dec 2006 15:22:48 -0000 1.8
--- ratehelpers.hpp 19 Dec 2006 14:35:21 -0000 1.9
***************
*** 1,3 ****
-
/*
Copyright (C) 2005, 2006 Eric Ehlers
--- 1,2 ----
***************
*** 24,28 ****
#include <ql/Indexes/iborindex.hpp>
#include <ql/TermStructures/ratehelpers.hpp>
-
#include <oh/objhandler.hpp>
--- 23,26 ----
Index: ratehelpers.cpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/ratehelpers.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** ratehelpers.cpp 14 Dec 2006 15:22:47 -0000 1.13
--- ratehelpers.cpp 19 Dec 2006 14:35:21 -0000 1.14
***************
*** 1,8 ****
/*
- Copyright (C) 2005, 2006 Eric Ehlers
Copyright (C) 2006 Ferdinando Ametrano
! Copyright (C) 2005 Plamen Neykov
Copyright (C) 2005 Aurelien Chanudet
This file is part of QuantLib, a free-software/open-source library
--- 1,9 ----
/*
Copyright (C) 2006 Ferdinando Ametrano
! Copyright (C) 2006 Marco Bianchetti
Copyright (C) 2005 Aurelien Chanudet
+ Copyright (C) 2005, 2006 Eric Ehlers
+ Copyright (C) 2005 Plamen Neykov
This file is part of QuantLib, a free-software/open-source library
***************
*** 38,42 ****
{
quoteHandle_ = quote;
-
libraryObject_ = boost::shared_ptr<QuantLib::RateHelper>(
new QuantLib::DepositRateHelper(quoteHandle_,
--- 39,42 ----
***************
*** 59,65 ****
quoteHandle_ = price;
convAdjHandle_= convAdj;
-
QuantLib::Date expiry = QuantLib::Date::IMMdate(immDateID);
-
libraryObject_ = boost::shared_ptr<QuantLib::RateHelper>(
new QuantLib::FuturesRateHelper(
--- 59,63 ----
***************
*** 85,89 ****
{
quoteHandle_ = quote;
-
libraryObject_ = boost::shared_ptr<QuantLib::RateHelper>(
new QuantLib::SwapRateHelper(quoteHandle_,
--- 83,86 ----
***************
*** 103,106 ****
--- 100,104 ----
struct RateHelperItem {
bool isFutures;
+ bool isDepo;
std::string objectID;
bool includeFlag;
***************
*** 109,112 ****
--- 107,111 ----
QuantLib::Date latestDate;
RateHelperItem(bool isFutures,
+ bool isDepo,
const std::string& objectID,
const bool includeFlag,
***************
*** 114,118 ****
const QuantLib::Date& earliestDate,
const QuantLib::Date& latestDate)
! : isFutures(isFutures), objectID(objectID),
includeFlag(includeFlag), priority(priority),
earliestDate(earliestDate), latestDate(latestDate) {}
--- 113,117 ----
const QuantLib::Date& earliestDate,
const QuantLib::Date& latestDate)
! : isFutures(isFutures), isDepo(isDepo), objectID(objectID),
includeFlag(includeFlag), priority(priority),
earliestDate(earliestDate), latestDate(latestDate) {}
***************
*** 124,131 ****
bool operator()(const RateHelperItem& h1,
const RateHelperItem& h2) const {
-
if (h1.latestDate > h2.latestDate)
return false;
-
if (h1.latestDate == h2.latestDate) {
if (h1.priority > h2.priority) {
--- 123,128 ----
***************
*** 135,141 ****
}
}
-
return true;
-
}
};
--- 132,136 ----
***************
*** 167,177 ****
for (i=0; i<nInstruments; i++) {
OH_GET_OBJECT(qlarh, instrumentIDs[i], RateHelper);
! bool isFutures;
if (boost::dynamic_pointer_cast<FuturesRateHelper>(qlarh))
isFutures = true;
else
isFutures = false;
qlarh->getLibraryObject(qlrh);
rhsAll.push_back(detail::RateHelperItem(isFutures,
instrumentIDs[i],
includeFlag[i],
--- 162,177 ----
for (i=0; i<nInstruments; i++) {
OH_GET_OBJECT(qlarh, instrumentIDs[i], RateHelper);
! bool isFutures, isDepo;
if (boost::dynamic_pointer_cast<FuturesRateHelper>(qlarh))
isFutures = true;
else
isFutures = false;
+ if (boost::dynamic_pointer_cast<DepositRateHelper>(qlarh))
+ isDepo = true;
+ else
+ isDepo = false;
qlarh->getLibraryObject(qlrh);
rhsAll.push_back(detail::RateHelperItem(isFutures,
+ isDepo,
instrumentIDs[i],
includeFlag[i],
***************
*** 190,206 ****
long futuresCounter = 0;
QuantLib::Date evalDate = QuantLib::Settings::instance().evaluationDate();
! std::vector<detail::RateHelperItem> rhs;
for (i=0; i<nInstruments; i++) {
! if (rhsAll[i].includeFlag) {
! if (!rhsAll[i].isFutures && (rhsAll[i].earliestDate >= evalDate)) {
! rhs.push_back(rhsAll[i]);
! } else if (futuresCounter<nFutures &&
(rhsAll[i].earliestDate-2-frontFuturesRollingDays >= evalDate)) {
! futuresCounter++;
rhs.push_back(rhsAll[i]);
}
}
}
-
std::vector<std::string> result;
--- 190,234 ----
long futuresCounter = 0;
QuantLib::Date evalDate = QuantLib::Settings::instance().evaluationDate();
! std::vector<detail::RateHelperItem> rhs, rhsDepo;
! // Look for the front Futures
! QuantLib::Date frontFuturesEarliestDate;
! bool thereAreFutures = false;
! i = 0;
! while (i<nInstruments) {
! if (rhsAll[i].isFutures &&
! (rhsAll[i].earliestDate-2-frontFuturesRollingDays >= evalDate)) {
! thereAreFutures = true;
! frontFuturesEarliestDate = rhsAll[i].earliestDate;
! break;
! }
! i++;
! }
! // Start selection
! bool depoAfterFrontFuturesAlreadyIncluded = false;
for (i=0; i<nInstruments; i++) {
! if (rhsAll[i].includeFlag && rhsAll[i].earliestDate >= evalDate) {
! if (rhsAll[i].isDepo) { // Check Depo conditions
! if (depoIncludeFlag) rhs.push_back(rhsAll[i]);
! if (!depoIncludeFlag && thereAreFutures) {
! if (rhsAll[i].latestDate <= frontFuturesEarliestDate) {
! rhs.push_back(rhsAll[i]);
! } else {
! if (depoAfterFrontFuturesAlreadyIncluded == false) {
! rhs.push_back(rhsAll[i]);
! depoAfterFrontFuturesAlreadyIncluded = true;
! }
! }
! }
! } else if (rhsAll[i].isFutures) { // Check Futures conditions
! if (futuresCounter<nFutures &&
(rhsAll[i].earliestDate-2-frontFuturesRollingDays >= evalDate)) {
! futuresCounter++;
! rhs.push_back(rhsAll[i]);
! }
! } else { // No conditions for other instruments
rhs.push_back(rhsAll[i]);
}
}
}
std::vector<std::string> result;
|