Skip to content

Commit c443a5f

Browse files
Merge pull request #5 from Techtonique/try-renaming2
renaming package to lower case esgtoolkit and include functions for yield curve interpolation and extrapolation (previously available in package ycinterextra)
2 parents 77b648e + f4245f2 commit c443a5f

22 files changed

+1981
-55
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
src/*.o
66
src/*.so
77
src/*.dll
8-
ESGtoolkit.Rcheck/
9-
ESGtoolkit*.tar.gz
10-
ESGtoolkit*.tgz
8+
esgtoolkit.Rcheck/
9+
esgtoolkit*.tar.gz
10+
esgtoolkit*.tgz
1111
docs

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `ESGtoolkit` Code of Conduct
1+
# `esgtoolkit` Code of Conduct
22

33
## 1. Purpose
44

DESCRIPTION

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
Package: ESGtoolkit
1+
Package: esgtoolkit
22
Type: Package
33
Title: Toolkit for Monte Carlo Simulations
4-
Version: 0.6.2
5-
Date: 2023-10-01
4+
Version: 1.0.0
5+
Date: 2023-10-09
66
Authors@R: c(
77
person("T.", "Moudiki", , "[email protected]", role = c("aut", "cre")
88
)
99
)
10-
URL: https://techtonique.github.io/ESGtoolkit/
11-
BugReports: https://github.com/Techtonique/ESGtoolkit/issues
10+
URL: https://github.com/Techtonique/esgtoolkit
11+
BugReports: https://github.com/Techtonique/esgtoolkit/issues
1212
Maintainer: T. Moudiki <[email protected]>
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' 'discount_factors.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: 9 additions & 1 deletion
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)
@@ -27,5 +35,5 @@ importFrom("graphics", "abline", "lines", "matplot", "par", "plot",
2735
importFrom("stats", "cor", "cor.test", "deltat", "end", "is.ts", "pt",
2836
"qnorm", "qt", "quantile", "sd", "start", "t.test", "time",
2937
"ts", "tsp", "window")
30-
useDynLib("ESGtoolkit")
38+
useDynLib("esgtoolkit")
3139

NEWS.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# version 1.0.0
2+
3+
- rename `ESGtoolkit` to `esgtoolkit` (announced [here](https://thierrymoudiki.github.io/blog/2023/10/02/r/esgtoolkit-v062))
4+
- include `ycinter` and `ycextra` (from package `ycinterextra`, discontinued and unilaterally removed from CRAN)
5+
16
# version 0.6.2
27

38
- **Important:** Starting with 1.0.0, the next version, it will be renamed as: 'esgtoolkit' (to finally remove all my active packages from CRAN)
@@ -20,7 +25,7 @@
2025

2126
- Use [VineCopula](http://tnagler.github.io/VineCopula/) package instead of CDVine (archived) for dependency simulation (means there's also now VineCopula's R-Vine Copulas simulation)
2227
- Remove roxygen2 comments
23-
- Create website with pkgdown, including docs --> https://techtonique.github.io/ESGtoolkit/
28+
- Create website with pkgdown, including docs --> https://techtonique.github.io/esgtoolkit/
2429

2530

2631
# version 0.2.0

R/RcppExports.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,38 @@
22
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
33

44
rnormESGcpp <- function(N, M) {
5-
.Call('_ESGtoolkit_rnormESGcpp', PACKAGE = 'ESGtoolkit', N, M)
5+
.Call('_esgtoolkit_rnormESGcpp', PACKAGE = 'esgtoolkit', N, M)
66
}
77

88
rOUESGcpp <- function(N, horizon, Delta, x0, theta, eps) {
9-
.Call('_ESGtoolkit_rOUESGcpp', PACKAGE = 'ESGtoolkit', N, horizon, Delta, x0, theta, eps)
9+
.Call('_esgtoolkit_rOUESGcpp', PACKAGE = 'esgtoolkit', N, horizon, Delta, x0, theta, eps)
1010
}
1111

1212
rOUESGcppexact <- function(N, horizon, Delta, x0, theta, eps) {
13-
.Call('_ESGtoolkit_rOUESGcppexact', PACKAGE = 'ESGtoolkit', N, horizon, Delta, x0, theta, eps)
13+
.Call('_esgtoolkit_rOUESGcppexact', PACKAGE = 'esgtoolkit', N, horizon, Delta, x0, theta, eps)
1414
}
1515

1616
rCIRESGcpp <- function(N, horizon, Delta, x0, theta, eps) {
17-
.Call('_ESGtoolkit_rCIRESGcpp', PACKAGE = 'ESGtoolkit', N, horizon, Delta, x0, theta, eps)
17+
.Call('_esgtoolkit_rCIRESGcpp', PACKAGE = 'esgtoolkit', N, horizon, Delta, x0, theta, eps)
1818
}
1919

2020
rCIRESGcppexact <- function(N, horizon, Delta, x0, theta, eps) {
21-
.Call('_ESGtoolkit_rCIRESGcppexact', PACKAGE = 'ESGtoolkit', N, horizon, Delta, x0, theta, eps)
21+
.Call('_esgtoolkit_rCIRESGcppexact', PACKAGE = 'esgtoolkit', N, horizon, Delta, x0, theta, eps)
2222
}
2323

2424
rGBMESGcpp <- function(N, horizon, Delta, x0, theta1, theta2, eps) {
25-
.Call('_ESGtoolkit_rGBMESGcpp', PACKAGE = 'ESGtoolkit', N, horizon, Delta, x0, theta1, theta2, eps)
25+
.Call('_esgtoolkit_rGBMESGcpp', PACKAGE = 'esgtoolkit', N, horizon, Delta, x0, theta1, theta2, eps)
2626
}
2727

2828
rGBMjumpsnormESGcpp <- function(N, horizon, Delta, x0, theta1, theta2, lambda, mu, sigma, eps) {
29-
.Call('_ESGtoolkit_rGBMjumpsnormESGcpp', PACKAGE = 'ESGtoolkit', N, horizon, Delta, x0, theta1, theta2, lambda, mu, sigma, eps)
29+
.Call('_esgtoolkit_rGBMjumpsnormESGcpp', PACKAGE = 'esgtoolkit', N, horizon, Delta, x0, theta1, theta2, lambda, mu, sigma, eps)
3030
}
3131

3232
rGBMjumpskouESGcpp <- function(N, horizon, Delta, x0, theta1, theta2, lambda, eta_up, eta_down, p, eps) {
33-
.Call('_ESGtoolkit_rGBMjumpskouESGcpp', PACKAGE = 'ESGtoolkit', N, horizon, Delta, x0, theta1, theta2, lambda, eta_up, eta_down, p, eps)
33+
.Call('_esgtoolkit_rGBMjumpskouESGcpp', PACKAGE = 'esgtoolkit', N, horizon, Delta, x0, theta1, theta2, lambda, eta_up, eta_down, p, eps)
3434
}
3535

3636
TAGcorecpp <- function(sim, sj_down, sj_up, n, p) {
37-
.Call('_ESGtoolkit_TAGcorecpp', PACKAGE = 'ESGtoolkit', sim, sj_down, sj_up, n, p)
37+
.Call('_esgtoolkit_TAGcorecpp', PACKAGE = 'esgtoolkit', sim, sj_down, sj_up, n, p)
3838
}
3939

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)