Skip to content

Commit

Permalink
added Windows build and manual
Browse files Browse the repository at this point in the history
  • Loading branch information
klausspanderen committed Aug 25, 2016
1 parent f03040e commit abbf64e
Show file tree
Hide file tree
Showing 12 changed files with 349 additions and 54 deletions.
24 changes: 24 additions & 0 deletions Boost_LICENSE.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

147 changes: 147 additions & 0 deletions QuantLib_LICENSE.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
QuantLib is
Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl

Copyright (C) 2001, 2002, 2003 Nicolas Di C�sar�
Copyright (C) 2001, 2002, 2003 Sadruddin Rejeb

Copyright (C) 2002, 2003, 2004 Decillion Pty(Ltd)
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Ferdinando Ametrano

Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2014 StatPro Italia srl
Copyright (C) 2003, 2004, 2007 Neil Firth
Copyright (C) 2003, 2004 Roman Gitlin
Copyright (C) 2003, 2005, 2013 Gary Kennedy
Copyright (C) 2003 Niels Elken S�nderby
Copyright (C) 2003 Kawanishi Tomoya

Copyright (C) 2004 FIMAT Group
Copyright (C) 2004 M-Dimension Consulting Inc.
Copyright (C) 2004 Mike Parker
Copyright (C) 2004 Walter Penschke
Copyright (C) 2004 Gianni Piolanti
Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Klaus Spanderen
Copyright (C) 2004 Jeff Yu

Copyright (C) 2005, 2006, 2008 Toyin Akin
Copyright (C) 2005 Sercan Atalik
Copyright (C) 2005, 2006 Theo Boafo
Copyright (C) 2005, 2006, 2007, 2009 Piter Dias
Copyright (C) 2005, 2006, 2007 Joseph Wang
Copyright (C) 2005 Charles Whitmore

Copyright (C) 2006, 2007 Banca Profilo S.p.A.
Copyright (C) 2006, 2007 Marco Bianchetti
Copyright (C) 2006 Yiping Chen
Copyright (C) 2006 Warren Chou
Copyright (C) 2006, 2007 Cristina Duminuco
Copyright (C) 2006, 2007 Giorgio Facchinetti
Copyright (C) 2006, 2007 Chiara Fornarola
Copyright (C) 2006 Silvia Frasson
Copyright (C) 2006 Richard Gould
Copyright (C) 2006, 2007, 2008, 2009, 2010 Mark Joshi
Copyright (C) 2006, 2007, 2008 Allen Kuo
Copyright (C) 2006, 2007, 2008, 2009, 2012 Roland Lichters
Copyright (C) 2006, 2007 Katiuscia Manzoni
Copyright (C) 2006, 2007 Mario Pucci
Copyright (C) 2006, 2007 Fran�ois du Vignaud

Copyright (C) 2007 Affine Group Limited
Copyright (C) 2007 Richard Gomes
Copyright (C) 2007, 2008 Laurent Hoffmann
Copyright (C) 2007, 2008, 2009, 2010, 2011 Chris Kenyon
Copyright (C) 2007 Gang Liang

Copyright (C) 2008, 2009 Jose Aparicio
Copyright (C) 2008 Yee Man Chan
Copyright (C) 2008, 2011 Charles Chongseok Hyun
Copyright (C) 2008 Piero Del Boca
Copyright (C) 2008 Paul Farrington
Copyright (C) 2008 Lorella Fatone
Copyright (C) 2008, 2009 Andreas Gaida
Copyright (C) 2008 Marek Glowacki
Copyright (C) 2008 Florent Grenier
Copyright (C) 2008 Frank H�vermann
Copyright (C) 2008 Simon Ibbotson
Copyright (C) 2008 John Maiden
Copyright (C) 2008 Francesca Mariani
Copyright (C) 2008, 2009, 2010, 2011, 2012 Master IMAFA - Polytech'Nice Sophia - Universit� de Nice Sophia Antipolis
Copyright (C) 2008, 2009 Andrea Odetti
Copyright (C) 2008 J. Erik Radmall
Copyright (C) 2008 Maria Cristina Recchioni
Copyright (C) 2008, 2009, 2012 Ralph Schreyer
Copyright (C) 2008 Roland Stamm
Copyright (C) 2008 Francesco Zirilli

Copyright (C) 2009 Nathan Abbott
Copyright (C) 2009 Sylvain Bertrand
Copyright (C) 2009 Fr�d�ric Degraeve
Copyright (C) 2009 Dirk Eddelbuettel
Copyright (C) 2009 Bernd Engelmann
Copyright (C) 2009, 2010, 2012 Liquidnet Holdings, Inc.
Copyright (C) 2009 Bojan Nikolic
Copyright (C) 2009, 2010 Dimitri Reiswich
Copyright (C) 2009 Sun Xiuxin

Copyright (C) 2010 Kakhkhor Abdijalilov
Copyright (C) 2010 Hachemi Benyahia
Copyright (C) 2010 Manas Bhatt
Copyright (C) 2010 DeriveXperts SAS
Copyright (C) 2010, 2014 Cavit Hafizoglu
Copyright (C) 2010 Michael Heckl
Copyright (C) 2010 Slava Mazur
Copyright (C) 2010, 2011, 2012, 2013 Andre Miemiec
Copyright (C) 2010 Adrian O' Neill
Copyright (C) 2010 Robert Philipp
Copyright (C) 2010 Alessandro Roveda
Copyright (C) 2010 SunTrust Bank

Copyright (C) 2011, 2013 Fabien Le Floc'h

Copyright (C) 2012, 2013 Grzegorz Andruszkiewicz
Copyright (C) 2012, 2013, 2014 Peter Caspers
Copyright (C) 2012 Mateusz Kapturski
Copyright (C) 2012 Simon Shakeshaft
Copyright (C) 2012 �douard Tallent
Copyright (C) 2012 Samuel Tebege

Copyright (C) 2013 BGC Partners L.P.
Copyright (C) 2013 Cheng Li
Copyright (C) 2013 Yue Tian

QuantLib includes code taken from Peter J�ckel's book "Monte Carlo
Methods in Finance".

QuantLib includes software developed by the University of Chicago,
as Operator of Argonne National Laboratory.

QuantLib includes a set of numbers provided by Stephen Joe and Frances
Kuo under a BSD-style license.


Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

Neither the names of the copyright holders nor the names of the QuantLib
Group and its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

The RHestonSLV package makes the implementation of the Heston
Stochastic Local Volatility model in
[QuantLib](https://github.com/lballabio/quantlib) visible to the R
user.
[QuantLib](https://github.com/lballabio/quantlib) visible for R users.

Local Stochastic Volatility (LSV) models have become the industry standard
for FX and equity markets. The local volatility extension of the popular Heston
Expand Down
20 changes: 10 additions & 10 deletions demo/barrierdelta.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with RHestonSLV. If not, see <http:#www.gnu.org/licenses/>.

library(RHestonSLV)
library(parallel)
#library(parallel)
library(RQuantLib)

vol <- 0.3
Expand All @@ -33,16 +33,16 @@ barriers <- seq(0, 100, 5)
slvBarrierDelta <- function(eta) {
process <- HestonProcess(cf(0.05), cf(0.02),
100, 0.09, 1.0, 0.06, eta * 0.4,-0.75)

model <- new (HestonSLVFDMModel,
Sys.Date(),
Sys.Date() + 1095,
localVol,
process,
params)

initialize <- leverageFunction(model, TRUE)(0.1, process["spot"])

sapply(barriers, function(barrier) {
hestonSLVBarrierPricer(
Sys.Date(),
Expand All @@ -59,16 +59,16 @@ slvBarrierDelta <- function(eta) {
})
}

cl <- makeCluster(detectCores(), "FORK")
#cl <- makeCluster(detectCores(), "FORK")

deltas <- parSapply(cl=cl, c(1.0,0.5,0.25, 0.1), function(eta) {
deltas <- sapply(c(1.0,0.5,0.25, 0.1), function(eta) {
slvBarrierDelta(eta)
})

stopCluster(cl)
#stopCluster(cl)

lvBarrierDelta <- sapply(barriers, function(barrier) {
barrierPrice <- function(underlying, barrier) {
barrierPrice <- function(underlying, barrier) {
BarrierOption(
"downout", "put",
underlying=underlying,
Expand All @@ -79,7 +79,7 @@ lvBarrierDelta <- sapply(barriers, function(barrier) {
volatility=0.3,
barrier=max(0.001, barrier))$value
}

10*(barrierPrice(100.1, barrier)-barrierPrice(100.0, barrier))
})

Expand All @@ -90,7 +90,7 @@ s4 <- spline(barriers, lvBarrierDelta-deltas[,4], n=100, method="natural")

par(mar=c(5.1,4.6,4.1,2.1))

plot(s1$x, s1$y, type='l', ,xlim=c(0,100), xlab="Barrier",
plot(s1$x, s1$y, type='l', ,xlim=c(0,100), xlab="Barrier",
ylab=expression(paste('\U0394'[local], ' - \U0394'[SLV])),
main=expression(paste('Barrier Option \U0394'[local], ' vs \U0394'[SLV])),lty=2,
cex.main=1.4,cex.lab=1.3)
Expand Down
8 changes: 4 additions & 4 deletions demo/barrierprice.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with RHestonSLV. If not, see <http:#www.gnu.org/licenses/>.

library(RHestonSLV)
library(parallel)
#library(parallel)
library(RQuantLib)

vol <- 0.3
Expand Down Expand Up @@ -59,13 +59,13 @@ slvBarrierPrices <- function(eta) {
})
}

cl <- makeCluster(detectCores(), "FORK")
#cl <- makeCluster(detectCores(), "FORK")

prices <- parSapply(cl=cl, c(1.0,0.5,0.25, 0.1), function(eta) {
prices <- sapply(c(1.0,0.5,0.25, 0.1), function(eta) {
slvBarrierPrices(eta)
})

stopCluster(cl)
#stopCluster(cl)

lvBarrierPrices <- sapply(barriers, function(barrier) {
BarrierOption(
Expand Down
8 changes: 4 additions & 4 deletions demo/forwardskew.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with RHestonSLV. If not, see <http:#www.gnu.org/licenses/>.

library(RHestonSLV)
library(parallel)
#library(parallel)

vol <- 0.3
localVol <- function(t, s) { vol }
Expand Down Expand Up @@ -48,13 +48,13 @@ impliedVols <- function(eta) {
})
}

cl <- makeCluster(detectCores(), "FORK")
#cl <- makeCluster(detectCores(), "FORK")

vols <- parSapply(cl=cl, c(1.0, 0.5, 0.25), function(eta) {
vols <- sapply(c(1.0, 0.5, 0.25), function(eta) {
impliedVols(eta)
})

stopCluster(cl)
#stopCluster(cl)

iv100 <- vols[,1]*100
iv050 <- vols[,2]*100
Expand Down
10 changes: 5 additions & 5 deletions demo/impliedvol.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with RHestonSLV. If not, see <http:#www.gnu.org/licenses/>.

library(RHestonSLV)
library(parallel)
#library(parallel)

vol <- 0.3
localVol <- function(t, s) { vol }
Expand Down Expand Up @@ -56,15 +56,15 @@ impliedVol <- function(strike, maturity, model) {

strikes <- seq(50, 250, 10)

cl <- makeCluster(detectCores(), "FORK")
#cl <- makeCluster(detectCores(), "FORK")

vfd <-parSapply(cl=cl, strikes, function(strike) {
vfd <-sapply(strikes, function(strike) {
impliedVol(strike, 1.0, modelfd) })

vmc <-parSapply(cl=cl, strikes, function(strike) {
vmc <-sapply(strikes, function(strike) {
impliedVol(strike, 1.0, modelmc) })

stopCluster(cl)
#stopCluster(cl)

plot(strikes, vmc*100, main="Round-Trip Error for 1Y Maturity",
xlab="Strike", ylab="Implied Volatility (in %)",
Expand Down
8 changes: 4 additions & 4 deletions demo/moustache.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with RHestonSLV. If not, see <http:#www.gnu.org/licenses/>.

library(RHestonSLV)
library(parallel)
#library(parallel)

process <- HestonProcess(cf(0.02), cf(0.01),
100, 0.09, 1.0, 0.06, 0.8, -0.8)
Expand Down Expand Up @@ -67,13 +67,13 @@ slvDoubleBarrierPrices <- function(eta) {
})
}

cl <- makeCluster(detectCores(), "FORK")
#cl <- makeCluster(detectCores(), "FORK")

slvPrices <- parSapply(cl=cl, c(1.0, 0.75, 0.5, 0.25, 0.001), function(eta) {
slvPrices <- sapply(c(1.0, 0.75, 0.5, 0.25, 0.001), function(eta) {
slvDoubleBarrierPrices(eta)
})

stopCluster(cl)
#stopCluster(cl)

bsNPV <- unlist(sapply(barriers, function(barrier) {
bsDoubleNoTouchBarrierPricer(
Expand Down
31 changes: 31 additions & 0 deletions readme.linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Build and installation on Linux

Prerequisite
R, QuantLib and boost are installed in standard directories.


1. install Rcpp

echo "install.packages(\"Rcpp\", repos=\"https://cran.r-project.org\")" | R --vanilla


2. download and build RHestonSLV

https://github.com/klausspanderen/RHestonSLV/archive/master.zip

und extract files.


2a. Open RStudio

File -> Open Project -> open RHestonSLV.Rproj

Build -> Build and Reload


2b. or alternatively run

R CMD INSTALL RHestonSLV


done
Loading

0 comments on commit abbf64e

Please sign in to comment.