NMOF-package {NMOF} | R Documentation |
Numerical Methods and Optimization in Finance
Description
Functions, data and other R code from the book ‘Numerical Methods and Optimization in Finance’. Comments/corrections/remarks/suggestions are very welcome (please contact the maintainer directly).
Details
The package contains implementations of several optimisation
heuristics: Differential Evolution (DEopt
), Genetic
Algorithms (GAopt
), (Stochastic) Local Search
(LSopt
), Particle Swarm (PSopt
),
Simuleated Annealing (SAopt
) and
Threshold Accepting (TAopt
). The term heuristic is meant
in the sense of general-purpose optimisation method.
Dependencies: The package is completely written in R. A
number of packages are suggested, but they are not
strictly required when using the NMOF package, and
most of the package's functionality is available without
them. Specifically, package MASS is needed to run
the complete example for PSopt
and also in
one of the vignettes (PSlms
). Package
parallel is optional for functions
bracketing
, GAopt
,
gridSearch
and restartOpt
, and
may become an option for other functions. Package
quadprog is needed for a vignette
(TAportfolio
), some tests, and it may be used for
computing mean-variance efficient portfolios.
Package Rglpk is needed for function minCVaR
.
Package readxl is needed to process the raw data in function
Shiller
; package datetimeutils is
used by French
and Shiller
.
PMwR would be needed to run the examples
of the backtesting examples in the NMOF book.
Finally, packages RUnit and tinytest are needed to
run the tests in subdirectory ‘unitTests
’.
Version numbering: package versions are numbered in the
form major-minor-patch
. The patch level is
incremented with any published change in a version.
Minor version numbers are incremented when a
feature is added or an existing feature is substantially
revised. (Such changes will be reported in the NEWS file.)
The major version number will only be increased if
there were a new edition of the book.
The source code of the NMOF package is also hosted at https://github.com/enricoschumann/NMOF/. Updates to the package and new features are described at http://enricoschumann.net/notes/NMOF/.
Optimisation
There are functions for
Differential Evolution (DEopt
),
Genetic Algorithms (GAopt
),
(Stochastic) Local Search (LSopt
),
Simuleated Annealing (SAopt
),
Particle Swarm (SAopt
),
and Threshold Accepting (TAopt
).
The function restartOpt
helps with
running restarts of these methods;
also available are functions for
grid search (gridSearch
) and
greedy search (greedySearch
).
Pricing Financial Instruments
For options: See vanillaOptionEuropean
,
vanillaOptionAmerican
, putCallParity
.
For pricing methods that use the characteristic function, see
callCF
.
For bonds and bond futures: See vanillaBond
,
bundFuture
and xtContractValue
.
Simulation
Data
See bundData
, fundData
and
optionData
.
Author(s)
Enrico Schumann
Maintainer: Enrico Schumann <es@enricoschumann.net>
References
Gilli, M., Maringer, D. and Schumann, E. (2019) Numerical Methods and Optimization in Finance. 2nd edition. Elsevier. doi:10.1016/C2017-0-01621-X
Schumann, E. (2023) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual
Examples
## Not run:
library("NMOF")
## overview
packageDescription("NMOF")
help(package = "NMOF")
## code from book
showExample("equations.R", edition = 1)
showExample("Heur")
## show NEWS file
news(Version >= "2.0-0", package = "NMOF")
## vignettes
vignette(package = "NMOF")
nss <- vignette("DEnss", package = "NMOF")
print(nss)
edit(nss)
## _book_ websites
browseURL("http://nmof.net")
browseURL("http://enricoschumann.net/NMOF/")
## _package_ websites
browseURL("http://enricoschumann.net/R/packages/NMOF/")
browseURL("https://cran.r-project.org/package=NMOF")
browseURL("https://git.sr.ht/~enricoschumann/NMOF")
browseURL("https://github.com/enricoschumann/NMOF")
## unit tests
file.show(system.file("unitTests/test_results.txt", package = "NMOF"))
## End(Not run)
test.rep <- readLines(system.file("unitTests/test_results.txt",
package = "NMOF"))
nt <- gsub(".*\\(([0-9]+) checks?\\).*", "\\1",
test.rep[grep("\\(\\d+ checks?\\)", test.rep)])
message("Number of unit tests: ", sum(as.numeric(nt)))