<div style="FONT-FAMILY: Arial; COLOR: rgb(0, 0, 0); FONT-SIZE: 10px"><pre class="GFKJRPGCGCB" id="rstudio_console_output" tabindex="0"><font size="3"><span style="font-weight: bold;">I've been trying to get  the Luxor demo to work.  I have 1 through 7 working and have modified to my needs and have working, but the walk.forward, which to me is key,<br />fails running the demo as delivered in the latest release:<br /></span></font><br />demo("luxor.8.walk.forward")<br />walk.forward> > r <- walk.forward(strategy.st, paramset.label='WFA', portfolio.st=portfolio.st, account.st=account.st, period='months',<br /> k.training=3, k.testing=1, obj.func=my.obj.func, obj.args=list(x=quote(result$apply.paramset)), user.func=ess,<br /> user.args=list('account.st'=account.st, 'portfolio.st'=portfolio.st), audit.prefix='wfa', anchored=FALSE, verbose=TRUE)<span class="GFKJRPGCBCB  ace_constant"><br />Error in if (!all(i <= 0)) stop("only zeros may be mixed with negative subscripts") :   missing value where TRUE/FALSE needed<br /><br /><font size="3"><span style="font-weight: bold;">I thought the error might be the results of the period being months and k.traing=3 and k.testing=1 and the data only having 10 days so <br />I tried period= days.  It got in to the WFA and then failed.<br /></span></font><br /></span>demo("luxor.8.walk.forward")<br />> r <- walk.forward(strategy.st, paramset.label='WFA', portfolio.st=portfolio.st, account.st=account.st, period='days',<br /> k.training=3, k.testing=1, obj.func=my.obj.func, obj.args=list(x=quote(result$apply.paramset)), user.func=ess,<br /> user.args=list('account.st'=account.st, 'portfolio.st'=portfolio.st), audit.prefix='wfa', anchored=FALSE, verbose=TRUE)<br />[1] "=== training WFA on 2002-10-21 00:30:00/2002-10-23 23:30:00"<span class="GFKJRPGCBCB  ace_constant">Error in walk.forward(strategy.st, paramset.label = "WFA", portfolio.st = portfolio.st,  : <br />  obj.func() returned empty result</span><span class="GFKJRPGCBCB  ace_constant">In addition: </span><span class="GFKJRPGCBCB  ace_constant">Warning message:</span><span class="GFKJRPGCBCB  ace_constant">In max(x$user.func$GBPUSD.DailyEndEq) :  no non-missing arguments to max; returning -Inf</span><br /><br /><font size="3"><span style="font-weight: bold;">Using my own data with 6 months of data and period=months:<br /></span></font><span class="GAKS5OJBIBB ace_keyword"><br /></span><span class="GAKS5OJBFCB ace_keyword"></span><span class="GAKS5OJBIBB ace_keyword">GBPUSD <- to.daily(readRDS("/dataIII/RData/gbpusd_2014-01-06v.rds"),OHLC=FALSE)[,c(1,2,3,4,9)]</span><span class="GAKS5OJBFCB ace_keyword"></span><span class="GAKS5OJBIBB ace_keyword">GBPUSD = align.time(GBPUSD, 86400)</span><span class="GAKS5OJBFCB ace_keyword"></span><span class="GAKS5OJBIBB ace_keyword">GBPUSD<-GBPUSD["2014-01-02 00:00:00/2014-06-30 00:00:00"]</span><span class="GAKS5OJBFCB ace_keyword"></span><span class="GAKS5OJBIBB ace_keyword">head(GBPUSD)</span>           Bid_Open Bid_High Bid_Low Bid_Close      Vol2014-01-02  1.65501  1.65501 1.65501   1.65501  1.500002014-01-03  1.64427  1.64427 1.64426   1.64426  4.129992014-01-04  1.64269  1.64269 1.64269   1.64269  2.000002014-01-05  1.64171  1.64171 1.64171   1.64171  1.500002014-01-07  1.64129  1.64129 1.64124   1.64124 15.159992014-01-08  1.64234  1.64234 1.64232   1.64232  9.829982014-01-08  1.64234  1.64234 1.64232   1.64232  9.82998<br /><br /><font size="3"><span style="font-weight: bold;">I get:<br /></span></font><br />### walk.forward> > r <- walk.forward(strategy.st, paramset.label='WFA', portfolio.st=portfolio.st, account.st=account.st, period='months', k.training=3, k.testing=1, obj.func=my.obj.func, obj.args=list(x=quote(result$apply.paramset)), user.func=ess, user.args=list('account.st'=account.st, 'portfolio.st'=portfolio.st), audit.prefix='wfa', anchored=FALSE, verbose=TRUE)[1] "=== training WFA on 2014-01-02/2014-03-30"numValues: 15, numResults: 0, stopped: TRUEgot results for task 1numValues: 15, numResults: 1, stopped: TRUEreturning status FALSEgot results for task 2numValues: 15, numResults: 2, stopped: TRUEreturning status FALSEgot results for task 3numValues: 15, numResults: 3, stopped: TRUEreturning status FALSEgot results for task 4numValues: 15, numResults: 4, stopped: TRUEreturning status FALSEgot results for task 5numValues: 15, numResults: 5, stopped: TRUEreturning status FALSEgot results for task 6numValues: 15, numResults: 6, stopped: TRUEreturning status FALSEgot results for task 7numValues: 15, numResults: 7, stopped: TRUEreturning status FALSEgot results for task 8numValues: 15, numResults: 8, stopped: TRUEreturning status FALSEgot results for task 9numValues: 15, numResults: 9, stopped: TRUEreturning status FALSEgot results for task 10numValues: 15, numResults: 10, stopped: TRUEreturning status FALSEgot results for task 11numValues: 15, numResults: 11, stopped: TRUEreturning status FALSEgot results for task 12numValues: 15, numResults: 12, stopped: TRUEreturning status FALSEgot results for task 13numValues: 15, numResults: 13, stopped: TRUEreturning status FALSEgot results for task 14numValues: 15, numResults: 14, stopped: TRUEreturning status FALSEgot results for task 15numValues: 15, numResults: 15, stopped: TRUEfirst call to combine functionevaluating call object to combine results:  fun(result.1, result.2, result.3, result.4, result.5, result.6,     result.7, result.8, result.9, result.10, result.11, result.12,     result.13, result.14, result.15)returning status TRUE[1] "=== testing param.combo 5 on 2014-04-01/2014-04-30"  nFAST nSLOW5     9    42<span class="GAKS5OJBMBB  ace_constant">Error in runSum(x, n) : Invalid 'n'<br /><br /><span style="font-weight: bold;">The 1st wfa appears to work but it fails in the testing phase and I don't know if the problem is<br />in my data or my code.<br /><br />This the demo code alterations highlighted:<br /><br />#!/usr/bin/Rscript --vanilla<br />#<br /># Jan Humme (@opentrades) - April 2013<br />#<br /># Tested and found to work correctly using blotter r1457<br />#<br /># After Jaekle & Tamasini: A new approach to system development and portfolio optimisation (ISBN 978-1-905641-79-6)<br />#<br /># Paragraph 3.7 walk forward analysis<br /><br />require(quantstrat)<br /><br />source(paste0(path.package("quantstrat"),"/demo/luxor.include.R"))<br /><span style="color: rgb(255, 0, 0);">#source(paste0(path.package("quantstrat"),"/demo/luxor.getSymbols.R"))<br />GBPUSD <- to.daily(readRDS("/dataIII/RData/gbpusd_2014-01-06v.rds"),OHLC=FALSE)[,c(1,2,3,4,9)]<br />GBPUSD = align.time(GBPUSD, 86400)<br />GBPUSD<-GBPUSD["2014-01-02 00:00:00/2014-06-30 00:00:00"]<br />head(GBPUSD)</span><br /><br />### foreach and doMC<br /><br />require(foreach)<br />require(doMC)<br />registerDoMC(cores=8)<br /><br />### blotter<br /><br />initPortf(portfolio.st, symbols='GBPUSD', initDate=initDate, currency='USD')<br />initAcct(account.st, portfolios=portfolio.st, initDate=initDate, currency='USD', initEq=100000)<br /><br />### quantstrat<br /><br />initOrders(portfolio.st, initDate=initDate)<br /><br />load.strategy(strategy.st)<br /><br />enable.rule(strategy.st, 'chain', 'StopLoss')<br />#enable.rule(strategy.st, 'chain', 'StopTrailing')<br />enable.rule(strategy.st, 'chain', 'TakeProfit')<br /><br />addPosLimit(<br />            portfolio=portfolio.st,<br />            symbol='GBPUSD',<br />            timestamp=initDate,<br />            maxpos=.orderqty)<br /><br />### objective function<br /><br />ess <- function(account.st, portfolio.st)<br />{<br />    require(robustbase, quietly=TRUE)<br />    require(PerformanceAnalytics, quietly=TRUE)<br /><br />    portfolios.st <- ls(pos=.blotter, pattern=paste('portfolio', portfolio.st, '[0-9]*',sep='.'))<br />    pr <- PortfReturns(Account = account.st, Portfolios=portfolios.st)<br /><br />    my.es <- ES(R=pr, clean='boudt')<br /><br />    return(my.es)<br />}<br /><br />my.obj.func <- function(x)<br />{<br />    # pick one of the following objective functions (uncomment)<br /><br />    #return(max(x$tradeStats$Max.Drawdown) == x$tradeStats$Max.Drawdown)<br /><br />    #return(max(x$tradeStats$Net.Trading.PL) == x$tradeStats$Net.Trading.PL)<br /><br />    return(max(x$user.func$GBPUSD.DailyEndEq) == x$user.func$GBPUSD.DailyEndEq)<br />}<br /><br />### walk.forward<br /><br />r <- walk.forward(strategy.st, paramset.label='WFA', portfolio.st=portfolio.st, account.st=account.st, period='months', <br />k.training=3, k.testing=1, obj.func=my.obj.func, obj.args=list(x=quote(result$apply.paramset)), user.func=ess,<br />user.args=list('account.st'=account.st, 'portfolio.st'=portfolio.st), audit.prefix='wfa', anchored=FALSE, verbose=TRUE)<br /><br />### analyse<br /><br />pdf(paste('GBPUSD', .from, .to, 'pdf', sep='.'))<br />chart.Posn(portfolio.st)<br />dev.off()<br /><br />ts <- tradeStats(portfolio.st)<br />save(ts, file=paste('GBPUSD', .from, .to, 'RData', sep='.'))<br /></span></span><br /><br /></pre></div>