Hello,

As usual, I'm not sure if this is the correct list to ask this, but it appears that the exponential moving average functions (emaTA and EWMA) use future information to calculate the moving average for periods prior to the kick-in of the weightings.  E.g. at one point it sets:

ylam[1] = mean(y[1:startup])

which, i am not quite able to trace through the rest of the function calls, but seems to be having the effect of starting the moving average calculation based on the average of future prices.  Am I correct in this?  If so, is there a reason why this might work that way?

Thanks, John. 

email: johnputz3655@yahoo.com
home: 206-632-6522
cell: 206-910-5229



----- Original Message ----
From: "r-sig-finance-request@stat.math.ethz.ch" <r-sig-finance-request@stat.math.ethz.ch>
To: r-sig-finance@stat.math.ethz.ch
Sent: Thursday, December 27, 2007 3:00:01 AM
Subject: R-SIG-Finance Digest, Vol 43, Issue 20

Send R-SIG-Finance mailing list submissions to
    r-sig-finance@stat.math.ethz.ch

To subscribe or unsubscribe via the World Wide Web, visit
    https://stat.ethz.ch/mailman/listinfo/r-sig-finance
or, via email, send a message with subject or body 'help' to
    r-sig-finance-request@stat.math.ethz.ch

You can reach the person managing the list at
    r-sig-finance-owner@stat.math.ethz.ch

When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-SIG-Finance digest..."


Today's Topics:

  1. Adding milliseconds to zoo object (Yuri Volchik)
  2. Re: Adding milliseconds to zoo object (Brian G. Peterson)
  3. Re: Adding milliseconds to zoo object (Gabor Grothendieck)
  4. Re: RBloomberg error (Thomas Steiner)
  5. Re: Adding milliseconds to zoo object (Yuri Volchik)
  6. Re: Adding milliseconds to zoo object (Gabor Grothendieck)
  7. Re: Adding milliseconds to zoo object (Gabor Grothendieck)
  8. Re: Adding milliseconds to zoo object (Yuri Volchik)
  9. get.hist.quote stalls (Markus Loecher)
  10. Re: get.hist.quote stalls (Patrick Burns)
  11. Non-financial "seasonality" (Walt Keneipp)


----------------------------------------------------------------------

Message: 1
Date: Wed, 26 Dec 2007 11:01:47 -0000
From: "Yuri Volchik" <volchik2000@list.ru>
Subject: [R-SIG-Finance] Adding milliseconds to zoo object
To: <r-sig-finance@stat.math.ethz.ch>
Message-ID: <000a01c847ae$b725d290$257177b0$@ru>
Content-Type: text/plain;    charset="us-ascii"

I've read already some discussions concerning milliseconds as an index in
zoo index and was wondering if there is a simple solution to differentiate
ticks which come with 1 second timestamp resolution by adding index for rows
with the same timestamp.
One of the solutions would be just to create an index with length of
nrows(x) and consider them as milli(micro)seconds, so my index will look
like:
2007-12-24 06:14:00.154  22.00  
2007-12-24 06:14:00.155  22.00  
2007-12-24 06:15:00.156  22.00  
2007-12-24 06:15:00.157  22.00  

So with solution order of the observations(ticks) is preserved, though the
solution is not very nice.
Is there a way to create index in the following way?
2007-12-24 06:14:00.154  22.00  
2007-12-24 06:14:00.155  22.00  
2007-12-24 06:15:00.001  22.00  
2007-12-24 06:15:00.002  22.00  

So this index will be in effect number(position) of the tick in the second.

Thanks



------------------------------

Message: 2
Date: Wed, 26 Dec 2007 08:59:52 -0600
From: "Brian G. Peterson" <brian@braverock.com>
Subject: Re: [R-SIG-Finance] Adding milliseconds to zoo object
To: Yuri Volchik <volchik2000@list.ru>,    R-SIG-Finance
    <r-sig-finance@stat.math.ethz.ch>
Message-ID: <47726C68.3000104@braverock.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Yuri Volchik wrote:
> I've read already some discussions concerning milliseconds as an index in
> zoo index and was wondering if there is a simple solution to differentiate
> ticks which come with 1 second timestamp resolution by adding index for rows
> with the same timestamp.
> One of the solutions would be just to create an index with length of
> nrows(x) and consider them as milli(micro)seconds, so my index will look
> like:
> 2007-12-24 06:14:00.154  22.00  
> 2007-12-24 06:14:00.155  22.00  
> 2007-12-24 06:15:00.156  22.00  
> 2007-12-24 06:15:00.157  22.00  
> 
> So with solution order of the observations(ticks) is preserved, though the
> solution is not very nice.
> Is there a way to create index in the following way?
> 2007-12-24 06:14:00.154  22.00  
> 2007-12-24 06:14:00.155  22.00  
> 2007-12-24 06:15:00.001  22.00  
> 2007-12-24 06:15:00.002  22.00  
> 
> So this index will be in effect number(position) of the tick in the second.

There was an extensive discussion on this list of millisecond support in 
zoo a few weeks ago.  Have you reviewed the suggestions posted in that 
thread, including by Gabor (one of the authors of zoo), Dirk, and other 
experienced users?

Regards,

    - Brian



------------------------------

Message: 3
Date: Wed, 26 Dec 2007 10:09:31 -0500
From: "Gabor Grothendieck" <ggrothendieck@gmail.com>
Subject: Re: [R-SIG-Finance] Adding milliseconds to zoo object
To: "Yuri Volchik" <volchik2000@list.ru>
Cc: r-sig-finance@stat.math.ethz.ch
Message-ID:
    <971536df0712260709r13200a05p777780e12e7d641d@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

The time class considerations for zoo are that whatever class you
use must support the methods indicated in ?zoo and the index on
any zoo time series must have unique elements.  If they are not
unique you can jitter them, add small amounts to make
them unique or aggregate them so that multiple non-unique points
are eliminated and replaced with a single point.

If your question is whether you could use ordered pairs as a time
class try the R "complex" class or create your own class.

> library(zoo)
> z1 <- zoo(11:15, complex(real = c(1, 1, 2, 2, 3), imag = c(2, 1, 1, 2, 5)))
> merge(z1, lag(z1))
    z1 lag(z1)
1+1i 12      11
1+2i 11      13
2+1i 13      14
2+2i 14      15
3+5i 15      NA

On Dec 26, 2007 6:01 AM, Yuri Volchik <volchik2000@list.ru> wrote:
> I've read already some discussions concerning milliseconds as an index in
> zoo index and was wondering if there is a simple solution to differentiate
> ticks which come with 1 second timestamp resolution by adding index for rows
> with the same timestamp.
> One of the solutions would be just to create an index with length of
> nrows(x) and consider them as milli(micro)seconds, so my index will look
> like:
> 2007-12-24 06:14:00.154  22.00
> 2007-12-24 06:14:00.155  22.00
> 2007-12-24 06:15:00.156  22.00
> 2007-12-24 06:15:00.157  22.00
>
> So with solution order of the observations(ticks) is preserved, though the
> solution is not very nice.
> Is there a way to create index in the following way?
> 2007-12-24 06:14:00.154  22.00
> 2007-12-24 06:14:00.155  22.00
> 2007-12-24 06:15:00.001  22.00
> 2007-12-24 06:15:00.002  22.00
>
> So this index will be in effect number(position) of the tick in the second.
>
> Thanks
>
> _______________________________________________
> R-SIG-Finance@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>



------------------------------

Message: 4
Date: Wed, 26 Dec 2007 16:13:19 +0100
From: "Thomas Steiner" <finbref.2006@gmail.com>
Subject: Re: [R-SIG-Finance] RBloomberg error
To: "Paul DeBruicker" <pdebruic@gmail.com>,
    r-sig-finance@stat.math.ethz.ch
Message-ID:
    <d0f55a670712260713p711c002dud06db5577e0e6c68@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

The problem is resolved. :)
I was bothering the help desk until wefound out together that I should
start the bbcomm first.
Thomas



------------------------------

Message: 5
Date: Wed, 26 Dec 2007 16:11:53 -0000
From: "Yuri Volchik" <volchik2000@list.ru>
Subject: Re: [R-SIG-Finance] Adding milliseconds to zoo object
To: <r-sig-finance@stat.math.ethz.ch>
Message-ID: <000c01c847da$08278730$18769590$@ru>
Content-Type: text/plain;    charset="us-ascii"

Thank you for replies Gabor & Brian,

Yes I did read the previous threads concerning similar problem and I saw
Dirk's post:

>> I pad my high-resolution times with an eps=1.0-6 to make them distinct,
if
>> need be 

So I presume the question is better formulated as how to pad high-resolution
times with an eps to make them distinct given that we have original index
with non-unique values, but order in the file reflect their relative
position inside this time interval.

2007-12-24 06:14:00  22.00
2007-12-24 06:14:00  22.00
2007-12-24 06:15:00  22.00
2007-12-24 06:15:00  22.00

My current idea is to convert timestamps to factors and run tapply on them,
but probably there is a better solution.



------------------------------

Message: 6
Date: Wed, 26 Dec 2007 11:40:18 -0500
From: "Gabor Grothendieck" <ggrothendieck@gmail.com>
Subject: Re: [R-SIG-Finance] Adding milliseconds to zoo object
To: "Yuri Volchik" <volchik2000@list.ru>
Cc: r-sig-finance@stat.math.ethz.ch
Message-ID:
    <971536df0712260840o151c3328v4f84653e303d8a1@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Even though non-unique times form illegal zoo objects, both
zoo() and read.zoo() will allow you to create such illegal zoo objects
with a warning, rather than an error, in order to give you a chance to
fix them up into legal ones.  You can still extract and replace the times
in case you want to apply jitter or fixed increments and aggregate.zoo
will still work in case you want to summarize all points with the same
time into a single point. Here is an example of adding increments via
interpolation with numeric times:

> library(zoo)
> z <- zoo(11:15, c(1, 1, 2, 2, 5))
Warning message:
In zoo(11:15, c(1, 1, 2, 2, 5)) :
  some methods for "zoo" objects do not work if the index entries in
'order.by' are not unique
> z
1  1  2  2  5
11 12 13 14 15
> time(z) <- na.approx(ifelse(duplicated(time(z)), NA, time(z)))
> z
  1 1.5  2 3.5  5
11  12  13  14  15


On Dec 26, 2007 11:11 AM, Yuri Volchik <volchik2000@list.ru> wrote:
> Thank you for replies Gabor & Brian,
>
> Yes I did read the previous threads concerning similar problem and I saw
> Dirk's post:
>
> >> I pad my high-resolution times with an eps=1.0-6 to make them distinct,
> if
> >> need be
>
> So I presume the question is better formulated as how to pad high-resolution
> times with an eps to make them distinct given that we have original index
> with non-unique values, but order in the file reflect their relative
> position inside this time interval.
>
> 2007-12-24 06:14:00  22.00
> 2007-12-24 06:14:00  22.00
> 2007-12-24 06:15:00  22.00
> 2007-12-24 06:15:00  22.00
>
> My current idea is to convert timestamps to factors and run tapply on them,
> but probably there is a better solution.
>
>
> _______________________________________________
> R-SIG-Finance@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>



------------------------------

Message: 7
Date: Wed, 26 Dec 2007 14:17:58 -0500
From: "Gabor Grothendieck" <ggrothendieck@gmail.com>
Subject: Re: [R-SIG-Finance] Adding milliseconds to zoo object
To: "Yuri Volchik" <volchik2000@list.ru>
Cc: r-sig-finance@stat.math.ethz.ch
Message-ID:
    <971536df0712261117x4d9e2040me1484196cbfbe5ec@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Dec 26, 2007 11:40 AM, Gabor Grothendieck <ggrothendieck@gmail.com> wrote:
> Even though non-unique times form illegal zoo objects, both
> zoo() and read.zoo() will allow you to create such illegal zoo objects
> with a warning, rather than an error, in order to give you a chance to
> fix them up into legal ones.  You can still extract and replace the times
> in case you want to apply jitter or fixed increments and aggregate.zoo
> will still work in case you want to summarize all points with the same
> time into a single point. Here is an example of adding increments via
> interpolation with numeric times:
>
> > library(zoo)
> > z <- zoo(11:15, c(1, 1, 2, 2, 5))
> Warning message:
> In zoo(11:15, c(1, 1, 2, 2, 5)) :
>  some methods for "zoo" objects do not work if the index entries in
> 'order.by' are not unique
> > z
>  1  1  2  2  5
> 11 12 13 14 15
> > time(z) <- na.approx(ifelse(duplicated(time(z)), NA, time(z)))
> > z
>  1 1.5  2 3.5  5
>  11  12  13  14  15

Just one follow up.  The code above will only work if the last
point in the series is at a unique time point.

Here is a solution that also deletes trailing duplicates so
it should be ok even in that case:

> z <- zoo(11:15, c(1, 1, 2, 2, 2))
Warning message:
In zoo(11:15, c(1, 1, 2, 2, 2)) :
  some methods for "zoo" objects do not work if the index entries in
'order.by' are not unique
> time(z) <- na.approx(ifelse(duplicated(time(z)), NA, time(z)), na.rm = FALSE)
> z <- z[!is.na(time(z))]
> z
  1 1.5  2
11  12  13


>
>
>
> On Dec 26, 2007 11:11 AM, Yuri Volchik <volchik2000@list.ru> wrote:
> > Thank you for replies Gabor & Brian,
> >
> > Yes I did read the previous threads concerning similar problem and I saw
> > Dirk's post:
> >
> > >> I pad my high-resolution times with an eps=1.0-6 to make them distinct,
> > if
> > >> need be
> >
> > So I presume the question is better formulated as how to pad high-resolution
> > times with an eps to make them distinct given that we have original index
> > with non-unique values, but order in the file reflect their relative
> > position inside this time interval.
> >
> > 2007-12-24 06:14:00  22.00
> > 2007-12-24 06:14:00  22.00
> > 2007-12-24 06:15:00  22.00
> > 2007-12-24 06:15:00  22.00
> >
> > My current idea is to convert timestamps to factors and run tapply on them,
> > but probably there is a better solution.
> >
> >
> > _______________________________________________
> > R-SIG-Finance@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only.
> > -- If you want to post, subscribe first.
> >
>



------------------------------

Message: 8
Date: Wed, 26 Dec 2007 19:21:16 -0000
From: "Yuri Volchik" <volchik2000@list.ru>
Subject: Re: [R-SIG-Finance] Adding milliseconds to zoo object
To: "'Gabor Grothendieck'" <ggrothendieck@gmail.com>
Cc: r-sig-finance@stat.math.ethz.ch
Message-ID: <000d01c847f4$7d008ec0$7701ac40$@ru>
Content-Type: text/plain;    charset="us-ascii"

Thanks, very interesting solution, works like magic. The only (very minor)
inconvenience are NA's at the end but they can be removed or extrapolated.

Thanks once again.


-----Original Message-----
From: Gabor Grothendieck [mailto:ggrothendieck@gmail.com] 
Sent: Wednesday, December 26, 2007 4:40 PM
To: Yuri Volchik
Cc: r-sig-finance@stat.math.ethz.ch
Subject: Re: [R-SIG-Finance] Adding milliseconds to zoo object

Even though non-unique times form illegal zoo objects, both
zoo() and read.zoo() will allow you to create such illegal zoo objects
with a warning, rather than an error, in order to give you a chance to
fix them up into legal ones.  You can still extract and replace the times
in case you want to apply jitter or fixed increments and aggregate.zoo
will still work in case you want to summarize all points with the same
time into a single point. Here is an example of adding increments via
interpolation with numeric times:

> library(zoo)
> z <- zoo(11:15, c(1, 1, 2, 2, 5))
Warning message:
In zoo(11:15, c(1, 1, 2, 2, 5)) :
  some methods for "zoo" objects do not work if the index entries in
'order.by' are not unique
> z
1  1  2  2  5
11 12 13 14 15
> time(z) <- na.approx(ifelse(duplicated(time(z)), NA, time(z)))
> z
  1 1.5  2 3.5  5
11  12  13  14  15



------------------------------

Message: 9
Date: Wed, 26 Dec 2007 15:50:44 -0500
From: Markus Loecher <markus@insightfromdata.com>
Subject: [R-SIG-Finance] get.hist.quote stalls
To: <r-sig-finance@stat.math.ethz.ch>
Message-ID: <C39828D4.43A%markus@insightfromdata.com>
Content-Type: text/plain;    charset="US-ASCII"

Dear all,
I am trying to download a few thousand financial timeseries from
yahoo.finance using get.hist.quote().
It worked great initially, but for some reason, my loop seems to always get
stuck after ~1500 requests. R becomes completely unresponsive and I need to
restart it (MAC OS). As these are daily aggregates for just a year, this
should not be a memory/data size problem.
Does Yaho protect itself against such automated scripts ?
If so, why does my get.hist.quote function not simply time out after a few
minutes ?

Any help would be immensely useful,

Thanks,
Markus



------------------------------

Message: 10
Date: Wed, 26 Dec 2007 22:21:34 +0000
From: Patrick Burns <patrick@burns-stat.com>
Subject: Re: [R-SIG-Finance] get.hist.quote stalls
To: Markus Loecher <markus@insightfromdata.com>
Cc: r-sig-finance@stat.math.ethz.ch
Message-ID: <4772D3EE.9090509@burns-stat.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

It could be a memory issue if you are growing
objects instead of creating an object the final
size and then subscripting into it with the assignment.


Patrick Burns
patrick@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

Markus Loecher wrote:

>Dear all,
>I am trying to download a few thousand financial timeseries from
>yahoo.finance using get.hist.quote().
>It worked great initially, but for some reason, my loop seems to always get
>stuck after ~1500 requests. R becomes completely unresponsive and I need to
>restart it (MAC OS). As these are daily aggregates for just a year, this
>should not be a memory/data size problem.
>Does Yaho protect itself against such automated scripts ?
>If so, why does my get.hist.quote function not simply time out after a few
>minutes ?
>
>Any help would be immensely useful,
>
>Thanks,
>Markus
>
>_______________________________________________
>R-SIG-Finance@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>-- Subscriber-posting only. 
>-- If you want to post, subscribe first.
>
>
>  
>



------------------------------

Message: 11
Date: Wed, 26 Dec 2007 18:57:48 -0600
From: "Walt Keneipp" <WKeneipp@stormproducts.com>
Subject: [R-SIG-Finance] Non-financial "seasonality"
To: <r-sig-finance@stat.math.ethz.ch>
Message-ID:
    <A7380169D8B74E48845894A481017AD301F364E8@wdgmxsms01.stormproducts.com>
    
Content-Type: text/plain;    charset="us-ascii"

We have a dataset with frequency from 40 to 1200 MHz in .01 MHz
increments, and corresponding amplitude in db.  There are spikes in
amplitude near 60 Hz and its harmonics caused by the AC line.  The
spikes are not necessarily AT 60 Hz, but vary between 59 and 61.  Is
there a good way to filter out these spikes?  If not, would smoothing be
the way to go?

Walt Keneipp
wkeneipp@stormproducts.com



------------------------------

_______________________________________________
R-SIG-Finance mailing list
R-SIG-Finance@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-finance


End of R-SIG-Finance Digest, Vol 43, Issue 20
*********************************************
	[[alternative HTML version deleted]]

