0

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 luxor.1.basic.strategy.R using nFast = 1, nSlow = 44 without the timespan optimization results in 106k. I did not run the full 24x24 hour scan above, but instead used .nSamples = 80 and:

.timespans<-c('T06:00/T10:00', 'T07:00/T11:00', 'T08:00/T12:00', 
    'T09:00/T13:00', 'T10:00/T14:00', 'T11:00/T15:00', 'T12:00/T16:00')

I checked with the result from the full scan version in luxor.timespan.24x24.2002-2008.RData and the NetTrading.PL was also about the same 20k.

I am quite confused, was there anything wrong? or was adding the timespan distribution to the strategy and then apply.parmaset() actually decreases the Net.Trading.PL?

Can anyone help me out please?. Thanks in advance.

I am just beginning to learn R and did not change anything in the code really. Here is a subsection from the file luxor.2.add.paramsets.R

## Timespan paramset

add.distribution(strategy.st,
    paramset.label = 'Timespan',
    component.type = 'enter',
    component.label = 'EnterLONG',
    variable = list(timespan = .timespans),
    label = 'EnterLong'
)

add.distribution(strategy.st,
    paramset.label = 'Timespan',
    component.type = 'enter',
    component.label = 'EnterSHORT',
    variable = list(timespan = .timespans),
    label = 'EnterShort'
)

add.distribution(strategy.st,
    paramset.label = 'Timespan',
    component.type = 'exit',
    component.label = 'Exit2LONG',
    variable = list(timespan = .timespans),
    label = 'ExitLong'
)

add.distribution(strategy.st,
    paramset.label = 'Timespan',
    component.type = 'exit',
    component.label = 'Exit2SHORT',
    variable = list(timespan = .timespans),
    label = 'ExitShort'
)

add.distribution.constraint(strategy.st,
    paramset.label = 'Timespan',
    distribution.label.1 = 'EnterLong',
    distribution.label.2 = 'EnterShort',
    operator = '==',
    label = 'EnterTimespan'
)

add.distribution.constraint(strategy.st,
    paramset.label = 'Timespan',
    distribution.label.1 = 'ExitLong',
    distribution.label.2 = 'ExitShort',
    operator = '==',
    label = 'ExitTimespan'
)

add.distribution.constraint(strategy.st,
    paramset.label = 'Timespan',
    distribution.label.1 = 'EnterLong',
    distribution.label.2 = 'ExitShort',
    operator = '==',
    label = 'EnterExitTimespan'
)

and here is a subsection from the file luxor.4.paramset.timespan.R

require(doParallel)
registerDoParallel(detectCores())

results <- apply.paramset(strategy.st, paramset.label = 'Timespan', 
portfolio.st = portfolio.st, account.st = account.st, 
nsamples = .nsamples, verbose = TRUE)

stats <- results$tradeStats
print(stats)
save(stats, file='luxor.4.paramset.timespan.RData')

1 Answers1

0

It's really hard to help if you do not provide a reproducible example, especially when you have made changes to the code. You may think you, "did not change anything in the code really", but you don't know all the ways what you have changed could affect the output.

Running the demos as-is does not produce P&L results anywhere near the values you mention, and I cannot get close to those P&L values by guessing what you changed based on the few things you mention in your question.

Despite all that, I think your expectations for the timespan optimization P&L are very unrealistic. It's probably not reasonable to expect similar P&L (or higher P&L even) if you restrict your trading to only 4 hours a day, which is what the timespan optimization does.

It seems perfectly reasonable to me that your P&L from trading only 16% of the hours in a day would be about 16% of the P&L you would make from trading all 24 hours of the day.

Community
  • 1
  • 1
Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
  • Thanks for pointing me to the right direction. I widen the time window to 8 hours and the strategy yielded a better P&L than the strategy without the time window. – Iwan Primaditya Sep 13 '16 at 02:55