Hi Brian,

Thanks. Simply using to.weekly(SPY) without passing any value also
solved the problem.

I would be happy to clean and contribute code to blotter but what I
did currently is much basic than the scenario you described below.

What I did is fairly simple i.e., basically read past transactions
from a file, read config (i.e., initCapital, bet sizing algorithm name
etc) and then using blotter populate a portfolio with those
transactions and correct unit sizes for each transaction based on
configured MM sizing algorithm. So far only Equal Weight MM is done.

My scenarios are probably more geared for independent trader who
already use trading platforms like tradestation/ ninjatrader but like
to use R to model scenarios that standard trading platforms cannot do.
These platforms IMO do very well when it comes to charting and other
functionality like those offered by quantmod/quantstrat packages. But
they fall short when it comes to multi-instrument rotation strategies
or modelling portfolios and accounts etc functionality as provided by
blotter.

Regards,

Pie

On 11/04/2012 01:20 AM, Pie T wrote:
>* Hi,*>* What is the difference between "endof" and "lastof" keywords in to.weekly()*>* and to.monthly functions?*
to.period (and the wrappers to.weekly and to.monthly) are provided by
xts, not PerformanceAnalytics.

While 'startof' and 'endof' are discussed at the beginning of to.period,
it looks from the code like only 'firstof' and 'lastof' are actually
*used*.  So, until we sort out the discrepancy, just use 'firstof' and
'lastof' if you absolutely need to pass a value here (but it's not clear
that you do, see below).

>* example: SPY = to.weekly(SPY, indexAt='endof', drop.time=FALSE)*>**>* Context:*>* I was getting duplicate index values in blotter account object for summary*>* i.e., getAccount(..)$summary. The source of the error finally turned out to*>* be  usage of "lastof" in to.weekly(..) function in PerformanceAnalytics. If*>* I use "endof" that seems to take care of the problem.*
to.period, by default, will take the last observation in the period, so
these extra options shouldn't be necessary in most cases anyway.  That
is, you shouldn't have to pass an indexAt argument at all for the
application you're describing.

>* On another note, currently to simulate equal asset weighting,  I track the*>* account capital and compute the quantity for each transaction in my program*>* before adding to portfolio. I am  wondering is there any API in*>* blotter/performance analytics where I can just provide weights for each*>* asset, initial capital and list of  transactions with quantity as 1 and the*>* rest is taken care automatically by an R package?*
You're kind of mixing two paradigms.

If you're dealing with weights and returns, then the
PerformanceAnalytics function Return.portfolio can do periodic
rebalancing, skipping the 'transactions' and 'prices' steps entirely.
If all you want to do is sort out the net return of a periodically
rebalanced equal weight portfolio (or any periodically rebalanced
portfolio), then using Return.portfolio will be the simplest thing.

If you want to deal with transactions in blotter and get cash results by
performing rebalancing trades to adjust the portfolio, then there is
currently no function for doing this in blotter (which deals with
transaction accounting).  If you've already written code to extract
weights from blotter and generate difference transactions to get to a
new target weight, it would be nice if you would contribute that code to
the dev team.  It's been on my list, but hasn't gotten anywhere near the
top of that list.

Regards,

   - Brian

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

	[[alternative HTML version deleted]]

