Finance-Quote-Yahoo 0.5.0 → 0.6.0
raw patch · 2 files changed
+24/−18 lines, 2 filesdep +curldep −HTTPdep −HTTP-SimplePVP ok
version bump matches the API change (PVP)
Dependencies added: curl
Dependencies removed: HTTP, HTTP-Simple
API changes (from Hackage documentation)
+ Finance.Quote.Yahoo: baseHistoricalURI :: [Char]
+ Finance.Quote.Yahoo: baseQuoteURI :: String
+ Finance.Quote.Yahoo: defaultQuoteFields :: [QuoteField]
Files
- Finance-Quote-Yahoo.cabal +3/−3
- Finance/Quote/Yahoo.hs +21/−15
Finance-Quote-Yahoo.cabal view
@@ -1,5 +1,5 @@ Name: Finance-Quote-Yahoo-Version: 0.5.0+Version: 0.6.0 Description: Obtain quote data from finance.yahoo.com Synopsis: Obtain quote data from finance.yahoo.com Category: Web@@ -10,6 +10,7 @@ Author: brad clawsie Maintainer: haskell@fastmail.fm cabal-version: >=1.2+build-type: Simple Flag splitBase Description: Choose the new smaller, split-up base package. Library @@ -17,6 +18,5 @@ Build-Depends: base >= 3,containers,old-locale else Build-Depends: base < 3- Build-Depends: network,HTTP,HTTP-Simple,time>=1.1.1- GHC-Options: -O+ Build-Depends: network,curl,time>=1.1.1 Exposed-modules: Finance.Quote.Yahoo
Finance/Quote/Yahoo.hs view
@@ -73,7 +73,8 @@ QuoteField,QuoteSymbol,QuoteValue,Quote, QuoteCurrency,QuoteFrequency(..), HistoricalQuote(..)) where-import qualified Network.HTTP.Simple as H (httpGet) +import qualified Network.Curl as C (curlGetString)+import qualified Network.Curl.Code as CC import qualified Network.URI as U (parseURI,escapeURIString, isUnescapedInURI) import qualified Data.Time.Calendar as T (Day(..),fromGregorian)@@ -100,7 +101,12 @@ fetchCSV :: QuoteSymbol -> IO (Maybe String) fetchCSV s = case U.parseURI s of Nothing -> error("uri malformed:" ++ s)- Just uri -> H.httpGet uri+ Just uri -> + do + tryCSV <- C.curlGetString s []+ case (fst tryCSV) of+ CC.CurlOK -> return (Just $ snd tryCSV)+ _ -> return (Nothing) -- | This is the base uri to get csv quotes. Exported. baseQuoteURI = "http://download.finance.yahoo.com/d/quotes.csv" :: String@@ -224,21 +230,21 @@ makeHistoricalQuote l = case (length l == 7) of False -> error("malformed line:" ++ (show l))- True -> let date' = makeDay (l!!0)- open' = read (l!!1) :: QuoteCurrency- high' = read (l!!2) :: QuoteCurrency- low' = read (l!!3) :: QuoteCurrency- close' = read (l!!4) :: QuoteCurrency+ True -> let date' = makeDay (l!!0)+ open' = read (l!!1) :: QuoteCurrency+ high' = read (l!!2) :: QuoteCurrency+ low' = read (l!!3) :: QuoteCurrency+ close' = read (l!!4) :: QuoteCurrency adjclose' = read (l!!6) :: QuoteCurrency- volume' = read (l!!5) :: Int - in HistoricalQuote { symbol = symbol',- date = date',- open = open',- high = high',- low = low',- close = close',+ volume' = read (l!!5) :: Int + in HistoricalQuote { symbol = symbol',+ date = date',+ open = open',+ high = high',+ low = low',+ close = close', adjclose = adjclose',- volume = volume' }+ volume = volume' } where -- Create a Day type from the str date from the csv. makeDay :: String -> T.Day