This gives me a bunch of errors in addition to the result

Welcome to DrRacket, version 5.0.0.1--2010-05-24(bece17d/g) [3m].
Language: racket; memory limit: 512 MB.
load-handler: expected a `module' declaration for `bernoulli-example' in #<path:/Users/matthias/Library/Racket/planet/300/5.0.0.1/cache/ williams/science.plt/2/9/examples/bernoulli-example.ss>, but found something else load-handler: expected a `module' declaration for `science-Z-A' in #<path:/Users/matthias/Library/Racket/planet/300/5.0.0.1/cache/ williams/science.plt/2/9/html/science-Z-A.scm>, but found something else load-handler: expected a `module' declaration for `control' in #<path:/ Users/matthias/Library/Racket/planet/300/5.0.0.1/cache/williams/ science.plt/2/9/ode-initval/control.ss>, but found something else setup-plt: error: during making for <planet>/williams/science.plt/2/9/ examples setup-plt: load-handler: expected a `module' declaration for `bernoulli-example' in #<path:/Users/matthias/Library/Racket/planet/ 300/5.0.0.1/cache/williams/science.plt/2/9/examples/bernoulli- example.ss>, but found something else setup-plt: error: during making for <planet>/williams/science.plt/2/9/ html setup-plt: load-handler: expected a `module' declaration for `science-Z-A' in #<path:/Users/matthias/Library/Racket/planet/ 300/5.0.0.1/cache/williams/science.plt/2/9/html/science-Z-A.scm>, but found something else setup-plt: error: during making for <planet>/williams/science.plt/2/9/ ode-initval setup-plt: load-handler: expected a `module' declaration for `control' in #<path:/Users/matthias/Library/Racket/planet/300/5.0.0.1/ cache/williams/science.plt/2/9/ode-initval/control.ss>, but found something else





On May 24, 2010, at 1:20 PM, John Clements wrote:

From my computational finance class today, a function that computes (log)mean and (log)stdev for the last 20 years of a stock:

#lang racket

(require net/url (planet williams/science/statistics))
(define (ticker->url t) (format "http://ichart.finance.yahoo.com/table.csv?s= ~a&a=04&b=24&c=1990&d=04&e=24&f=2010&g=d&ignore=.csv" t))

(define (pair-from-ticker ticker)
 (let* ([prices
(map (lambda (l) (string->number (seventh (regexp-split #rx"," l)))) (rest (port->lines (get-pure-port (string->url (ticker- >url ticker))))))] [logdiffs (list->vector (for/list ([p1 (in-list (rest prices))]
                                           [p2 (in-list prices)])
                                  (log (/ p2 p1))))])
   (vector (standard-deviation logdiffs)
           (mean logdiffs))))

(map pair-from-ticker '("T" "IBM"))


... bummer about the long url.

I'm about to combine this with a web-scraper to get the last 20 years of data for every member of the S&P that's been around for 20 years, but that *really* won't fit in the box.

John


_________________________________________________
 For list-related administrative tasks:
 http://list.cs.brown.edu/mailman/listinfo/plt-dev

_________________________________________________
 For list-related administrative tasks:
 http://list.cs.brown.edu/mailman/listinfo/plt-dev

Reply via email to