[tech-spec] Re: Yahoo! quotes

  • From: Dirk Eddelbuettel <edd@xxxxxxxxxx>
  • To: tech-spec@xxxxxxxxxxxxx
  • Date: Tue, 19 Oct 2004 17:47:43 -0500

On Tue, Oct 19, 2004 at 06:32:54PM -0400, Daniel Flam wrote:
> I wrote a script in perl that imports the data directly into MySQL and that
> makes life easy, because besides the regular data pull out, it allows me to
> get synchronized data between series if i want to compare things like VIX vs
> SPX or two stock arbitrage using a select. So i wrote a RODBC to quickly run
> queries
> such as
> select a.price as VIX, b.price as SPX from dailyprices as a, dailyprices as
> b where a.date=b.date

How about this:

$ R --quiet
> library(its)                          # its is a mots useful package
> VIX <- priceIts("^VIX")
> SPX <- priceIts("^GSPC")
> jointData <- intersect(VIX, SPX)      
> summary(lm(X.GSPC.Close ~ X.VIX.Close, 
> data=data.frame(core(diff(jointData)))))

The column names are a little pahthological, I guess priceIts could do with
better defaults, and the export from its to data.frame is a little clumsy
too, but heck -- done in five lines, including the merge-by-dates!

> this would be a mess to accomplish without SQL

Been there done that, but proper data objects help a lot and free you from
having to go to the DB. 

Dirk



> 
> 
> ----- Original Message ----- 
> From: "BBands" <BBands@xxxxxxxxxxxxxxxxxx>
> To: <tech-spec@xxxxxxxxxxxxx>
> Sent: Tuesday, October 19, 2004 12:17 PM
> Subject: [tech-spec] Re: Yahoo! quotes
> 
> 
> > > As I should know better than to force any convinced Python
> > > hacker to look at
> > > Perl code, I include an example shell script below.
> >
> > I am not a total loss, I can read and write a bit of perl; have to to keep
> > up the likes of you and the mighty Moe! ;-)
> >
> > > Given that R can
> > > retrieve directly from read.csv() via url() as its file argument, this
> > > should adapt easily. Could you report your snippets back?
> > > Maybe this could
> > > be something to contribute back as a little helper function?
> >
> > Absolutely. In fact I will report back an intergrated BB charting function
> > for R based on the work we did in the Spring on Crusher.
> >
> > > So below is the
> > > old-ish script 'examine_server.sh' which has some
> > > documentation on which cgi
> > > query symbol stands for which datum.
> >
> > <snip>
> >
> > That helped a lot. Results in a few days.
> >
> >     --jab
> >
> 
> 

-- 
Those are my principles, and if you don't like them... well, I have others.
                                                -- Groucho Marx

Other related posts: