Skip to content

xts objects and speed

13 messages · E D, michael.weylandt at gmail.com (R. Michael Weylandt, Brian G. Peterson +3 more

If I understand you, it might take a little jerry-rigging (sp?) but I think you could use the to.period() functions and pull out the "High"s and "Low"s. 

Hope this gets you going in the right direction,

Michael
On Jun 18, 2012, at 9:40 PM, E D <e065c8515d206cb0e190 at gmail.com> wrote:

            
#
On 06/18/2012 09:40 PM, E D wrote:
You didn't provide a reproducible example, so you run the risk

Your email suggests that you are doing something like:

for (t in 180:nrow(myXTS)) {
	out<-max(last(myXTS[1:t],'3 hours'))
}

which will indeed be painfully slow.

In the hopes of eliciting a little more detail, here's a reproducible 
example...

#######################

# on a very slow web browsing desktop at home
# (as opposed to a 'modern workstation'
# on which I do real work):


require(TTR)

#?runMax

# construct a one-minute index
idx<-seq.POSIXt(from=as.POSIXct('2012-05-01'),
		to=as.POSIXct('2012-06-18'),by='min')

# construct a fake time series
myXTS<-xts(cumsum(rnorm(length(idx))),order.by=idx)

myXTS<-myXTS['T09:30/T16:00'] #subset by time

outs<-vector(length=nrow(myXTS))
system.time(
   for (t in 180:nrow(myXTS)) {
      outs[t]<-max(last(myXTS[1:t],'3 hours'))
   }
)

#    user  system elapsed
# 127.092   0.020 127.137

system.time(
	outf<-runMax(myXTS,180)
)

#   user  system elapsed
#  0.032   0.000   0.032

######################

Cheers,

    - Brian
1 day later
#
Precisely what do you mean by "the SVN is not working?"  When you read
the thread that Julien provided, did you follow this link that I
provided in that thread?
http://stackoverflow.com/questions/11105131/cannot-install-r-forge-package-using-install-packages

R-Forge does not build packages for old versions of R.  You have to
build it yourself.
If it really is an SVN problem, then R-sig-finance is not the best place to ask.

HTH,
Garrett

On Thu, Jun 21, 2012 at 7:21 AM, Pierre-Alexandr des Mazis
<p.desmazis at gmail.com> wrote:
#
Hi

I used SVN with Cygwin to checkout the project but host name could not be "reached".


Regards

Pierre-Alexandre des Mazis
+ 447 779 171 499
On 21 Jun 2012, at 13:59, G See <gsee000 at gmail.com> wrote:

            
#
I suggest that when you take this up on a Cygwin SVN list you show
*exactly* what commands you entered, and *exactly* what errors you
saw.

Or, you could just use TortoiseSVN.

On Thu, Jun 21, 2012 at 8:19 AM, Pierre-Alexandr des Mazis
<p.desmazis at gmail.com> wrote:
#
G,

I was just wondering if there is any alternative solution to the r-forge website. I must admit I am not too sure about how to build a package. I will code my own script to do the job.

Thanks anyway

Regards,






 

Pierre-Alexandre des Mazis
+ 447 779 171 499
On 21 Jun 2012, at 15:13, G See <gsee000 at gmail.com> wrote:

            
#
The alternative to the r-forge *website* is SVN.  If you're going to
try to source files instead of building the package, you're on your
own.

I guess you could browse through the repository here,
https://r-forge.r-project.org/scm/viewvc.php/pkg/PortfolioAnalytics/?root=returnanalytics,
and click the "download" link for files you're interested in.  For
example, suppose you want the "charts.DE.R" file.  You can browse to
it, and click the download link which will bring you here
http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/PortfolioAnalytics/R/charts.DE.R?root=returnanalytics

You can source that directly
source("http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/PortfolioAnalytics/R/charts.DE.R?root=returnanalytics")

(You may have to replace https with http in the link)

Gooood luck with that,
Garrett

On Thu, Jun 21, 2012 at 11:25 AM, Pierre-Alexandr des Mazis
<p.desmazis at gmail.com> wrote:
#
Thank you very much G see 

I will dig into the subject once home and hopefully will be able to find a solution. 

regards

Pierre-Alexandre des Mazis
+ 447 779 171 499
On 21 Jun 2012, at 17:50, G See <gsee000 at gmail.com> wrote: