Functions, examples and data from the first and the second edition of "Numerical Methods and Optimization in Finance" by M. Gilli, D. Maringer and E. Schumann (2019, ISBN:978-0128150658). The package provides implementations of optimisation heuristics (Differential Evolution, Genetic Algorithms, Particle Swarm Optimisation, Simulated Annealing and Threshold Accepting), and other optimisation tools, such as grid search and greedy search. There are also functions for the valuation of financial instruments, such as bonds and options, and functions that help with stochastic simulations.
o new function 'convexity'
o new vignette 'Solving the N-Queens Problem with Local Search'
o new functions 'bundFuture' and 'bundFutureImpliedRate', for computing theoretical futures prices and implied repo rates, respectively
o new function 'divRatio', for computing the diversification ratio
o 'LSopt' gains an option 'OF.target', which lets the algorithm stop when a desired objective-function value is reached
o 'minvar' allows Inf and -Inf as maximum/minimum weights; the function now also returns the portfolio's variance
o 'resampleC': if only two series are passed, 'cormat' can be a single number (the correlation)
o various small updates in documentation
o new function 'CPPI': simulate a constant-proportion portfolio-insurance strategy
o new function 'SAopt': optimisation with Simulated Annealing
o new function 'minvar': compute minimum-variance portfolios
o manual has been updated: http://enricoschumann.net/NMOF.htm#NMOFmanual
o new function 'xtTickValue', which computes the tick value for of Australian government-bond futures
o new function 'xtContractValue', for computing contract values of Australian government-bond futures
o fixed: LSopt did not switch off 'printBar' in cases when 'printDetail > 1'
o updates to documentation of LSopt/TAopt
o fixed: 'gbb' failed when only a single path was to be computed
o gbm: add fanplot example
o fixed: 'DEopt' did not work for univariate optimisation models. (Thanks to Torsten von Bartenwerffer for reporting.)
o TAopt: new option 'OF.target', which lets the algorithm stop when a desired objective-function value is reached
o TA.info: the best solution ('xbest') is now also provided
o new test function 'tfEggholder'
o TAopt: experimental/rudimentary plot and print methods. The methods are invoked if 'algo$classify' is TRUE (default is FALSE in order to keep old behaviour)
o there is now a public Git repository at https://github.com/enricoschumann/NMOF
o repairMatrix: new argument 'eps', which specifies the replacement value for negative eigenvalues
o bracketing: the resulting matrix's columns are named 'lower' and 'upper'
o restartOpt: when 'cl' is specified and 'method' is identical to 'loop', the function will now issue a warning before changing method to 'snow'
o functions from packages other than 'base' are now explicity imported: 'grDevices', 'graphics', 'stats', 'utils'
o TAopt: more informative error message when objective function evaluates to NA during computation of thresholds
o experimental: new function 'LS.info' for accessing information during optimisation run (eg, current iteration)
o small correction in parameter description in 'callMerton' (suggested by Laurs Leth)
o new function 'pm' for computing partial moments
o fixed: 'DEopt' did not properly handle the 'minmaxConstr' option, which could result in solutions that violated the box constraints. (Thanks to David Ashear for reporting.)
o no user-visible changes (see ChangeLog for non-visible changes)
o Functions such as 'mclapply' from package 'parallel' are imported; 'parallel' is no longer attached when these functions are used (ie, the package is not added to the user's search path). [Please note that the CRAN version of NMOF has required R (>= 2.14) for some time now, and since that R-version package 'parallel' has been available anyway.]
o report 'Distributed computations with the NMOF package' was updated
o updates in documentation and vignettes
o argument 'offset' in 'ytm' can be a vector (that worked before as well, but is now documented)
o several small updates in documentation
o new function 'colSubset'
o experimental: new function 'TA.info' for accessing information during optimisation run (eg, current iteration)
o rewrote example in 'Asset selection with Local Search'
o various small updates in documentation and vignettes (e.g. links to mailing lists)
o expanded vignette 'Overview of the NMOF package'
o new function 'callMerton' for European calls under Merton's jump--diffusion model
o new vignette 'Overview of the NMOF package'
o smaller changes/updates in documentation
o new function 'duration'
o function 'ytm' has an argument 'offset' now; see ?ytm for examples
o function 'ytm' is slightly faster now
o small additions to documentation
o added function 'drawdown'
o Code examples in subdirectory 'NMOFex' (manual) updated.
o small updates in documentation
o vignettes are now all placed in vignettes, again [see NEWS entries v0.27-5 (2013-04-26) and v0.26-0 (2012-09-19)]; small changes in vignettes
o 'snow' was removed from 'Suggested'. Whenever distribution of computations is done via method 'snow', package 'parallel' is now used. Note that this is currently experimental and little-tested; feedback is thus much appreciated.
o in 'callHestoncf' and 'callCF', the upper integration limit is now 'Inf' (suggested by Wolfgang H"ormann). This may make it easier to compare different numerical implementations (but accuracy with the old cutoff value was sufficient: numeric differences in prices are of the order of a few hundredths of one cent).
o 'multicore' was removed from the 'Suggested' packages. (Package 'parallel' had already been used -- if possible -- since version 0.25-6; see the NEWS entry.)
o the package now 'Depends' on R version >= 2.14 (because of 'parallel')
o new functions 'gbm' and 'gbb' added (geometric Brownian motion/bridge)
o since vignettes are built offline, the number of restarts was increased again; cf. NEWS entry for v0.26-0 (2012-09-19)
o fixed a small error in help page for 'vanillaBond'
o internal changes in option pricing functions; more tests added for dividend handling
o function 'putCallParity' added
o for 'vanillaOptionEuropean', a parameter 'vol' can be passed via '...' (which is translated into 'v' by squaring and ignored if 'v' is already specified)
o a few internal changes and doc changes
o Experimental: 'vanillaOptionEuropean' has arguments 'model' (default is NULL which corresponds to Black-Scholes-Merton) and '...'. This allows to pass other models; for example, 'heston'. With 'greeks' set to TRUE, the function also returns (some) derivatives. More will be added over time, so the results should be extracted by name, not by position (eg, x[["delta"]], but not x[[2L]]). (Adding derivatives for non-BSM models was suggested by Nitesh Kumar.)
o Small corrections in docs for 'ytm' and 'vanillaOptionEuropean'.
o Added functions 'ytm' and 'vanillaBond': compute yield-to-maturity and price of plain-vanilla bond.
o Function 'qTable' has new arguments 'funs', 'tabular.format' and 'skip'; see vignette 'qTableEx' and ?qTable. The function now (correctly) adds more space at the end of the tabular (unless 'skip' is FALSE, which corresponds to the previous behaviour).
o Minor changes in documentation and examples.
o Code examples in subdirectory 'NMOFex' (manual) updated.
o Important: all option pricing functions that return lists of named elements (callCF, vanillaOptionE/A, callHestoncf) now call the theoretical option value just 'value'. Before, they returned 'price' or 'callPrice', which could be confusing for instance in case of implied vol calculations.
o DEopt, GAopt and PSopt now also return the initial populations (but only if 'algo$storeSolutions' is TRUE)
o More unit tests added.
o Changes in documentation and unit tests.
o Small changes in documentation (option pricing functions).
o Code examples in subdirectory 'NMOFex' (manual) updated.
o Vignettes (except for one) are now built offline to reduce build/check time for R-Forge/CRAN. (As suggested by Kasper Daniel Hansen in this post: https://stat.ethz.ch/pipermail/r-devel/2012-September/064810.html )
o Small changes in documentation.
o Added functions 'vanillaOptionEuropean', 'VanillaOptionAmerican' and 'vanillaOptionImpliedVol'.
o Test files have been reorganised (there are now about 700 unit tests; they all can be run from /unitTests/runTests.R).
o New maintainer e-mail address.
o all opt-functions now return 'initial.state' (which is the value of '.Random.seed' when the function is called). All the warnings of '?Random' apply (in particular, see section 'Note'); the preferred way is still to set a seed explicitly with 'set.seed'.
o minor internal changes (the only visible update are small changes in some of the examples)
o Package 'parallel' is now suggested. In functions gridSearch, restartOpt, bracket: with method 'multicore' the functions first check if package 'parallel' is available; if not, they look for package 'multicore'
o 'restartOpt' has a new argument 'best.only': if TRUE, only the best run is reported. Default is FALSE.
o Added checks in DEopt that vectorised functions return objects of correct size (will be added to PSopt and GAopt as well).
o Removed NEWS.Rd (NEWS now back to plain text).
o Added checks on the parameters for 'callCF'; added new arguments 'uniroot.control', which allows to pass the settings for 'uniroot' (to compute implied vol), and 'uniroot.info'. (Computation of implied vol would fail when spot equalled strike and r equalled q; thanks to Douglas McLean for reporting this case.)
o Small changes in the vignettes (mostly layout).
o Code examples in subdirectory 'NMOFex' updated.
o Small changes in the vignettes (mostly layout).
o In 'TAopt', 'LSopt': if 'x0' is not a function, it is initialised with 'eval(x0)'; thus, it can be an expression.
o Several minor internal changes.
o Edited some of the examples in the documentation; minor modifications in docs.
o Code examples in subdirectory 'NMOFex' updated.
o All the R-code examples from the book are now available in the package through function 'showExample'; eg, 'showExample("equations.R")' (The scripts are stored in subdirectory 'book'.)
o A first draft of the 'NMOF Manual' is available from http://enricoschumann.net/NMOF.htm . The manual's code examples are collected in file 'NMOFman.R' (in subdirectory 'NMOFex'). The manual supersedes 'Examples and Extensions for the NMOF package'.
o The tests on specific TA applications (minimum variance, tangency portfolio) have been removed; the code was added to the manual.
o Small changes in vignettes.
o Re-organised existing/added new unit tests.
o Added function 'resampleC': allows to sample with replacement from arbitrary numeric vectors (ie, samples) and making the samples (rank) correlated.
o 'DEopt' and 'PSopt' now have an argument 'algo$minmaxConstr'. If TRUE, 'algo$min' and 'algo$max' are become constraints. These constraints are implemented through an internal repair function that is called before any user-defined repair function.
o fixed: 'restartOpt' could not take an argument named 'X' via the '...' argument. o Unit tests added in unitTests1.R.
o fixed: with 'algo$storeSolutions==TRUE', functions 'LSopt' and 'TAopt' only returned the current (=accepted) solution in a given iteration, but not the candidate solution. (These data can be found in 'xlist'. See ?TAopt and ?LSopt, under 'Value'.) o Unit tests added in unitTests1.R.
o Added 'Depends: R (>= 2.10)' to DESCRIPTION (necessary because of file compression).
o Dataset 'optionData' was added. o More tests were added for function 'callCF'; and its documentation was updated.
o with 'algo$printDetail = TRUE', functions DEopt, GAopt and PSopt give more information o vignette 'DEnss.Rnw' was shortened to reduce build-time of the package (removed parts are now in 'Examples and Extensions for the NMOF package') o code examples in subdirectory 'NMOFex' updated
o minor changes in vignettes/documentation o code examples in subdirectory 'NMOFex' updated
o tests for distributed computing have been organised into a report, 'Distributed computations with the NMOF package', available as a pdf-file from http://enricoschumann.net/files/NMOFdist_Windows.pdf and http://enricoschumann.net/files/NMOFdist_Linux.pdf (package 'multicore' is only available on Linux) o the code for 'Distributed computations with the NMOF package' is available in file 'NMOFdist.R', stored in subdirectory 'NMOFex' (the file 'multicore.R' has been removed from subdirectory 'unitTests') o unit tests updated
o documentation updated o slight changes in vignette 'DEnss.Rnw' (to reduce time to build package)
o fixed: in 'GAopt', optional arguments for 'mclapply' (multicore) were not passed. An example for passing an argument was added to file 'unitTests/multicore.R'. o documentation for 'GAopt' updated o code examples in subdirectory 'NMOFex' updated
o 'GAopt' now has an argument 'algo$methodOF' that supports 'loop' (default) but also 'snow' or 'multicore'. See 'Examples and Extensions for the NMOF package' (with code in subdirectory 'NMOFex') for an example. o vignette 'TAportfolio' updated (now with example for rank-deficient matrix)
o fixed: 'gridSearch' with 'printDetail=TRUE' did not give a meaningful message o experimental: 'GAopt' now has an argument 'algo$methodOF' that can be 'loop' (default) but also 'snow' or 'multicore' (currently, only 'snow' is operational). If 'algo$methodOF' is not 'loop', the evaluation of the objective function will be distributed. See 'Examples and Extensions for the NMOF package'(with code in subdirectory 'NMOFex') for an example.
o fixed: with 'printDetail' greater than zero, 'TAopt' did not print the best solution, but the current solution (but internal book keeping worked correctly, and the best solution was returned) o 'bracketing', 'gridSearch', 'restartOpt': when 'cl' argument is not NULL, then argument 'method' is set to 'snow' (but as before it is checked whether package 'snow' is available) o the latest pdf-version of 'Examples and Extensions for the NMOF package' is now available from http://enricoschumann.net/files/NMOFex.pdf o code examples in subdirectory 'NMOFex' updated
o the 'printDetail' option for opt-functions is now more consistent: a positive integer 'i' greater than one means that information is printed at every 'i'th iteration o minor changes in vignettes o unit tests for 'callCF' added (in file 'unitTests/unitTests5.R')
o added function 'callCF' as a wrapper for pricing European calls with the characteristic function; characteristic functions for BSM, Merton, Bates, Heston and Variance-Gamma were also added o when 'algo$q' in 'TAopt' is zero, all thresholds are set to zero o code examples in subdirectory 'NMOFex' updated o CITATION file now points to the book's homepage http://nmof.net
o the 'keepNames' argument of function 'gridSearch' is now supported o more examples added for 'gridSearch' (and corresponding tests in 'unitTests/unitTests2.R') o fixed: some typos in vignette 'Vectorised objective functions'
o first CRAN release o the 'printDetail' argument for 'LSopt' now recognises TRUE and FALSE (as before), but also an integer 'i' greater than 1. In the latter case, information on the best solution is printed at every 'i'th step. o minor cleanups in documentation
o small changes in vignette 'Repairing solutions' o small internal changes in 'GAopt' and 'DEopt' (auxiliary functions like 'switch' and 'shift' have been inlined) o code examples in subdirectory 'NMOFex' updated
o fixed: a bug had been introduced into 'GAopt' in version 0.19-2 (revision 88), which let the population grow to algo$nP+1 o minor changes in documentation/examples
o minor cleanups in documentation
o minor cleanups in documentation o minor internal changes in 'restartOpt' (passing of the '...' arguments for method 'snow')
o 'bracketing', 'gridSearch' and 'restartOpt' now support distributed evaluation of 'fun' via 'clusterApply' from the 'snow' package. As a side effect, the interface of 'gridSearch' and 'restartOpt' has changed: instead of an option 'multicore', they now have an argument 'method', which can be 'loop', 'multicore' or 'snow'. See the documentation of these functions. o for consistency, the 'method' argument of 'bracketing' expects 'vectorised' rather than 'vectorise' (but both work, and also the '-ize' spellings) o substantial revision of documentation/examples o more intelligible error/warning messages in 'bracketing' added o small changes in vignettes 'Robust Regression with Particle Swarm Optimisation and Differential Evolution' and 'Repairing solutions' o file 'multicore.R' was moved to subdirectory inst/unitTests; thus, it is installed with the package. Some tests for package 'snow' were added. o more tests added (subdirectory unitTests); in particular, tests are more comprehensively commented now
o fixed: 'restartOpt' with 'multicore = TRUE' did not correctly pass '...' arguments to 'fun' o fixed: typo in message issued by 'gridSearch' o new file 'multicore.R' added in subdirectory tests; it contains a number of timing tests to see if the 'multicore' option works. (The tests are not run when the package is built.) o minor updates in documentation
o 'restartOpt' now has option 'multicore' o the 'method' option of function 'xwGauss' can now take on values 'hermite' and 'laguerre' o documentation updated o new examples added in 'Examples and Extensions for the NMOF package' (see subdirectory NMOFex) o test cases added for 'restartOpt' and 'xwGauss' (see subdirectory unitTests)
o functions for Gaussian integration added: 'xwGauss' computes nodes and weights; 'changeInterval' transforms the nodes/weights to arbitrary intervals. Currently, only method 'legendre' is supported. o documentation updated o more tests added for opt-functions (for returned objects 'Fmat' and 'xlist')
o all opt-functions now have arguments 'storeF' and 'storeSolutions' (passed through 'algo'). If the latter is TRUE, intermediary results will be stored in a list 'xlist' that is returned by the function (what exactly 'xlist' contains, depends on the specific function) o minor revision in vignette 'Robust Regression with Particle Swarm Optimisation and Differential Evolution' o NEWS file can now be found under inst/NEWS.Rd o internal changes: a number of test utilities have been added (not exported); see, for instance, ?checkList
o fixed: 'bracketing' had not been added to the NAMESPACE file (now it is) o tests for 'bracketing' added (see directory unitTests)
o function 'bracketing' added o minor changes in function 'MA' (added checks)
o vignette for 'qTable' added/corrected
o 'qTable' revised (user-specified labels are now possible) o (very) short vignette for 'qTable' added o minor changes in code/documentation/examples
o experimental: 'DEopt' takes further arguments 'storeF' and 'storeSolutions' (through list 'algo'). If 'storeF' is FALSE, objective function values are not stored ('Fmat' is set to NA; see ?DEopt). If 'storeSolutions' is TRUE, all population matrices are stored for every generation. This should be helpful for diagnostic checking (and demonstration purposes), but may use up a lot of memory for larger problems; hence default is FALSE. (These settings will either be removed from 'DEopt' or be added to all opt-functions in one of the next package versions.)
o new vignette ('Vectorised objective functions') added o more safeguards added to 'gridSearch'
o function 'gridSearch' now takes a list 'mc.control' as an argument; it allows to pass settings to 'mclapply' o more tests were added (see unitTests.R) o minor changes in code/documentation/examples
o more tests were added (see unitTests.R) o minor changes in code/documentation/examples
o function 'gridSearch' can now evaluate a function that expects a list or a vector as its first argument o test cases for 'gridSearch' added (in unitTests/unitTests.R) o 'DEopt' can take a vector 'F' to set specific step sizes for each decision variable (this actually worked before but is now documented and tested) o 'PSopt' can take a function 'changeV' and a logical 'loopChangeV' (passed via the list 'algo'); 'changeV' allows to impose restrictions on the velocity (see the code in directory NMOFex for an example) o more checks were added in opt-functions o small changes in the vignettes (in particular, seeds are set now) o minor changes in documentation/examples
o experimental: 'gridSearch' now an has argument 'multicore'; if TRUE, the function calls 'mclapply' (from the multicore package) to evaluate argument 'fun'. Currently added only for cross-platform testing (in particular, to see how R CMD check reacts under Windows). o directory NMOFex was updated o small correction in output of 'TAopt'
o test cases for portfolio optimisation added (in unitTests/unitTests.R)
o function 'gridSearch' was added
o an initial population in 'DEopt', 'GAopt' and 'PSopt' is now passed through 'algo$initP' (before, a population could be passed via 'algo$mP') o directory NMOFex was updated o documentation was updated
o directory NMOFex was updated o internal changes in several functions o GAopt.Rd was updated
o directory NMOFex was updated o minor internal changes in several functions
o directory NMOFex was added; it contains the code for 'Examples and Extensions for the NMOF package' o documentation updated; minor changes in examples and vignettes
o documentation, checks, unit tests added for function 'GAopt'
o the population in 'GAopt' is now of mode logical (mistaking a logical vector for a numeric one is less harmful than the other way around)
o function 'GAopt' added (minimisation by a Genetic Algorithm) o several unit tests added o documentation revised (thanks to Manfred Gilli for comments)
o fewer simulation runs in vignettes to reduce build time
o documentation has been revised
o a number of test functions have been added (see ?testFunctions) o new examples added for 'DEopt' and 'TAopt' o vignettes have been revised
o opt-functions now have 'printBar' and 'printDetail' option (set via 'algo')