[R-SIG-Finance] Another blotter test case

Brian G. Peterson brian at braverock.com
Fri Dec 24 13:38:53 CET 2010


On 12/24/2010 03:35 AM, Wolfgang Wu wrote:
> I am still bumping into problems trying to implement some of our trading
> strategies using blotter. So here is another one that seems to go wrong using
> r511.
>
> library(blotter)
> dateRange<- as.Date(as.Date('2010-01-02'):as.Date('2010-01-05'))
> currency('USD')
> stock('ABC', currency='USD')
> ABC<- xts(102:105, order.by=dateRange)
> colnames(ABC) = "Close"
>
> initPortf('portA', symbols="ABC", initDate='2010-01-01');
> initAcct('accA',portfolios='portA', initDate='2010-01-01', initEq=100);
> addTxn("portA", Symbol='ABC', TxnDate='2010-01-02', TxnPrice=102, TxnQty =1,
> TxnFees=0, verbose=TRUE)
> updatePortf('portA', Dates = dateRange)
> updateAcct('accA', Dates = dateRange)
> updateEndEq('accA', Dates = dateRange)
> #Equity wrong?
> getAccount('accA')
>
>
>
> I get the following result with the End.Eq staying at 101 where I am expecting
> it to increase as the stock increases in value.
>

This looks like a bug.  Looks like for some reason updateEndEq isn't 
accumulating the Trading.PL.  It's showing properly in the $posPL slot 
as Unrealized.PL and Trading.PL, so we'll have to sort out what's wrong 
with the equity calculation.

Thanks for the report, should be fixed at the latest early next week. 
As always, thank you for the reproducible test case, these always make 
debugging easier.

Also, for 'bug reports', it's generally considered best to email the 
maintainer of the package first, to not bother the list.  For 'help' or 
'support' requests, the list may be a better outlet, as others will 
likely have relevant experience and all benefit from sharing.

Regards,

   - Brian

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



More information about the R-SIG-Finance mailing list