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

How to use sigPeak() function in quantstrat

I cannot grasp how to properly use sigPeak() in quantstrat. A (not working) example follows. I add an indicator to mktdata: add.indicator(strategy = name, name = 'WinDoPar', arguments = list(x = quote(OHLC(mktdata)), …
Lisa Ann
  • 3,345
  • 6
  • 31
  • 42
2
votes
1 answer

Netting transactions in quantstrat

Let's say I have a strategy with multiple rules that generates multiple orders on the same symbol at the same timestamp. For example, on 2012-05-23 one rule might buy 10 shares of IBM while another rule sells 5 shares of IBM. In production, a…
James Hirschorn
  • 7,032
  • 5
  • 45
  • 53
2
votes
1 answer

Error attempt to set 'colnames' on an object with less than two dimensions

I will try to be as clear as possible as I have been rebuked by some users. I deleted the last questions and I will try to be sufficiently explicative in this one. I apologize if the data I will insert will not be enough. So, I am trying to run a…
Pietro
  • 347
  • 1
  • 3
  • 15
2
votes
1 answer

Trading Strategy in R using Donchian Channel

I want to set up a trading strategy using quantstrat. It should compare, if the closeprice is higher than the Donchianchannel high. i would like to create a Longsignal if: Closeprice > 0.85 * Donchianchannel high. library(quantstrat) Sys.setenv(TZ =…
Ramon
  • 71
  • 8
2
votes
2 answers

quantstrat: how to create multiple indicators, signal rules

I want to add multiple rules based on different signals like SMA50 > SMA10 and MACD > 0. However, I am getting an error using sigComparision. Can anyone suggest a better way to do it?
Rajat
  • 37
  • 4
2
votes
2 answers

How to Write a Custom Rule Function for Quantstrat in R - Replace trailing stop order with stoplimit with ruleOrderProc

My goal is to use the rule that I outline below to generate a signal to place a new 'stoplimit' order that replaces my trailing stop. I don't want my stop to trail indefinitely, only until it reaches my breakeven price (if this can be achieved…
Jared Marks
  • 948
  • 8
  • 15
2
votes
1 answer

Quantstrat: Is it possible to execute several orders for the same instrument within a single day?

I'm a bit puzzled with how exactly Quantstrat places orders if they are generated within a single day by several signals. I'm trying to implement a simple pair-trading strategy (with zero being both an entry and exit threshold), so when z-score…
2
votes
0 answers

Load data.table in QuantMod & Quantstrat

I have a data.table with my own data prices for 3 Isins. PricesDir= "C:/Downloads/Prices" #With 10 CSVs just with bid-ask info. files=list.files(PricesDir, pattern="*csv",full.names = TRUE) prices = rbindlist(lapply(files, fread, fill = TRUE), fill…
Rose
  • 203
  • 2
  • 10
2
votes
1 answer

saving and loading blotter portfolio

I am using blotter to hold and do the accounting of some transactions, but I would need to save and load them on a daily basis. I haven´t been able to save my transactions, I believe that that happens because they are in a different enviroment…
Augusto
  • 51
  • 1
  • 6
2
votes
1 answer

How to get current "symbol" inside custom function when applyIndicators or applyStrategy in quantstrat

i would like to access the current symbol string eg "GOOG" inside my custom indicator function. Here is the most basic example i could make. require(quantstrat) Sys.setenv(TZ="UTC") symbols <- c("GOOG", "AAPL") getSymbols(symbols,…
GeV 126
  • 351
  • 1
  • 3
  • 14
2
votes
1 answer

Quantstrat: Trading ticker X based on signal in ticker Y

I can't figure out how I can backtest a strategy trading ticker X and ticker Y based on a signal from a synthetic asset created from a combination of ticker X and Y. The data background is a list of XTS series of tickers. Right now I am solving it…
mfvas
  • 115
  • 1
  • 11
2
votes
2 answers

problems in quantstrat : argument "price" is missing, with no default

I am a new user trying to backtesting on quantstrat, when I run the following code shows the message at the bottom. Can anyone help me to fix it? library(quantmod) initdate = "1999-01-01" from = "2003-01-01" to =…
2
votes
1 answer

R: Quantstrat TxnFees Multiplier

I am trying to run a backtesting strategy in R's Quantstrat package. The instrument is Wheat futures and is quoted in US cents. The contract size is 5000 bushels. I have therefore added the following code. future(symbols, currency = "USD", …
youjustreadthis
  • 622
  • 3
  • 9
  • 24
2
votes
2 answers

Installing Quantstrat in a recently updated R in Fedora Linux

I have updated my Fedora Distribution recently, and R was updated too. I re installed most of the packages, but I couuldnt install blotter and quantstrat. How can I solve this issue? Thank you! The error I get is the following…
2
votes
1 answer

Write orderbook from quantstrat into CSV file

I am trying to save as a CSV file the orderbook generated after running a portfolio on quantstrat. order_book <- getOrderBook(qs.portfolio) write.csv(order_book, "orderbook.csv") I am getting the following error message: Error in…
Yago
  • 63
  • 5