[R-SIG-Finance] quantstrat: NA for "Order.Prefer" for a stoptrailing order
Ivan Popivanov
ivan.popivanov at gmail.com
Sun Apr 14 23:54:59 CEST 2013
See the attachment. The script needs to be sourced from the directory, the
SPY.bin is the data file. Seems to happen only for short orders.
Regards,
Ivan
On Sun, Apr 14, 2013 at 3:53 PM, Joshua Ulrich <josh.m.ulrich at gmail.com>wrote:
> Ivan,
>
> I've been working on a similar issue for the past few days. Can you
> please provide a reproducible example that causes problems for you?
>
> Thanks,
> --
> Joshua Ulrich | about.me/joshuaulrich
> FOSS Trading | www.fosstrading.com
>
> R/Finance 2013: Applied Finance with R | www.RinFinance.com
>
>
> On Sun, Apr 14, 2013 at 12:13 PM, Ivan Popivanov
> <ivan.popivanov at gmail.com> wrote:
> > Not 100% sure about the root cause (could be also some bad logic in my
> > script), but I managed to track it as far as addOrder - to me the
> following
> > code seems very dubious at least:
> >
> > for (i in 1:length(price)) {
> > if(is.null(prefer[i])) prefer[i] = ''
> >
> > Notice that the function has a parameter *prefer* with a default value of
> > NULL. The first time this loop is entered, is.null(prefer[1]) is TRUE,
> > thus, prefer[i] is set to ''. However, subsequent values will be NA,
> thus,
> > the if is not entered and prefer[2] will be left as NA.
> >
> > Probably better to initialize prefer prior to the loop?
> >
> > if(is.null(prefer)) prefer = rep(NULL, length(price))
> >
> > Thanks,
> > Ivan
> >
> > [[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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20130414/c1fc16d5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: repro.tar.gz
Type: application/x-gzip
Size: 106491 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20130414/c1fc16d5/attachment.gz>
More information about the R-SIG-Finance
mailing list