[[tags: egg]]
== yahoo-finance
[[toc:]]
This is a tiny library for accessing Yahoo Finance's stock quote API from
Chicken Scheme.
The source for this egg is available at [[http://github.com/evhan/yahoo-finance]].
=== Requirements
* [[/egg/csv-xml|csv-xml]]
* [[/egg/uri-common|uri-common]]
* [[/egg/intarweb|intarweb]]
* [[/egg/http-client|http-client]]
=== API
There are two functions.
(fetch-quotes symbol-or-symbols field-or-fields)
{{fetch-quotes}} takes one or more stock symbols and one or more field name
symbols and returns a table of the requested information:
> (use yahoo-finance)
> (fetch-quotes 'aapl 'eps)
((stock (eps 42.548)))
> (fetch-quotes 'aapl '(name p/e p/s p/b))
((stock (name "Apple Inc.")
(p/e 15.86)
(p/s 4.25)
(p/b 5.66)))
> (fetch-quotes '(aapl goog msft) '(name high low change)))
((stock (name "Apple Inc.")
(high 677.67)
(low 672.6)
(change -1.334))
(stock (name "Google Inc.")
(high 688.99)
(low 676.15)
(change 10.76))
(stock (name "Microsoft Corpora")
(high 30.75)
(low 30.44)
(change 0.02)))
Read the code for a list of available fields.
(fetch-quotes symbol [interval [start-date [end-date]]])
{{fetch-history}} takes a single stock symbol and, as optional arguments, an
interval symbol (one of {{daily}}, {{weekly}}, {{monthly}}, or {{dividends}}),
a start date as a list of numbers of the form {{(dd mm yyyy)}}, and an end date
of the same form. It returns a table in one of two forms:
> (fetch-history 'aapl 'monthly)
((row (date "2012-08-01")
(open 615.91)
(high 680.87)
(low 600.25)
(close 673.47)
(volume 13327800)
(adjusted-close 673.47))
(row (date "2012-07-02")
(open 584.73)
(high 619.87)
(low 570.0)
(close 610.76)
(volume 15938700)
(adjusted-close 608.15))
...)
> (fetch-history 'aapl 'dividends '(1 1 1987) '(1 1 1989))
((row (date "1988-11-21") (dividend 0.025))
(row (date "1988-08-15") (dividend 0.02))
(row (date "1988-05-16") (dividend 0.02))
(row (date "1988-02-12") (dividend 0.02))
(row (date "1987-11-17") (dividend 0.02))
(row (date "1987-08-10") (dividend 0.015))
(row (date "1987-05-11") (dividend 0.015)))
=== License
Written by Evan Hanson, licensed under the WTFPL.