[R-SIG-Finance] RMySQL returning too much data?

Mark Knecht markknecht at gmail.com
Tue Jan 7 19:42:32 CET 2014


On Tue, Jan 7, 2014 at 9:34 AM, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote:
<SNIP>
>>    It hadn't occurred to me that an input to getSymbols would be
>> passed to src=yahoo but not to src=MySQL but that's fine now that I
>> know. It does seem a bit non-intuitive from a design & documentation
>> POV but I'm happy that it's not a bug. Spend your time designing new,
>> great stuff and don't mess with this until/unless one day you think it
>> warrants the time.
>>
> Yes, I can see how that's confusing.  The design is difficult to
> change at this point, but documentation is easily updated.  I'd
> appreciate any patches you think would help make the documentation
> clearer in this regard.


I'll give some thought to what ?getSymbols might say. Looking quickly
though the list of sources it seems like about half of them support
to/from and the other half don't. Based on that I probably wouldn't
say much more than "Be careful about assuming what getSymbol
parameters are passed to the actual code that talks to your data
source" but of course worded better.

Subsetting the data was easy but as I'd never used the assign function
before I had to do fix(getSymbols.MYSQL) and see what was going on in
there and then change my code to look like what follows. Now all the
data starts and ends as per DataStart/DataEnd.

I'll have to have 2 date ranges now - one for data and one for when I
actually trade, but that's OK as it supports future things like
walk-forward analysis, etc.

Thanks for all the help!

Cheers,
Mark

if (DownloadNewData){
  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")
      #NOTE: getSymbols.MYSQL doesn't support to/from so we subset the data
      assign(SymbolList[i], get(SymbolList[i])[paste0(DataStart,"/",DataEnd)])
    }
    #Close connection to MySQL
    dbDisconnect(dbc)
  }
}



More information about the R-SIG-Finance mailing list