Login  Register

Re: QuantLib R package from SWIG code

Posted by Dirk Eddelbuettel on Jun 04, 2013; 1:59am
URL: http://quantlib.414.s1.nabble.com/QuantLib-R-package-from-SWIG-code-tp14318p14319.html


On 3 June 2013 at 20:06, Dirk Eddelbuettel wrote:
| edd@max:~/svn/rquantlib/pkg/QuantLib$ R --slave -e 'source("demo/bonds.R")'
| Today :[1] "2008-09-15"
| Settlement Date: [1] "2008-09-18"
|
| Results:
|                 zeroCoupon fixedRate floatingRate
| NPV                100.922 107.66829  102.3593146
| Clean Price        100.922 106.12753  101.7972017
| Dirty Price        100.922 107.66829  102.3593146
| Accrued Amount       0.000   1.54076    0.5621129
| Previous Coupon         NA   0.04500    0.0288625
| Next Coupon             NA   0.04500    0.0342984
|
| Sample indirect computations (for the floating rate bond):
| Yield to Clean Price: [1] 101.797
| Clean Price to Yield: [1] 0.0220096
| edd@max:~/svn/rquantlib/pkg/QuantLib$

Here is the same from slightly better version (and now source'd from R)

R> source("bonds.R")
Today :[1] "2008-09-15"
Settlement Date: [1] "2008-09-18"

Results:
                zeroCoupon fixedRate floatingRate
NPV               100.9222  107.6683    102.35931
Clean Price       100.9222  106.1275    101.79720
Dirty Price       100.9222  107.6683    102.35931
Accrued Amount      0.0000    1.5408      0.56211
Previous Coupon         NA    4.5000      2.88625
Next Coupon             NA    4.5000      3.42984
Yield               3.0001    3.6476      2.20096

Sample indirect computations (for the floating rate bond):
Yield to Clean Price: [1] 101.797
Clean Price to Yield: [1] 0.0220096


The file is in the SVN repo for R. It starts with library(QuantLib), the
three lines in Joe's README can also be used to load the shared library and
pre-created data types.  I'd be happy to check it into QuantLib too.

Dirk


--
Dirk Eddelbuettel | [hidden email] | http://dirk.eddelbuettel.com

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev