On Sun, 2015-08-16 at 20:19 +0300, Akane Fortuna wrote:
> I am trying to test a strategy with random parameters that change every
> month as some kind of a benchmark to compare my other strategies against.
> This strategy is applied to the same instrument every month.  I tried to
> make a loop with applystrategy(), where in each iteration the different
> random parameter values are passed, and the next month's data is used. The
> first iteration is executed without problems but I cannot make the next
> iterations work.
> 
> I want to be able to use chart.Posn(), tradeStats() (in consolidated form),
> chart.ME(), getOrderBook(), getTxns() with the consolidated strategy
> backtest.
> 
> How should I go about doing this? No code is necessary for an answer, but I
> appreciate it if there is. Just outline/plan of the code is sufficient.
> Thank you.

The challenge with what you're trying to do is that the indicators and
signals are presumed to be vectorized functions.  So they are applied to
the entire dataset at once.

You're talking about subsetting the data by months, and applying
different parameter values.

If your indicators and signals don't have any lookback period, or are
constant over the entire test, then you should be able to use a
rebalance rule, which will subset the data and let you change things
around on your rebalance periods.

Assuming that's not the case, your options are somewhat more limited.

You have no problems using the same portfolio and account over
progressively increasing time periods.  You're basically just adding new
transactions over time.

The slightly challenging point will be in controlling the start and end
periods for everything else.  You'll need to make sure you don't have
signals before the start of the subset period, or after the end of the
subset period.

A minimal reproducible example would help others help you.

Regards,

Brian


-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

_______________________________________________
R-SIG-Finance@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

Reply via email to