Questions tagged [quantstrat]

quantstrat is a quantitative strategy framework for R

quantstrat (an R package) provides a generic infrastructure to model and backtest signal-based quantitative trading strategies. It is a high-level abstraction layer (built on the R packages xts, FinancialInstrument, blotter, etc.) that allows you to build and test strategies in very few lines of code. quantstrat is still under development but is used on real portfolios.

The latest codebase for quantstrat and blotter is at:

https://github.com/braverock/quantstrat

https://github.com/braverock/blotter

274 questions
2
votes
2 answers

getSymbols with csv in Quantmod R

I am trying to upload a group of symbols into the package quantstrat using quantmod::getSymbols. The symbols I am loading are not available on Yahoo (they are South African stocks), so I need to load them from a local directory and from .csv…
NMRQL
  • 65
  • 1
  • 6
2
votes
1 answer

Failing to install Quantstrat

I'm trying to install quantstrat package on Mac, but when I try install.packages("quantstrat",repos="http://R-Forge.R-project.org") I get this package 'quantstrat' is available as a source package but not as a binary Warning in install.packages : …
Filipe Ferminiano
  • 8,373
  • 25
  • 104
  • 174
2
votes
1 answer

Error implementing a stoplimit order in quantstrat

After adding ordertype=stoplimit rules for stoploss implementation in quantstrat's pair_trade.R demo (only the short side shown below) as, # stop loss for short order (child) add.rule(strategy=pairStrat, name = 'ruleSignal',…
marital_weeping
  • 618
  • 5
  • 18
2
votes
1 answer

Error in the pair_trade.R demo in quantsrat

The insightful pair_trade.R demo of the wonderful quanstrat package (updated minutes ago via SVN) with input parameters: SD <- 1 ; N <-10 gives the following error: [1] "2009-01-26 00:00:00 DIA -500 @ 76.1735958352934" Error in `/.default`(TxnFees,…
marital_weeping
  • 618
  • 5
  • 18
2
votes
1 answer

R - FinancialInstrument Package Changing Symbol Names when using stock

I'm currently in the process of building a strategy using quantstrat/blotter. The price data that I'm using uses numbers as the security identifiers and these numbers are therefore the column names as well as what I use for the synbol names in…
user6893
  • 143
  • 1
  • 2
  • 9
2
votes
1 answer

Optimizing Signal Parameters with Quantstrat results in error: attempt to select less than one element

I have a simple long-only bollinger strategy implemented in quantstrat (reproducable example below). The code runs properly, but now I want to optimize the sigThreshold values (i.e. 0.3 and 0.7). The apply.paramset function runs through the defined…
Pat
  • 1,299
  • 4
  • 17
  • 40
2
votes
1 answer

Color option in xtsExtra

I am having trouble adjusting the colors of a multiple time series plot using xtsExtra. This is the code of a minimal example: require("xtsExtra") n <- 50 data <- replicate(2, rnorm(n)) my.ts <- as.xts(ts(data, start=Sys.Date()-n,…
Eckhard
  • 169
  • 10
2
votes
1 answer

quantstrat: how to execute on the same bar?

I know that you're not supposed to be doing this but since I almost exclusively trade based on daily and weekly data, I think I'd be getting a more realistic idea of trading ideas if I were able to execute on the same bar instead of buying on next…
aciM
  • 89
  • 1
  • 1
  • 8
2
votes
1 answer

pennyPerShare quantstrat not working

When I use: stratRank <- add.rule(stratRank, name="ruleSignal", arguments=list(sigcol="EntryCond", sigval=TRUE, orderqty=max.size, ordertype="market", orderside="long", pricemethod="market", …
user1665355
  • 3,324
  • 8
  • 44
  • 84
2
votes
1 answer

quantStrat won't recognize column names

I wrote the following codes and got an error message when apply the strategy: Error in eval(expr, envir, enclos) : object 'Close' not found sounds like the strategy can not find column "Close" price, while the last line of code "head(mktdata)"…
Rstudent
  • 41
  • 2
2
votes
1 answer

Capital aware position sizing in quantstrat

I am looking to make maximum allowed position for a particular asset(symbol) a function of capital(initial allocation+ PL), and indicators. I tried going through replacing osMaxPos. I add this at the top, where initial value is hardcoded, and ddQ is…
ndr
  • 1,427
  • 10
  • 11
2
votes
1 answer

R Quanstrat package add.signal function arguments (gt, lt, gte, eq, etc...)

I have a simple question but can anyone please point in the direction of online documentation that explains what "gt, lt, lte, gte" relationship arguments mean in the add.signal function in the quantstrat package? I can't seem to find these codes…
Blackmarkt
  • 71
  • 1
  • 7
2
votes
1 answer

R: Using foreach with blotter, portfolio already exists error

I'm using the blotter package to run a backtest, and using foreach to speed things up. I'm running into an error where blotter finds the portfolio with the same name even though they are supposed to be removed at the start of the function. Here's a…
2
votes
2 answers

Customizing new trading strategy in R using quantmod

I want to create a new custom TA-indicator to the stock symbol in R. But I have no idea about how to convert my SQL conditional strategy into R self-defined function and add it up to the ChartSeries in R. The question are listed in the following…
user3015546
  • 73
  • 1
  • 5
2
votes
2 answers

Quantstrat faber_rebal.R demo error

I have been going through the demos in quantstrat. I have a problem running faber_rebal.r. It fails with the following error: > out<-applyStrategy.rebalancing(strategy='faber' , portfolios='faber') Error in `colnames<-`(`*tmp*`, value = c("MaxPos",…
Charles
  • 439
  • 4
  • 18