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
0
votes
1 answer

Xts conversion fails on update from xts 0.9.7 to 0.10.0

Dataframe to xts conversion fails on update from xts 0.9.7 to 0.10.0. #THIS WORKS (uses xts 0.9.7): library(xts) DFX <- structure(list(DateTime = structure(list(sec = c(0, 0, 0), min = c(10L, 0L, 5L), hour = c(17L, 18L, 18L), mday =…
Krug
  • 1,003
  • 13
  • 33
0
votes
1 answer

Quantstrat applyStrategy failure

I am using quantstart but for some reason the applyStrategy function does not spit out any information. It just goes through. As a result, when I then do the tradeStats function I get null. Here is the code I used:…
0
votes
1 answer

Backtesting SMA crossover in quanstrat using CSV files

I have backtested a strategy using getSymbols() before, but the docs are not clear how to use CSVs. I am trying to test SMA crossover on some intraday data. Having searched online I did find that you have to give quantstrat an xts object to work…
eliquinox
  • 33
  • 5
0
votes
1 answer

Holding portfolios over a month/quarter/year in quantstrat

As a variation on a previous question, I would like to know how to implement a holding period using the quantstrat package which prevents portfolio updating between periods of multiple stocks despite signals (here crossing thresholds). I have…
Hysterio
  • 11
  • 3
0
votes
1 answer

Close position on specifc month day

I'm writting a strategy in R using quantstrat that needs to close any open position at the 15th day for every month. I've already tried using add.signal with sigTimespan, but it seems it only works with time, and not dates. Maybe I'm not passing the…
0
votes
1 answer

quantstrat demo luxor.4.paramset.timespan optimization

I was trying the luxor.4.paramset.timespan.R to to find the best entry time for the luxor strategy and the script ran without error. However, when I examined the result using tradeGraphs(), the maximum Net.Trading.PL was only about 20k, whereas the…
0
votes
1 answer

Error in .xts index length must match number of observations

When dealing with timeseries data what does this error mean? Does it have something to do with some columns having NA? This SO post solves the issue for someone else, but I specifically would like someone to explain how the length could be wrong,…
Rilcon42
  • 9,584
  • 18
  • 83
  • 167
0
votes
1 answer

Quantstrat WFA with intraday Data

I've been getting WFA to run on the full set of intraday GBPUSD 30min data, and have come across a couple of things that need addressing. The first is I believe the save function needs changing to remove the time from the string (as shown here as a…
Ed Wilson
  • 267
  • 3
  • 12
0
votes
1 answer

quantstrat signal referencing other signals

What is the correct method to have signals reference other signals? Is it not intended functionality? I cant seem to find a way to do it in my code. library(PerformanceAnalytics) library(quantmod) library(lattice) startDate <- '2010-01-01' # start…
Rilcon42
  • 9,584
  • 18
  • 83
  • 167
0
votes
1 answer

timeSpan/Entry/Exit Optimization in Quantstrat

i have been working on this code for past few days. I couldn't find any help on this topic. As the title says, I am trying to find the best times to enter and exit my trades. To keep the code simple, i need to optimize my rule in quantstrat. I…
turtle_in_mind
  • 986
  • 1
  • 18
  • 36
0
votes
1 answer

Where does values of argument `timestamp` of quantstrat::ruleSignal's come from?

When reading source code of ruleSignal, argument timestamp at line 66 is a very important input, but I could not figure out where timestamp data come from. It seems that functions add.indicator, add.signal, add.rule, applyIndicators, applySignals,…
Daniel
  • 1,428
  • 3
  • 16
  • 35
0
votes
1 answer

volemont/insights:chart.EquityCurve.R: a bug in graphing peaks of cumulative return?

I came cross a function of graphing cumulative return of a strategy and the peaks of the return in a great example of combining shiny and quantstrat, thanks to Simon Otziger. The source code is here. The code works fine most of time, but for some…
Daniel
  • 1,428
  • 3
  • 16
  • 35
0
votes
0 answers

Quantstart `osMaxPos` source code second typo error is testified?

I looked into osMaxPos just trying to understand quantstrat a little better, however, there are two lines of codes confused me, I think they are typo errors. source code can be found at this link Briefly, the two typo errors are: 1. source code line…
Daniel
  • 1,428
  • 3
  • 16
  • 35
0
votes
1 answer

Format POSIX in R (quantstrat)

I'm working on extracting a date from a variable: "curIndex." Here's what the code looks likes show(txntime1 <- timestamp(mktdata[curIndex+1L])[,1]) show(txntime <- strftime(txntime1, '%Y-%m-%d %H:%M:%OS6')) And the output is this: "##------ Tue…
Saile
  • 115
  • 1
  • 11
0
votes
0 answers

quantstrat (2016.3.11 version) demo luxor.4 warning message

I have installed the latest quantstrat from source, previous error with luxor.4 is gone, but still got a warning message as follows: Warning message: In data.frame(forex.1 = list(param.combo = list(EnterLong = 1L, : row names were found from a…
Daniel
  • 1,428
  • 3
  • 16
  • 35