Guy Yollin's blotter.pdf Example
Stergios, Clearly this example is largely based off of the longtrend demo in blotter. As you noted, the equity position is retreived at the top of the loop and this requires the updates at the bottom of the loop. I believe that you probably could refactor the loop so that you only call the update functions if you've just had a cross-over so that a position change may need to be made; in this case I believe you're date range would be "::CurrentDate" G
On 9/16/2014 9:52 AM, stergios marinopoulos wrote:
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]]
_______________________________________________ R-SIG-Finance at 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.