[R-SIG-Finance] Problem using Quantmod and MySQL

Joshua Ulrich josh.m.ulrich at gmail.com
Mon Mar 30 18:59:08 CEST 2015


On Mon, Mar 30, 2015 at 11:49 AM, Mark Knecht <markknecht at gmail.com> wrote:
> On Mon, Mar 30, 2015 at 9:25 AM, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote:
>> On Sun, Mar 29, 2015 at 5:37 PM, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote:
>>> On Sun, Mar 29, 2015 at 1:50 PM, Ueli Hofstetter
>>> <uelihofstetter at gmail.com> wrote:
>>>> I have some problems loading symbols from an mysql db using getSymbols.
>>>>
>>>> Instead of repeating the issue, here is a link to the description on
>>>> stackoverflow
>>>>
>>>> http://stackoverflow.com/questions/29333330/quantmod-error-loading-symbols-from-mysql-db
>>>>
>>>> Any help is greatly appreciated
>>>>
>>> The "character" method for dbConnect was removed in the 0.10 release
>>> of RMySQL. I'm not sure whether or not this was intentional. It was
>>> not mentioned in the release notes.
>>>
>> It was removed intentionally.  I do not have a MySQL database
>> available for testing, so I would really appreciate some help from
>> those who use this functionality.  Can someone please try this
>> suggested edit:
>> https://github.com/rstats-db/RMySQL/issues/62#issuecomment-87692704
>>
>> And provide feedback at: https://github.com/joshuaulrich/quantmod/issues/45
>>
>> Thanks!
>> Josh
>>
>>
>> --
>> Joshua Ulrich  |  about.me/joshuaulrich
>> FOSS Trading  |  www.fosstrading.com
>>
>> _______________________________________________
>> 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.
>
>
>
> I'm happy to try it out but a little confused as to all the locations
> I need to edit. Help me clear this up and I'll try it out immediately.
>
> The failure is coming when I'm trying to get the data using the following code:
>
>> if (DownloadNewData){
> +   if (!UseMySQL){
> +     for (i in 1:length(TestSym)){
> +       print(paste("From ",SymbolSrc," -- ",TestSym[i]))
> +       getSymbolsCont(TestSym[i], from = DataStart, to = DataEnd,
> adjust = MyAdjust, src=SymbolSrc)
> +     }
> +   } else {
> +     for (i in 1:length(TestSym)){
> +       print(paste("From MySQL -- ",TestSym[i]))
> + #      getSymbols(TestSym[i], src="MySQL")
> +       getSymbols(TestSym[i], src="MySQL", user="mark",
> password="MyTempPassword", dbname=dbName)
> +       assign(TestSym[i], get(TestSym[i])[paste0(DataStart,"/",DataEnd)])
> +     }
> +     dbDisconnect(dbc)
> +   }
> + }
> [1] "From MySQL --  SPY"
>  Show Traceback
>
>  Rerun with Debug
>
> Error in (function (classes, fdef, mtable)  :
>   unable to find an inherited method for function ‘dbConnect’ for
> signature ‘"character"’
>
>
> Am I correct that the suggestion is to edit two lines?
>
> First, I use
>
> library(RMySQL)
>
> Is the first edit to change this to
>
> requireNamespace("RMySQL", quietly = TRUE)
>
> or do I add this to my code somewhere and keep the library command?
>
No, you shouldn't need to change anything in your code.

> Later in my code I have:
>
> if (UseMySQL){
>   if (MyAdjust) { dbName = paste0(dbName, "Adjust")}
>   dbc = dbConnect(MySQL(), dbname=dbName)
> #  setDefaults(getSymbols.MySQL, user="mark",
> password="MyTempPassword", dbname=dbName)
> }
>
> This would be where the second edit goes?
>
> dbConnect("MySQL", ...) to dbConnect(RMySQL::MySQL, ...)
>
No. Again, you shouldn't need to change your code.  The change
required is on L614 of getSymbols.R.

> Thanks,
> Mark



-- 
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com



More information about the R-SIG-Finance mailing list