Skip to content

Commit d61fae2

Browse files
renaming Pt.2
1 parent 39b36bd commit d61fae2

File tree

15 files changed

+1816
-3
lines changed

15 files changed

+1816
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ BugReports: https://github.com/Techtonique/esgtoolkit/issues
1212
Maintainer: T. Moudiki <thierry.moudiki@gmail.com>
1313
Description: A toolkit for Monte Carlo Simulations in Finance, Economics, Insurance, Physics. Multiple simulation models can be created by combining building blocks provided in the package.
1414
License: BSD_3_clause Clear + file LICENSE
15-
Depends: ggplot2, gridExtra, reshape2, VineCopula, randtoolbox
15+
Depends: ggplot2, gridExtra, methods, reshape2, VineCopula, randtoolbox
1616
Imports: Rcpp(>= 0.11.0)
1717
Suggests:
1818
devtools,
1919
testthat
2020
LinkingTo: Rcpp
21-
Collate: 'RcppExports.R' 'calculatereturns.R' 'fwdrates.R' 'plots.R' 'rates_interpolation.R' 'simulations_risks.R' 'simulations_shocks.R' 'tests.R' 'tools.R' 'zzz.R'
2221
Packaged: 2014-06-12 23:32:30 UTC; Thierry
2322
NeedsCompilation: yes
2423
Repository: CRAN

NAMESPACE

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ export(esgplotshocks)
1010
export(esgplotts)
1111
export(simdiff)
1212
export(simshocks)
13+
export(forwardrates)
14+
export(ycextra)
15+
export(ycinter)
16+
importFrom("graphics", "hist")
17+
importFrom("methods", "new")
18+
importFrom("stats", "density", "median", "nlminb", "optim", "pf",
19+
"qqline", "qqnorm", "shapiro.test")
20+
importFrom("utils", "setTxtProgressBar", "txtProgressBar")
1321
importFrom(ggplot2, ggplot)
1422
importFrom(ggplot2, qplot)
1523
importFrom(gridExtra, grid.arrange)

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# version 1.0.0
22

33
- rename `ESGtoolkit` to `esgtoolkit`
4-
- include `ycinter` and `ycextra` (?)
4+
- include `ycinter` and `ycextra` (from package `ycinterextra`, discontinued and unilaterally removed from CRAN)
55

66
# version 0.6.0
77

R/utils.R

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
########## Tools
2+
# simply coumpounded euribor rate
3+
euriborfromprice <- function(t, T, ZC)
4+
{
5+
# Brigo P. 7
6+
tau <- T-t
7+
return(as.vector((1/ZC - 1)/tau))
8+
}
9+
euriborfromprice <- compiler::cmpfun(euriborfromprice)
10+
11+
12+
# simply coumpounded zero-coupon price
13+
pricefromeuribor <- function(t, T, L)
14+
{
15+
# Brigo P. 7
16+
tau <- T-t
17+
return(as.vector(1/(1 + L*tau)))
18+
}
19+
pricefromeuribor <- compiler::cmpfun(pricefromeuribor)
20+
21+
# simply coumpounded forward rate
22+
fwdrate <- function(T_, S, ZC_T, ZC_S)
23+
{
24+
# Brigo P. 12
25+
tau <- S-T_
26+
return((ZC_T/ZC_S - 1)/tau)
27+
}
28+
fwdrate <- compiler::cmpfun(fwdrate)
29+
30+
# Swap curve bootstrap
31+
bootstrapswapcurve <- function(swaprate, maturity, typeres=c("rates", "prices"))
32+
{
33+
swaprate <- swaprate/100
34+
accrual <- diff(maturity)
35+
n <- length(swaprate)
36+
ZC <- numeric(n)
37+
ZC[1] <- 1/(1+maturity[1]*swaprate[1])
38+
39+
for (i in seq_len(n)[-1])
40+
{
41+
ind <- seq_len(i-1)
42+
ZC[i] <- (1 - swaprate[i]*sum(accrual[ind]*ZC[ind]))/(1+swaprate[i]*accrual[i-1])
43+
}
44+
45+
typeres <- match.arg(typeres)
46+
47+
if (missing(typeres) || typeres == "prices")
48+
{return(ts(ZC))}
49+
50+
if (typeres == "rates")
51+
{return((1-ZC)/(maturity*ZC))}
52+
}
53+
bootstrapswapcurve <- compiler::cmpfun(bootstrapswapcurve)

0 commit comments

Comments
 (0)