[R-SIG-Finance] 'Defaults' removed from CRAN? (2014-10-03)
Mark Knecht
markknecht at gmail.com
Wed Oct 8 16:43:22 CEST 2014
On Tue, Oct 7, 2014 at 7:14 PM, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote:
> I just pushed an updated quantmod_0.4-2 to R-Forge. Most of the
> Defaults-related issues have been addressed, except for
> getSymbols.MySQL and setTA/unsetTA. Feedback would be much
> appreciated.
> --
> Joshua Ulrich | about.me/joshuaulrich
> FOSS Trading | www.fosstrading.com
>
>
> On Tue, Oct 7, 2014 at 3:40 PM, Brian G. Peterson <brian at braverock.com> wrote:
>> On 10/07/2014 03:26 PM, Daniel Cegiełka wrote:
>>>
>>> http://cran.r-project.org/web/packages/Defaults/index.html
>>>
>>> That's a pretty important package that is required by quantmod.
>>
>>
>> Yes.
>>
>> Defaults makes use of unlockBindings to change loaded package namespaces.
>> That's no longer allowed by CRAN.
>>
>> So, we'll need to modify getSymbols to not require it.
>>
>> The old chartSeries uses it too, but we'll be replacing that soon, so I'm
>> not worried about that dependency.
>>
>> Regards,
>>
>> Brian
>>
>>
>> --
>> Brian G. Peterson
>> http://braverock.com/brian/
>> Ph: 773-459-4973
>> IM: bgpbraverock
>>
>>
>> _______________________________________________
>> R-SIG-Finance at r-project.org 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.
>
> _______________________________________________
> R-SIG-Finance at r-project.org 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.
OK, it seems to work but requires me to modify long working code to remove
setDefaults and then put the database stuff in the actual call. Is
this the way this
is intended to work in the future and I should modify my files?
I'm pretty sure the data is coming from MySQL as AAPL is not in the ETF
database and it fails if I add it to the symbol list:
> source('~/.active-rstudio-document')
[1] "From MySQL -- SPY"
[1] "From MySQL -- IWM"
[1] "From MySQL -- QQQ"
[1] "From MySQL -- AAPL"
Error in Symbols[[i]] : subscript out of bounds
In addition: Warning message:
In getSymbols.MySQL(Symbols = "AAPL", env = <environment>, verbose = FALSE, :
could not load symbol(s): AAPL
>
The code I ran is at the bottom.
Thanks,
Mark
> source('~/R/Test Cases/RMySQL-Test.R')
Loading required package: xts
Loading required package: zoo
Attaching package: ‘zoo’
The following objects are masked from ‘package:base’:
as.Date, as.Date.numeric
Loading required package: TTR
Version 0.4-0 included new data defaults. See ?getSymbols.
Loading required package: DBI
[1] "From MySQL -- SPY"
As of 0.4-0, ‘getSymbols’ uses env=parent.frame() and
auto.assign=TRUE by default.
This behavior will be phased out in 0.5-0 when the call will
default to use auto.assign=FALSE. getOption("getSymbols.env") and
getOptions("getSymbols.auto.assign") are now checked for alternate defaults
This message is shown once per session and may be disabled by setting
options("getSymbols.warning4.0"=FALSE). See ?getSymbol for more details
[1] "From MySQL -- IWM"
[1] "From MySQL -- QQQ"
>
llibrary(quantmod)
library(RMySQL)
Sys.setenv(TZ = "UTC")
DataStart = "1990-01-01"
DataEnd = format(Sys.time(), "%Y-%m-%d")
SymbolSrc = "yahoo"
dbName = "R_ETF"
MyAdjust = TRUE
UseMySQL = TRUE
SymbolList = c("SPY","IWM","QQQ")
if (UseMySQL){
if (MyAdjust) { dbName = paste0(dbName, "Adjust")}
dbc = dbConnect(MySQL(), dbname=dbName)
# setDefaults(getSymbols.MySQL, user="mark",
password="MyTempPassword", dbname=dbName)
}
if (!UseMySQL){
for (i in 1:length(SymbolList)){
print(paste("From ",SymbolSrc," -- ",SymbolList[i]))
getSymbolsCont(SymbolList[i], from = DataStart, to = DataEnd,
adjust = MyAdjust, src=SymbolSrc)
}
} else {
for (i in 1:length(SymbolList)){
print(paste("From MySQL -- ",SymbolList[i]))
# getSymbols(SymbolList[i], src="MySQL")
getSymbols(SymbolList[i], src="MySQL", user="mark",
password="MyTempPassword", dbname=dbName)
assign(SymbolList[i], get(SymbolList[i])[paste0(DataStart,"/",DataEnd)])
}
dbDisconnect(dbc)
}
More information about the R-SIG-Finance
mailing list