#!/bin/env gxi (import :std/net/request :std/format :std/xml :std/text/json) #| Yahoo Finance Headers headers: '( ("x-rapidapi-host" . "apidojo-yahoo-finance-v1.p.rapidapi.com") ("x-rapidapi-key" . "98c32048f8mshe6f4d8a686ddce9p18cc5ajsn8b8888e7e256") ) |# ; Declare the file from which we'll load our stockminder configuration ; Things like stock symbols, favourite functions, timing preferences, etc. (define-values (stockminder-config stocklist output-file) (values (open-input-file "stocklist.conf") ; Initialize our stocklist so we can throw stuff in there after we parse ; the config file. `() (open-output-file "test.out") ) ) ; The procedure we'll use to iterate through config values and add symbols ; to our stocklist (define read-config (lambda (config-file) (let read-loop ((config-chomp (read config-file))) (if (eof-object? config-chomp) (close-input-port config-file) (and (set! stocklist (append stocklist `(,config-chomp))) (read-loop (read config-file)) ) ) ) )) ; Now the business end; parse the config file (read-config stockminder-config) (define-values (api-function api-url api-key) (values "TIME_SERIES_DAILY" "https://www.alphavantage.co/" "EC4C0NRKZAK1Q2UG" ) ) (let ((stock-symbols stocklist)) (map (lambda (x) (display (string-append api-url "query?function=" api-function "&symbol=" (symbol->string x) "&apikey=" api-key "\n"))) stock-symbols ) )