Quantcast

qsiblive, how to debug code with source() as sub procedure

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

qsiblive, how to debug code with source() as sub procedure

unsown
I'm not an experienced R user and I'm currently trying with the psiblive demo codes. I found the source() command has been used in quite a few places  in the codes. I understand that by using this a long procedure can be separated into several modules, but  I found it is not easy to debug. One of the difficulty is that it seems not easy to find out which file and which line the error belonged to. I tried commands such as debug, browser, trace and recover, but often ended up with nowhere. It takes me a lot time to locate where the problem is. So I wondered if there is any standard way or procedure to debug code with many files sourced into it?

And as far as I know the R will interpret the sourced codes by aggregating them into a single procedure. I wondered if it would be safer and clearer to just use functions for the same purpose of source()?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: qsiblive, how to debug code with source() as sub procedure

gsee
On Sat, Jul 14, 2012 at 9:59 AM, unsown <[hidden email]> wrote:
> I'm not an experienced R user and I'm currently trying with the psiblive demo
> codes. I found the source() command has been used in quite a few places  in
> the codes. I understand that by using this a long procedure can be separated
> into several modules, but  I found it is not easy to debug. One of the
> difficulty is that it seems not easy to find out which file and which line
> the error belonged to.

Maybe ?getSrcFilename can help with this

Regards,
Garrett

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: qsiblive, how to debug code with source() as sub procedure

unsown
Thanks for your reply. But what if the error occurs in an expression instead of in a function defined in the source code?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: qsiblive, how to debug code with source() as sub procedure

soren wilkening
Hi

interesting question. I guess that when I started writing qsiblive I was debugging/testing the source files individually, with small test scripts, so by the time I would run the whole package at once, the likelihood of having an error in any of the source files was very small.

Whenever there was an error while testing the whole package, I suppose that I more or less knew where to look, depending on what the error actually was. I never used the standard R debugging tools for this. I guess one way to do it differently would  be to just include all the separated source files into one main file that you can then debug with the usual R tools ... (never done it, though)

If you want, share the error either here or with me directly (use email given on censix.com) and I may have a look at it and will see if divine intuition tells me something about it origin :)

Cheers

Soren
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: qsiblive, how to debug code with source() as sub procedure

unsown
Thanks for your suggestion, Soren.  After getting familiar with the debugging tools of R and the codes by you, I'm now able to looking into the codes line by line. The command traceback() and browser() work best for me.

BTW. I might have identified a problem with IBrokers during the debugging. Here is the version I'm using:
IBrokers version 0.9-3:
Implementing API Version 9.64

After building a connection. the "nextId" filed of the returned connection is actually the account name instead of an integer number, which cause a problem when place an order.

The latest IB API is version 9.66. I thought it might because of my IBrokers is out of date and I found there is another version of IBrokers on Google Code. But it looks like that version is even older (0.9-0).
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: qsiblive, how to debug code with source() as sub procedure

gsee
Please see this thread:
https://stat.ethz.ch/pipermail/r-sig-finance/2012q2/010264.html

If you're still unable to checkout, build and install the latest code,
then see this SO post: http://stackoverflow.com/a/11105132

Don't give up until you see
packageVersion("IBrokers")
[1] ‘0.9.7’

Garrett

On Thu, Jul 19, 2012 at 10:53 PM, unsown <[hidden email]> wrote:

> Thanks for your suggestion, Soren.  After getting familiar with the debugging
> tools of R and the codes by you, I'm now able to looking into the codes line
> by line. The command traceback() and browser() work best for me.
>
> BTW. I might have identified a problem with IBrokers during the debugging.
> Here is the version I'm using:
> IBrokers version 0.9-3:
> Implementing API Version 9.64
>
> After building a connection. the "nextId" filed of the returned connection
> is actually the account name instead of an integer number, which cause a
> problem when place an order.
>
> The latest IB API is version 9.66. I thought it might because of my IBrokers
> is out of date and I found there is another version of IBrokers on Google
> Code. But it looks like that version is even older (0.9-0).
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/qsiblive-how-to-debug-code-with-source-as-sub-procedure-tp4636519p4637147.html
> Sent from the Rmetrics mailing list archive at Nabble.com.
>
> _______________________________________________
> [hidden email] 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.

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: qsiblive, how to debug code with source() as sub procedure

unsown
Thank you very much. This is exactly the problem I met. Guess I should do
more searching.

On Fri, Jul 20, 2012 at 12:13 PM, G See <[hidden email]> wrote:

> Please see this thread:
> https://stat.ethz.ch/pipermail/r-sig-finance/2012q2/010264.html
>
> If you're still unable to checkout, build and install the latest code,
> then see this SO post: http://stackoverflow.com/a/11105132
>
> Don't give up until you see
> packageVersion("IBrokers")
> [1] ‘0.9.7’
>
> Garrett
>
> On Thu, Jul 19, 2012 at 10:53 PM, unsown <[hidden email]> wrote:
> > Thanks for your suggestion, Soren.  After getting familiar with the
> debugging
> > tools of R and the codes by you, I'm now able to looking into the codes
> line
> > by line. The command traceback() and browser() work best for me.
> >
> > BTW. I might have identified a problem with IBrokers during the
> debugging.
> > Here is the version I'm using:
> > IBrokers version 0.9-3:
> > Implementing API Version 9.64
> >
> > After building a connection. the "nextId" filed of the returned
> connection
> > is actually the account name instead of an integer number, which cause a
> > problem when place an order.
> >
> > The latest IB API is version 9.66. I thought it might because of my
> IBrokers
> > is out of date and I found there is another version of IBrokers on Google
> > Code. But it looks like that version is even older (0.9-0).
> >
> >
> > --
> > View this message in context:
> http://r.789695.n4.nabble.com/qsiblive-how-to-debug-code-with-source-as-sub-procedure-tp4636519p4637147.html
> > Sent from the Rmetrics mailing list archive at Nabble.com.
> >
> > _______________________________________________
> > [hidden email] 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.
>
        [[alternative HTML version deleted]]


_______________________________________________
[hidden email] 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.
Loading...