packages feed

coinbase-pro 0.9.2.0 → 0.9.2.2

raw patch · 12 files changed

+118/−78 lines, 12 filesdep +exceptionsdep ~cryptonitePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: exceptions

Dependency ranges changed: cryptonite

API changes (from Hackage documentation)

+ CoinbasePro.Authenticated.Accounts: instance GHC.Classes.Ord CoinbasePro.Authenticated.Accounts.Balance
+ CoinbasePro.Authenticated.Accounts: instance GHC.Classes.Ord CoinbasePro.Authenticated.Accounts.FeeRate
+ CoinbasePro.Authenticated.Accounts: instance GHC.Num.Num CoinbasePro.Authenticated.Accounts.Balance
+ CoinbasePro.Authenticated.Limits: instance GHC.Classes.Ord CoinbasePro.Authenticated.Limits.Max
+ CoinbasePro.Authenticated.Limits: instance GHC.Classes.Ord CoinbasePro.Authenticated.Limits.Remaining
+ CoinbasePro.Authenticated.Request: instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (CoinbasePro.Authenticated.Request.CBAuthT m)
+ CoinbasePro.Authenticated.Request: instance Control.Monad.Catch.MonadMask m => Control.Monad.Catch.MonadMask (CoinbasePro.Authenticated.Request.CBAuthT m)
+ CoinbasePro.Authenticated.Request: instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (CoinbasePro.Authenticated.Request.CBAuthT m)
+ CoinbasePro.Authenticated.Request: runDefCbAuthT :: Environment -> CoinbaseProCredentials -> CBAuthT ClientM a -> IO a
+ CoinbasePro.MarketData.Types: instance GHC.Classes.Ord CoinbasePro.MarketData.Types.CBTime
+ CoinbasePro.Types: instance GHC.Classes.Ord CoinbasePro.Types.CreatedAt
+ CoinbasePro.Types: instance GHC.Num.Num CoinbasePro.Types.Price
+ CoinbasePro.Types: instance GHC.Num.Num CoinbasePro.Types.Size
+ CoinbasePro.Unauthenticated: singleProduct :: ProductId -> ClientM Product
+ CoinbasePro.Unauthenticated.API: singleProduct :: ProductId -> CBRequest Product
- CoinbasePro.Request: run :: Environment -> ClientM a -> IO a
+ CoinbasePro.Request: run :: Environment -> Runner a
- CoinbasePro.Request: runWithManager :: Manager -> Environment -> ClientM a -> IO a
+ CoinbasePro.Request: runWithManager :: Manager -> Environment -> Runner a
- CoinbasePro.Request: run_ :: Environment -> ClientM a -> IO ()
+ CoinbasePro.Request: run_ :: Environment -> Runner ()

Files

README.md view
@@ -88,7 +88,7 @@ ### Authenticated Private Requests  ```haskell-runCbAuthT (run Sandbox) cpc $ do+runDefCbAuthT Sandbox cpc $ do     fills (Just btcusd) Nothing >>= liftIO . print   where     accessKey  = CBAccessKey "<access-key>"
changelog.md view
@@ -1,3 +1,14 @@+# Version 0.9.2.2++- Added `CoinbasePro.Unauthenticated.singleProduct`++# Version 0.9.2.1++- Use `Runner` instead of `ClientM a -> IO a` where applicable+- Added more documentation around `Runner`+- Added `runDefCbAuthT` as a default for calling `runCbAuthT` without passing in a `Runner`+- Updated `src/example/request/Main.hs` to reflect `runDefCbAuthT` and a minor refactor+ # Version 0.9.2.0  Feature complete! (except FIX)
coinbase-pro.cabal view
@@ -1,13 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack------ hash: 9fd25d5880f390c5d7bd6d9d15430fda9adbdbe220b886dda4c4832c46e9e634  name:           coinbase-pro-version:        0.9.2.0+version:        0.9.2.2 synopsis:       Client for Coinbase Pro description:    Client for Coinbase Pro REST and Websocket APIs category:       Web, Finance@@ -25,7 +23,7 @@  source-repository head   type: git-  location: https://github.com/https://github.com/mdunnio/coinbase-pro+  location: https://github.com/mdunnio/coinbase-pro  library   exposed-modules:@@ -74,35 +72,36 @@   hs-source-dirs:       src/lib/   build-depends:-      HsOpenSSL >=0.11 && <0.12+      HsOpenSSL ==0.11.*     , aeson >=1.2 && <1.6     , aeson-casing >=0.1 && <0.3     , async >=2.1 && <2.3     , base >=4.7 && <5-    , binary >=0.8 && <0.9-    , bytestring >=0.10 && <0.11+    , binary ==0.8.*+    , bytestring ==0.10.*     , containers >=0.5 && <0.7-    , cryptonite >=0.24 && <0.28+    , cryptonite >=0.24 && <0.30+    , exceptions >=0.4 && <1.0     , http-api-data >=0.3 && <0.5     , http-client >=0.5 && <0.7-    , http-client-tls >=0.3 && <0.4-    , http-streams >=0.8 && <0.9-    , http-types >=0.12 && <0.13-    , io-streams >=1.5 && <1.6+    , http-client-tls ==0.3.*+    , http-streams ==0.8.*+    , http-types ==0.12.*+    , io-streams ==1.5.*     , memory >=0.14 && <0.16     , network >=2.6 && <3.2     , servant >=0.14 && <0.19     , servant-client >=0.14 && <0.19     , servant-client-core >=0.14 && <0.19-    , text >=1.2 && <1.3+    , text ==1.2.*     , time >=1.8 && <2.0-    , transformers >=0.5 && <0.6-    , unagi-streams >=0.2 && <0.3-    , unordered-containers >=0.2 && <0.3-    , uuid >=1.3 && <1.4-    , vector >=0.12 && <0.13-    , websockets >=0.12 && <0.13-    , wuss >=1.1 && <1.2+    , transformers ==0.5.*+    , unagi-streams ==0.2.*+    , unordered-containers ==0.2.*+    , uuid ==1.3.*+    , vector ==0.12.*+    , websockets ==0.12.*+    , wuss ==1.1.*   default-language: Haskell2010  executable test-request@@ -112,36 +111,37 @@   hs-source-dirs:       src/example/request/   build-depends:-      HsOpenSSL >=0.11 && <0.12+      HsOpenSSL ==0.11.*     , aeson >=1.2 && <1.6     , aeson-casing >=0.1 && <0.3     , async >=2.1 && <2.3     , base >=4.7 && <5-    , binary >=0.8 && <0.9-    , bytestring >=0.10 && <0.11+    , binary ==0.8.*+    , bytestring ==0.10.*     , coinbase-pro     , containers >=0.5 && <0.7-    , cryptonite >=0.24 && <0.28+    , cryptonite >=0.24 && <0.30+    , exceptions >=0.4 && <1.0     , http-api-data >=0.3 && <0.5     , http-client >=0.5 && <0.7-    , http-client-tls >=0.3 && <0.4-    , http-streams >=0.8 && <0.9-    , http-types >=0.12 && <0.13-    , io-streams >=1.5 && <1.6+    , http-client-tls ==0.3.*+    , http-streams ==0.8.*+    , http-types ==0.12.*+    , io-streams ==1.5.*     , memory >=0.14 && <0.16     , network >=2.6 && <3.2     , servant >=0.14 && <0.19     , servant-client >=0.14 && <0.19     , servant-client-core >=0.14 && <0.19-    , text >=1.2 && <1.3+    , text ==1.2.*     , time >=1.8 && <2.0-    , transformers >=0.5 && <0.6-    , unagi-streams >=0.2 && <0.3-    , unordered-containers >=0.2 && <0.3-    , uuid >=1.3 && <1.4-    , vector >=0.12 && <0.13-    , websockets >=0.12 && <0.13-    , wuss >=1.1 && <1.2+    , transformers ==0.5.*+    , unagi-streams ==0.2.*+    , unordered-containers ==0.2.*+    , uuid ==1.3.*+    , vector ==0.12.*+    , websockets ==0.12.*+    , wuss ==1.1.*   default-language: Haskell2010  executable test-stream@@ -151,34 +151,35 @@   hs-source-dirs:       src/example/stream/   build-depends:-      HsOpenSSL >=0.11 && <0.12+      HsOpenSSL ==0.11.*     , aeson >=1.2 && <1.6     , aeson-casing >=0.1 && <0.3     , async >=2.1 && <2.3     , base >=4.7 && <5-    , binary >=0.8 && <0.9-    , bytestring >=0.10 && <0.11+    , binary ==0.8.*+    , bytestring ==0.10.*     , coinbase-pro     , containers >=0.5 && <0.7-    , cryptonite >=0.24 && <0.28+    , cryptonite >=0.24 && <0.30+    , exceptions >=0.4 && <1.0     , http-api-data >=0.3 && <0.5     , http-client >=0.5 && <0.7-    , http-client-tls >=0.3 && <0.4-    , http-streams >=0.8 && <0.9-    , http-types >=0.12 && <0.13-    , io-streams >=1.5 && <1.6+    , http-client-tls ==0.3.*+    , http-streams ==0.8.*+    , http-types ==0.12.*+    , io-streams ==1.5.*     , memory >=0.14 && <0.16     , network >=2.6 && <3.2     , servant >=0.14 && <0.19     , servant-client >=0.14 && <0.19     , servant-client-core >=0.14 && <0.19-    , text >=1.2 && <1.3+    , text ==1.2.*     , time >=1.8 && <2.0-    , transformers >=0.5 && <0.6-    , unagi-streams >=0.2 && <0.3-    , unordered-containers >=0.2 && <0.3-    , uuid >=1.3 && <1.4-    , vector >=0.12 && <0.13-    , websockets >=0.12 && <0.13-    , wuss >=1.1 && <1.2+    , transformers ==0.5.*+    , unagi-streams ==0.2.*+    , unordered-containers ==0.2.*+    , uuid ==1.3.*+    , vector ==0.12.*+    , websockets ==0.12.*+    , wuss ==1.1.*   default-language: Haskell2010
src/example/request/Main.hs view
@@ -18,15 +18,16 @@  main :: IO () main = do-    run Sandbox (stats btcusd) >>= print-    run Sandbox (candles btcusd Nothing Nothing Minute) >>= print-    run Sandbox (trades btcusd) >>= print-    run Sandbox time >>= print-    run Sandbox products >>= print-    run Sandbox (aggregateOrderBook btcusd (Just Best)) >>= print-    run Sandbox (aggregateOrderBook btcusd (Just TopFifty)) >>= print-    run Sandbox (fullOrderBook btcusd) >>= print-    runCbAuthT (run Sandbox) cpc $ do+    run Sandbox $ do+        stats btcusd >>= liftIO . print+        candles btcusd Nothing Nothing Minute >>= liftIO . print+        trades btcusd >>= liftIO . print+        time >>= liftIO . print+        products >>= liftIO . print+        aggregateOrderBook btcusd (Just Best) >>= liftIO . print+        aggregateOrderBook btcusd (Just TopFifty) >>= liftIO . print+        fullOrderBook btcusd >>= liftIO . print+    runDefCbAuthT Sandbox cpc $ do         accounts >>= liftIO . print         account aid >>= liftIO . print         accountHistory aid >>= liftIO . print
src/lib/CoinbasePro/Authenticated/Accounts.hs view
@@ -53,7 +53,7 @@   newtype Balance = Balance Double-    deriving (Eq, Show)+    deriving (Eq, Show, Ord, Num)   instance ToJSON Balance where@@ -90,7 +90,7 @@   newtype FeeRate = FeeRate { unFeeRate :: Double }-    deriving (Eq, Show, FromJSON, ToJSON)+    deriving (Eq, Show, Ord, FromJSON, ToJSON)   data Fees = Fees
src/lib/CoinbasePro/Authenticated/Limits.hs view
@@ -20,11 +20,11 @@   newtype Max = Max Double-  deriving (Eq, Show, ToJSON, FromJSON)+  deriving (Eq, Show, Ord, ToJSON, FromJSON)   newtype Remaining = Remaining Double-  deriving (Eq, Show, ToJSON, FromJSON)+  deriving (Eq, Show, Ord, ToJSON, FromJSON)   newtype PeriodInDays = PeriodInDays Int
src/lib/CoinbasePro/Authenticated/Request.hs view
@@ -7,6 +7,7 @@ module CoinbasePro.Authenticated.Request     ( CBAuthT (..)     , runCbAuthT+    , runDefCbAuthT      , CoinbaseProCredentials (..)     , CBSecretKey (..)@@ -20,6 +21,7 @@     , mkCBAccessTimeStamp     ) where +import           Control.Monad.Catch               (MonadCatch, MonadThrow, MonadMask) import           Control.Monad.IO.Class            (MonadIO, liftIO) import           Control.Monad.Trans.Class         (MonadTrans, lift) import           Control.Monad.Trans.Reader        (ReaderT, asks, runReaderT)@@ -50,8 +52,10 @@                                                     CBAccessPassphrase (..),                                                     CBAccessSign (..),                                                     CBAccessTimeStamp (..))+import           CoinbasePro.Environment           (Environment) import           CoinbasePro.Headers               (userAgent)-import           CoinbasePro.Request               (Body, RequestPath, Runner)+import           CoinbasePro.Request               (Body, RequestPath, Runner,+                                                    run)   newtype CBSecretKey = CBSecretKey String@@ -66,11 +70,21 @@   newtype CBAuthT m a = CBAuthT { unCbAuth :: ReaderT CoinbaseProCredentials m a }-    deriving (Functor, Applicative, Monad, MonadIO, MonadTrans)+    deriving (Functor, Applicative, Monad, MonadIO, MonadTrans, MonadThrow, MonadCatch, MonadMask)  +-- | Sequences `ClientM` actions using the same auth credentials+--+-- This allows for custom `Runner`s to be used. runCbAuthT :: Runner a -> CoinbaseProCredentials -> CBAuthT ClientM a -> IO a runCbAuthT runEnv cpc = runEnv . flip runReaderT cpc . unCbAuth+++-- | Sequences `ClientM` actions using the same auth credentials+--+-- Should be used over `runCbAuthT` unless a bespoke `Runner` needs to be used.+runDefCbAuthT :: Environment -> CoinbaseProCredentials -> CBAuthT ClientM a -> IO a+runDefCbAuthT env = runCbAuthT (run env)   type instance AuthClientData (AuthProtect "CBAuth") = (CBAccessKey, CBAccessSign, CBAccessTimeStamp, CBAccessPassphrase)
src/lib/CoinbasePro/MarketData/Types.hs view
@@ -49,7 +49,7 @@     toQueryParam = toQueryParam . productId  -newtype CBTime = CBTime { unCBTime :: UTCTime } deriving (Eq, Show)+newtype CBTime = CBTime { unCBTime :: UTCTime } deriving (Eq, Show, Ord)   instance FromJSON CBTime where
src/lib/CoinbasePro/Request.hs view
@@ -48,7 +48,7 @@ -- ^ Serialized as a part of building CBAccessSign type Body        = ByteString -+-- ^ Sequenced `ClientM a` that result in `IO a` type Runner a = ClientM a -> IO a  @@ -57,7 +57,7 @@ -- -- > run Production products >>= print ---run :: Environment -> ClientM a -> IO a+run :: Environment -> Runner a run env f = do     mgr <- newManager tlsManagerSettings     runWithManager mgr env f@@ -65,7 +65,7 @@  ------------------------------------------------------------------------------ -- | Same as 'run', except uses `()` instead of a type `a`-run_ :: Environment -> ClientM a -> IO ()+run_ :: Environment -> Runner () run_ = (void .) . run  @@ -80,7 +80,7 @@ -- print prds -- @ ---runWithManager :: Manager -> Environment -> ClientM a -> IO a+runWithManager :: Manager -> Environment -> Runner a runWithManager mgr env f = either throw return =<<     runClientM f (mkClientEnv mgr (BaseUrl Https api 443 mempty))   where
src/lib/CoinbasePro/Types.hs view
@@ -111,7 +111,7 @@   newtype Price = Price { unPrice :: Double }-    deriving (Eq, Ord, ToHttpApiData)+    deriving (Eq, Ord, Num, ToHttpApiData)   instance Show Price where@@ -128,7 +128,7 @@   newtype Size = Size { unSize :: Double }-    deriving (Eq, Ord, ToHttpApiData)+    deriving (Eq, Ord, Num, ToHttpApiData)   instance Show Size where@@ -198,7 +198,7 @@   newtype CreatedAt = CreatedAt UTCTime-    deriving (Eq, Show)+    deriving (Eq, Show, Ord)   deriveJSON defaultOptions ''CreatedAt
src/lib/CoinbasePro/Unauthenticated.hs view
@@ -2,6 +2,7 @@  module CoinbasePro.Unauthenticated    ( products+   , singleProduct    , aggregateOrderBook    , fullOrderBook    , trades@@ -31,6 +32,11 @@ -- | https://docs.pro.coinbase.com/#get-products products :: ClientM [Product] products = API.products userAgent+++-- | https://docs.pro.coinbase.com/#get-single-product+singleProduct :: ProductId -> ClientM Product+singleProduct prid = API.singleProduct prid userAgent   -- | https://docs.pro.coinbase.com/#get-product-order-book
src/lib/CoinbasePro/Unauthenticated/API.hs view
@@ -3,6 +3,7 @@  module CoinbasePro.Unauthenticated.API     ( products+    , singleProduct     , aggregateOrderBook     , fullOrderBook     , trades@@ -35,6 +36,10 @@  type Products = "products" :> CBGet [Product] +type ProductSingle = "products"+                   :> Capture "product" ProductId+                   :> CBGet Product+ type ProductAggregateOrderBook = "products"                                :> Capture "product" ProductId                                :> "book"@@ -71,6 +76,7 @@ type Time = "time" :> CBGet CBTime  type API =    Products+         :<|> ProductSingle          :<|> ProductAggregateOrderBook          :<|> ProductFullOrderBook          :<|> Trades@@ -85,6 +91,7 @@   products :: CBRequest [Product]+singleProduct :: ProductId -> CBRequest Product aggregateOrderBook :: ProductId -> Maybe AggregateBookLevel -> CBRequest AggregateOrderBook fullOrderBook :: ProductId -> Maybe FullBookLevel -> CBRequest FullOrderBook trades :: ProductId -> CBRequest [Trade]@@ -92,4 +99,4 @@ stats :: ProductId -> CBRequest TwentyFourHourStats currencies :: CBRequest [Currency] time :: CBRequest CBTime-products :<|> aggregateOrderBook :<|> fullOrderBook :<|> trades :<|> candles :<|> stats :<|> currencies :<|> time = client api+products :<|> singleProduct :<|> aggregateOrderBook :<|> fullOrderBook :<|> trades :<|> candles :<|> stats :<|> currencies :<|> time = client api