Update of /cvsroot/quantlibaddin/QuantLibAddin/qlo
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv4982/qlo
Modified Files:
swap.cpp swap.hpp vanillaswap.cpp vanillaswap.hpp
Log Message:
1) in synch with QuantLib Swap/VanillaSwap refactoring
2) VaniilaSwap now inherits from Swap (as in QuantLib)
still to do: export to Excel multi-leg swap
Index: swap.cpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/swap.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** swap.cpp 6 Jun 2006 08:10:05 -0000 1.3
--- swap.cpp 6 Jun 2006 17:16:48 -0000 1.4
***************
*** 2,7 ****
/*
Copyright (C) 2005 Eric Ehlers
! Copyright (C) 2005 Plamen Neykov
Copyright (C) 2005 Aurelien Chanudet
This file is part of QuantLib, a free-software/open-source library
--- 2,9 ----
/*
Copyright (C) 2005 Eric Ehlers
! Copyright (C) 2006 Ferdinando Ametrano
Copyright (C) 2005 Aurelien Chanudet
+ Copyright (C) 2005 Plamen Neykov
+ Copyright (C) 2006 Katiuscia Manzoni
This file is part of QuantLib, a free-software/open-source library
***************
*** 23,26 ****
--- 25,29 ----
#include <qlo/swap.hpp>
+ #include <ql/CashFlows/parcoupon.hpp>
namespace QuantLibAddin {
***************
*** 37,43 ****
mInstrument = boost::shared_ptr<QuantLib::Instrument>(
! new QuantLib::Swap(paidLeg, recvLeg, discountingTermStructure));
}
!
}
--- 40,89 ----
mInstrument = boost::shared_ptr<QuantLib::Instrument>(
! new QuantLib::Swap(discountingTermStructure, paidLeg, recvLeg));
}
!
!
! const std::vector<std::vector<double> >& Swap::legAnalysis(QuantLib::Size i) {
! const std::vector<boost::shared_ptr<QuantLib::CashFlow> >& cashflows =
! getObject().leg(i);
!
! flowAnalysis_.clear();
! for(QuantLib::Size i = 0; i < cashflows.size(); i++) {
! std::vector<double> cf;
!
! cf.push_back(cashflows[i]->date().serialNumber());
! cf.push_back(cashflows[i]->amount());
!
! boost::shared_ptr<QuantLib::Coupon> c =
! boost::dynamic_pointer_cast<QuantLib::Coupon>(cashflows[i]);
! cf.push_back(c->nominal());
! cf.push_back(c->accrualStartDate().serialNumber());
! cf.push_back(c->accrualEndDate().serialNumber());
! cf.push_back(c->accrualDays());
! //cf.push_back(c->dayCounter().name());
! cf.push_back(c->accrualPeriod());
! cf.push_back(c->rate());
!
! boost::shared_ptr<QuantLib::ParCoupon> floatingCoupon =
! boost::dynamic_pointer_cast<QuantLib::ParCoupon>(cashflows[i]);
! if (floatingCoupon!=0) {
! cf.push_back(floatingCoupon->fixingDays());
! cf.push_back(floatingCoupon->fixingDate().serialNumber());
! cf.push_back(floatingCoupon->indexFixing());
! cf.push_back(floatingCoupon->spread());
! } else {
! cf.push_back(0.0);
! cf.push_back(0.0);
! cf.push_back(0.0);
! cf.push_back(0.0);
! }
!
! flowAnalysis_.push_back(cf);
! }
! return flowAnalysis_;
! }
!
!
!
}
Index: vanillaswap.hpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/vanillaswap.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** vanillaswap.hpp 6 Jun 2006 08:10:05 -0000 1.1
--- vanillaswap.hpp 6 Jun 2006 17:16:48 -0000 1.2
***************
*** 21,31 ****
#define qla_simpleswap_hpp
- #include <qlo/baseinstruments.hpp>
#include <qlo/xibor.hpp>
#include <ql/Instruments/vanillaswap.hpp>
namespace QuantLibAddin {
! class VanillaSwap : public Instrument {
public:
VanillaSwap(
--- 21,31 ----
#define qla_simpleswap_hpp
#include <qlo/xibor.hpp>
#include <ql/Instruments/vanillaswap.hpp>
+ #include <qlo/swap.hpp>
namespace QuantLibAddin {
! class VanillaSwap : public Swap {
public:
VanillaSwap(
***************
*** 51,60 ****
EXPORT_UNDERLYING_OBJECT(QuantLib::VanillaSwap, mInstrument)
! const std::vector<std::vector<double> >& getFixLeg();
! const std::vector<std::vector<double> >& getFloatLeg();
- private:
- std::vector<std::vector<double> > fixLeg;
- std::vector<std::vector<double> > floatLeg;
};
}
--- 51,61 ----
EXPORT_UNDERLYING_OBJECT(QuantLib::VanillaSwap, mInstrument)
! const std::vector<std::vector<double> >& fixedLeg() {
! return Swap::legAnalysis(0);
! }
! const std::vector<std::vector<double> >& floatingLeg() {
! return Swap::legAnalysis(1);
! }
};
}
Index: vanillaswap.cpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/vanillaswap.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** vanillaswap.cpp 6 Jun 2006 08:10:05 -0000 1.1
--- vanillaswap.cpp 6 Jun 2006 17:16:48 -0000 1.2
***************
*** 2,7 ****
/*
Copyright (C) 2005, 2006 Eric Ehlers
! Copyright (C) 2005 Plamen Neykov
Copyright (C) 2005 Aurelien Chanudet
This file is part of QuantLib, a free-software/open-source library
--- 2,9 ----
/*
Copyright (C) 2005, 2006 Eric Ehlers
! Copyright (C) 2006 Ferdinando Ametrano
Copyright (C) 2005 Aurelien Chanudet
+ Copyright (C) 2005 Plamen Neykov
+ Copyright (C) 2006 Katiuscia Manzoni
This file is part of QuantLib, a free-software/open-source library
***************
*** 74,114 ****
}
- const std::vector<std::vector<double> >&
- VanillaSwap::getFixLeg() {
- const std::vector<boost::shared_ptr<QuantLib::CashFlow> >& flows = getObject().fixedLeg();
- fixLeg.clear();
- for(size_t i = 0; i < flows.size(); i++) {
- std::vector<double> cf;
- QuantLib::FixedRateCoupon& c = (QuantLib::FixedRateCoupon&) *(flows[i]);
- cf.push_back(c.accrualStartDate().serialNumber());
- cf.push_back(c.accrualEndDate().serialNumber());
- cf.push_back(c.date().serialNumber());
- cf.push_back(c.accrualPeriod());
- cf.push_back(c.accrualDays());
- cf.push_back(c.amount());
- fixLeg.push_back(cf);
- }
- return fixLeg;
- }
-
- const std::vector<std::vector<double> >&
- VanillaSwap::getFloatLeg() {
- const std::vector<boost::shared_ptr<QuantLib::CashFlow> >& flows = getObject().floatingLeg();
- floatLeg.clear();
- for(size_t i = 0; i < flows.size(); i++) {
- std::vector<double> cf;
- QuantLib::ParCoupon& c = (QuantLib::ParCoupon&)*(flows[i]);
- cf.push_back(c.accrualStartDate().serialNumber());
- cf.push_back(c.accrualEndDate().serialNumber());
- cf.push_back(c.date().serialNumber());
- cf.push_back(c.fixingDate().serialNumber());
- cf.push_back(c.accrualPeriod());
- cf.push_back(c.accrualDays());
- cf.push_back(c.amount());
- cf.push_back(c.indexFixing());
- floatLeg.push_back(cf);
- }
- return floatLeg;
- }
}
-
--- 76,78 ----
Index: swap.hpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/swap.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** swap.hpp 24 May 2006 14:59:44 -0000 1.2
--- swap.hpp 6 Jun 2006 17:16:48 -0000 1.3
***************
*** 2,7 ****
/*
Copyright (C) 2005 Eric Ehlers
! Copyright (C) 2005 Plamen Neykov
Copyright (C) 2005 Aurelien Chanudet
This file is part of QuantLib, a free-software/open-source library
--- 2,9 ----
/*
Copyright (C) 2005 Eric Ehlers
! Copyright (C) 2006 Ferdinando Ametrano
Copyright (C) 2005 Aurelien Chanudet
+ Copyright (C) 2005 Plamen Neykov
+ Copyright (C) 2006 Katiuscia Manzoni
This file is part of QuantLib, a free-software/open-source library
***************
*** 34,39 ****
const boost::shared_ptr < CouponVector > &recvLegWrapper,
const boost::shared_ptr < QuantLib::YieldTermStructure > &termStructure);
!
! EXPORT_UNDERLYING_OBJECT(QuantLib::Swap, mInstrument)
};
--- 36,49 ----
const boost::shared_ptr < CouponVector > &recvLegWrapper,
const boost::shared_ptr < QuantLib::YieldTermStructure > &termStructure);
!
! EXPORT_UNDERLYING_OBJECT(QuantLib::Swap, mInstrument);
!
! const std::vector<std::vector<double> >& legAnalysis(QuantLib::Size i);
!
! protected:
! Swap() {}
!
! private:
! std::vector<std::vector<double> > flowAnalysis_;
};
|