[Rquantlib-commits] r185 - papers/rinfinance2010
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Mar 8 18:00:40 CET 2010
Author: knguyen
Date: 2010-03-08 18:00:40 +0100 (Mon, 08 Mar 2010)
New Revision: 185
Removed:
papers/rinfinance2010/BondsR2.cpp
papers/rinfinance2010/QLBondExample.R
papers/rinfinance2010/QLBondExample.R.dvi
papers/rinfinance2010/QLBondExample.R.tex
Log:
remove unwanted dvi and tex
Deleted: papers/rinfinance2010/BondsR2.cpp
===================================================================
--- papers/rinfinance2010/BondsR2.cpp 2010-03-08 16:59:17 UTC (rev 184)
+++ papers/rinfinance2010/BondsR2.cpp 2010-03-08 17:00:40 UTC (rev 185)
@@ -1,461 +0,0 @@
-/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/*!
- Copyright (C) 2008 Florent Grenier
-
- This file is part of QuantLib, a free-software/open-source library
- for financial quantitative analysts and developers - http://quantlib.org/
-
- QuantLib is free software: you can redistribute it and/or modify it
- under the terms of the QuantLib license. You should have received a
- copy of the license along with this program; if not, please email
- <quantlib-dev at lists.sf.net>. The license is also available online at
- <http://quantlib.org/license.shtml>.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the license for more details.
- */
-
-/* This example shows how to set up a term structure and then price
- some simple bonds. The last part is dedicated to peripherical
- computations such as "Yield to Price" or "Price to Yield"
- */
-
-// the only header you need to use QuantLib
-#include <ql/quantlib.hpp>
-
-#include <boost/timer.hpp>
-#include <iostream>
-#include <iomanip>
-
-using namespace QuantLib;
-
-#if defined(QL_ENABLE_SESSIONS)
-namespace QuantLib {
-
-Integer sessionId() { return 0; }
-
-}
-#endif
-
-
-int main(int, char* []) {
-
- try {
-
- boost::timer timer;
- std::cout << std::endl;
-
- /*********************
- *** MARKET DATA ***
- *********************/
-
- Calendar calendar = TARGET();
-
- Date settlementDate(18, September, 2008);
- // must be a business day
- settlementDate = calendar.adjust(settlementDate);
-
- Integer fixingDays = 3;
- Natural settlementDays = 3;
-
- Date todaysDate = calendar.advance(settlementDate, -fixingDays, Days);
- // nothing to do with Date::todaysDate
- Settings::instance().evaluationDate() = todaysDate;
-
- std::cout << "Today: " << todaysDate.weekday()
- << ", " << todaysDate << std::endl;
-
- std::cout << "Settlement date: " << settlementDate.weekday()
- << ", " << settlementDate << std::endl;
-
-
- // Building of the bonds discounting yield curve
-
- /*********************
- *** RATE HELPERS ***
- *********************/
-
- // RateHelpers are built from the above quotes together with
- // other instrument dependant infos. Quotes are passed in
- // relinkable handles which could be relinked to some other
- // data source later.
-
- // Common data
-
- // ZC rates for the short end
- Rate zc3mQuote=0.0096;
- Rate zc6mQuote=0.0145;
- Rate zc1yQuote=0.0194;
-
- boost::shared_ptr<Quote> zc3mRate(new SimpleQuote(zc3mQuote));
- boost::shared_ptr<Quote> zc6mRate(new SimpleQuote(zc6mQuote));
- boost::shared_ptr<Quote> zc1yRate(new SimpleQuote(zc1yQuote));
-
- DayCounter zcBondsDayCounter = Actual365Fixed();
-
- boost::shared_ptr<RateHelper> zc3m(new DepositRateHelper(
- Handle<Quote>(zc3mRate),
- 3*Months, fixingDays,
- calendar, ModifiedFollowing,
- true, zcBondsDayCounter));
- boost::shared_ptr<RateHelper> zc6m(new DepositRateHelper(
- Handle<Quote>(zc6mRate),
- 6*Months, fixingDays,
- calendar, ModifiedFollowing,
- true, zcBondsDayCounter));
- boost::shared_ptr<RateHelper> zc1y(new DepositRateHelper(
- Handle<Quote>(zc1yRate),
- 1*Years, fixingDays,
- calendar, ModifiedFollowing,
- true, zcBondsDayCounter));
-
- // setup bonds
- Real redemption = 100.0;
-
- const Size numberOfBonds = 5;
-
- Date issueDates[] = {
- todaysDate + 3,
- todaysDate + 3,
- todaysDate + 3,
- todaysDate + 3,
- todaysDate + 3
- };
-
- Date maturities[] = {
- calendar.advance(todaysDate + 3, 5, Years),
- calendar.advance(todaysDate + 3, 6, Years),
- calendar.advance(todaysDate + 3, 7, Years),
- calendar.advance(todaysDate + 3, 16, Years),
- calendar.advance(todaysDate + 3, 48, Years)
- };
-
- Real couponRates[] = {
- 0.02375,
- 0.04625,
- 0.03125,
- 0.04000,
- 0.04500
- };
-
- Real marketQuotes[] = {
- 100.390625,
- 106.21875,
- 100.59375,
- 101.6875,
- 102.140625
- };
-
- std::vector< boost::shared_ptr<SimpleQuote> > quote;
- for (Size i=0; i<numberOfBonds; i++) {
- boost::shared_ptr<SimpleQuote> cp(new SimpleQuote(marketQuotes[i]));
- quote.push_back(cp);
- }
-
- RelinkableHandle<Quote> quoteHandle[numberOfBonds];
- for (Size i=0; i<numberOfBonds; i++) {
- quoteHandle[i].linkTo(quote[i]);
- }
-
- // Definition of the rate helpers
- std::vector<boost::shared_ptr<FixedRateBondHelper> > bondsHelpers;
-
- for (Size i=0; i<numberOfBonds; i++) {
-
- Schedule schedule(issueDates[i], maturities[i], Period(Semiannual), UnitedStates(UnitedStates::GovernmentBond),
- Unadjusted, Unadjusted, DateGeneration::Backward, false);
-
- boost::shared_ptr<FixedRateBondHelper> bondHelper(new FixedRateBondHelper(
- quoteHandle[i],
- settlementDays,
- 100.0,
- schedule,
- std::vector<Rate>(1,couponRates[i]),
- ActualActual(ActualActual::Bond),
- Unadjusted,
- redemption,
- issueDates[i]));
-
- bondsHelpers.push_back(bondHelper);
- }
-
- /*********************
- ** CURVE BUILDING **
- *********************/
-
- // Any DayCounter would be fine.
- // ActualActual::ISDA ensures that 30 years is 30.0
- DayCounter termStructureDayCounter =
- ActualActual(ActualActual::ISDA);
-
- double tolerance = 1.0e-15;
-
- // A depo-bond curve
- std::vector<boost::shared_ptr<RateHelper> > bondInstruments;
-
- // Adding the ZC bonds to the curve for the short end
-// bondInstruments.push_back(zc3m);
- // bondInstruments.push_back(zc6m);
- // bondInstruments.push_back(zc1y);
-
- // Adding the Fixed rate bonds to the curve for the long end
- for (Size i=0; i<numberOfBonds; i++) {
- bondInstruments.push_back(bondsHelpers[i]);
- }
-
- ExponentialSplinesFitting exponentialSplines(true);
- boost::shared_ptr<YieldTermStructure> bondDiscountingTermStructure(
- new FittedBondDiscountCurve(settlementDays,
- calendar,
- bondsHelpers,
- termStructureDayCounter,
- exponentialSplines,
- tolerance,
- 5000));
-
-// boost::shared_ptr<YieldTermStructure> bondDiscountingTermStructure(
- // new PiecewiseYieldCurve<Discount,LogLinear>(
- // settlementDate, bondInstruments,
- // termStructureDayCounter,
- // tolerance));
-
- // Building of the Libor forecasting curve
- // deposits
- Rate d1wQuote=0.043375;
- Rate d1mQuote=0.031875;
- Rate d3mQuote=0.0320375;
- Rate d6mQuote=0.03385;
- Rate d9mQuote=0.0338125;
- Rate d1yQuote=0.0335125;
- // swaps
- Rate s2yQuote=0.0295;
- Rate s3yQuote=0.0323;
- Rate s5yQuote=0.0359;
- Rate s10yQuote=0.0412;
- Rate s15yQuote=0.0433;
-
-
- /********************
- *** QUOTES ***
- ********************/
-
- // SimpleQuote stores a value which can be manually changed;
- // other Quote subclasses could read the value from a database
- // or some kind of data feed.
-
- // deposits
- boost::shared_ptr<Quote> d1wRate(new SimpleQuote(d1wQuote));
- boost::shared_ptr<Quote> d1mRate(new SimpleQuote(d1mQuote));
- boost::shared_ptr<Quote> d3mRate(new SimpleQuote(d3mQuote));
- boost::shared_ptr<Quote> d6mRate(new SimpleQuote(d6mQuote));
- boost::shared_ptr<Quote> d9mRate(new SimpleQuote(d9mQuote));
- boost::shared_ptr<Quote> d1yRate(new SimpleQuote(d1yQuote));
- // swaps
- boost::shared_ptr<Quote> s2yRate(new SimpleQuote(s2yQuote));
- boost::shared_ptr<Quote> s3yRate(new SimpleQuote(s3yQuote));
- boost::shared_ptr<Quote> s5yRate(new SimpleQuote(s5yQuote));
- boost::shared_ptr<Quote> s10yRate(new SimpleQuote(s10yQuote));
- boost::shared_ptr<Quote> s15yRate(new SimpleQuote(s15yQuote));
-
- /*********************
- *** RATE HELPERS ***
- *********************/
-
- // RateHelpers are built from the above quotes together with
- // other instrument dependant infos. Quotes are passed in
- // relinkable handles which could be relinked to some other
- // data source later.
-
- // deposits
- DayCounter depositDayCounter = Actual360();
-
- boost::shared_ptr<RateHelper> d1w(new DepositRateHelper(
- Handle<Quote>(d1wRate),
- 1*Weeks, fixingDays,
- calendar, ModifiedFollowing,
- true, depositDayCounter));
- boost::shared_ptr<RateHelper> d1m(new DepositRateHelper(
- Handle<Quote>(d1mRate),
- 1*Months, fixingDays,
- calendar, ModifiedFollowing,
- true, depositDayCounter));
- boost::shared_ptr<RateHelper> d3m(new DepositRateHelper(
- Handle<Quote>(d3mRate),
- 3*Months, fixingDays,
- calendar, ModifiedFollowing,
- true, depositDayCounter));
- boost::shared_ptr<RateHelper> d6m(new DepositRateHelper(
- Handle<Quote>(d6mRate),
- 6*Months, fixingDays,
- calendar, ModifiedFollowing,
- true, depositDayCounter));
- boost::shared_ptr<RateHelper> d9m(new DepositRateHelper(
- Handle<Quote>(d9mRate),
- 9*Months, fixingDays,
- calendar, ModifiedFollowing,
- true, depositDayCounter));
- boost::shared_ptr<RateHelper> d1y(new DepositRateHelper(
- Handle<Quote>(d1yRate),
- 1*Years, fixingDays,
- calendar, ModifiedFollowing,
- true, depositDayCounter));
-
- // setup swaps
- Frequency swFixedLegFrequency = Annual;
- BusinessDayConvention swFixedLegConvention = Unadjusted;
- DayCounter swFixedLegDayCounter = Thirty360(Thirty360::European);
- boost::shared_ptr<IborIndex> swFloatingLegIndex(new Euribor6M);
-
- const Period forwardStart(1*Days);
-
- boost::shared_ptr<RateHelper> s2y(new SwapRateHelper(
- Handle<Quote>(s2yRate), 2*Years,
- calendar, swFixedLegFrequency,
- swFixedLegConvention, swFixedLegDayCounter,
- swFloatingLegIndex, Handle<Quote>(),forwardStart));
- boost::shared_ptr<RateHelper> s3y(new SwapRateHelper(
- Handle<Quote>(s3yRate), 3*Years,
- calendar, swFixedLegFrequency,
- swFixedLegConvention, swFixedLegDayCounter,
- swFloatingLegIndex, Handle<Quote>(),forwardStart));
- boost::shared_ptr<RateHelper> s5y(new SwapRateHelper(
- Handle<Quote>(s5yRate), 5*Years,
- calendar, swFixedLegFrequency,
- swFixedLegConvention, swFixedLegDayCounter,
- swFloatingLegIndex, Handle<Quote>(),forwardStart));
- boost::shared_ptr<RateHelper> s10y(new SwapRateHelper(
- Handle<Quote>(s10yRate), 10*Years,
- calendar, swFixedLegFrequency,
- swFixedLegConvention, swFixedLegDayCounter,
- swFloatingLegIndex, Handle<Quote>(),forwardStart));
- boost::shared_ptr<RateHelper> s15y(new SwapRateHelper(
- Handle<Quote>(s15yRate), 15*Years,
- calendar, swFixedLegFrequency,
- swFixedLegConvention, swFixedLegDayCounter,
- swFloatingLegIndex, Handle<Quote>(),forwardStart));
-
-
- /*********************
- ** CURVE BUILDING **
- *********************/
-
- // Any DayCounter would be fine.
- // ActualActual::ISDA ensures that 30 years is 30.0
-
- // A depo-swap curve
- std::vector<boost::shared_ptr<RateHelper> > depoSwapInstruments;
- depoSwapInstruments.push_back(d1w);
- depoSwapInstruments.push_back(d1m);
- depoSwapInstruments.push_back(d3m);
- depoSwapInstruments.push_back(d6m);
- depoSwapInstruments.push_back(d9m);
- depoSwapInstruments.push_back(d1y);
- depoSwapInstruments.push_back(s2y);
- depoSwapInstruments.push_back(s3y);
- depoSwapInstruments.push_back(s5y);
- depoSwapInstruments.push_back(s10y);
- depoSwapInstruments.push_back(s15y);
- boost::shared_ptr<YieldTermStructure> depoSwapTermStructure(
- new PiecewiseYieldCurve<Discount,LogLinear>(
- settlementDate, depoSwapInstruments,
- termStructureDayCounter,
- tolerance));
-
- // Term structures that will be used for pricing:
- // the one used for discounting cash flows
- RelinkableHandle<YieldTermStructure> discountingTermStructure;
- // the one used for forward rate forecasting
- RelinkableHandle<YieldTermStructure> forecastingTermStructure;
-
- /*********************
- * BONDS TO BE PRICED *
- **********************/
-
- // Common data
- Real faceAmount = 100;
-
- // Pricing engine
- boost::shared_ptr<PricingEngine> bondEngine(
- new DiscountingBondEngine(discountingTermStructure));
-
- // Zero coupon bond
- ZeroCouponBond zeroCouponBond(
- settlementDays,
- UnitedStates(UnitedStates::GovernmentBond),
- faceAmount,
- Date(15,August,2013),
- Following,
- Real(116.92),
- Date(15,August,2003));
-
- zeroCouponBond.setPricingEngine(bondEngine);
-
- // Fixed 4.5% US Treasury Note
- Schedule fixedBondSchedule(Date(15, May, 2007),
- Date(15,May,2017), Period(Semiannual),
- UnitedStates(UnitedStates::GovernmentBond),
- Unadjusted, Unadjusted, DateGeneration::Backward, false);
-
- FixedRateBond fixedRateBond(
- settlementDays,
- faceAmount,
- fixedBondSchedule,
- std::vector<Rate>(1, 0.045),
- ActualActual(ActualActual::Bond),
- ModifiedFollowing,
- 100.0, Date(15, May, 2007));
-
- fixedRateBond.setPricingEngine(bondEngine);
-
-
- // Yield curve bootstrapping
- forecastingTermStructure.linkTo(depoSwapTermStructure);
- discountingTermStructure.linkTo(bondDiscountingTermStructure);
-
-
- /***************
- * BOND PRICING *
- ****************/
-
- std::cout << std::endl;
-
- // write column headings
- Size widths[] = { 18, 10, 10, 10 };
-
- std::cout << std::setw(widths[0]) << " "
- << std::setw(widths[1]) << "ZC"
- << std::setw(widths[2]) << "Fixed"
- << std::endl;
-
- std::string separator = " | ";
- Size width = widths[0]
- + widths[1]
- + widths[2]
- + widths[3];
- std::string rule(width, '-'), dblrule(width, '=');
- std::string tab(8, ' ');
-
- std::cout << rule << std::endl;
-
- std::cout << std::fixed;
- std::cout << std::setprecision(2);
-
- std::cout << std::setw(widths[0]) << "Net present value"
- << std::setw(widths[1]) << zeroCouponBond.NPV()
- << std::setw(widths[2]) << fixedRateBond.NPV()
- << std::endl;
-
-
- return 0;
-
- } catch (std::exception& e) {
- std::cout << e.what() << std::endl;
- return 1;
- } catch (...) {
- std::cout << "unknown error" << std::endl;
- return 1;
- }
-}
-
Deleted: papers/rinfinance2010/QLBondExample.R
===================================================================
--- papers/rinfinance2010/QLBondExample.R 2010-03-08 16:59:17 UTC (rev 184)
+++ papers/rinfinance2010/QLBondExample.R 2010-03-08 17:00:40 UTC (rev 185)
@@ -1,69 +0,0 @@
-library(RQuantLib)
-
-fixingDays <- 3
-settlementDays <- 3
-
-settlementDate <- as.Date('2008-09-18')
-todaysDate <- settlementDate - fixingDays
-
-#begin to set up bond discounting term structure
-lengths <- c(5, 6, 7, 16, 48)
-coupons <- c(0.02375, 0.04625, 0.03125, 0.04000, 0.04500)
-marketQuotes <- c(100.390625, 106.21875, 100.59375, 101.6875, 102.140625)
-dateparams <- list(settlementDays=settlementDays,
- period=2,
- dayCounter="ActualActual",
- businessDayConvention ="Unadjusted")
-curveparams <- list(method="ExponentialSplinesFitting",
- origDate=todaysDate)
-bondDsctTsr <- FittedBondCurve(curveparams,
- lengths,
- coupons,
- marketQuotes,
- dateparams)
-
-#begin to set up swap term structure
-swp.tsr.params <- list(tradeDate=todaysDate,
- settleDate=todaysDate+2,
- dt=0.25,
- interpWhat="discount",
- interpHow="loglinear")
-market.quotes <- list(d1w=0.043375,
- d1m=0.031875,
- d3m=0.0320375,
- d6m=0.03385,
- d9m=0.0338125,
- d1y=0.0335125,
- s2y=0.0295,
- s3y=0.0323,
- s5y=0.0359,
- s10y=0.0412,
- s15y=0.0433)
-depoSwpTsr <- DiscountCurve(swp.tsr.params, market.quotes)
-
-#Zero-Coupon Bond
-zc.bond.param <- list(maturityDate=as.Date('2013-08-15'),
- issueDate=as.Date('2003-08-15'),
- redemption=116.92)
-zc.bond.dateparam <- list(refDate=todaysDate,
- settlementDays=settlementDays,
- businessDayConvention='Following')
-ZeroCouponBond(zc.bond.param, bondDsctTsr, zc.bond.dateparam)
-
-#Fixed-Coupon Bond
-fixed.bond.param <- list(maturityDate=as.Date('2017-05-15'),
- issueDate=as.Date('2007-05-15'),
- redemption=100,
- effectiveDate=as.Date('2007-05-15'))
-fixed.bond.dateparam <- list(settlementDays=settlementDays,
- dayCounter='ActualActual',
- period='Semiannual',
- businessDayConvention='Unadjusted',
- terminationDateConvention='Unadjusted',
- dateGeneration='Backward',
- endOfMonth=0)
-fixed.bond.coupon <- c(0.045)
-FixedRateBond(fixed.bond.param,
- fixed.bond.coupon,
- bondDsctTsr,
- fixed.bond.dateparam)
Deleted: papers/rinfinance2010/QLBondExample.R.dvi
===================================================================
(Binary files differ)
Deleted: papers/rinfinance2010/QLBondExample.R.tex
===================================================================
--- papers/rinfinance2010/QLBondExample.R.tex 2010-03-08 16:59:17 UTC (rev 184)
+++ papers/rinfinance2010/QLBondExample.R.tex 2010-03-08 17:00:40 UTC (rev 185)
@@ -1,85 +0,0 @@
-\documentclass{article}
-\usepackage{color}
-\usepackage{alltt}
-\usepackage[latin1]{inputenc}
-
-\input {highlight.sty}
-
-\title{QLBondExample.R}
-\begin{document}
-\pagecolor{bgcolor}
-\noindent
-\ttfamily
-\hlstd{}\hlkwc{library}\hlstd{}\hlsym{(}\hlstd{RQuantLib}\hlsym{)}\hspace*{\fill}\\
-\hlstd{\hspace*{\fill}\\
-fixingDays\ }\hlsym{$<${-}\ }\hlstd{}\hlnum{3}\hspace*{\fill}\\
-\hlstd{settlementDays\ }\hlsym{$<${-}\ }\hlstd{}\hlnum{3}\hspace*{\fill}\\
-\hlstd{\hspace*{\fill}\\
-settlementDate\ }\hlsym{$<${-}\ }\hlstd{}\hlkwc{as.Date}\hlstd{}\hlsym{(}\hlstd{}\hlstr{'2008{-}09{-}18'}\hlstd{}\hlsym{)}\hspace*{\fill}\\
-\hlstd{todaysDate\ }\hlsym{$<${-}\ }\hlstd{settlementDate\ }\hlsym{{-}\ }\hlstd{fixingDays}\hspace*{\fill}\\
-\hspace*{\fill}\\
-\hlslc{\#begin\ to\ set\ up\ bond\ discounting\ term\ structure}\hspace*{\fill}\\
-\hlstd{lengths\ }\hlsym{$<${-}\ }\hlstd{}\hlkwc{c}\hlstd{}\hlsym{(}\hlstd{}\hlnum{5}\hlstd{}\hlsym{,\ }\hlstd{}\hlnum{6}\hlstd{}\hlsym{,\ }\hlstd{}\hlnum{7}\hlstd{}\hlsym{,\ }\hlstd{}\hlnum{16}\hlstd{}\hlsym{,\ }\hlstd{}\hlnum{48}\hlstd{}\hlsym{)}\hspace*{\fill}\\
-\hlstd{coupons\ }\hlsym{$<${-}\ }\hlstd{}\hlkwc{c}\hlstd{}\hlsym{(}\hlstd{}\hlnum{0.02375}\hlstd{}\hlsym{,\ }\hlstd{}\hlnum{0.04625}\hlstd{}\hlsym{,\ }\hlstd{}\hlnum{0.03125}\hlstd{}\hlsym{,\ }\hlstd{}\hlnum{0.04000}\hlstd{}\hlsym{,\ }\hlstd{}\hlnum{0.04500}\hlstd{}\hlsym{)}\hspace*{\fill}\\
-\hlstd{marketQuotes\ }\hlsym{$<${-}\ }\hlstd{}\hlkwc{c}\hlstd{}\hlsym{(}\hlstd{}\hlnum{100.390625}\hlstd{}\hlsym{,\ }\hlstd{}\hlnum{106.21875}\hlstd{}\hlsym{,\ }\hlstd{}\hlnum{100.59375}\hlstd{}\hlsym{,\ }\hlstd{}\hlnum{101.6875}\hlstd{}\hlsym{,\ }\hlstd{}\hlnum{102.140625}\hlstd{}\hlsym{)}\hspace*{\fill}\\
-\hlstd{dateparams\ }\hlsym{$<${-}\ }\hlstd{}\hlkwc{list}\hlstd{}\hlsym{(}\hlstd{settlementDays}\hlsym{=}\hlstd{settlementDays}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{period}\hlsym{=}\hlstd{}\hlnum{2}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{dayCounter}\hlsym{=}\hlstd{}\hlstr{"ActualActual"}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{businessDayConvention\ }\hlsym{=}\hlstd{}\hlstr{"Unadjusted"}\hlstd{}\hlsym{)}\hspace*{\fill}\\
-\hlstd{curveparams\ }\hlsym{$<${-}\ }\hlstd{}\hlkwc{list}\hlstd{}\hlsym{(}\hlstd{method}\hlsym{=}\hlstd{}\hlstr{"ExponentialSplinesFitting"}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{origDate}\hlsym{=}\hlstd{todaysDate}\hlsym{)}\hspace*{\fill}\\
-\hlstd{bondDsctTsr\ }\hlsym{$<${-}\ }\hlstd{FittedBondCurve}\hlsym{(}\hlstd{curveparams}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{lengths}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{coupons}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{marketQuotes}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{dateparams}\hlsym{)}\hspace*{\fill}\\
-\hlstd{}\hspace*{\fill}\\
-\hlslc{\#begin\ to\ set\ up\ swap\ term\ structure}\hspace*{\fill}\\
-\hlstd{swp.tsr.params\ }\hlsym{$<${-}\ }\hlstd{}\hlkwc{list}\hlstd{}\hlsym{(}\hlstd{tradeDate}\hlsym{=}\hlstd{todaysDate}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{settleDate}\hlsym{=}\hlstd{todaysDate}\hlsym{+}\hlstd{}\hlnum{2}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{}\hlkwc{dt}\hlstd{}\hlsym{=}\hlstd{}\hlnum{0.25}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{interpWhat}\hlsym{=}\hlstd{}\hlstr{"discount"}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{interpHow}\hlsym{=}\hlstd{}\hlstr{"loglinear"}\hlstd{}\hlsym{)}\hspace*{\fill}\\
-\hlstd{market.quotes\ }\hlsym{$<${-}\ }\hlstd{}\hlkwc{list}\hlstd{}\hlsym{(}\hlstd{d1w}\hlsym{=}\hlstd{}\hlnum{0.043375}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{d1m}\hlsym{=}\hlstd{}\hlnum{0.031875}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{d3m}\hlsym{=}\hlstd{}\hlnum{0.0320375}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{d6m}\hlsym{=}\hlstd{}\hlnum{0.03385}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{d9m}\hlsym{=}\hlstd{}\hlnum{0.0338125}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{d1y}\hlsym{=}\hlstd{}\hlnum{0.0335125}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{s2y}\hlsym{=}\hlstd{}\hlnum{0.0295}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{s3y}\hlsym{=}\hlstd{}\hlnum{0.0323}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{s5y}\hlsym{=}\hlstd{}\hlnum{0.0359}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{s10y}\hlsym{=}\hlstd{}\hlnum{0.0412}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{s15y}\hlsym{=}\hlstd{}\hlnum{0.0433}\hlstd{}\hlsym{)}\hspace*{\fill}\\
-\hlstd{depoSwpTsr\ }\hlsym{$<${-}\ }\hlstd{DiscountCurve}\hlsym{(}\hlstd{swp.tsr.params}\hlsym{,\ }\hlstd{market.quotes}\hlsym{)}\hspace*{\fill}\\
-\hlstd{}\hspace*{\fill}\\
-\hlslc{\#Zero{-}Coupon\ Bond}\hspace*{\fill}\\
-\hlstd{zc.bond.param\ }\hlsym{$<${-}\ }\hlstd{}\hlkwc{list}\hlstd{}\hlsym{(}\hlstd{maturityDate}\hlsym{=}\hlstd{}\hlkwc{as.Date}\hlstd{}\hlsym{(}\hlstd{}\hlstr{'2013{-}08{-}15'}\hlstd{}\hlsym{),}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{issueDate}\hlsym{=}\hlstd{}\hlkwc{as.Date}\hlstd{}\hlsym{(}\hlstd{}\hlstr{'2003{-}08{-}15'}\hlstd{}\hlsym{),}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{redemption}\hlsym{=}\hlstd{}\hlnum{116.92}\hlstd{}\hlsym{)}\hspace*{\fill}\\
-\hlstd{zc.bond.dateparam\ }\hlsym{$<${-}\ }\hlstd{}\hlkwc{list}\hlstd{}\hlsym{(}\hlstd{refDate}\hlsym{=}\hlstd{todaysDate}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{settlementDays}\hlsym{=}\hlstd{settlementDays}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{businessDayConvention}\hlsym{=}\hlstd{}\hlstr{'Following'}\hlstd{}\hlsym{)}\hspace*{\fill}\\
-\hlstd{ZeroCouponBond}\hlsym{(}\hlstd{zc.bond.param}\hlsym{,\ }\hlstd{bondDsctTsr}\hlsym{,\ }\hlstd{zc.bond.dateparam}\hlsym{)}\hspace*{\fill}\\
-\hlstd{}\hspace*{\fill}\\
-\hlslc{\#Fixed{-}Coupon\ Bond}\hspace*{\fill}\\
-\hlstd{fixed.bond.param\ }\hlsym{$<${-}\ }\hlstd{}\hlkwc{list}\hlstd{}\hlsym{(}\hlstd{maturityDate}\hlsym{=}\hlstd{}\hlkwc{as.Date}\hlstd{}\hlsym{(}\hlstd{}\hlstr{'2017{-}05{-}15'}\hlstd{}\hlsym{),}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{issueDate}\hlsym{=}\hlstd{}\hlkwc{as.Date}\hlstd{}\hlsym{(}\hlstd{}\hlstr{'2007{-}05{-}15'}\hlstd{}\hlsym{),}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{redemption}\hlsym{=}\hlstd{}\hlnum{100}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{effectiveDate}\hlsym{=}\hlstd{}\hlkwc{as.Date}\hlstd{}\hlsym{(}\hlstd{}\hlstr{'2007{-}05{-}15'}\hlstd{}\hlsym{))}\hspace*{\fill}\\
-\hlstd{fixed.bond.dateparam\ }\hlsym{$<${-}\ }\hlstd{}\hlkwc{list}\hlstd{}\hlsym{(}\hlstd{settlementDays}\hlsym{=}\hlstd{settlementDays}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{dayCounter}\hlsym{=}\hlstd{}\hlstr{'ActualActual'}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{period}\hlsym{=}\hlstd{}\hlstr{'Semiannual'}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{businessDayConvention}\hlsym{=}\hlstd{}\hlstr{'Unadjusted'}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{terminationDateConvention}\hlsym{=}\hlstd{}\hlstr{'Unadjusted'}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{dateGeneration}\hlsym{=}\hlstd{}\hlstr{'Backward'}\hlstd{}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{endOfMonth}\hlsym{=}\hlstd{}\hlnum{0}\hlstd{}\hlsym{)}\hspace*{\fill}\\
-\hlstd{fixed.bond.coupon\ }\hlsym{$<${-}\ }\hlstd{}\hlkwc{c}\hlstd{}\hlsym{(}\hlstd{}\hlnum{0.045}\hlstd{}\hlsym{)}\hspace*{\fill}\\
-\hlstd{FixedRateBond}\hlsym{(}\hlstd{fixed.bond.param}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{fixed.bond.coupon}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{bondDsctTsr}\hlsym{,}\hspace*{\fill}\\
-\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{fixed.bond.dateparam}\hlsym{)}\hlstd{}\hspace*{\fill}\\
-\mbox{}
-\normalfont
-\end {document}
-(* LaTeX generated by highlight 2.10, http://www.andre-simon.de/ *)
More information about the Rquantlib-commits
mailing list