Re: [R] [R-SIG-Finance] RTAQ - convert function: warning causes incorrect loading of data

2012-10-13 Thread Jeff Ryan
FWIW %m is the proper conversion for months. %M is minutes. 

Looks like a bug. 

Jeffrey Ryan|Founder|jeffrey.r...@lemnica.com

www.lemnica.com

On Oct 13, 2012, at 10:33 AM, Nicolae Caprarescu capra...@cs.man.ac.uk wrote:

 Hi Michael,
 
 Thank you for pointing me in the right direction, I'm now using an email
 client rather than Nabble.
 
 Related to the issue I described below, it's resolved now, I have managed
 to fix it myself. However, I believe this might be a bug, or at least
 something that needs improving; I have described both how to reproduce this
 issue and its solution in the below 4 steps:
 1) library(RTAQ)
 2) Create XXX_trades.csv file with the contents below using a relative
 path like [somewhere]/TAQData/2010-11-01/XXX_trades.csv
 SYMBOL,DATE,TIME,PRICE,SIZE,G127,CORR,COND,EX
 XXX,20101101,10:30:00,11.49,500,0,0,@,B
 XXX,20101101,10:30:02,11.49,322,0,0,0,B
 XXX,20101101,10:30:02,11.49,178,0,0,@,B
 XXX,20101101,10:30:03,11.49,500,0,0,@,B
 XXX,20101101,10:30:03,11.49,187,0,0,@,D
 3) 
 #convert does not generate any errors/warnings, however it does not work
 properly
 convert(from=2010-11-01,
 to=2010-11-01,datasource=[somewhere]/TAQData/,
 datadestination=[somewhere]/TAQDataRData/,trades=T,quotes=F,ticker=XXX,dir=T,
 extention=csv, header=T, tradecolnames=c(SYMBOL, DATE, TIME,
 PRICE, SIZE, G127, CORR, COND, EX))
 #loading the RData created by convert
 TAQLoad(XXX,from=2010-11-01,to=2010-11-01,datasource=[somewhere]TAQDataRData/,
 trades=T,quotes=F)
 #output of TAQLoad 
 SYMBOL EX  PRICE   SIZE  COND CORR G127
 NA XXX  B 11.49 500 @  0  0 
 NA XXX  B 11.49 322 0  0  0 
 NA XXX  B 11.49 178 @  0  0 
 NA XXX  B 11.49 500 @  0  0 
 NA XXX  D 11.49 187 @  0  0 
 Warning message:
 timezone of object (GMT) is different than current timezone (). 
 
 Problem are the NAs. If one does not supply the format of date and time
 to the convert function, it is assumed that the standard NYSE format is
 used, and therefore RTAQ internally (convert_to_RData.r line 32) represents
 this as Y%M%D %H:%M:%S. Whilst this works fine for some things, when a
 timeDate is initialised using this format (convert_to_RData.r line 102), it
 does not work. timeDate expects a correct format like %Y%m%d %H:%M:%S
 format rather than Y%M%D %H:%M:%S.
 Run the below two to confirm: 
 tdobject=timeDate:::timeDate(paste(as.vector(2010-10-11),
 as.vector(10:30:30)), format=%Y%M%D
 %H:%M:%S,FinCenter=GMT,zone=GMT)
 #tdobject is GMT [1] [NA]
 tdobject=timeDate:::timeDate(paste(as.vector(20101011),
 as.vector(10:30:30)), format=%Y%m%d
 %H:%M:%S,FinCenter=GMT,zone=GMT)
 #tdobject is now GMT [1] [2010-10-11 10:30:30]
 
 Therefore, if one explicitly includes format=%Y%m%d %H:%M:%S in the
 convert function, everything works fine and the NA problem above is
 solved; this is my solution. Can I please suggest that, once you
 investigate this and provided that you confirm my understanding,
 convert_to_RData.r is changed in order to use %Y%m%d %H:%M:%S as the
 default format? 
 
 4) My environment:
 R version 2.15.1 (2012-06-22)
 Platform: i686-pc-linux-gnu (32-bit)
 
 locale:
 [1] LC_CTYPE=en_GB   LC_NUMERIC=C LC_TIME=en_GB   
 [4] LC_COLLATE=C LC_MONETARY=en_GBLC_MESSAGES=en_GB   
 [7] LC_PAPER=C   LC_NAME=CLC_ADDRESS=C
 [10] LC_TELEPHONE=C   LC_MEASUREMENT=en_GB LC_IDENTIFICATION=C 
 
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base 
 
 other attached packages:
 [1] RTAQ_0.2 timeDate_2160.97 xts_0.8-6zoo_1.7-8   
 
 loaded via a namespace (and not attached):
 [1] grid_2.15.1lattice_0.20-6
 
 
 Best wishes,
 Nicolae
 
 
 
 On Fri, 12 Oct 2012 21:52:22 +0100, R. Michael Weylandt
 michael.weyla...@gmail.com wrote:
 I'm forwarding this to the R-SIG-Finance list, where ou'll have a more
 specialized audience.
 
 In the meanwhile, you may wish to look at
 
 http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
 
 Finally, I note you're posting from Nabble. Please do include context in
 your reply -- I don't believe Nabble does this automatically, so
 you'll need to manually include it. Most of the regular respondents on
 these lists don't use Nabble -- it is a _mailing list_ after all -- so
 we don't get the forum view you do, only emails of the individual
 posts. Combine that with the high volume of posts, and it's quite
 difficult to trace a discussion if we all don't make sure to include
 context.
 
 Cheers,
 Michael
 
 On Fri, Oct 12, 2012 at 7:01 PM, caprarn9 capra...@cs.man.ac.uk wrote:
 Hello,
 
 I am closely following the RTAQ documentation in order to load my
 dataset
 into R, however I get this warning when running the convert function in
 the
 following way:
 
 convert(from=2010-11-01, to=2010-11-01,datasource=datasource,
 datadestination=datadestination,trades=T,quotes=T,ticker=BAC,dir=T,
 extention=csv, header=T, tradecolnames=c(SYMBOL, DATE, TIME,
 

Re: [R] [R-sig-hpc] Quickest way to make a large empty file on disk?

2012-05-02 Thread Jeff Ryan
Look at the man page for dd (assuming you are on *nix)

A quick google will get you a command to try. I'm not at my desk or I would as 
well. 

Jeff

Jeffrey Ryan|Founder|jeffrey.r...@lemnica.com

www.lemnica.com

On May 2, 2012, at 5:23 PM, Jonathan Greenberg j...@illinois.edu wrote:

 R-helpers:
 
 What would be the absolute fastest way to make a large empty file (e.g.
 filled with all zeroes) on disk, given a byte size and a given number
 number of empty values.  I know I can use writeBin, but the object in
 this case may be far too large to store in main memory.  I'm asking because
 I'm going to use this file in conjunction with mmap to do parallel writes
 to this file.  Say, I want to create a blank file of 10,000 floating point
 numbers.
 
 Thanks!
 
 --j
 
 -- 
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 http://www.geog.illinois.edu/people/JonathanGreenberg.html
 
[[alternative HTML version deleted]]
 
 ___
 R-sig-hpc mailing list
 r-sig-...@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-hpc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [R-sig-hpc] Quickest way to make a large empty file on disk?

2012-05-02 Thread Jeff Ryan
Something like:

http://markus.revti.com/2007/06/creating-empty-file-with-specified-size/

Is one way I know of. 

Jeff

Jeffrey Ryan|Founder|jeffrey.r...@lemnica.com

www.lemnica.com

On May 2, 2012, at 5:23 PM, Jonathan Greenberg j...@illinois.edu wrote:

 R-helpers:
 
 What would be the absolute fastest way to make a large empty file (e.g.
 filled with all zeroes) on disk, given a byte size and a given number
 number of empty values.  I know I can use writeBin, but the object in
 this case may be far too large to store in main memory.  I'm asking because
 I'm going to use this file in conjunction with mmap to do parallel writes
 to this file.  Say, I want to create a blank file of 10,000 floating point
 numbers.
 
 Thanks!
 
 --j
 
 -- 
 Jonathan A. Greenberg, PhD
 Assistant Professor
 Department of Geography and Geographic Information Science
 University of Illinois at Urbana-Champaign
 607 South Mathews Avenue, MC 150
 Urbana, IL 61801
 Phone: 415-763-5476
 AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007
 http://www.geog.illinois.edu/people/JonathanGreenberg.html
 
[[alternative HTML version deleted]]
 
 ___
 R-sig-hpc mailing list
 r-sig-...@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-hpc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Another quantmod question

2011-05-08 Thread Jeff Ryan
Hi Russ,

Colnames don't get rewritten if they already exist. The reason is due to 
performance and how cbind is written at the R level. 

It isn't perfect per se, but the complexity and variety of dispatch that can 
take place for cbind in R, as it isn't a generic, is quite challenging to get 
to behave as one may hope.  After years of trying I'd say it is nearly 
impossible to do what you want without causing horrible memory issues on non 
trivial objects they are use in production systems **using** xts on objects 
with billions of rows.  Your simple case that has a simple workaround would 
cost everyone using in the other 99.999% of cases to pay a recurring cost that 
isn't tolerable. 

If this is frustrating to you you should stop using the class. 

Jeff

Jeffrey Ryan|Founder|jeffrey.r...@lemnica.com

www.lemnica.com

On May 8, 2011, at 2:07 PM, Russ Abbott russ.abb...@gmail.com wrote:

 I'm having troubles with the names of columns.
 
 quantmod deal with stock quotes.  I've created an array of the first 5 
 closing prices from Jan 2007. (Is there a problem that the name is the same 
 as the variable name? There shouldn't be.)
 
 
  close
 
 
 
  close
 
 2007-01-03 1416.60
 
 2007-01-04 1418.34
 
 2007-01-05 1409.71
 
 2007-01-08 1412.84
 
 2007-01-09 1412.11
 
 When I try to create a more complex array by adding columns, the names get 
 fouled up.  Here's a simple example.
 
 
 
  cbind(changed.close = close+1, zero = 0, close)
 
 
 
 
  close zero close.1
 
 
 2007-01-03 1417.600 1416.60
 
 
 2007-01-04 1419.340 1418.34
 
 
 2007-01-05 1410.710 1409.71
 
 
 2007-01-08 1413.840 1412.84
 
 
 2007-01-09 1413.110 1412.11
 
 The first column should be called changed.close, but it's called close. 
 The second column has the right name. The third column should be called 
 close but it's called close.1. Why is that? Am I missing something?
 
 If I change the order of the columns and let close have its original name, 
 there is still a problem.
 
 
  cbind(close, zero = 0, changed.close = close+1)
 
 
 
  close zero close.1
 
 2007-01-03 1416.600 1417.60
 
 2007-01-04 1418.340 1419.34
 
 2007-01-05 1409.710 1410.71
 
 2007-01-08 1412.840 1413.84
 
 2007-01-09 1412.110 1413.11
 
 Now the names on the first two columns are ok, but the third column is still 
 wrong. Again, why is that?  Apparently it's not letting me assign a name to a 
 column that comes from something that already has a name.  Is that the way it 
 should be?
 
 I don't get that same problem on a simpler example.
 
 
 
  IX - cbind(I=0, X=(1:3))
  IX
 
  I X
 
 [1,] 0 1
 
 [2,] 0 2
 
 [3,] 0 3
 
  cbind(Y = 1, Z = IX[, I], W = IX[, X])
 
  Y Z W
 
 [1,] 1 0 1
 
 [2,] 1 0 2
 
 [3,] 1 0 3
 
 Is this a peculiarity to xts objects?
 
 Thanks.
  
 -- Russ 
 
 P.S. Once again I feel frustrated because it's taken me far more time than it 
 deserves to track down and characterize this problem. I can fix it by using 
 the names function. But I shouldn't have to do that.  

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Another quantmod question

2011-05-08 Thread Jeff Ryan
  0.152   0.000   0.153

Yep, nearly 10x faster than a matrix op - AND you still have the time index.
To get there you need to sometimes make sacrifices.  xts does, though I like
to think they are well thought out and consistent*

*enough ;-)

Best,
Jeff


On Sun, May 8, 2011 at 8:57 PM, Joshua Ulrich josh.m.ulr...@gmail.comwrote:

 Russ,

 On May 8, 2011 6:29 PM, Russ Abbott russ.abb...@gmail.com wrote:
 
  Hi Jeff,
 
  The xts class has some very nice features, and you have done a valuable
  service in developing it.
 
  My primary frustration is how difficult it seems to be to find out what
 went
  wrong when my code doesn't work.  I've been writing quite sophisticated
 code
  for a fairly long time. It's not that I'm new to software development.
 
  The column name rule is a good example.  I'm willing to live with the
 rule
  that column names are not changed for efficiency sake.  What's difficult
 for
  me is that I never saw that rule anywhere before.  Of course, I'm not an
 R
  expect. I've been using it for only a couple of months. But still, I
 would
  have expected to run into a rule like that.
 
  Worse, since the rule is in conflict with the explicit intent of
 cbind--one
  can name columns when using cbind; in fact the examples illustrate how to
 do
  it--it would really be nice of cbind would issue a warning when one
 attempts
  to rename a column in violation of that rule.  Instead, cbind is silent,
  giving no hint about what went wrong.
 
 Naming columns is not the explicit intent of cbind.  The explicit
 intent is to combine objects by columns.  Please don't overstate the
 case.

 While the examples for the generic show naming columns, neither
 ?cbind.zoo or ?cbind.xts have such examples.  That's a hint.

  It's those sorts of things that have caused me much frustration. And it's
  these sorts of things that seem pervasive in R.  One never knows what one
 is
  dealing with. Did something not work because there is a special case rule
  that I haven't heard of? Did it not work because a special convenience
 was
  programmed into a function in a way that conflicted with normal use?
  Since
  these sorts of things seem to come up so often, I find myself feeling
 that
  there is no good way to track down problems, which leads to a sense of
  helplessness and confusion. That's not what one wants in a programming
  language.
 
 If that's not what one wants, one can always write their own
 programming language.

 Seriously, it seems like you want to rant more than understand what's
 going on.  You have the R and xts help pages and the source code.  The
 Note section of help(cbind) tells you that the method dispatch is
 different.  It even tells you what R source file to look at to see how
 dispatching is done.  Compare the relevant source files from
 base::cbind and xts::cbind.xts, look at the R Language Definition
 manual to see how method dispatch is normally done.

 But you've been writing quite sophisticated code for a fairly long
 time, so I'm not telling you anything you don't know... you just don't
 think you should have to do the legwork.

  -- Russ
 
 

 --
 Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



  On Sun, May 8, 2011 at 2:42 PM, Jeff Ryan jeff.a.r...@gmail.com wrote:
 
   Hi Russ,
  
   Colnames don't get rewritten if they already exist. The reason is due
 to
   performance and how cbind is written at the R level.
  
   It isn't perfect per se, but the complexity and variety of dispatch
 that
   can take place for cbind in R, as it isn't a generic, is quite
 challenging
   to get to behave as one may hope.  After years of trying I'd say it is
   nearly impossible to do what you want without causing horrible memory
 issues
   on non trivial objects they are use in production systems **using** xts
 on
   objects with billions of rows.  Your simple case that has a simple
   workaround would cost everyone using in the other 99.999% of cases to
 pay a
   recurring cost that isn't tolerable.
  
   If this is frustrating to you you should stop using the class.
  
   Jeff
  
   Jeffrey Ryan|Founder| jeffrey.r...@lemnica.com
   jeffrey.r...@lemnica.com
  
   www.lemnica.com
  
   On May 8, 2011, at 2:07 PM, Russ Abbott russ.abb...@gmail.com wrote:
  
   I'm having troubles with the names of columns.
  
   quantmod deal with stock quotes.  I've created an array of the first 5
   closing prices from Jan 2007. (Is there a problem that the name is the
 same
   as the variable name? There shouldn't be.)
  
close
  
close
  
   2007-01-03 1416.60
  
   2007-01-04 1418.34
  
   2007-01-05 1409.71
  
   2007-01-08 1412.84
  
   2007-01-09 1412.11
  
  
   When I try to create a more complex array by adding columns, the names
 get
   fouled up.  Here's a simple example.
  
cbind(changed.close = close+1, zero = 0, close)
  
close zero close.1
  
   2007-01-03 1417.600 1416.60
  
   2007-01-04 1419.340 1418.34
  
   2007-01-05

Re: [R] quantmod's addTA plotting functions

2011-05-05 Thread Jeff Ryan
There is a struggle in documentation that revolves around being too brief to
be useful and too verbose which then is often ignored.  In general, R
proper is far less verbose than quantmod docs - so if you have trouble
with quantmod...

from ?addTA

Value:

 ‘addTA’ will invisibly return an S4 object of class ‘chobTA’. If
 this function is called interactively, the ‘chobTA’ object will be
 evaluated and added to the current chart.

 ‘newTA’ will return a function object that can either be assigned
 or evaluated.  Evaluating this function will follow the logic of
 any standard addTA-style call, returning invisibly a ‘chobTA’
 object, or adding to the chart.

In addition there is a see also that references ?TA

One can also use the archives to see this problem discussed over and over.
 It isn't for lack of documentation typically - it is for lack of looking.

That said, could the docs be more clear/verbose?  Certainly.  Does that take
time?  Certainly.  Does answering the same question in a public forum take
time? Certainly.  What the latter does though is provide for an excellent
reference for those who misunderstand or don't understand the 'Value' aspect
of the docs (which here explains quite clearly that nothing is printed by
the call itself).

A suitably phrased patch for the docs is one way to contribute in a
productive manner - though it may not always be applied by those you submit
it to (to me or any of the other 3000 package author/maintainers/etc).

HTH
Jeff

On Thu, May 5, 2011 at 11:42 AM, Russ Abbott russ.abb...@gmail.com wrote:

 Thanks. You're right. I didn't see that.  I read the ?addTA help page,
 which (annoyingly) didn't mention that feature, but I didn't read the ?TA
 page. (That page was mentioned as a see also, but not as a must see.)

 I don't know what it means to wrap these calls in a plot call. I tried to
 put the addTA calls into a function and call that function from the higher
 level function, but that didn't work either. Would you tell me what it means
 to wrap these calls in a plot call.

 Thanks

 *-- Russ *

 P.S. Pardon my irritation, but I continually find that many of the help
 files assume one already knows the information one is looking for. If you
 don't know it, the help files are not very helpful.  This is a good example.
  In fact, it's two good examples.  I didn't know that I had to look at
 another page, and I (still) don't know what it means to wrap plot calls in
 another plot call.


 On Thu, May 5, 2011 at 3:39 AM, P Ehlers ehl...@ucalgary.ca wrote:

 On 2011-05-05 0:47, Russ Abbott wrote:

 Hi,

 I'm having trouble with quantmod's addTA plotting functions.  They seem
 to
 work fine when run from the command line. But when run inside a function,
 only the last one run is visible.  Here's an example.


 test.addTA- function(from = 2010-06-01) {
 getSymbols(^GSPC, from = from)
 GSPC.close- GSPC[,GSPC.Close]
 GSPC.EMA.3- EMA(GSPC.close, n=3, ratio=NULL)
 GSPC.EMA.10- EMA(GSPC.close, n=10, ratio=NULL)
 chartSeries(GSPC.close, theme=chartTheme('white'), up.col=black,
 dn.col=black)
 addTA(GSPC.EMA.3,   on = 1, col = #ff)
 addTA(GSPC.EMA.10,  on = 1, col = #ff)
 # browser()
 }


 When I run this, GSPC.close always appears.  But only GSPC.EMA10 appears
 on
 the plot along with it. If I switch the order of the addTA calls,
 only GSPC.EMA3 appears. If I uncomment the call to browser() neither
 appears
 when the browser() interrupt occurs. I can then draw both GSPC.EMA.3 and
 GSPC.EMA10 manually, and let the function terminate. All intended plots
 are
 visible after the function terminates. So it isn't as if one wipes out
 the
 other. This shows that it's possible to get all three lines on the plot,
 but
 I can't figure out how to do it without manual intervention. Any
 suggestions
 are appreciated.


 Perhaps you didn't see this NOTE on the ?TA help page:

 Calling any of the above methods from within a function
 or script will generally require them to be wrapped in a
 plot call as they rely on the context of the call to
 initiate the actual charting addition.

 Peter Ehlers


 Thanks.

 *-- Russ *

[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.





-- 
Jeffrey Ryan
jeffrey.r...@lemnica.com

www.lemnica.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] quantmod's addTA plotting functions

2011-05-05 Thread Jeff Ryan
Sorry, I forgot to give you a quick example of 'wrapping in plot'

plot(addTA(...))

The objects returned by most of the charting functions in quantmod results
from the desire for the functions to be syntactically identical whether
called from inside of chartSeries (e.g. TA=addMACD() ) as they are from
outside:

R addMACD()

The code the simplicity of this (and the lack of need for documenting 2
different functions, and learning all the details of 2 different functions
(2x the work)) you need to be a bit clever in how R works.  Describing that
is 1) not simple and 2) ironically, not very well documented in base R.  For
me to write it I just had to get around number 2.

HTH
Jeff

On Thu, May 5, 2011 at 11:55 AM, Jeff Ryan jeff.a.r...@gmail.com wrote:

 There is a struggle in documentation that revolves around being too brief
 to be useful and too verbose which then is often ignored.  In general, R
 proper is far less verbose than quantmod docs - so if you have trouble
 with quantmod...

 from ?addTA

 Value:

  ‘addTA’ will invisibly return an S4 object of class ‘chobTA’. If
  this function is called interactively, the ‘chobTA’ object will be
  evaluated and added to the current chart.

  ‘newTA’ will return a function object that can either be assigned
  or evaluated.  Evaluating this function will follow the logic of
  any standard addTA-style call, returning invisibly a ‘chobTA’
  object, or adding to the chart.

 In addition there is a see also that references ?TA

 One can also use the archives to see this problem discussed over and
 over.  It isn't for lack of documentation typically - it is for lack of
 looking.

 That said, could the docs be more clear/verbose?  Certainly.  Does that
 take time?  Certainly.  Does answering the same question in a public forum
 take time? Certainly.  What the latter does though is provide for an
 excellent reference for those who misunderstand or don't understand the
 'Value' aspect of the docs (which here explains quite clearly that nothing
 is printed by the call itself).

 A suitably phrased patch for the docs is one way to contribute in a
 productive manner - though it may not always be applied by those you submit
 it to (to me or any of the other 3000 package author/maintainers/etc).

 HTH
 Jeff

 On Thu, May 5, 2011 at 11:42 AM, Russ Abbott russ.abb...@gmail.comwrote:

 Thanks. You're right. I didn't see that.  I read the ?addTA help page,
 which (annoyingly) didn't mention that feature, but I didn't read the ?TA
 page. (That page was mentioned as a see also, but not as a must see.)

 I don't know what it means to wrap these calls in a plot call. I tried to
 put the addTA calls into a function and call that function from the higher
 level function, but that didn't work either. Would you tell me what it means
 to wrap these calls in a plot call.

 Thanks

 *-- Russ *

 P.S. Pardon my irritation, but I continually find that many of the help
 files assume one already knows the information one is looking for. If you
 don't know it, the help files are not very helpful.  This is a good example.
  In fact, it's two good examples.  I didn't know that I had to look at
 another page, and I (still) don't know what it means to wrap plot calls in
 another plot call.


 On Thu, May 5, 2011 at 3:39 AM, P Ehlers ehl...@ucalgary.ca wrote:

 On 2011-05-05 0:47, Russ Abbott wrote:

 Hi,

 I'm having trouble with quantmod's addTA plotting functions.  They seem
 to
 work fine when run from the command line. But when run inside a
 function,
 only the last one run is visible.  Here's an example.


 test.addTA- function(from = 2010-06-01) {
 getSymbols(^GSPC, from = from)
 GSPC.close- GSPC[,GSPC.Close]
 GSPC.EMA.3- EMA(GSPC.close, n=3, ratio=NULL)
 GSPC.EMA.10- EMA(GSPC.close, n=10, ratio=NULL)
 chartSeries(GSPC.close, theme=chartTheme('white'), up.col=black,
 dn.col=black)
 addTA(GSPC.EMA.3,   on = 1, col = #ff)
 addTA(GSPC.EMA.10,  on = 1, col = #ff)
 # browser()
 }


 When I run this, GSPC.close always appears.  But only GSPC.EMA10 appears
 on
 the plot along with it. If I switch the order of the addTA calls,
 only GSPC.EMA3 appears. If I uncomment the call to browser() neither
 appears
 when the browser() interrupt occurs. I can then draw both GSPC.EMA.3 and
 GSPC.EMA10 manually, and let the function terminate. All intended plots
 are
 visible after the function terminates. So it isn't as if one wipes out
 the
 other. This shows that it's possible to get all three lines on the plot,
 but
 I can't figure out how to do it without manual intervention. Any
 suggestions
 are appreciated.


 Perhaps you didn't see this NOTE on the ?TA help page:

 Calling any of the above methods from within a function
 or script will generally require them to be wrapped in a
 plot call as they rely on the context of the call to
 initiate the actual charting addition.

 Peter Ehlers


 Thanks.

 *-- Russ *

[[alternative HTML

[R] R/Finance 2011 Conference Agenda

2011-04-01 Thread Jeff Ryan
R community:

We're excited to post a preliminary agenda for the upcoming 3rd
conference on R and Applied Finance, to be held in Chicago on April
29th and 30th.

In addition to keynotes from John Bollinger, Mebane Faber, Stefano
Iacus and Louis Kates, we are excited to have 31 additional talks
covering the state of R and applied finance.

This represents a phenomenal opportunity to meet and interact with
some of the leading contributors in the field of finance, all with
relevant contributions using R.  We expect more than 200 participants
from industry, government, and academia for the 2 day event.  In
addition, a conference dinner Friday evening in the heart of the
financial district along Chicago's picturesque river will offer an
unprecedented opportunity to enjoy amazing food, drink and
conversation.

http://www.rinfinance.com/agenda/index.html

Registration is open, though pre-conference workshops are rapidly filling up.

Register now and join your fellow colleagues at R/Finance 2011!
http://www.rinfinance.com/register/



Thanks to our 2011 Co-Sponsors and Sponsors:

  International Center for Futures and Derivatives at UIC
  REvolution Analytics

  OneMarketData
  RStudio
  lemnica

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [R-SIG-Finance] Derivative of a smooth function

2010-04-02 Thread Jeff Ryan
Please keep in mind this question has absolutely nothing to do with
finance, and therefore needs to instead be directed to R-help.

Thanks in advance for keeping the R-finance list on topic.

Jeff

On Fri, Apr 2, 2010 at 3:36 AM, FMH kagba2...@yahoo.com wrote:

 Dear All,

 I've been searching for appropriate codes to compute the rate of change and 
 the curvature of  nonparametric regression model whish was denoted by a 
 smooth function but unfortunately don't manage to do it. I presume that such 
 characteristics from a smooth curve can be determined by the first and second 
 derivative operators.

 The following are the example of fitting a nonparametric regression model via 
 smoothing spline function from the Help file in R.

 ###
 attach(cars)
 plot(speed, dist, main = data(cars)    smoothing splines)
 cars.spl - smooth.spline(speed, dist)
 lines(cars.spl, col = blue)
 lines(smooth.spline(speed, dist, df=10), lty=2, col = red)
 legend(5,120,c(paste(default [C.V.] = df =,round(cars.spl$df,1)),s( * , 
 df = 10)), col = c(blue,red), lty = 1:2, bg='bisque')
 detach()

 ###


 Could someone please advice me the appropriate way to determine such 
 derivatives on the curves which were fitted by the function above and would 
 like to thank you in advance.

 Cheers
 Fir





 ___
 r-sig-fina...@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.
 -- Also note that this is not the r-help list where general R questions 
 should go.




-- 
Jeffrey Ryan
jeffrey.r...@insightalgo.com

ia: insight algorithmics
www.insightalgo.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [R-sig-DB] How to save a model in DB and retrieve It

2010-04-02 Thread Jeff Ryan
A very simple option, since you're only looking to efficiently store
and retrieve, is something like a key-value store.

There is a new rredis (redis) package on CRAN, as well as the
RBerkeley (Oracle Berkeley DB) package.

RBerkeley is as simple as db_put() and db_get() calls where you
specify a key and serialize/unserialize the object before and after.

Caveat to RBerkeley is that it is only functional on *nix until
someone contributes a Windows version or insight on what I need to do
to make that work (issue is that Berkeley DB can't be compiled easily
using the R version of mingw to compile).  The package code is likely
to work for windows if you can manage to get the db headers/libs
installed with the R toolchain.

HTH
Jeff

On Fri, Apr 2, 2010 at 3:37 AM, Daniele Amberti daniele.ambe...@ors.it wrote:
 I'm wondering how to save an object (models like lm, loess, etc) in a DB to 
 retrieve and use it afterwards, an example:

 wind_ms - abs(rnorm(24*30)*4+8)
 air_kgm3 - rnorm(24*30, 0.1)*0.1 + 1.1
 wind_dg - rnorm(24*30) * 360/7
 ms - c(0:25)
 kw_mm92 - c(0,0,0,20,94,205,391,645,979,1375,1795,2000,2040)
 kw_mm92 - c(kw_mm92, rep(2050, length(ms)-length(kw_mm92)))
 modelspline - splinefun(ms, kw_mm92)
 kw - abs(modelspline(wind_ms) - (wind_dg)*2 + (air_kgm3 - 1.15)*300 + 
 rnorm(length(wind_ms))*10)
 #plot(wind_ms, kw)
 windDat - data.frame(kw, wind_ms, air_kgm3, wind_dg)
 windDat[windDat$wind_ms  3, 'kw'] - 0
 model - loess(kw ~ wind_ms + air_kgm3 + wind_dg, data = windDat, enp.target 
 = 10*5*3) #, span = 0.1)

 modX - serialize(model, connection = NULL, ascii = T)

 Channel - odbcConnect(someSysDSN; UID=aUid; PWD=aPwd)
 sqlQuery(Channel,
 paste(
 INSERT INTO GRT.GeneratorsModels
           ([cGeneratorID]
           ,[tModel]
   VALUES
           (1,,
           paste(', gsub(', '', rawToChar(modX)), ', sep = ''),
           ), sep = ) )
 # Up to this it is working correctly,
 # in DB I have the modX variable
 # Problem arise retrieving data and 64kb limit:
  strQ - 
    SELECT  CONVERT(varchar(max), tModel) AS tModel
    FROM    GRT.GeneratorsModels
    WHERE   (cGeneratorID = 1)
    
 x - sqlQuery(Channel, strQ, stringsAsFactors = F, believeNRows = FALSE)
 x - sqlQuery(Channel, strQ, stringsAsFactors = F, believeNRows = FALSE) 
 #read error



 Above code is working for simplier models that have a shorter representation 
 in variable modX.
 Any advice on how to store and retieve this kind of objects?
 Thanks
 Daniele


 ORS Srl

 Via Agostino Morando 1/3 12060 Roddi (Cn) - Italy
 Tel. +39 0173 620211
 Fax. +39 0173 620299 / +39 0173 433111
 Web Site www.ors.it

 
 Qualsiasi utilizzo non autorizzato del presente messaggio e dei suoi allegati 
 è vietato e potrebbe costituire reato.
 Se lei avesse ricevuto erroneamente questo messaggio, Le saremmo grati se 
 provvedesse alla distruzione dello stesso
 e degli eventuali allegati.
 Opinioni, conclusioni o altre informazioni riportate nella e-mail, che non 
 siano relative alle attività e/o
 alla missione aziendale di O.R.S. Srl si intendono non  attribuibili alla 
 società stessa, né la impegnano in alcun modo.
 ___
 R-sig-DB mailing list -- R Special Interest Group
 r-sig...@stat.math.ethz.ch
 https://stat.ethz.ch/mailman/listinfo/r-sig-db




-- 
Jeffrey Ryan
jeffrey.r...@insightalgo.com

ia: insight algorithmics
www.insightalgo.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [R-SIG-Finance] Creating regularly spaced time series from irregular one

2010-02-22 Thread Jeff Ryan
Firstly, don't cross-post.

Second, take a look at the archives on both these lists for answers to
your questions.

'its' is rather old, and not where you want to be looking.

Take a look at xts for fast time-series manipulation like you need,
specifically to.period, endpoints, and align.time.  There is a wealth
of documentation in the package, in the vignette, and even online in
more than a few places, but you can start here:

http://cran.r-project.org/web/packages/xts/vignettes/xts.pdf
http://www.quantmod.com/examples/data/

Also zoo for na.locf etc.

Additional options include the fts package and timeSeries.

HTH
Jeff

On Mon, Feb 22, 2010 at 2:52 PM, Ivan Kalafatic
ivan.kalafa...@gmail.com wrote:
 Hello,
 I have a series of intraday (high-frequency) price data in the form of POSIX
 timestamp followed by the value.
 I sucesfuly loaded that into its package object. I would like to create
 from it a regularly spaced time series of prices (for example 1min, 5min,
 etc apart) so i could calcualte returns.
 There is an interpolation function locf() that for timestamp with value NA
 uses last known observation.
 I guess the idea would be to start from the begining of my series and, for
 example, if there is no timestamp for t+5min add that time with value NA.
 Than I could use locf() function to fill those NAs. Finaly I should extract
 from that series, series with 5min spaced timestamps with prices.
 Appart from applying locf() function, I have no idea how to add NAs into
 original series or extract the regular series after.
 Can someone help me with this?
 Thank you.

        [[alternative HTML version deleted]]

 ___
 r-sig-fina...@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.
 -- Also note that this is not the r-help list where general R questions 
 should go.




-- 
Jeffrey Ryan
jeffrey.r...@insightalgo.com

ia: insight algorithmics
www.insightalgo.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R/Finance 2010: Applied Finance with R --- Call for Papers

2009-10-28 Thread Jeff Ryan
Call for Papers:

R/Finance 2010: Applied Finance with R
April 16 and 17, 2010
Chicago, IL, USA

The second annual R/Finance conference for applied finance using R
will be held this spring in Chicago, IL, USA on April 16 and 17, 2010.
 The two-day conference will cover topics including portfolio
management, time series analysis, advanced risk tools,
high-performance computing, market microstructure and econometrics.
All will be discussed within the context of using R as a primary tool
for financial risk management and trading.

One-page abstracts or complete papers (in txt or pdf format) are
invited for consideration. Academic and practitioner research
proposals related to R are encouraged. We will accept submissions for
full talks, abbreviated lightning talks, and a limited number of
pre-conference tutorial sessions.  Please indicate with your
submission if you would be willing to produce a formal paper (10-15
pages) for a peer-reviewed conference proceedings publication.

Presenters are strongly encouraged to provide working R code to
accompany the presentation/paper.  Data sets should also be made
public for the purposes of reproducibility (though we realize this may
be limited due to contracts with data vendors). Preference may be
given to presenters who have released R packages.

Please send submissions to: committee at RinFinance.com

The submission deadline is December 31st, 2010.

Submissions will be evaluated and submitters notified via email on a
rolling basis. Determination of whether a presentation will be a long
presentation or a lightning talk will be made once the full list of
presenters is known.

R/Finance 2009 included keynote presentations by Patrick Burns, Robert
Grossman, David Kane, Roger Koenker, David Ruppert, Diethelm Wuertz,
and Eric Zivot.  Attendees included practitioners, academics, and
government officials. We anticipate another exciting line-up for 2010
and will announce details at the conference website
http://www.RinFinance.com as they become available.

For the program committee:
Gib Bassett, Peter Carl, Dirk Eddelbuettel, John Miller,
Brian Peterson, Dale Rosenthal, Jeffrey Ryan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] currency conversion function?

2009-10-16 Thread Jeff Ryan
On Fri, Oct 16, 2009 at 8:04 AM, Liviu Andronic landronim...@gmail.com wrote:
 On 10/15/09, Jeff Ryan jeff.a.r...@gmail.com wrote:
   getFX(EUR/USD,from=2009-04-01)

 Indeed, with the date correctly specified, the function no longer
 generates errors. There is one issue though (similar to the one in the
 code posted by Henrique):
 getFX(EUR/PEN,from=2009-10-16)
 [1] EURPEN
 EURPEN
           EUR.PEN
 2009-10-16  4.3197
 getFX(PEN/EUR,from=2009-10-16)
 [1] PENEUR
 PENEUR  ### doesn't coincide with the value on the web page
           PEN.EUR
 2009-10-16  0.2377
 #Friday, October 16, 2009
 #1 Euro = 4.31973 Peruvian Nuevo Sol
 #1 Peruvian Nuevo Sol (PEN) = 0.23150 Euro (EUR)

 While EUR/PEN is correct, PEN/EUR seems wrong. I spotted this in other
 currencies, too.


When I look on the site now:

onversion Table: PEN to EUR (Interbank rate)

   Time period: 10/10/09 to 10/16/09.
Daily averages:

10/10/2009,0.23960
10/11/2009,0.24120
10/12/2009,0.24120
10/13/2009,0.24170
10/14/2009,0.24090
10/15/2009,0.23630
10/16/2009,0.23770

Which seems to match...  This is from the FXHistory section.

 getFX(PEN/EUR, from=2009-10-16)
[1] PENEUR
 PENEUR
   PEN.EUR
2009-10-16  0.2377


Is it possible you are looking at a 'live' quote?  Or maybe just
getting an update at precisely the wrong time?

Given the 24-7 nature of the market, I think this just reflects when
they choose to mark the price for history quotes.

Jeff




  If you are looking for additional FX data, the FRED archive (St. Louis Fed)
  is very good as well...

  http://research.stlouisfed.org/fred2/categories/94

   getSymbols(DEXUSEU, src=FRED)

 Thank you for the pointer. Best
 Liviu




-- 
Jeffrey Ryan
jeffrey.r...@insightalgo.com

ia: insight algorithmics
www.insightalgo.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] currency conversion function?

2009-10-15 Thread Jeff Ryan


OandA now limits fills to 500 days (as indicated by the error).  You can of
course just request 500 days at a time.  The function itself will not
automatically do that as that would be clearly abusing the rules that OandA
have established.  Of course what you do with your own code is your own
business...


 getFX(EUR/USD,from=2009-04-01)
[1] EURUSD
 head(EURUSD)
   EUR.USD
2009-04-01  1.3277
2009-04-02  1.3227
2009-04-03  1.
2009-04-04  1.3443
2009-04-05  1.3490
2009-04-06  1.3491


If you are looking for additional FX data, the FRED archive (St. Louis Fed)
is very good as well...

http://research.stlouisfed.org/fred2/categories/94

 getSymbols(DEXUSEU, src=FRED)
[1] DEXUSEU
 head(DEXUSEU)
   DEXUSEU
1999-01-04  1.1812
1999-01-05  1.1760
1999-01-06  1.1636
1999-01-07  1.1672
1999-01-08  1.1554
1999-01-11  1.1534

Keep in mind that FX data isn't coming from a centralized exchange, so all
vendors will be different.  

 ?getFX
 ?getSymbols.FRED

HTH,
Jeff

-- 
View this message in context: 
http://www.nabble.com/currency-conversion-function--tp25888083p25913241.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R CMD --meetup=Chicago --when=Oct 29 --where=Jak'sTap

2009-10-09 Thread Jeff Ryan
Chicagoland R Users:

We are pleased to announce a Fall meetup for Chicagoland R users. This
is open to anyone with an interest in R: practioners, researchers,
casual users and other interested parties.

WHEN: October 29, 2009 @5:30
WHERE: Jak's Tap www.jakstap.com

A short series of so-called lightning talks from some noted R
contributors and users is on the agenda. Speakers include:

Gib Basset (UIC)
Bryan Lewis (Revolution Computing)
JD Long (Cerebral Mastication)
David St. John (UIC, ttrTests package)

Casual conversation and food will follow, courtesy of the
International Center for Futures and Derivatives at the University of
Illinois at Chicago and the organizers of the R/Finance conferences:
http://www.RinFinance.com


Best,
Jeffrey Ryan
(on behalf of the organizing committee)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Yahoo data downloading problem

2009-02-07 Thread Jeff Ryan

I didn't look into the yahoo.get.hist.quote, but the quantmod package has a
working simple solution with getSymbols:

library(quantmod)
getSymbols(AAPL)

 head(AAPL)
   AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Volume AAPL.Adjusted
2007-01-03 86.29 86.5881.90  83.8044225700 83.80
2007-01-04 84.05 85.9583.82  85.6630259300 85.66
2007-01-05 85.77 86.2084.40  85.0529812200 85.05
2007-01-08 85.96 86.5385.28  85.4728468100 85.47
2007-01-09 86.45 92.9885.15  92.57   119617800 92.57
2007-01-10 94.75 97.8093.45  97.00   10546 97.00

Examples of that and more (FX, FED/FRED, Financials(google),
Dividends(Yahoo), Quotes...) are at:

http://www.quantmod.com/examples http://www.quantmod.com/examples 

And
http://www.quantmod.com/examples/intro
http://www.quantmod.com/examples/intro 

HTH
Jeff


Bogaso wrote:
 
 Hi,
 
 I got some problems while was trying to download data from Yahoo using
 yahoo.get.hist.quote() function. My script is as follows :
 
 app - yahoo.get.hist.quote(aapl, start=02/07/09, end=02/07/06,
 quote=close)
 
 However I got following error :
 
 trying URL
 'http://chart.yahoo.com/table.csv?s=aapla=6b=09c=0002d=6e=06f=0002g=dq=qy=0z=aaplx=.csv'
 Error in download.file(url, destfile) : 
   cannot open URL
 'http://chart.yahoo.com/table.csv?s=aapla=6b=09c=0002d=6e=06f=0002g=dq=qy=0z=aaplx=.csv'
 In addition: Warning message:
 In download.file(url, destfile) :
   cannot open: HTTP status was '404 Not Found'
 
 I got a similar thread in
 http://tolstoy.newcastle.edu.au/R/help/06/08/33770.html however, I could
 not figure out exactly what to do. Can anybody please help me?
 
 Regards,
 

-- 
View this message in context: 
http://www.nabble.com/Yahoo-data-downloading-problem-tp21886591p21888527.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] temporal join

2009-01-13 Thread Jeff Ryan

The data.table package may be more in line with what you are after, but xts
and zoo can also do what you need in this particular example:

 a - xts(c('a1','a2','a3'), timeBasedSeq(20090101/20090103))
 colnames(a) - 'foo'

 b - xts(c('b1'), as.Date('2009-01-04'))
 colnames(b) - 'foo'
 a
   foo 
2009-01-01 a1
2009-01-02 a2
2009-01-03 a3
 b
   foo 
2009-01-04 b1
 cbind(a,b)
   foo  foo.1
2009-01-01 a1 NA   
2009-01-02 a2 NA   
2009-01-03 a3 NA   
2009-01-04 NA   b1 
 na.locf(cbind(a,b))['20090104']
   foo  foo.1
2009-01-04 a3 b1 

cbind/merge will merge along the union on the time-index by default (though
all common joins are supported).  The subsetting by time will then find the
dates (or range of dates/times) that match.

na.locf will carry forward last observations.  That is from zoo; which works
on xts, as xts extends zoo.  

HTH,
Jeff




mckenzig wrote:
 
 I have dataframe a:
 
 sym date val1
 ===  
 foo 20090101 a1
 foo 20090102 a2
 foo 20090103 a3
 
 and dataframe b:
 
 sym date val2
 ===  
 foo 20090104 b1
 
 I would like to join/merge them to generate the following:
 
 sym date val2 val1
 ===   
 foo 20090104 b1 a3
 
 i.e. an equijoin on column 'sym' and a temporal join on column 'date'
 where the closest matching row is retrieved. I have been through the
 various regular/irregular timeseries packages and can not see anything
 like this.
 
 Regards.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/temporal-join-tp21395414p21437847.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] quantmod ATR problem

2008-11-19 Thread Jeff Ryan

This is a bug.  It has now been fixed in the R-forge source.

I will be updating the package in the next week or so with about a dozen
more indicators, as well as some additional features.  At that point I will
push the change to CRAN.

Thanks,
Jeff

Chris-672 wrote:
 
 Trying to plot ATR of time series using SMA using quantmod, plots fine
 with maType=EMA.
 However, when I use maType=SMA I get the following error:
 
 Error in SMA(c(0, 0, 0, 0, 0, ... :
unused arguments(s) (wilder = FALSE)
 Calls: addATR - ATR - do.call - SMA
 Execution halted
 
 The code I am using is:
 
 addATR(n=20, wilder=FALSE, maType=SMA)   # does not work
 addATR(n=20, maType=EMA)  # works fine
 
 Note, the problem still occurs if the wilder argument is modified or
 completely removed.
 This is probably quite simply, but I am very new to [R] - any help
 would be appeciated.
 
 Regards,
 
 Chris.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/quantmod-ATR-problem-tp20576540p20595551.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] subscripting a one column matrix drops dimension

2008-10-21 Thread Jeff Ryan

This is expected behavior:

?'['
Usage:

 x[i]
 x[i, j, ... , drop = TRUE]

drop: For matrices and arrays.  If 'TRUE' the result is coerced to
  the lowest possible dimension (see the examples).  This only
  works for extracting elements, not for the replacement.  See
  'drop' for further details. 

try cov(x[sub, drop=FALSE])

HTH
Jeff



Pedroso MOACIR wrote:
 
 Hi all,
 
 Well, I just sent a help msg to the list with this subject,
 but I think I figured out a way to solve my problem
 (although I still have no clue if the behavior I described
 is correct).
 
 What I did was to replace occurrences of (for example)
 
 cov(x[sub, ])
 
 with
 
 cov(matrix(x[sub, ], ncol=ncol(x))
 
 It works.
 
 I updated my source version of the cclust package. It
 may be of interest to somebody else, but I don't know
 how to submit to the package mantainer.
 
 Thank you.
 
 Moacir Pedroso Jr.
 Embrapa - Empresa Brasileira de Pesquisa Agropecuária
 (on leave at INRA - Instutute National de la Recherche Agronomique)
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/subscripting-a-one-column-matrix-drops-dimension-tp20098143p20098917.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] OHLC Plot with EMA in it

2008-09-26 Thread Jeff Ryan

Using quantmod and TTR (for EMA, as well as many, many more technical tools):

library(quantmod)

# get some data
getSymbols()

barChart()
addEMA()

Lots of examples at:

http://www.quantmod.com http://www.quantmod.com 
---and---
http://www.quantmod.com/examples/charting/
http://www.quantmod.com/examples/charting/ 


Do like Dirk suggests and find your way to R-Sig-Finance.

Enjoy!
Jeff


Michael Zak wrote:
 
 Hi there
 
 I have some timeseries data which I plot in a OHLC Plot. In the same  
 plot I'd like to have the EMA of this timeseries. I tried to add the  
 EMA point to OHLC with lines(), but this doesn't work. Has anyone an  
 idea how to handle it?
 
 Regards, Michael Zak
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/OHLC-Plot-with-EMA-in-it-tp19669847p19699297.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Truncating dates (and other date-time manipulations)

2008-09-12 Thread Jeff Ryan

I'm still not entirely sure I follow the desired usage, as the original post
made no reference to ggplot2, but as Gabor mentioned the yearmon etc stuff
is quite useful.

If you are formatting arbitrary precision dates, take a look at
axTicksByTime in xts.  Both xts and quantmod use it for plotting.  The core
calculation is from ?endpoints

I think the effect is what you desire --- though the logic of the function
may be more than you want/need.  I use it within the package(s) to make
intelligent breaks given the periodicity of the data.

Some examples are at:   http://www.quantmod.com http://www.quantmod.com 

My presentation slides from July's Rmetrics conference in Switzerland are
posted here:  http://www.quantmod.com/Rmetrics2008/
http://www.quantmod.com/Rmetrics2008/ 

Most of the functions you have written are somewhere within xts already.  At
least the functionality is. See the vignette: 
http://cran.r-project.org/web/packages/xts/index.html
http://cran.r-project.org/web/packages/xts/index.html 

Jeff  

-- 
View this message in context: 
http://www.nabble.com/Truncating-dates-%28and-other-date-time-manipulations%29-tp19436962p19458228.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Truncating dates (and other date-time manipulations)

2008-09-12 Thread Jeff Ryan

One last item that could be of use:

?timeBasedSeq

Lets you create ranges in any standard format, with simple ISO style
formatting. The level of detail you specify is interpreted as the resolution
that is desired.

e.g.
 timeBasedSeq(2000/2008)
[1] 2000-01-01 2001-01-01 2002-01-01 2003-01-01 2004-01-01
[6] 2005-01-01 2006-01-01 2007-01-01 2008-01-01

 timeBasedSeq(2000/200012)
 [1] Jan 2000 Feb 2000 Mar 2000 Apr 2000 May 2000 Jun 2000
 [7] Jul 2000 Aug 2000 Sep 2000 Oct 2000 Nov 2000 Dec 2000

 timeBasedSeq(2000/200012, 'Date')
 [1] 2000-01-01 2000-02-01 2000-03-01 2000-04-01 2000-05-01
 [6] 2000-06-01 2000-07-01 2000-08-01 2000-09-01 2000-10-01
[11] 2000-11-01 2000-12-01

 timeBasedSeq(2000/2115)
 [1] 2000-01-01 2000-01-02 2000-01-03 2000-01-04 2000-01-05
 [6] 2000-01-06 2000-01-07 2000-01-08 2000-01-09 2000-01-10
[11] 2000-01-11 2000-01-12 2000-01-13 2000-01-14 2000-01-15

 timeBasedSeq(2000/210110)
 [1] 2000-01-01 00:00:00 CST 2000-01-01 01:00:00 CST
 [3] 2000-01-01 02:00:00 CST 2000-01-01 03:00:00 CST
 [5] 2000-01-01 04:00:00 CST 2000-01-01 05:00:00 CST
 [7] 2000-01-01 06:00:00 CST 2000-01-01 07:00:00 CST
 [9] 2000-01-01 08:00:00 CST 2000-01-01 09:00:00 CST
[11] 2000-01-01 10:00:00 CST
 


Jeff Ryan wrote:
 
 I'm still not entirely sure I follow the desired usage, as the original
 post made no reference to ggplot2, but as Gabor mentioned the yearmon etc
 stuff is quite useful.
 
 If you are formatting arbitrary precision dates, take a look at
 axTicksByTime in xts.  Both xts and quantmod use it for plotting.  The
 core calculation is from ?endpoints
 
 I think the effect is what you desire --- though the logic of the function
 may be more than you want/need.  I use it within the package(s) to make
 intelligent breaks given the periodicity of the data.
 
 Some examples are at:   http://www.quantmod.com http://www.quantmod.com 
 
 My presentation slides from July's Rmetrics conference in Switzerland are
 posted here:  http://www.quantmod.com/Rmetrics2008/
 http://www.quantmod.com/Rmetrics2008/ 
 
 Most of the functions you have written are somewhere within xts already. 
 At least the functionality is. See the vignette: 
 http://cran.r-project.org/web/packages/xts/index.html
 http://cran.r-project.org/web/packages/xts/index.html 
 
 Jeff  
 
 

-- 
View this message in context: 
http://www.nabble.com/Truncating-dates-%28and-other-date-time-manipulations%29-tp19436962p19458976.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Truncating dates (and other date-time manipulations)

2008-09-12 Thread Jeff Ryan
Not really the ceiling and floor, though I haven't tried your code
(and my brain isn't at 100% capacity today to simply parse the code in
my head :) )

Though I think ?firstof and ?lastof  as well as startof/endof might be
something along those lines.  ?to.period has the ability to change
periodicity of a series (price or OHLCV-style price). Internal to that
is a method to re-align the output series:

From the help:
 To adjust the final indexing style, it is possible to set
 'indexAt' to one of the following: 'yearmon', 'yearqtr',
 'firstof', 'lastof', 'startof', or 'endof'.  The final index will
 then be 'yearmon', 'yearqtr', the first time of the period, the
 last time of the period, the starting time in the data for that
 period, or the ending time in the data for that period,
 respectively.

Might that be what you are after (not the actual implementation per
se, but the spirit).

BTW, I am philosophically opposed to typing :)

Actually the chartSeries stuff is quite dynamic (and no more
specialized IMO than boxplot et al) --- take a look.

Jeff

On Fri, Sep 12, 2008 at 11:16 AM, hadley wickham [EMAIL PROTECTED] wrote:
 On Fri, Sep 12, 2008 at 10:53 AM, Jeff Ryan [EMAIL PROTECTED] wrote:

 I'm still not entirely sure I follow the desired usage, as the original post
 made no reference to ggplot2, but as Gabor mentioned the yearmon etc stuff
 is quite useful.

 Well, I said I need to be able to correct draw date-time scales,
 which means I need to be able to deal with a wide range of date time
 data types.  I wasn't really aware of xts before - I'll definitely
 look into it in more detail.

 If you are formatting arbitrary precision dates, take a look at
 axTicksByTime in xts.  Both xts and quantmod use it for plotting.  The core
 calculation is from ?endpoints

 I think the effect is what you desire --- though the logic of the function
 may be more than you want/need.  I use it within the package(s) to make
 intelligent breaks given the periodicity of the data.

 That's exactly what I want!  I've written my own method, but I think
 you've done a much nicer job.  (Although I draw minor grid lines as
 well)  I'll definitely look at using that function in a future version
 of ggplot2.


 Some examples are at:   http://www.quantmod.com http://www.quantmod.com

 Very nice - however, I'm philosophically opposed to special purpose
 plotting functions!

 Most of the functions you have written are somewhere within xts already.  At
 least the functionality is. See the vignette:
 http://cran.r-project.org/web/packages/xts/index.html
 http://cran.r-project.org/web/packages/xts/index.html

 Including the ceiling and floor functions?  That's what I'm really
 interested in.

 Hadley


 --
 http://had.co.nz/




-- 
Jeffrey Ryan
[EMAIL PROTECTED]

ia: insight algorithmics
www.insightalgo.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] periodicity validation

2008-09-11 Thread Jeff Ryan

Take a look at the xts package.

?periodicity

HTH
Jeff

yk-4 wrote:
 
 There is a series of data contains time in fixed step and energy
 varying with time, how to test its periodicity?In R, it seems there is
 no direct tools since I have search the R manual with periodic and I
 have not found any related topic.
 Thanks a lot
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/periodicity-validation-tp19426522p19433896.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Package for financial options calculation

2008-09-11 Thread Jeff Ryan

Take a look at the fOptions package, as well as all the packages in Rmetrics
(see www.rmetrics.org).

There is also a wrapper to QuantLib called RQuantLib.

Also, your question would have a better chance of being answered on the
R-sig-finance mailing list.

HTH
Jeff


Arun Kumar Saha wrote:
 
 Hi all,
 
 Is there any R package on European/American oprions pricing? And on
 calculation of it's sensitivities?
 
 Regards,
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Package-for-financial-options-calculation-tp19430481p19433943.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] yahoo finance into R

2008-09-11 Thread Jeff Ryan

Take a look at quantmod.

http://www.quantmod.com http://www.quantmod.com 

?getSymbols.yahoo (called by getSymbols)
?getQuote
?yahooQF
?getFin
?getFX

HTH
Jeff

thomastos wrote:
 
 Hi R, 
 
 I am familiar with the basics of R.
 To learn more I would like how to get data from Yahoo!finance directly
 into R. So basically I want a data frame or matrix to do some data
 analysis.
 How do I do this?
 
 Thank you very much.
 
 Thomas
 
 

-- 
View this message in context: 
http://www.nabble.com/yahoo-finance-into-R-tp19385481p19434000.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] intraday OHLC plot

2008-03-23 Thread Jeff Ryan
Hi Thomas,

The issue is probably the quantmod package being outdated.  Try to
install this version:

http://r-forge.r-project.org/R/?group_id=125

The second issue is that xlab and ylab are no longer being applied -
they had some issue, and I haven't settled on a way to address yet.  I
will make that a priority though.

The third issue you *might* see upon updating quantmod is that you may
be better off calling chartSeries with the type='bar' argument - as
barChart just does this, but due to R lazy evaluation and the TA
mechanism/args things may break without a volume in the series.  The
alternate would be explicitly add TA=NULL to the call.

Jeff

On Sun, Mar 23, 2008 at 9:49 AM, Thomas Steiner [EMAIL PROTECTED] wrote:
 Dear Gabor and Jeff,

  thanks for your hint! I tried it out and played around but could not
  succeed completely:

   library(quantmod)
   raw=read.table(file=eurusd-id.csv,sep=\t,dec=,,header =T)
   date.d=as.POSIXct(raw$Date..GMT)
   z=zoo(cbind(raw$Open,raw$High,raw$Low,raw$Close),order.by=date.d)
   q - as.quantmod.OHLC(z, col.names = c(Open, High, Low, Close))
   barChart(q,show.vol=F, show.grid=F,theme=white,name=EURUSD Intraday 
 data,up.col=black,dn.col=black,xlab=time,ylab=FX)
  Fehler in as.graphicsAnnot(labels) : objekt x.labels nicht gefunden

  So it does not find the object x.labels... I just fould in the
  pdf-documentation that this should be of type character.

  Perhaps you know why it fails,
  Thomas




-- 
There's a way to do it better - find it.
Thomas A. Edison

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Re intraday OHLC plot

2008-03-22 Thread Jeff Ryan
Hi Thomas,

You may want to check out the quantmod package.  There is a whole
suite of charting functionality now included.

You will need to change the 'Last' colname to Close, but other than
that your data should work.  If you download the most recent build or
svn snapshot from http://r-forge.r-project.org/projects/quantmod
you'll find many additional functional that may be of use.

Additionally, there are some (possibly dated) examples on the main
site page at http://www.quantmod.com

The most recent version allows for custom tick mark location by dates,
as well as zooming capabilities.  Additionally TA analysis can be
applied to the charts (the underlying functionality coming from the
TTR package on CRAN and r-forge)

Jeff

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.