[R-SIG-Finance] ?getSymbol.MySQL
Brian G. Peterson
brian at braverock.com
Thu Dec 30 22:11:01 CET 2010
On 12/30/2010 03:03 PM, Mark Knecht wrote:
> Just a quick question. I'm playing around seriously for the first time
> with MySQL. The man page for getSymbol.MySQL says I shouldn't call it
> directly. However I note from reading that the default assumptions for
> column names don't match what I have in my database. Additionally I
> have other columns in the database I'd like to fetch if possible.
> (Indicators, trading system status, etc.)
>
> Is there any way to remap the column names that get fetched within R
> using getSymbol? I.e. - a generic fetch of whatever column I want
> instead of just predefined price data?
>
> Am I better off in the long run digging into the getSymbol.MySQL R
> code and then making my own function to do this job?
>
> Maybe there's a more general package for MySQL interface vs one used
> specifically for stock data?
Well, certainly there's the RMySQL package...
The 'don't call this directly' bit is a reference to setSymbolLookup.
Ideally, you use setSymbolLookup to tell getSymbols which method (yahoo,
rda, google, oanda, MySQL, etc.) to use for a particular symbol. We do
that with a little custom function that runs in everybody's .Rprofile to
point getSymbols at all our in-house tick data stored in rda files by
day (see getSymbols.FI in the FinancialInstrument package).
I would recommend that you pull apart getSymbols.MySQL and add the
columns you want. Make sure you rename the OHLCV or tick data columns
in your output xts object to line up with what the other quantmod
functions expect, but otherwise just use whatever columns you want from
your data.
then use setSymbolLookup to tell getSymbols to use your method function
'getSymbols.MK_mySQL' (or whatever) to load those symbols.
Regards,
- Brian
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list