I've tested my code against individual symbols and very small groups of symbols. I'm finding the more symbols I add the fewer trades I get. For instance, if I just include the first five symbols, all of them seem to have at least one trade. If I expand to 20 or so then a few symbols have trades but none of the symbols in the first group have trades anymore.
I'm looking to execute the strategy on the list of 158 symbols.
I've added the parallel package. That does not seem to help. I'm using Guy Yollin's Luxor (MACD) example.
My initial applyStrategy was:
out <- applyStrategy(strategy=strategy.st,
portfolios=portfolio.st,
parameters=list(nFast=fastMA,
nSlow=slowMA,
nSig=signalMA,
maType=maType),
debug=TRUE,
verbose=TRUE)
The above returns no errors, but no trades either (again, tested on smaller samples I do get trades).
My attempt with the foreach/parallel package was:
foreach (i=1:length(symbols)) %dopar%
out <- applyStrategy(strategy=strategy.st,
portfolios=portfolio.st,
parameters=list(nFast=fastMA,
nSlow=slowMA,
nSig=signalMA,
maType=maType),
symbols=c(symbols[i]),
debug=TRUE,
verbose=TRUE)
This piece of code returns the following error:
Error in foreach(i = 1:length(symbols)) %dopar% out <- applyStrategy(strategy = strategy.st, : target of assignment expands to non-language object
So, naturally now I'm at a loss. I can do the symbols individually (did yesterday) but it took forever and I know it can be simpler.
Sample script uploaded to Dropbox
Any advice greatly appreciated!