Skip to content
pnathan edited this page Jan 9, 2012 · 13 revisions

cl-yahoo-finance

cl-yahoo-finance provides a thin layer over the Yahoo Finance endpoint.

The current version is 1.1. Any modifications to the existing API will cause a version bump. Any bugfixes will induce a minor revision bump. cl-yahoo-finance is available in the January 2012 Quicklisp distribution.

Example (from USAGE.lisp)

;; Load me up
(asdf:load-system :cl-yahoo-finance)

;; Pull in the complete details for the big G and big Blue
(cl-yahoo-finance:read-current-data '("GOOG" "IBM"))

;; Get the historical data from TSLA
(cl-yahoo-finance:read-historical-data "TSLA" '(1 1 2011) '(6 1 2011))

Manual

READ-CURRENT-SYMBOLS

Syntax: READ-CURRENT-DATA list-of-symbols|symbol

READ-CURRENT-DATA reads the "most recent" series of datapoints for symbol(s) and returns a list of HASH-TABLEs containing the string keys mapping to the data.

READ-HISTORICAL-DATA

Syntax: READ-HISTORICAL-DATA symbol start-date-triple end-date-triple

READ-HISTORICAL-DATA reads the historical data for symbol(s) and returns a list of lists mapping to the Date, Open, High, Low, Close, Volume, Adj-Close for all days within the range.

start-date-triple and end-date-triple are three-element lists of month day year integers

Caveats

cl-yahoo-finance is subject to the same availabilities and delays as Yahoo itself.

It requires a number of libraries, all available through Quicklisp

REPL

* (cl-yahoo-finance:read-historical-data "TSLA" '(1 1 11) '(6 1 11))
;; one hojillion datapoints
(...
("2011-01-03" 26.84 27.0 25.9 26.62 1283000 26.62))

*  (cl-yahoo-finance:read-current-data "TSLA")

(#<HASH-TABLE :TEST EQUAL :COUNT 82 {1002887273}>)

*  (cl-yahoo-finance:read-current-data '("TSLA" "GOOG"))

(#<HASH-TABLE :TEST EQUAL :COUNT 82 {10042D7203}>
 #<HASH-TABLE :TEST EQUAL :COUNT 82 {10042E7353}>)

*   (gethash "symbol" (car (cl-yahoo-finance:read-current-data '("TSLA" "GOOG"))))

"TSLA"
 T
Clone this wiki locally