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
3
votes
0 answers

Quanstrat - chain and OCO orders

I have a simple strategy that: enters long when the rolling volume sum of last 5 seconds is higher or equal to 20. submits a 1% take-profit order when entering long, and submits a -1% stop-loss order when entering long. The first entry order is…
Steef Gregor
  • 544
  • 1
  • 7
  • 21
3
votes
1 answer

how to apply long only add.distribution parameterset in quantStrat - simpleError in param.combo[[param.label]]

I am applying similar add.distribution rule as in the luxor-demo while my strategy has only a long position. The whole strategy works, but when applying a parameterset I get following error: TakeProfitLONG 47 0.047 TakeProfitLONG 47 …
Aylon
  • 65
  • 5
3
votes
1 answer

Can Quantstrat be used to generate orders for a production system

After using Quantstrat to successfully backtest a strategy, is there any way to use the same signal/indicator/rule code to generate orders for production trading? It seems like this might be possible by using the order book, but I haven't been able…
3
votes
0 answers

Implementing multiple conditions in quantstrat, whilst referencing n periods ago in TA indicator

I am attempting to apply a very basic strategy in quantstrat using the ADX indicator. The strategy looks for situations with a low but upwardly trending ADX, specifically: Rule 1: ADX <20; Rule 2: ADX today greater than ADX 5 periods ago; Rule 3:…
RichS
  • 659
  • 12
  • 19
3
votes
0 answers

Simple intraday signal processing code in quantstrat package

I'm new to R and quantstrat, so I appreciate your patience. I note that a lot of the demo / example files around the web for quantstrat give great examples using TA rules. My Question / TL;DR How can I construct a simple intraday threshold crossing…
rStack
  • 31
  • 1
3
votes
2 answers

Guy Yollin's QuantStrat I lecture issue

I've been going through Guy's quantstrat lecture (link below) and after repeatedly attempting to re-execute the code, I'm getting a few initial errors that are preventing most of the subsequent code in the lecture from functioning. Here is the code…
user1462733
3
votes
1 answer

backtest simple strategies using R

I am looking to do simple backtesting that could properly keep track of pnl, rebalance portfolio, liquidate etc. I need it to do things a bit differently than backtest. That is, backtest splits things up by quntile and the sort. I would like a more…
Alex
  • 19,533
  • 37
  • 126
  • 195
3
votes
1 answer

"Error in mktdata[, keep] : number of dimensions incorrect " due to stock "T" referring to TRUE?

I have a problem when trying to run an example of quantstrat on the stock AT&T referred with the symbole "T". I believe it is because R is somewhere thinking this T is refering to TRUE. Here is my…
jeremy.staub
  • 369
  • 4
  • 12
2
votes
1 answer

Add text label near the position arrows in chart.Posn () function of blotter

Is it possible to add texts like "BUY" and "SELL" near the green and red arrows in chart.Posn() function. (not with manual trial of coordinates, I need an automatic solution) I have changed the source code of function a bit and increased the size of…
Serhat Akay
  • 115
  • 10
2
votes
0 answers

R quantstrat: Is it possible to use quantstrat to create complex rules?

I went over demos within quantstrat GitHub, also took a bootcamp course on how to use the package and read several posts and Q&As concerning signals and rules, however I am still failing to implement complex rules where thresholds are hit multiple…
2
votes
2 answers

How do I replace Quantstrat 'for loop' with mclapply [parallelized]?

I'd like to parallelize quantstrat. My code isn't exactly like this, but this showcases the issue. The problem I believe is the .blotter env is initialized to a pointer memory address and i am unable to initialize an array/matrix of…
thistleknot
  • 1,098
  • 16
  • 38
2
votes
1 answer

quantstrat package stock function: Error: C stack usage is too close to the limit

I am new to financial mathematics and trying to do a homework about backtest with R: library(FinancialInstrument) start.date <- '2017-01-01' end.date <- '2019-12-30' HSI <-…
Peter Chung
  • 1,010
  • 1
  • 13
  • 31
2
votes
1 answer

(very) Simple quantstrat trading model using logistic regression

I have been playing around with the quantstrat backtesting package in R and I want to get some advice on a particularly (poor) strategy. The idea is to buy whenever a logistic regression model tells me that the market is going to go up (indicated a…
2
votes
1 answer

Problems with the "^" sign in ^GSPC in Quantstrat

To retrieve stock prices data, I have done the following: options("getSymbols.warning4.0" = FALSE) tickers <- c("^GSPC","AAPL") startDate = "1990-01-01" from = "2006-01-01" to = "2009-12-31" getSymbols(tickers, from = from, to = to) However, when I…
Daimon
  • 77
  • 1
  • 5
2
votes
1 answer

Combining shiny with Quantstrat backtests

I am trying to make a web app with the intention of using quantstrat. However I am having a bit of difficulty integrating the two. There is no documentation on this so it's tough to find a place to start. Here is the code I have right now. It would…
Jordan Wrong
  • 1,205
  • 1
  • 12
  • 32
1 2
3
18 19