Finance-Quote-Yahoo 0.2 → 0.3
raw patch · 2 files changed
+9/−5 lines, 2 files
Files
- Finance-Quote-Yahoo.cabal +1/−1
- Finance/Quote/Yahoo.hs +8/−4
Finance-Quote-Yahoo.cabal view
@@ -1,5 +1,5 @@ Name: Finance-Quote-Yahoo-Version: 0.2+Version: 0.3 Description: Obtain quote data from finance.yahoo.com Synopsis: Obtain quote data from finance.yahoo.com Category: Web
Finance/Quote/Yahoo.hs view
@@ -39,6 +39,9 @@ end date. Yahoo does not let you choose the fields to see in historical quotes, data is limited to price and volume information. +quoteRec - useful for debugging the quote URI to see if Yahoo is denying+the service.+ Here is small complete program illustrating the use of this module @@@ -66,7 +69,7 @@ -} module Finance.Quote.Yahoo (getQuote,getHistoricalQuote,defaultQuoteFields,- baseQuoteURI,baseHistoricalURI,+ baseQuoteURI,baseHistoricalURI,quoteReq, QuoteField,QuoteSymbol,QuoteValue,Quote, QuoteCurrency,HistoricalQuote) where import qualified Network.HTTP.Simple as H (httpGet) @@ -99,7 +102,7 @@ Just uri -> H.httpGet uri -- | This is the base uri to get csv quotes. Exported. -baseQuoteURI = "http://finance.yahoo.com/d/quotes.csv" :: String+baseQuoteURI = "http://download.finance.yahoo.com/d/quotes.csv" :: String -- | If you just want the name, latest price and change, use this. Exported. defaultQuoteFields = ["n","l1","c"] :: [QuoteField] @@ -145,9 +148,10 @@ IO (Maybe (M.Map (QuoteSymbol, QuoteField) QuoteValue)) getQuote symbols fields = do- trycsv <- fetchCSV (quoteReq symbols fields)+ let req = quoteReq symbols fields+ trycsv <- fetchCSV req case trycsv of- Nothing -> return Nothing+ Nothing -> error("no csv returned for " ++ req) Just csv -> return $ parseQuote symbols fields csv -- | This is the base uri to get csv historical quote data. Exported.