These examples are based on revision 31 from r-forge and will not work under earlier revisions
(and may not work with later revisions). LSPM is still in very
alpha status. Expect things to change, perhaps significantly.
These examples were run using code from DEoptim_1.3-3 that has been bundled inside LSPM. We are working with the DEoptim authors to address issues with more recent versions of DEoptim. LSPM will use the most recent version of DEoptim as soon as the issues are resolved.
The first two examples are taken from Vince, Ralph (2009). The Leverage Space Trading Model. New York: John Wiley & Sons, Inc.
The results will not match the book because of differences between optimization via DEoptim and Ralph's genetic algorithm implementation. Ralph believes his genetic algorithm is getting hung up on a local maximum, whereas DEoptim is closer to the global solution.
# Load the LSPM package
# Multiple strategy example (data found on pp. 84-87)
trades <- cbind(
probs <- c(rep(0.076923077,2),0.153846154,rep(0.076923077,9))
# Create a Leverage Space Portfolio object
port <- lsp(trades,probs)
# DEoptim parameters (see ?DEoptim)
# NP=30 (10 * number of strategies)
# itermax=100 (maximum number of iterations)
DEctrl <- list(NP=30,itermax=100)
# Unconstrainted Optimal f (results on p. 87)
res <- optimalf(port,control=DEctrl)
# Drawdown-constrained Optimal f (results on p. 137)
# Since horizon=12, this optimization will take about an hour
res <- optimalf(port,probDrawdown,0.1,DD=0.2,horizon=12,calc.max=4,control=DEctrl)
# Ruin-constrained Optimal f
res <- optimalf(port,probRuin,0.1,DD=0.2,horizon=4,control=DEctrl)
# Drawdown-constrained Optimal f
res <- optimalf(port,probDrawdown,0.1,DD=0.2,horizon=4,control=DEctrl)