You can add allowMagicalThinking=TRUE to your call to applyRules. If you add allowMagicalThinking=TRUE to your call to applyStrategy, it will be passed to applyRules.
The solution was: I downloaded the .zip version of quantstrat and blotter (currently both are 3.1.3) and both installed successfully. Interesting.
r,csv,quantmod,yahoo-finance,quantstrat
I don't know how to do this without "reinventing the wheel" because I'm not aware of any existing solutions. It's pretty easy to do with a custom function though. intradataYahoo <- function(symbol, ...) { # ensure xts is available stopifnot(require(xts)) # construct URL URL <- paste0("http://chartapi.finance.yahoo.com/instrument/1.0/", symbol, "/chartdata;type=quote;range=1d/csv") # read...
getsymbols.csv expects six columns: Open, High, Low, Close, Volume, Adjusted Your data does not have the "Adjusted" column; it has 5 column names instead of 6, which is causing the dimnames error you're seeing. If you can modify the local data files, try adding an empty "Adjusted" column (easily done...
Removing some columns from mktdata and moving the price column to the very left solved the issue.
instrument names need to begin with a letter or a dot. The instrument function uses make.names to ensure this. If it's important to be able to find your instruments by a number, then you can add it as an identifier. stock("X1234", currency("USD"), identifiers=list(num=1234)) getInstrument("1234") #primary_id :"X1234" #currency :"USD" #multiplier :1...
Finally I have found an answer to my question. The problem is that strptime() converts my chart to POSIXlt time format. Apparently only POSIXct format is working. Therefore you just have to use as.POSIXct() to solve the problem. Modified example: as.POSIXct(strptime(GBPUSD$V2,"%Y%m%d %H:%M:%S"))....
Your bitbucket code runs for me if I assign the output of add.rule and enable.rule back to pairStrat (as is done for all the other add.rule calls in the demo). # wrong add.rule(strategy=pairStrat, ...) enable.rule(pairStrat,'chain',"StopLoss_Long","StopLoss_Short") # correct pairStrat <- add.rule(strategy=pairStrat, ...) pairStrat <- enable.rule(pairStrat,'chain',"StopLoss_Long","StopLoss_Short") ...
Q1. If you take time to read the help text for plot.xts, you see that the function does not have a col argument. Together with the fact that partial matching of argument names doesn't seem to be allowed in the function, it explains why plot.xts it does not respond col...
This is the same bug as # 5776. It was fixed for "signal" component types, but not for "chain". It should now be fixed as of revision 1669 on R-Forge.
It's theoretically possible, but why would you want to? quantstrat is designed to make it easier to test ideas quickly and accurately. That's a very different problem domain than production trading. In short, use the right tool for the job. If you really want to go this route, you would...
The problem is the same issue reported in bug #5808, which has been fixed in r1681 on R-Forge. The issue was that match.fun(TxnFees) wasn't being called before transactions that cause the position to cross zero. So there would be an error, if TxnFees was a character string representing a function...
r,parallel-processing,xts,quantmod,quantstrat
You need to add the position limit to your portfolio before you call apply.paramset. And you probably want to assign the output of apply.paramset to something. This worked for me using the latest revisions of blotter and quantstrat. addPosLimit(portfolio.st, 'XLF', timestamp=initDate, maxpos=500, minpos=0) ap <- apply.paramset(strategy.st, paramset.label='sigThreshold', portfolio.st=portfolio.st, account.st=account.st, nsamples=0)...