Skip to content

apply

4 messages · Joshua Ulrich, Diego Peroni

#
Hi everybody,

I'm running last quantstrat build from a couple of days on a CentOS 
server (128GB ram, 6 core XEON):

Version: *0.9.1739*| Last change: *2016-04-17 20:25:28+02*| Rev.: *1748

**Using:

**library(doMC)
registerDoMC(cores=detectCores())
results = apply.paramset(my.strategy, paramset.label = "OPT",
                           portfolio=my.strategy, account=my.strategy, 
nsamples=0, calc='slave', audit=NULL, verbose=FALSE)
*
*This new release crashes in few minutes with just 500 combinations 
because memory allocation ***increases *of each single process very very 
fast.

**It never happened to me with this simple strategy before quantstrat 
upgrade.*
*
Someone can help me?*
*
Thanks*
*Diego
*
#
On Fri, Jan 27, 2017 at 12:04 PM, Diego Peroni <diegoperoni at vodafone.it> wrote:
That is not the last quantstrat build.  You're using the last commit
from R-Forge, but quantstrat moved from R-Forge to GitHub in May 2016.
https://github.com/braverock/quantstrat
It's going to be very difficult for people to help you with so little
information about the strategy.

It would also be helpful to know the versions of R and all relevant
packages both *before* and after this issue occurred.  You think the
issue is with quantstrat because you're trying to run a strategy, but
quantstrat depends on a lot of other packages and an issue in one of
them could be causing this issue.

  
    
#
Hi Joshua,

thanks for your answer!

I'm going to download and test last version from GitHub first and I'll 
check if my problem persists...

Diego
On 27/01/2017 19:13, Joshua Ulrich wrote:
#
Hi Joshua,

I've found the same problem (fast memory increse until swap and crash) 
using last quantstrat release from GitHub (0.10.0).

I'm running a very simple demo strategy (in attach to this email) based 
on ES 2006 x minute data (163MB).
The strategy do just few trades per case to run to the end of 
combinations quickly.
It seems to me that at each new case the memory increases because old 
data are not dropped from memory.
I didn't had this problem using quantstrat 0.9.1709

My configuration is the following:

- CentOS server (128GB ram, 6 core XEON)
- RStudio Server Version 0.99.484
- R version 3.2.2 (2015-08-14)
- TTR 0.23.1
- quantmod 0.4.7
- blotter 0.9.1741
- PerformanceAnalytics 1.4.3662

I'm sending to you (in private) a link to download the data 
(ES_2006.RData) that the strategy uses:

Thanks in advance for your time and let me know if I've missed important 
information for you.

Regards

Diego
On 28/01/2017 12:14, Diego Peroni wrote:
-------------- next part --------------
rm(list=ls())

library(quantstrat)

Sys.setenv(TZ="UTC")
Sys.setlocale('LC_TIME', 'C')
options("scipen"=100, "digits"=10)

osMaxPosLongShort = function(data, timestamp, orderqty, ordertype, orderside, portfolio, symbol, ruletype, ...) {
  maxpos = osMaxPos(data, timestamp, orderqty, ordertype, orderside, portfolio, symbol, ruletype, ...)
  curpos = getPosQty(portfolio, symbol, timestamp)
  if (orderside == 'long' & curpos<0)
    maxpos = 0
  if (orderside == 'short' & curpos>0)
    maxpos = 0
  return (maxpos)
}

initEq = 10000
symbol = 'ES'
currency('USD')

initDate = startDate = '2006-01-01'
endDate = '2006-12-31'

load('ES_2016.RData') # loading minute data

stock(symbol, currency='USD', multiplier=50, tick_size=0.25)

qs.strategy = 'teststrategy'
rm.strat(qs.strategy)
initPortf(qs.strategy, symbol, initDate = initDate)
initAcct(qs.strategy, portfolios = qs.strategy, initDate = initDate, initEq = initEq)
initOrders(portfolio = qs.strategy, initDate = initDate)
strategy(qs.strategy, store = TRUE)

addPosLimit(portfolio = qs.strategy, symbol = symbol, timestamp = initDate, maxpos = 1, minpos = -1)

add.indicator(qs.strategy, name='RSI',
              arguments = list(price=quote(Cl(mktdata)), n=12), label='rsi')

add.signal(qs.strategy, name = "sigThreshold",
           arguments = list(column="EMA.rsi", threshold=0.01, relationship="lt", cross=TRUE), label="upTrend")

add.rule(qs.strategy, name='ruleSignal',
         arguments = list(sigcol="upTrend", sigval=TRUE,
                          replace=TRUE,
                          prefer='open',
                          orderside='long',
                          ordertype='market',
                          orderqty=1,
                          osFUN='osMaxPosLongShort',
                          orderset='ocolong'),
         timespan='T09:30/T16:00',
         type='enter',
         label='LE')
add.rule(qs.strategy, name='ruleSignal',
         arguments=list(sigcol='upTrend', sigval=TRUE,
                        prefer='open',
                        replace=FALSE,
                        orderside='long',
                        ordertype='stoptrailing',
                        threshold=0.005,
                        tmult=TRUE,
                        orderqty='all',
                        orderset='ocolong'
         ),
         type='chain', parent='LE',
         label='StopTrailingLong',
         enabled=TRUE)


add.distribution(qs.strategy,
                 paramset.label = 'MACDOPT',
                 component.type = 'signal',
                 component.label = 'upTrend',
                 variable = list(threshold = seq(1, 2, by=.003)),
                 label = 'threshold.upTrend')


library(doMC)
registerDoMC(cores=detectCores())
results = apply.paramset(qs.strategy, paramset.label = "MACDOPT", portfolio=qs.strategy, account=qs.strategy, nsamples=0, calc='slave', audit=NULL, verbose=TRUE)
r = t(data.frame(do.call(rbind, results$tradeStats)))