packages feed

Finance-Quote-Yahoo 0.4 → 0.4.1

raw patch · 2 files changed

+17/−9 lines, 2 filesdep +old-localedep −MissingH

Dependencies added: old-locale

Dependencies removed: MissingH

Files

Finance-Quote-Yahoo.cabal view
@@ -1,5 +1,5 @@ Name:                Finance-Quote-Yahoo-Version:             0.4+Version:             0.4.1 Description:         Obtain quote data from finance.yahoo.com Synopsis:	     Obtain quote data from finance.yahoo.com Category:            Web@@ -14,8 +14,8 @@   Description: Choose the new smaller, split-up base package. Library    if flag(splitBase)-    Build-Depends: base >= 3,containers,network,HTTP,HTTP-Simple,MissingH,time>=1.1.1+    Build-Depends: base >= 3,containers,network,HTTP,HTTP-Simple,time>=1.1.1,old-locale   else-    Build-Depends: base < 3,network,HTTP,HTTP-Simple,MissingH,time>=1.1.1+    Build-Depends: base < 3,network,HTTP,HTTP-Simple,time>=1.1.1   GHC-Options:         -O   Exposed-modules:     Finance.Quote.Yahoo
Finance/Quote/Yahoo.hs view
@@ -71,15 +71,15 @@ module Finance.Quote.Yahoo (getQuote,getHistoricalQuote,defaultQuoteFields,                             baseQuoteURI,baseHistoricalURI,quoteReq,                             QuoteField,QuoteSymbol,QuoteValue,Quote,-                            QuoteCurrency,HistoricalQuote) where+                            QuoteCurrency,HistoricalQuote(..)) where import qualified Network.HTTP.Simple as H (httpGet) -import qualified Data.String as S (join,split) import qualified Network.URI as U (parseURI,escapeURIString,                                    isUnescapedInURI)  import qualified Data.Time.Calendar as T (Day(..),fromGregorian) import qualified Data.Time.Format as F (formatTime) import qualified System.Locale as L (defaultTimeLocale) import qualified Data.Map as M (fromList,Map(..))+import Data.List (intersperse)  {-    License info:@@ -113,7 +113,7 @@ quoteReq symbols fields =      U.escapeURIString U.isUnescapedInURI           $ baseQuoteURI ++ "?s=" ++ -         (S.join "+" symbols) ++ "&f=" ++ (concat fields)+         (join "+" symbols) ++ "&f=" ++ (concat fields)  -- | parseQuote will take a list of symbols, a list of fields, and the  -- csv data and return a Data.Map, as described below (see getQuote).@@ -122,7 +122,7 @@ parseQuote :: [QuoteSymbol] -> [QuoteField] -> QuoteCSV ->               Maybe (M.Map (QuoteSymbol, QuoteField) QuoteValue) parseQuote symbols fields csv = -    let l = concat $ map (S.split ",") $ lines $ +    let l = concat $ map (split ',') $ lines $              filter (\c -> notElem c "\r\"") csv         p = [(x,y) | x <- symbols, y <- fields] in     case (length p == length l) of@@ -200,7 +200,7 @@ -- a list of HistoricalQuote entries. parseHistorical :: QuoteSymbol -> QuoteCSV -> Maybe [HistoricalQuote] parseHistorical symbol' csv = -    let l = reverse $ map (S.split ",") $+    let l = reverse $ map (split ',') $             (tail . lines) $ filter (\c -> notElem c "\r") csv in         Just $ map (makeHistoricalQuote) l     where@@ -228,7 +228,7 @@             -- Create a Day type from the str date from the csv.             makeDay :: String -> T.Day             makeDay s = -                let a = S.split "-" s in+                let a = split '-' s in                 case (length a == 3) of                    False -> error("date field " ++ s ++ " malformed")                   True -> let y = read (a!!0) :: Integer@@ -264,3 +264,11 @@         case trycsv of           Nothing -> return Nothing           Just csv -> return $ parseHistorical symbol csv++split :: Char -> String -> [String]+split delim s = if null rest then [token]+                             else token : split delim (tail rest)+  where (token,rest) = span (/=delim) s++join :: String -> [String] -> String+join sep = concat . intersperse sep