Update of /cvsroot/quantlibaddin/QuantLibAddin/qlo
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv19039/qlo
Modified Files:
bonds.cpp bonds.hpp couponvectors.cpp couponvectors.hpp
swap.cpp swap.hpp vanillaswap.hpp
Log Message:
added flowAnalysis to Bond
Index: couponvectors.hpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/couponvectors.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** couponvectors.hpp 14 Jun 2006 18:34:31 -0000 1.4
--- couponvectors.hpp 14 Jun 2006 20:33:10 -0000 1.5
***************
*** 1,4 ****
--- 1,5 ----
/*
+ Copyright (C) 2006 Ferdinando Ametrano
Copyright (C) 2005 Aurelien Chanudet
***************
*** 27,30 ****
--- 28,34 ----
typedef std::vector<boost::shared_ptr<QuantLib::CashFlow> > CashFlowVector;
+
+ std::vector<std::vector<double> > flowAnalysis(CashFlowVector);
+
class CouponVector : public ObjHandler::Object {
Index: couponvectors.cpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/couponvectors.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** couponvectors.cpp 24 May 2006 14:59:44 -0000 1.2
--- couponvectors.cpp 14 Jun 2006 20:33:10 -0000 1.3
***************
*** 1,4 ****
--- 1,5 ----
/*
+ Copyright (C) 2006 Ferdinando Ametrano
Copyright (C) 2006 Eric Ehlers
Copyright (C) 2005 Aurelien Chanudet
***************
*** 31,34 ****
--- 32,73 ----
namespace QuantLibAddin {
+ std::vector<std::vector<double> > flowAnalysis(CashFlowVector cashflows) {
+
+ std::vector<std::vector<double> > flowAnalysis_;
+ 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_;
+ }
+
double CouponVector::getBPS(
const boost::shared_ptr < QuantLib::YieldTermStructure > &termStructure) const {
Index: vanillaswap.hpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/vanillaswap.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** vanillaswap.hpp 9 Jun 2006 18:58:47 -0000 1.3
--- vanillaswap.hpp 14 Jun 2006 20:33:10 -0000 1.4
***************
*** 49,56 ****
const boost::shared_ptr < QuantLib::YieldTermStructure > &discYC);
! const std::vector<std::vector<double> >& fixedLeg() {
return Swap::legAnalysis(0);
}
! const std::vector<std::vector<double> >& floatingLeg() {
return Swap::legAnalysis(1);
}
--- 49,56 ----
const boost::shared_ptr < QuantLib::YieldTermStructure > &discYC);
! std::vector<std::vector<double> > fixedLeg() {
return Swap::legAnalysis(0);
}
! std::vector<std::vector<double> > floatingLeg() {
return Swap::legAnalysis(1);
}
Index: bonds.hpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/bonds.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** bonds.hpp 14 Jun 2006 19:27:11 -0000 1.2
--- bonds.hpp 14 Jun 2006 20:33:10 -0000 1.3
***************
*** 28,31 ****
--- 28,34 ----
class Bond : public Instrument {
+ public:
+ std::vector<std::vector<double> > flowAnalysis();
+
};
Index: bonds.cpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/bonds.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** bonds.cpp 14 Jun 2006 19:27:11 -0000 1.2
--- bonds.cpp 14 Jun 2006 20:33:10 -0000 1.3
***************
*** 24,27 ****
--- 24,28 ----
#include <qlo/bonds.hpp>
+ #include <qlo/couponvectors.hpp>
#include <qlo/generalutils.hpp>
#include <qlo/termstructures.hpp>
***************
*** 33,36 ****
--- 34,46 ----
namespace QuantLibAddin {
+ std::vector<std::vector<double> > Bond::flowAnalysis() {
+ const boost::shared_ptr<QuantLib::Bond> temp =
+ getLibraryObject<QuantLib::Bond>();
+ const std::vector<boost::shared_ptr<QuantLib::CashFlow> >& cashflows =
+ temp->cashflows();
+
+ return QuantLibAddin::flowAnalysis(cashflows);
+ }
+
ZeroCouponBond::ZeroCouponBond(
const QuantLib::Date& issueDate,
Index: swap.cpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/swap.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** swap.cpp 14 Jun 2006 18:16:45 -0000 1.7
--- swap.cpp 14 Jun 2006 20:33:10 -0000 1.8
***************
*** 25,28 ****
--- 25,29 ----
#include <qlo/swap.hpp>
+ #include <qlo/couponvectors.hpp>
#include <ql/CashFlows/parcoupon.hpp>
***************
*** 45,91 ****
! const std::vector<std::vector<double> >& Swap::legAnalysis(QuantLib::Size i) {
! const boost::shared_ptr < QuantLib::Swap > temp = getLibraryObject < QuantLib::Swap >();
const std::vector<boost::shared_ptr<QuantLib::CashFlow> >& cashflows =
temp->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_;
}
-
-
}
-
--- 46,57 ----
! std::vector<std::vector<double> > Swap::legAnalysis(QuantLib::Size i) {
! const boost::shared_ptr<QuantLib::Swap> temp =
! getLibraryObject<QuantLib::Swap>();
const std::vector<boost::shared_ptr<QuantLib::CashFlow> >& cashflows =
temp->leg(i);
! return flowAnalysis(cashflows);
}
}
Index: swap.hpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/qlo/swap.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** swap.hpp 9 Jun 2006 18:58:47 -0000 1.5
--- swap.hpp 14 Jun 2006 20:33:10 -0000 1.6
***************
*** 37,47 ****
termStructure);
! const std::vector<std::vector<double> >& legAnalysis(QuantLib::Size i);
protected:
Swap() {}
-
- private:
- std::vector<std::vector<double> > flowAnalysis_;
};
--- 37,44 ----
termStructure);
! std::vector<std::vector<double> > legAnalysis(QuantLib::Size i);
protected:
Swap() {}
};
|