[Rquantlib-commits] r190 - papers/rinfinance2010

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 9 22:33:47 CET 2010


Author: knguyen
Date: 2010-03-09 22:33:47 +0100 (Tue, 09 Mar 2010)
New Revision: 190

Modified:
   papers/rinfinance2010/rquantlib_slides.tex
Log:
update slides

Modified: papers/rinfinance2010/rquantlib_slides.tex
===================================================================
--- papers/rinfinance2010/rquantlib_slides.tex	2010-03-09 20:37:25 UTC (rev 189)
+++ papers/rinfinance2010/rquantlib_slides.tex	2010-03-09 21:33:47 UTC (rev 190)
@@ -63,35 +63,35 @@
   \end{itemize}
 \end{frame}
 
-\begin{frame}[fragile]  % fragile important when lstlisting used
-  \frametitle{We can do code}
-  \framesubtitle{Thanks to lstlisting}
+%\begin{frame}[fragile]  % fragile important when lstlisting used
+%  \frametitle{We can do code}
+%  \framesubtitle{Thanks to lstlisting}
+%
+%\lstset{language=C++,basicstyle=\tiny}
+%\begin{lstlisting}
+%#include <Rcpp.hpp>
+%
+%RcppExport SEXP dd_rcpp(SEXP v) {
+%  SEXP  rl = R_NilValue;             // Use this when nothing is returned
+%
+%  RcppVector<int> vec(v);            // vec parameter viewed as vector of doubles
+%  int n = vec.size(), i = 0;
+%
+%  for (int a = 0; a < 9; a++)
+%    for (int b = 0; b < 9; b++)
+%      for (int c = 0; c < 9; c++)
+%        for (int d = 0; d < 9; d++)
+%          vec(i++) = a*b - c*d;
+%
+%  RcppResultSet rs;                  // Build result set returned as list to R
+%  rs.add("vec", vec);                // vec as named element with name 'vec'
+%  rl = rs.getReturnList();           // Get the list to be returned to R.
+%
+%  return rl;
+%}
+%\end{lstlisting}
 
-\lstset{language=C++,basicstyle=\tiny}
-\begin{lstlisting}
-#include <Rcpp.hpp>
 
-RcppExport SEXP dd_rcpp(SEXP v) {
-  SEXP  rl = R_NilValue;             // Use this when nothing is returned
-
-  RcppVector<int> vec(v);            // vec parameter viewed as vector of doubles
-  int n = vec.size(), i = 0;
-
-  for (int a = 0; a < 9; a++)
-    for (int b = 0; b < 9; b++)
-      for (int c = 0; c < 9; c++)
-        for (int d = 0; d < 9; d++)
-          vec(i++) = a*b - c*d;
-
-  RcppResultSet rs;                  // Build result set returned as list to R
-  rs.add("vec", vec);                // vec as named element with name 'vec'
-  rl = rs.getReturnList();           // Get the list to be returned to R.
-
-  return rl;
-}
-\end{lstlisting}
-
-
 \end{frame}
 
 \begin{frame}
@@ -112,12 +112,12 @@
 			\begin{itemize}
 				\item Curve fitting functions return a DiscountCurve object that contains a two column dates/zeroRates data frame.
 				\item The returned DiscountCurve object are used as inputs for pricing functions. 
-				\item Currently, there are two curve fitting functions
-					\begin{itemize}
-						\item DiscountCurve - constructs the spot term structure of interest rates based on input market data including the settltment date, deposit rates, future prices, FRA rates or swap rates in various combination.
-						\item FittedBondCurve - fits a term structure to a set of bonds using three different fitting methods (ExponentialSplinesFitting, SimplePolynomialFitting, NelsonSiegelFitting).
-					\end{itemize}
 			\end{itemize}
+		\item Currently, there are two curve fitting functions
+			\begin{itemize}
+				\item DiscountCurve - constructs the spot term structure of interest rates based on input market data including the settltment date, deposit rates, future prices, FRA rates or swap rates in various combination.
+				\item FittedBondCurve - fits a term structure to a set of bonds using three different fitting methods (ExponentialSplinesFitting, SimplePolynomialFitting, NelsonSiegelFitting).
+			\end{itemize}
 	\end{itemize}
 \end{frame}
 
@@ -142,7 +142,9 @@
 
 \begin{frame}[shrink]
 	\frametitle{Fixed Income in RQuantLib}
-	\framesubtitle{Examples: Curve fitting}
+	\framesubtitle{Examples: Curve fitting with DiscountCurve function}
+Building a discount curve from the market data. This data is taken from codes shipped with QuantLib 0.9.7. 
+\vskip15pt
 \pagecolor{bgcolor}
 \noindent
 \ttfamily
@@ -164,6 +166,13 @@
 \end{frame}
 
 \begin{frame}
+	\frametitle{Fixed Income in RQuantLib}
+	\framesubtitle{Examples: Curve fitting with DiscountCurve function}
+\pagecolor{bgcolor}
+\noindent
+\ttfamily
+\hlstd{}\hlkwc{plot}\hlstd{}\hlsym{(}\hlstd{curves)}
+\normalfont
 \begin{center}
 \resizebox{75mm}{!}{\includegraphics{discountCurve.png}}
 \end{center}
@@ -204,8 +213,9 @@
 
 \begin{frame}
 	\frametitle{Fixed Income in RQuantLib}
-	\framesubtitle{Examples: Curve fitting}
-
+	\framesubtitle{Examples: Curve fitting with FittedBondCurve function}
+Fitting a curve to a set of bonds. The data is taken from codes shipped with QuantLib 0.9.7.
+\vskip5pt
 \pagecolor{bgcolor}
 \noindent
 \ttfamily
@@ -230,6 +240,13 @@
 \end{frame}
 
 \begin{frame}
+	\frametitle{Fixed Income in RQuantLib}
+	\framesubtitle{Examples: Curve fitting with FittedBondCurve function}
+\pagecolor{bgcolor}
+\noindent
+\scriptsize
+\ttfamily
+\vskip5pt
 \hlstd{}\hlkwc{library}\hlstd{}\hlsym{(}\hlstd{zoo}\hlsym{)}\hspace*{\fill}\\
 \hlstd{z\ }\hlsym{$<${-}\ }\hlstd{zoo}\hlsym{(}\hlstd{}\hlkwc{curve}\hlstd{\$}\hlkwc{table}\hlstd{\$zeroRates}\hlsym{,\ }\hlstd{order.by}\hlsym{=}\hlstd{}\hlkwc{curve}\hlstd{\$}\hlkwc{table}\hlstd{\$}\hlkwc{date}\hlstd{}\hlsym{)}\hspace*{\fill}\\
 \hlstd{}\hlkwc{plot}\hlstd{}\hlsym{(}\hlstd{z, xlab='Date', ylab='Zero Rates')}
@@ -268,6 +285,8 @@
 \begin{frame}
 	\frametitle{Fixed Income in RQuantLib}
 	\framesubtitle{Examples: Bond pricing}	
+In this example, we construct a bond discounting term structure and a swap term structure then use them to price a zero coupon bond and a fixed rate bond. First, we will walk quickly through the QuantLib's implementation.
+\vskip5pt
 \pagecolor{bgcolor}
 \tiny
 \noindent
@@ -700,6 +719,8 @@
 \begin{frame}
 	\frametitle{Fixed Income in RQuantLib}
 	\framesubtitle{Examples: Bond pricing}	
+Here, we are doing it in R using RQuantLib....
+\vskip5pt
 \pagecolor{bgcolor}
 \noindent
 \ttfamily
@@ -880,38 +901,27 @@
 
 \begin{frame}[fragile]
 	\frametitle{Fixed Income in RQuantLib}
-	\framesubtitle{Examples: Perform a spread effect analysis of a 4\%-coupon convertible bond callable at 110 at the end of the second year, maturing at par in 5 years, with yield to maturity of 5\% and spread (of YTM versus 5-year treasury) of 0, 50, 100, and 150 basis points. The underlying stock pays no dividend.}	
-
+	\framesubtitle{Examples: Convertible Bond from Matlab's Fixed Income Toolbox}	
+Perform a spread effect analysis of a 4\%-coupon convertible bond callable at 110 at the end of the second year, maturing at par in 5 years, with yield to maturity of 5\% and spread (of YTM versus 5-year treasury) of 0, 50, 100, and 150 basis points. The underlying stock pays no dividend. 
 \lstset{language=Matlab,basicstyle=\tiny}
 	\begin{lstlisting}
-RiskFreeRate = 0.05;
-Sigma        = 0.3;
-ConvRatio    = 1;
-NumSteps     = 200;
+RiskFreeRate = 0.05;	Sigma        = 0.3;
+ConvRatio    = 1;   	NumSteps     = 200;
 IssueDate    = datenum('2-Jan-2002');
 Settle       = datenum('2-Jan-2002');
 Maturity     = datenum('2-Jan-2007');
-CouponRate   = 0.04;
-Period       = 2;
-Basis        = 1;
-EndMonthRule = 1;
-DividendType = 0;
-DividendInfo = [];
+CouponRate   = 0.04;    Period       = 2;
+Basis        = 1;		EndMonthRule = 1;
+DividendType = 0;		DividendInfo = [];
 CallInfo     = [datenum('2-Jan-2004'), 110]; 
-CallType     = 1;
-TreeType     = 1;   
+CallType     = 1;		TreeType     = 1;   
 % Nested loop accross prices and static spread dimensions
 % to compute convertible prices.
 for j = 0:0.005:0.015;
 StaticSpread = j;
       for i = 0:10:100
           Price = 40+i;
-          [CbMatrix, UndMatrix, DebtMatrix, EqtyMatrix] = ...
-           cbprice(RiskFreeRate, StaticSpread, Sigma, Price, ...
-           ConvRatio, NumSteps, IssueDate, Settle, ...
-           Maturity, CouponRate, Period, Basis, EndMonthRule, ...
-           DividendType, DividendInfo, CallType, CallInfo, ...
-           TreeType);
+          [CbMatrix, UndMatrix, DebtMatrix, EqtyMatrix] =  cbprice(RiskFreeRate, StaticSpread, Sigma, Price, ConvRatio, NumSteps, IssueDate, Settle, Maturity, CouponRate, Period, Basis, EndMonthRule, DividendType, DividendInfo, CallType, CallInfo, TreeType);
    
            convprice(i/10+1,j*200+1) =  CbMatrix(1,1);
            stock(i/10+1,j*200+1)     =  Price;
@@ -944,6 +954,8 @@
 \end{frame}
 
 \begin{frame}
+Doing it in R using RQuantLib....
+\vskip5pt
 \scriptsize
 \pagecolor{bgcolor}
 \noindent



More information about the Rquantlib-commits mailing list