[R-SIG-Finance] TTR's RSI
Hae Kyung Im
haky.im at gmail.com
Wed Apr 29 01:46:16 CEST 2009
well... this time with the attachment
On Tue, Apr 28, 2009 at 6:43 PM, Hae Kyung Im <haky.im at gmail.com> wrote:
> Hi Josh,
>
> I am attaching the following files
>
> test.Rdata (with data.xmin, the xts object)
> replic.r
> replic.output.txt (output when I source replic.r)
>
> Thanks
> Haky
>
>
> On Tue, Apr 28, 2009 at 5:49 PM, Josh Ulrich <josh.m.ulrich at gmail.com> wrote:
>> Hi Haky,
>>
>> Could you provide more information? I cannot replicate your results.
>>
>>> Lines <- " Open High Low Close Volume
>> \"2008-03-16 17:00:00\" 119 120 119 119 1305
>> \"2008-03-16 18:00:00\" 119 120 119 120 3237
>> \"2008-03-16 19:00:00\" 120 120 120 120 2813
>> \"2008-03-16 20:00:00\" 120 120 120 120 2857
>> \"2008-03-16 21:00:00\" 120 120 120 120 4561
>> \"2008-03-16 22:00:00\" 120 120 120 120 1988
>> \"2008-03-16 23:00:00\" 120 120 120 120 805
>> \"2008-03-17 00:00:00\" 120 120 120 120 1177
>> \"2008-03-17 01:00:00\" 120 120 120 120 1245
>> \"2008-03-17 02:00:00\" 120 120 120 120 1263
>> \"2008-03-17 03:00:00\" 120 120 120 120 5565
>> \"2008-03-17 04:00:00\" 120 120 120 120 4081
>> \"2008-03-17 05:00:00\" 120 120 120 120 4462
>> \"2008-03-17 06:00:00\" 120 120 120 120 12409
>> \"2008-03-17 07:00:00\" 120 120 119 119 34083
>> \"2008-03-17 08:00:00\" 119 120 119 120 34742
>> \"2008-03-17 09:00:00\" 120 120 120 120 29412
>> \"2008-03-17 10:00:00\" 120 120 120 120 40087
>> \"2008-03-17 11:00:00\" 120 120 120 120 21834
>> \"2008-03-17 12:00:00\" 120 120 120 120 26442
>> \"2008-03-17 13:00:00\" 120 120 120 120 36671
>> \"2008-03-17 14:00:00\" 120 120 120 120 20468
>> \"2008-03-17 15:00:00\" 120 120 120 120 8802"
>>> data.60min <- read.table(textConnection(Lines))
>>> dim(data.60min)
>> [1] 23 5
>>> #class(data.xmin) # I don't know what the 'data.xmin' object is...
>>> class(data.60min)
>> [1] "data.frame"
>>> length(RSI(data.60min[,"Close"]))
>> [1] 23
>>> length(RSI(as.xts(data.60min)[,"Close"]))
>> [1] 23
>>> sessionInfo()
>> R version 2.9.0 (2009-04-17)
>> i386-unknown-freebsd7.1
>>
>> locale:
>> C
>>
>> attached base packages:
>> [1] stats graphics grDevices utils datasets methods base
>>
>> other attached packages:
>> [1] TTR_0.2-1 xts_0.6-4 zoo_1.5-5
>>
>> loaded via a namespace (and not attached):
>> [1] grid_2.9.0 lattice_0.17-22
>>
>> Best,
>> Josh
>> --
>> http://quantemplation.blogspot.com
>> http://www.fosstrading.com
>>
>>
>>
>> On Tue, Apr 28, 2009 at 5:29 PM, Hae Kyung Im <haky.im at gmail.com> wrote:
>>> Hi,
>>>
>>> for some reason when I calculate RSI on a xts object of length n, I
>>> get a result of length n+1 as in the following example:
>>>
>>>> dim(data.60min)
>>> [1] 23 5
>>>
>>>> class(data.xmin)
>>> [1] "xts" "zoo"
>>>
>>>> length(RSI(data.60min[,"Close"]))
>>> [1] 24
>>>
>>> If I plug in a vector of length 23, RSI gives me a vector of length 23.
>>>
>>>> length(RSI(runif(23)))
>>> [1] 23
>>>
>>> am I missing something here?
>>>
>>> Thanks
>>> Haky
>>>
>>>
>>> --------------------------------------------
>>> Here is the data for your reference:
>>>> data.60min
>>> Open High Low Close Volume
>>> 2008-03-16 17:00:00 119 120 119 119 1305
>>> 2008-03-16 18:00:00 119 120 119 120 3237
>>> 2008-03-16 19:00:00 120 120 120 120 2813
>>> 2008-03-16 20:00:00 120 120 120 120 2857
>>> 2008-03-16 21:00:00 120 120 120 120 4561
>>> 2008-03-16 22:00:00 120 120 120 120 1988
>>> 2008-03-16 23:00:00 120 120 120 120 805
>>> 2008-03-17 00:00:00 120 120 120 120 1177
>>> 2008-03-17 01:00:00 120 120 120 120 1245
>>> 2008-03-17 02:00:00 120 120 120 120 1263
>>> 2008-03-17 03:00:00 120 120 120 120 5565
>>> 2008-03-17 04:00:00 120 120 120 120 4081
>>> 2008-03-17 05:00:00 120 120 120 120 4462
>>> 2008-03-17 06:00:00 120 120 120 120 12409
>>> 2008-03-17 07:00:00 120 120 119 119 34083
>>> 2008-03-17 08:00:00 119 120 119 120 34742
>>> 2008-03-17 09:00:00 120 120 120 120 29412
>>> 2008-03-17 10:00:00 120 120 120 120 40087
>>> 2008-03-17 11:00:00 120 120 120 120 21834
>>> 2008-03-17 12:00:00 120 120 120 120 26442
>>> 2008-03-17 13:00:00 120 120 120 120 36671
>>> 2008-03-17 14:00:00 120 120 120 120 20468
>>> 2008-03-17 15:00:00 120 120 120 120 8802
>>>
>>> _______________________________________________
>>> R-SIG-Finance at 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.
>>>
>>
>
-------------- next part --------------
R version 2.8.1 (2008-12-22)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> options(STERM='iESS', editor='emacsclient')
> ## test
>
> rm(list=ls())
> options(digits=3,digits.sec=4)
> library(quantmod)
Loading required package: xts
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
Loading required package: Defaults
quantmod: Quantitative Financial Modelling Framework
Version 0.3-7, Revision 461
http://www.quantmod.com
> library(TTR)
> load('test.Rdata')
> ls()
[1] "data.xmin"
> class(data.xmin)
[1] "xts" "zoo"
> dim(data.xmin)
[1] 90 5
> length(RSI(data.xmin[,"Close"]))
[1] 91
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.Rdata
Type: application/octet-stream
Size: 1340 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20090428/35dadc36/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: replic.r
Type: application/octet-stream
Size: 173 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20090428/35dadc36/attachment-0001.obj>
More information about the R-SIG-Finance
mailing list