[R-SIG-Finance] Possible bug in blotter
Wolfgang Wu
wobwu22 at yahoo.de
Wed Dec 22 15:06:27 CET 2010
I don't fully understand the code but the following patch fixes the problem for
me.
tmpPL$Con.Mult.1 <- na.locf(tmpPL$Con.Mult.1)
tmpPL$Con.Mult.1 <- ifelse(is.na(tmpPL$Con.Mult) & !is.na(tmpPL$Con.Mult.1) ,
tmpPL$Con.Mult.1, tmpPL$Con.Mult)
tmpPL$Con.Mult <- na.locf(tmpPL$Con.Mult)
+tmpPL$Con.Mult <- na.locf(tmpPL$Con.Mult, fromLast=TRUE)
tmpPL$Con.Mult <- ifelse(is.na(tmpPL$Con.Mult) ,1, tmpPL$Con.Mult)
There might be a more elegant solution however as I think it might be this bit
of code quickly assumes that the multiplier is 1 when is.na == true
tmpPL$Con.Mult <- ifelse(is.na(tmpPL$Con.Mult) ,1, tmpPL$Con.Mult)
Wolfgang Wu
----- Ursprüngliche Mail ----
Von: Brian G. Peterson <brian at braverock.com>
An: r-sig-finance at r-project.org
Gesendet: Mittwoch, den 22. Dezember 2010, 13:43:24 Uhr
Betreff: Re: [R-SIG-Finance] Possible bug in blotter
On 12/22/2010 04:30 AM, Wolfgang Wu wrote:
> thank you for the explanation. I understand this now. However consider a
> different example where the security is now a futures contract with a
>multiplier
> of 2. Then blotter will produce a wrong End.Eq. (See example code) I suspect
>the
> Con.Mult column in the first row of the portfolio object is set wrongly and is
> causing the problem. Would you agree?
The first row doesn't have anything to do with it. That row has a zero value,
and is only there to initialize things.
It does appear that your example highlights a problem in the multiplier being
applied to one of the Avg.Cost columns in the $posPL slot.
We'll investigate and fix. Thanks for the report.
Regards,
- Brian
-- Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
_______________________________________________
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: updatePosPL.patch
Type: application/octet-stream
Size: 571 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20101222/e196a0de/attachment.obj>
More information about the R-SIG-Finance
mailing list