blotter

Convert from R to quantstrat setup for trading strategy backtesting

丶灬走出姿态 提交于 2019-12-30 05:34:05
问题 I am trying to backtest a trading strategy with "quantstrat" package. My strategy is composed by 4 indicators, 3 different EMAs and 1 lagged EMA. I want to go long when: EMA1 > EMA2 & EMA1 > EMA3 & EMA1_lag < EMA1 I want to exit and go flat when: EMA1 < EMA3 It's pretty simple but I am not able to write it into quantstrat environment. Here's a data integrity check function used in both examples: # Data integrity check checkBlotterUpdate <- function(port.st,account.st,verbose=TRUE) { ok <-

Xts conversion fails on update from xts 0.9.7 to 0.10.0

感情迁移 提交于 2019-12-24 20:15:33
问题 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 = c(24L, 24L, 24L), mon = c(5L, 5L, 5L), year = c(114L, 114L, 114L), wday = c(2L, 2L, 2L), yday = c(174L, 174L, 174L), isdst = c(1L, 1L, 1L), zone = c("EDT", "EDT", "EDT"), gmtoff = c(NA_integer_, NA_integer_, NA_integer_)), .Names = c("sec", "min", "hour", "mday",

R: Quantstrat examples of Guy Yollin. Indicators necessary? And what is stored in these financial instruments?

隐身守侯 提交于 2019-12-13 05:06:45
问题 Hi I'm working through this code (this works and is reproducible) if (!exists('.blotter')) .blotter <- new.env() if (!exists('.strategy')) .strategy <- new.env() if (!exists('.instrument')) .instrument <- new.env() currency("USD") stock("SPY",currency="USD",multiplier=1) ls(envir=FinancialInstrument:::.instrument) initDate <- '1997-12-31' startDate <- '1998-01-01' endDate <- '2013-07-31' initEq <- 1e6 Sys.setenv(TZ="UTC") getSymbols('SPY', from=startDate, to=endDate, adjust=T) SPY=to.monthly

Add Technical Indicator to chart.Posn

烈酒焚心 提交于 2019-12-12 12:54:51
问题 For some reason I cannot add a ROC signal to a blotter chart. In the documentation it should be allowed. I want to create a new chart bellow with this indicator. Can someone help? # plot performance for symbol chart.Posn(strategy_AbsMom, Symbol = 'SPY', Dates = '1998::',theme=myTheme) chart.Posn(strategy_AbsMom, Symbol = 'SPY', Dates = '1998::',theme=myTheme, TA='addROC(n=lookback,col=4)') 回答1: chart.Posn uses chart_Series (not chartSeries ) internally, so you have to use add_* functions (not

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

我是研究僧i 提交于 2019-12-11 06:47:23
问题 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 somehow already, please let me know). I am hoping to write a custom rule in quantstrat with the following objective: If today's "Close" minus (-) the threshold value (a scalar) on the timestamp of trade open, is greater than (>) the "Open" price on

Cant install blotter package used for quantstrat

孤街醉人 提交于 2019-12-04 05:30:59
问题 I'm trying to use the quantstrat package in R. I have uploaded/installed the package using install.packages("quantstrat", repos="http://R-Forge.R-project.org") However the once I use require(quanstrat) I get the message : Loading required package: quantstrat Failed with error: ‘package ‘blotter’ required by ‘quantstrat’ could not be found’ I then use install.packages("blotter", repos="http://R-Forge.R-project.org") but get the following message: Package which is only available in source form,

Convert from R to quantstrat setup for trading strategy backtesting

老子叫甜甜 提交于 2019-11-30 16:57:55
I am trying to backtest a trading strategy with "quantstrat" package. My strategy is composed by 4 indicators, 3 different EMAs and 1 lagged EMA. I want to go long when: EMA1 > EMA2 & EMA1 > EMA3 & EMA1_lag < EMA1 I want to exit and go flat when: EMA1 < EMA3 It's pretty simple but I am not able to write it into quantstrat environment. Here's a data integrity check function used in both examples: # Data integrity check checkBlotterUpdate <- function(port.st,account.st,verbose=TRUE) { ok <- TRUE p <- getPortfolio(port.st) a <- getAccount(account.st) syms <- names(p$symbols) port.tot <- sum

Guy Yollin's QuantStrat I lecture issue

最后都变了- 提交于 2019-11-30 07:43:45
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 (copied from the lecture with very minor re-arrangements): rm(list=ls(all=TRUE)) #added this to delete memory library(quantstrat) library(blotter) #added this hoping it would rectify the errors library(FinancialInstrument) #added this hoping it would rectify the errors # initialize portfolio, accounts and orders qs.strategy <- "qsFaber" initPortf(qs

Guy Yollin's QuantStrat I lecture issue

巧了我就是萌 提交于 2019-11-29 10:24:54
问题 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 (copied from the lecture with very minor re-arrangements): rm(list=ls(all=TRUE)) #added this to delete memory library(quantstrat) library(blotter) #added this hoping it would rectify the errors library(FinancialInstrument) #added this hoping it