[R-SIG-Finance] quantstrat with intraday data

G See gsee000 at gmail.com
Wed May 2 17:04:11 CEST 2012


As an alternative to adjusting for dividends in quantstrat or blotter,
my qmao package (https://r-forge.r-project.org/R/?group_id=1113) has
two functions that adjust intraday data for dividends.

`adjustIntraday.yahoo` will download dividend data from yahoo and
calculate daily ratios.  Those ratios will then be applied to intraday
data.

`AddCumDiv` simply adds back all dividends to the price series.

With adjustIntraday.yahoo, the most recent observations will be the
same as the unadjusted data, but the older observations will be lower
than those that are unadjusted.

With AddCumDiv, the oldest observations will be the same for the
adjusted and unadjusted data, but the most recent observations will be
higher for AddCumDiv.

Although I believe these functions work like they're supposed to, they
have not been rigorously tested, so YMMV.  bug reports encouraged.

Since I just committed the AddCumDiv function a few minutes ago, it is
not yet in the R-Forge build (although it is in the repo if you know
how to svn checkout).  Since it's not in the build yet, I attached it.

Regards,
Garrett

On Wed, May 2, 2012 at 8:02 AM, Brian G. Peterson <brian at braverock.com> wrote:
> On Wed, 2012-05-02 at 00:00 -0400, Jim Green wrote:
>> Greetings!
>> Pls forgive me if this is an old topic. I have searched through list
>> archives extensively but I am just not sure if I am using quantstrat
>> correctly with intraday data.
> <...>
>> Currently I use something similar to attached test.R to do intraday
>> work. in the code I liquidate everything before close so that I don't
>> need to worry about splits and dividends. Is what I am doing the
>> correct way of using quantstrat with intraday data?
>
> That's certainly the easiest answer.
>
> blotter contains some support for dividends, but it is only lightly
> tested, since I personally don't need that functionality.  Additional
> testing, direct feedback, and patches are always welcome.  Participation
> by users is one of the ways these packages grow over time.  (and feel
> free to take those conversations off-list)
>
>> Also if in future I will hold overnight positions, How would I make
>> sure dividends and splits are correctly adjusted for pnl and summary
>> statistics? would underlying blotter be smart enough to handle all the
>> housekeeping?
>
> No Guarantees (of course that's true of everything in R).
>
> My recollection is that the addDiv function will add cash to your
> account to cover dividends.
>
> I don't believe that there is a function for splits.  You'd likely need
> to write that, we'd love the contribution.  It shouldn't be hard, as all
> that needs to happen is that you add a transaction for the split with a
> price of zero, adding more shares and lowering your average cost to
> compensate for the split.
>
> As xts gains support for differing column classes this summer as part of
> the funded GSoC project, it will get easier to add additional
> information to transactions that will definitely include transaction
> type.
>
> 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: AddCumDiv.R
Type: application/octet-stream
Size: 3461 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20120502/e1c13821/attachment.obj>


More information about the R-SIG-Finance mailing list