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
13
votes
2 answers

Is there a general manual for the R packages, "quantstrat","blotter","FinancialInstrument" etc. other than the function help files and demos?

I'd like to learn how to use these packages, but I cannot seem to find any vignettes that offer something other than extensive code snippets. I'd like to learn about how they all fit together and something akin to a "walk through". I've found some…
n.e.w
  • 1,128
  • 10
  • 23
9
votes
1 answer

R - Loading External Indicators into Quantstrat

I noticed that Quantstrat typically takes indicators that are based on price. However, I would like to load several indicators that have been externally calculated along with the price data. For instance, I have 2 extra columns in a csv file that…
Tyler
  • 91
  • 3
9
votes
2 answers

Quanstrat strategy - error

My quanstrat strategy returns an error which I didnt find being discussed yet. Strategy is very simple: calculate rolling sum over given period of time. If the rolling sum is over some threshold, enter long and submit siultanesouly two oco orders,…
Steef Gregor
  • 544
  • 1
  • 7
  • 21
9
votes
1 answer

Is there something in Python similar to quantstrat in R?

Is there something in Python similar to quantstrat in R?
Terence Ng
  • 442
  • 2
  • 8
  • 19
8
votes
1 answer

quantstrat in R: Setting a date based exit signal

Much of quantstrat and the accompanying examples seem to be set around entering and exiting trades by crossing some kind of technical indicator. However, let's say you have an arbitrary indicator which you're using to trigger an entry to the trade,…
n.e.w
  • 1,128
  • 10
  • 23
7
votes
2 answers

install quantstrat for R latest R version ()

I would like to install a package when using the latest R version in RStudio. In particular the quantstrat package Is that possible? This is the R latest version I have 3.4.1 my error message: Warning in install.packages : package ‘quantstrat’ is…
jonas
  • 13,559
  • 22
  • 57
  • 75
7
votes
1 answer

What is the correct way to do a multi time frame strategy with quantstrat?

Here is an example of a multi-timeframe strategy I'm working on with quantstrat. Is this the correct way of doing a multi-timeframe strategy or am I doing it all wrong? I haven't come across any other examples doing multi-timeframe in the quantstrat…
GeV 126
  • 351
  • 1
  • 3
  • 14
6
votes
1 answer

While loop in R quantstrat code - how to make it faster?

In quantstrat package I have located one of the main culprits for slowness of the applyRule function and wonder if there is more efficient to write the while loop. Any feedback would be helpful. For anyone experience wrapping this part into Parallel…
user987652
  • 61
  • 2
5
votes
1 answer

Loading intraday data into R for handling it with quantmod

I need to modify this example code for using it with intraday data which I should get from here and from here. As I understand, the code in that example works well with any historical data (or not?), so my problem then boils down to a question of…
5
votes
1 answer

quantstrat: buy next bar at open

How to implement "Buy at next bar with Open price" in quantstrat? Here is my experiment with maCross.R sample. Add prefer='Open' in ruleSignal stratMACROSS <- add.rule(strategy = stratMACROSS, name='ruleSignal', arguments…
tch
  • 51
  • 3
4
votes
2 answers

Quantstrat add.rule arguments: orderqty vs tradeSize vs maxSize

I can't find in the Quantstrat documentation the definition of the add.rule arguments. I'm interested in knowing what is the difference between orderqty, tradeSize and maxSize. Found the following related material on quantstrattrader: The orderqty…
Krug
  • 1,003
  • 13
  • 33
4
votes
1 answer

quantstrat, How could I put a stop-loss at a specific price?

Good day! Friends I really need your help! My question is: How could I put a stop-loss at a specific price? Quantstrat works like this (for long position): Stop price = entry price – entry price * threshold. For example, I try to run my code. But…
Anatolye
  • 75
  • 5
4
votes
1 answer

Generating indicators of different periodicity in quantstrat

I would like to use indicators of timeframes different to the data I am using. I have seen this asked a few time but no solutions as of yet (at least for me anyway). The below example uses daily stock data however the actual project uses intraday…
user3180258
  • 97
  • 13
4
votes
0 answers

How do blotter/quantstrat/quantmod/performanceanalytics handle internal cashflows and expiring instruments?

I don't understand how internal cashflows are handled in blotter/quantstrat/quantmod/performanceanalytics. This mainly concerns two aspects: Regular cashflows like dividends, coupons etc. as well as cashflows from expiring instruments (e.g. a cash…
Ueli Hofstetter
  • 2,409
  • 4
  • 29
  • 52
4
votes
1 answer

quantstrat enable.rule not working

When I use enable.rule I cannot override the rule's internal enabled=FALSE. For example: ## Stop Loss Rule stratstocky <- add.rule(stratstocky, name = "ruleSignal", arguments = list(sigcol = "sdH", …
int64
  • 81
  • 4
1
2 3
18 19