[Quantmod-commits] r592 - in pkg: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Dec 27 15:59:02 CET 2012


Author: jryan
Date: 2012-12-27 15:59:02 +0100 (Thu, 27 Dec 2012)
New Revision: 592

Modified:
   pkg/DESCRIPTION
   pkg/R/chob.R
   pkg/R/getSymbols.R
Log:
o  changed how chob objects are handled internally - they are now within an environment in the quantmod namespace, a convenient workaround for the unlock/lockBinding issues of R CMD check, and cleaner code to boot!
o getSymbols.R cleanup of some unneeded code
o DESCRIPTION Depends to xts 0.9 ... need to check xts here before actually rolling this out to CRAN (and get xts on CRAN in suitable version)



Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2012-12-27 14:37:55 UTC (rev 591)
+++ pkg/DESCRIPTION	2012-12-27 14:59:02 UTC (rev 592)
@@ -4,7 +4,7 @@
 Version: 0.3-22
 Date: 2012-10-23
 Author: Jeffrey A. Ryan
-Depends: Defaults, xts(>= 0.8-3), zoo, TTR(>= 0.2), methods
+Depends: Defaults, xts(>= 0.9-0), zoo, TTR(>= 0.2), methods
 Suggests: DBI,RMySQL,RSQLite,timeSeries,its
 Maintainer: Jeffrey A. Ryan <jeff.a.ryan at gmail.com>
 Description: Specify, build, trade, and analyse quantitative financial trading strategies

Modified: pkg/R/chob.R
===================================================================
--- pkg/R/chob.R	2012-12-27 14:37:55 UTC (rev 591)
+++ pkg/R/chob.R	2012-12-27 14:59:02 UTC (rev 592)
@@ -1,32 +1,37 @@
 `.chob` <- list(NULL)
+.chob <- new.env()
+.chob$.chob <- list(NULL)
 
 `write.chob` <-
 function(x,pos)
 {
   env <- as.environment("package:quantmod")
   environment(x) <- env
-  locked <- bindingIsLocked('.chob',env)
-  if(locked)
-    unlockBinding('.chob',env)
+  #locked <- bindingIsLocked('.chob',env)
+  #if(locked)
+  #  unlockBinding('.chob',env)
   orig.chob <- get.chob()
   if(missing(pos)) pos <- length(orig.chob)+1
   orig.chob[[pos]] <- x
-  assign('.chob',orig.chob,env)
-  if(locked) {
-    ow <- options("warn")
-    on.exit(options(ow))
-    options(warn=-1)
-    lockBinding('.chob',env)
-   }
+  .chob$.chob <- orig.chob
+  #assign('.chob',orig.chob,env)
+  #if(locked) {
+  #  ow <- options("warn")
+  #  on.exit(options(ow))
+  #  options(warn=-1)
+  #  lockBinding('.chob',env)
+  # }
   invisible(1)
 }
 
 `get.chob` <-
 function()
 {
-  x <- get('.chob',as.environment("package:quantmod"))
-  attr(x,'.Environment') <- NULL
+  x <- .chob$.chob
   return(x)
+  #x <- get('.chob',as.environment("package:quantmod"))
+  #attr(x,'.Environment') <- NULL
+  #return(x)
 }
 
 `release.chob` <-
@@ -39,16 +44,17 @@
   }
   env <- as.environment("package:quantmod")
   environment(x) <- env
-  locked <- bindingIsLocked('.chob',env)
-  if(locked)
-    unlockBinding('.chob',env)
+  #locked <- bindingIsLocked('.chob',env)
+  #if(locked)
+  #  unlockBinding('.chob',env)
+  .chob$.chob <- x
   assign('.chob',x,env)
-  if(locked) {
-    ow <- options("warn")
-    on.exit(options(ow))
-    options(warn=-1)
-    lockBinding('.chob',env)
-   }
+  #if(locked) {
+  #  ow <- options("warn")
+  #  on.exit(options(ow))
+  #  options(warn=-1)
+  #  lockBinding('.chob',env)
+  # }
   invisible(1)
 }
 

Modified: pkg/R/getSymbols.R
===================================================================
--- pkg/R/getSymbols.R	2012-12-27 14:37:55 UTC (rev 591)
+++ pkg/R/getSymbols.R	2012-12-27 14:59:02 UTC (rev 592)
@@ -338,6 +338,8 @@
        colnames(fr) <- paste(toupper(gsub('\\^','',Symbols.name)),
                              c('Open','High','Low','Close','Volume'),
                              sep='.')
+       # convert '-' to NAs
+       suppressWarnings(storage.mode(fr) <- "numeric")
        fr <- convert.time.series(fr=fr,return.class=return.class)
        Symbols[[i]] <-toupper(gsub('\\^','',Symbols[[i]])) 
        if(auto.assign)
@@ -599,10 +601,10 @@
                    
     format <- getSymbolLookup()[[Symbols[[i]]]]$format
     if(is.null(format)) format<-''
-    if(!is.null(list(...)[['format']])) {
-        format<-list(...)[['format']] # dots overrides anything we stored in setSymbolLookup
-        list(...)[['format']]<-NULL # avoid R's "formal argument "format" matched by multiple actual arguments"
-    }
+##    if(!is.null(list(...)[['format']])) {
+##        format<-list(...)[['format']] # dots overrides anything we stored in setSymbolLookup
+##        list(...)[['format']]<-NULL # avoid R's "formal argument "format" matched by multiple actual arguments"
+##    }
 
     if(verbose) cat("loading ",Symbols[[i]],".....")
     if(dir=="") {



More information about the Quantmod-commits mailing list