yahoo-prices-0.1.0.5: A wrapper around Yahoo API for downloading market data.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Web.Data.Yahoo.API

Description

A wrapper around Yahoo API for downloading market data. It sends a request to Yahoo's servers and returns results as they are, without any postprocessing. The simples way to use it is to send an empty request. The last price is returned.

>>> fetch $ request "RSX"
Right [Price {date = <last_date>, ...}]

or, more explicitly

>>> fetchLatest "RSX"
Right (Price {date = <latest_date>, ...})
Synopsis

Documentation

type Request = YahooRequest Source #

An alias for a type representing the request record.

fetch :: YahooRequest -> IO (Either String [PriceResponse]) Source #

Sends a request and returns a list of prices or an error message.

fetchLatest :: String -> IO (Either String PriceResponse) Source #

Sends a request for the specified ticker and returns its latest prices or an error code. Throws an exception if the returned list of prices is empty.

request :: String -> YahooRequest Source #

Creates an unparameterized request for the ticker provided. If the request gets send without specifying any additional parameters, it'll return the latest price(s).

withDaily :: YahooRequest -> YahooRequest Source #

Specifies the request to query for daily data.

>>> fetch $ after (day 2021 01 07) . withDaily . request $ "RSX"
Right [Price {date = 2021-01-07, ...}, {date = 2021-01-08, ...} ...]

withWeekly :: YahooRequest -> YahooRequest Source #

Specifies the request to query for weekly data. Note that Yahoo returns data for a beginning of every week specified, including the ones that don't fully fit within the specified range. This might mean that the first record returned might refer to a day that comes before the time range specified in the request.

>>> fetch $ after (day 2021 01 08) . withWeekly . request $ "RSX"
Right [Price {date = 2021-01-04, ...},Price {date = 2021-01-11, ...}, ...]

after :: Day -> YahooRequest -> YahooRequest Source #

Specifies the request to query for all the data available after the specified day, including this day.

>>> fetch $ after (day 2021 01 08) . request $ "RSX"
Right [Price {date = 2021-01-08, ...},Price {date = 2021-01-09, ...}, ...]

before :: Day -> YahooRequest -> YahooRequest Source #

Specifies the request to query for all the data available before the specified day, excluding this day.

>>> fetch $ before (day 2021 01 08) . request $ "RSX"
Right [Price {date = 2007-04-30, ...}, ..., Price {date = 2021-01-07, ...}]

between :: (Day, Day) -> YahooRequest -> YahooRequest Source #

Specifies the request to query for all the data between the range specified, including the opening day and excluding the end day.

>>> fetch $ between (day 2021 01 08, day 2021 01 12) . request $ "RSX"
Right [Price {date = 2021-01-08, ...}, Price {date = 2021-01-11, ...}]

day :: Integer -> Int -> Int -> Day Source #

An alias for "Data.Time.Calendar.fromGregorian". Included for convenience only. Feel free to use "fromGregorian" if it's more conveninent.