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

Installing blotter and quantstrat on GitHub

I am experiencing a hard time in installing the blotter and quantstrat packages from Github. Most helps I can find online are quite outdated issued back then when they are hosted on sourceforge. I try to use the install_github() function and it…
bluk
  • 400
  • 6
  • 15
2
votes
1 answer

Keep getting the "dims do not match the length of object" in quantstrat

I have been modifying a backtest I made a few months ago using quantstrat. It was all working fine until I added in signal and rule 6 (donchian channel low) My full code is below. Any help would be greatly appreciated. Thanks in advance. PS: Sorry…
Cameron Giles
  • 72
  • 1
  • 8
2
votes
1 answer

Limit number of Position in Quantstrat

I have been scratching my head for the last few days trying to understand how to limit the number of position in a strategy. Its a channel breakout strategy (go long/shirt the 20d breakout channel with a 10d high/low stop loss. I don't want the…
NicolasB
  • 83
  • 5
2
votes
1 answer

Changing time frame in quantstrat from daily to weekly

So I am just doing EMA50 cross strategy in quantstrat, it works fine, but I was hoping to change the time frame from daily to weekly. I tried storing stock() function as to.weekly(SPY) but they wouldn't let me do that. I want to try this for the…
이종연
  • 129
  • 1
  • 9
2
votes
1 answer

quantstrat: Strategy not taking positions despite signal values appearing to be valid?

I opened a new question as the original post was already too long and the solution I have arrived at pretty much negates that post. Below is the workaround I have found for adding indicators of a periodicity different to that of your data. The…
user3180258
  • 97
  • 13
2
votes
3 answers

R - quantstrat CSV import for intra-day data

I am trying to import data into R for the first time to use in the R package quantstrat. Please see the following: fn1 <- "fgbl_formatted_vpoc_prior_week.txt" > fn1 > dat <- read.table(file=fn1,sep=",",header=T,as.is=T) > dat …
nipy
  • 5,138
  • 5
  • 31
  • 72
2
votes
1 answer

Is this quantstrat code unusually slow?

I try to run and optimize a very simple system, using quantstrat. My strategy is: enter when Close > SMA, exit when Close < SMA. I am running on daily data from 2010-01-01 to 2014-01-01. Optimization is .nSMA = (10:20). My system is i5 m480 2.67Ghz,…
Anatolye
  • 75
  • 5
2
votes
1 answer

Quantstrat: Execute on the same bar

I know this has been asked before here, but Id like to extend the question further. Lets say my entry price is 50, so at the start of the day I place a limit order bid 50 for 1 lot. During the trading day, the market collapses and I get filled on my…
Ed Wilson
  • 267
  • 3
  • 12
2
votes
1 answer

Is cross parameter to IKTrading::sigAND really necessary?

sigAND is a useful function in creating a new column with dates when two selected columns both have values (or not NA). Thanks to Ilya Kipnis and his IKTrading package. However, I noticed in this function's help page, cross is used. I am confused…
Daniel
  • 1,428
  • 3
  • 16
  • 35
2
votes
0 answers

Tradestats for whole portfolio

I am using R / Quantstrat for backtesting and it all works well. I have a strategy which only generates a few trades per year for a symbol, but I have many symbols in my portfolio. I like the statistics generated by the tradeStats() function,…
2
votes
1 answer

Charting OHLC data with chart_Series function

The csv file with OHLC (Open-High-Low-Close) and Volume data (hourly data with the format of DD.MM.YYYY HH:mm) of a currency-pair named XXXZZZ.csv: Date;Open;High;Low;Close;Volume 02.01.2009…
ehbeehefak
  • 23
  • 5
2
votes
1 answer

Using the addDiv(command) in R from quantstrat/blotter

What is the format for using the addDiv command in R? I know how to use the function as far as inputs go, but I can't figure out where it should be placed beyond a general idea. Do I place it after where I instantiate the portfolio? Below is the…
2
votes
1 answer

quantstrat logical error - missing value where TRUE/FALSE needed

I am getting this error when applying strategy in quantstrat: Error in if (length(j) == 0 || (length(j) == 1 && j == 0)) { : missing value where TRUE/FALSE needed My code is as follows: .blotter <- new.env() .strategy <-…
Sean Sinykin
  • 542
  • 4
  • 22
2
votes
2 answers

R Quantstrat & Shiny: getSymbols error

I am trying to create a Shiny app using quanstrat. The code runs flawlessly under normal conditions; however, when I put it in Shiny it fails. When running the code below, I get: Error in get(symbol) : object 'BDCL' not found I've tried to…
kng229
  • 473
  • 5
  • 13
2
votes
0 answers

Quantstrat Rebalancing - Irrationally Long Running Time

After getting help from the kind members here, I finally built my own sample strategy in quantstrat. The code works well and fast (~1 min) in a universe of <100 stocks, but the running time increases dramatically to (> 5hrs) when the universe is…
Eric
  • 51
  • 4