Drop unneeded import.
[haskell-cryptsy-api.git] / Cryptsy / API / Public / OrderData.hs
blob9fdd37b69ed3d74050541801b8a5d014ef88c3b3
1 {-# LANGUAGE FlexibleContexts, UndecidableInstances #-}
2 module Cryptsy.API.Public.OrderData
3 ( module Cryptsy.API.Public.OrderData
4 , module Cryptsy.API.Public.Types.OrderBook
5 , module Cryptsy.API.Public.Types.Monad
6 , module Cryptsy.API.Public.Types.Num
8 where
10 -- aeson
11 import Data.Aeson (FromJSON(..), Value, withObject)
12 import Data.Aeson.Types (Parser)
14 -- base
15 import Data.Function (($))
16 import Data.Functor (fmap, (<$>))
17 import Data.String (String)
18 import Data.Traversable (mapM)
19 import Prelude ()
20 import Text.Show (Show)
22 -- text
23 import Data.Text (Text)
25 -- unordered-containers
26 import Data.HashMap.Strict (HashMap)
28 -- this package
29 import Cryptsy.API.Public.Internal
30 import Cryptsy.API.Public.Types.OrderBook
31 import Cryptsy.API.Public.Types.Monad
32 import Cryptsy.API.Public.Types.Num
34 -- |general order data parameterized by types for prices, quantities,
35 -- and totals (price * quantity)
36 newtype GOrderData p q t =
37 OrderData { orderBooks :: HashMap Text (GOrderBook p q t) }
38 deriving Show
40 -- |default order data
41 type OrderData = GOrderData CryptsyNum CryptsyNum CryptsyNum
43 instance FromJSON (GOrderBook p q t) => FromJSON (GOrderData p q t) where
44 parseJSON = parseOrderData parseJSON
46 -- |Build parser for multiple orderbooks from parser for single orderbook.
47 parseOrderData :: (Value -> Parser (GOrderBook p q t)) -- ^ orderbook parser
48 -> Value -> Parser (GOrderData p q t)
49 parseOrderData parseBook =
50 withObject "OrderData" $ fmap OrderData <$> mapM parseBook
52 -- |URL for API call
53 orderdataURL :: String
54 orderdataURL = pubURL "orderdata"
56 -- |Request full order book for all markets.
57 orderData :: FromJSON (GOrderData p q t) => PubCryptsy (GOrderData p q t)
58 orderData = pubCryptsy orderdataURL parseJSON