[R-SIG-Finance] Guy Yollin's blotter.pdf Example

stergios marinopoulos stergenator at gmail.com
Tue Sep 16 18:52:32 CEST 2014


In Guy Yollin's blotter.pdf slide there's an example on page 30 about which
I have a question.

The example is a loop over each period of data where the trading rules are
applied.  At the very end of the loop the three blotter functions named
updatePortf(), updateAcct(), and updateEndEq() are called.  Here it is
briefly:

for( i in 1:nrow(SPY) ) {

    // Trading Rules Omitted

    updatePortf(b.strategy,Dates=CurrentDate)
    updateAcct(b.strategy,Dates=CurrentDate)
    updateEndEq(b.strategy,CurrentDate)

}


My question is "could we hoist those last 3 functions out of the loop, and
place them afterwards with an expanded date range to cover all dates?"
 Doing so dramatically speeds up processing.  A downside to doing so is not
having the current equity available for use in trade sizing.  Of course,
there may be a loss of clarity in the example as well.  Are there other
important reasons for keeping the functions inside the loop?

Perhaps those functions could be called inside the loop only when a
position is closed out, or when rebalancing needs to occur?

Thanks for your thoughts on the matter.

--
sm
Stergios Marinopoulos

	[[alternative HTML version deleted]]



More information about the R-SIG-Finance mailing list