Safe Haskell | None |
---|---|
Language | Haskell2010 |
Here's a simple wrapper around API offered by Stooq.pl. It's capable of returning the latest price for the given instrument. For more information about tickers available, visit the service. Keep in mind that in some situations their ticker convention is different to what's known e.g. from Yahoo Finance e.g.
xxxx.UK: London Stock Exchange (LSE)
xxxx.US: NYSE (OTC market not available, so a lot of ADRs like OGZPY or SBRCY can't be fetched)
xxxx.DE: Deutsche Börse
xxxx.JP: Tokyo Stock Exchange
xxxx: (no exchange code after full stop) Warsaw Stock Exchange (GPW)
Use:
>>>
fetch "SPY.US"
Just [StooqPrice {symbol = StooqSymbol "SPY.US", time = ..., ...}]
Synopsis
- newtype StooqSymbol = StooqSymbol String
- data StooqPrice = StooqPrice {}
- fetchPrice :: StooqSymbol -> IO (Maybe [StooqPrice])
- fetchPrices :: [StooqSymbol] -> IO (Maybe [StooqPrice])
- fetch :: String -> IO (Maybe [StooqPrice])
Documentation
newtype StooqSymbol Source #
A single-case DU that represents a ticker.
Instances
Eq StooqSymbol Source # | |
Defined in Web.Data.Stooq.API (==) :: StooqSymbol -> StooqSymbol -> Bool # (/=) :: StooqSymbol -> StooqSymbol -> Bool # | |
Ord StooqSymbol Source # | |
Defined in Web.Data.Stooq.API compare :: StooqSymbol -> StooqSymbol -> Ordering # (<) :: StooqSymbol -> StooqSymbol -> Bool # (<=) :: StooqSymbol -> StooqSymbol -> Bool # (>) :: StooqSymbol -> StooqSymbol -> Bool # (>=) :: StooqSymbol -> StooqSymbol -> Bool # max :: StooqSymbol -> StooqSymbol -> StooqSymbol # min :: StooqSymbol -> StooqSymbol -> StooqSymbol # | |
Read StooqSymbol Source # | |
Defined in Web.Data.Stooq.API readsPrec :: Int -> ReadS StooqSymbol # readList :: ReadS [StooqSymbol] # readPrec :: ReadPrec StooqSymbol # readListPrec :: ReadPrec [StooqSymbol] # | |
Show StooqSymbol Source # | |
Defined in Web.Data.Stooq.API showsPrec :: Int -> StooqSymbol -> ShowS # show :: StooqSymbol -> String # showList :: [StooqSymbol] -> ShowS # |
data StooqPrice Source #
A type representing market price data returned by Stooq.
Instances
Show StooqPrice Source # | |
Defined in Web.Data.Stooq.API showsPrec :: Int -> StooqPrice -> ShowS # show :: StooqPrice -> String # showList :: [StooqPrice] -> ShowS # |
fetchPrice :: StooqSymbol -> IO (Maybe [StooqPrice]) Source #
Sends a request for the specified ticker and returns its latest price. Returns Nothing if the response is invalid (this is most likely due to using a non-existent ticker).
fetchPrices :: [StooqSymbol] -> IO (Maybe [StooqPrice]) Source #
Sends a request for multiple tickers at once. The function makes only a single HTTP call.
fetch :: String -> IO (Maybe [StooqPrice]) Source #
A shorthand around "fetchPrice" that allows to call the function using a plain String, without converting it to a StooqSymbol
first.