packages feed

coinbase-pro 0.9.3.0 → 0.9.3.1

raw patch · 11 files changed

+105/−35 lines, 11 files

Files

LICENSE view
@@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Michael Dunn <michaelsdunn1@gmail.com>+Copyright (c) 2022 Michael Dunn <michaelsdunn1@gmail.com>  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
changelog.md view
@@ -1,3 +1,8 @@+# Version 0.9.3.1++- Added test data to `extra-source-files` so that `cabal test` can be run straight from the hackage+  package+ # Version 0.9.3.0  - `Order` now has `Maybe Bool` instead of `Bool` for `postOnly`. Required to maintain spec compliance.
coinbase-pro.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4.+-- This file has been generated from package.yaml by hpack version 0.35.0. -- -- see: https://github.com/sol/hpack  name:           coinbase-pro-version:        0.9.3.0+version:        0.9.3.1 synopsis:       Client for Coinbase Pro description:    Client for Coinbase Pro REST and Websocket APIs category:       Web, Finance@@ -13,13 +13,14 @@ bug-reports:    https://github.com/mdunnio/coinbase-pro/issues author:         Michael Dunn <michaelsdunn1@gmail.com> maintainer:     Michael Dunn <michaelsdunn1@gmail.com>-copyright:      2021 Michael Dunn <michaelsdunn1@gmail.com>+copyright:      2022 Michael Dunn <michaelsdunn1@gmail.com> license:        MIT license-file:   LICENSE build-type:     Simple extra-source-files:     README.md     changelog.md+    src/test/data/list-orders.json  source-repository head   type: git
src/example/request/Main.hs view
@@ -33,8 +33,8 @@         accountHistory aid >>= liftIO . print         fills (Just btcusd) Nothing >>= liftIO . print         listOrders (Just [All]) (Just btcusd) >>= liftIO . print-        placeOrder Nothing btcusd Sell (Size 0.001) (Price 99999.00) True Nothing Nothing Nothing >>= liftIO . print-        placeOrder Nothing btcusd Buy (Size 1.0) (Price 1.00) True Nothing Nothing Nothing >>= liftIO . print+        placeOrder Nothing btcusd Sell (Just $ Size 0.001) (Just $ Price 99999.00) (Just True) Nothing Nothing Nothing >>= liftIO . print+        placeOrder Nothing btcusd Buy (Just $ Size 1.0) (Just $ Price 1.00) (Just True) Nothing Nothing Nothing >>= liftIO . print         cancelAll (Just btcusd) >>= liftIO . print   where     accessKey  = CBAccessKey "accesskey"
src/lib/CoinbasePro/Authenticated.hs view
@@ -237,9 +237,9 @@ placeOrder :: Maybe ClientOrderId            -> ProductId            -> Side-           -> Size-           -> Price-           -> Bool+           -> Maybe Size+           -> Maybe Price+           -> Maybe Bool            -> Maybe OrderType            -> Maybe STP            -> Maybe TimeInForce@@ -248,7 +248,7 @@     authRequest methodPost requestPath (encodeBody body) $ API.placeOrder body   where     requestPath = encodeRequestPath [ordersPath]-    body        = PlaceOrderBody clordid prid sd sz price po ot stp tif Nothing Nothing+    body        = PlaceOrderBody clordid prid sd sz Nothing price po ot stp tif Nothing Nothing   -- | https://docs.pro.coinbase.com/#place-a-new-order
src/lib/CoinbasePro/Authenticated/Deposit.hs view
@@ -10,6 +10,8 @@     , CryptoDepositAddress (..)     ) where +import           Data.Aeson                         (FromJSON, parseJSON,+                                                     withObject, (.:)) import           Data.Aeson.Casing                  (snakeCase) import           Data.Aeson.TH                      (defaultOptions, deriveJSON,                                                      fieldLabelModifier)@@ -62,9 +64,13 @@     , rPayoutAt :: UTCTime     } deriving (Eq, Show) --deriveJSON defaultOptions { fieldLabelModifier = snakeCase . drop 1 } ''DepositResponse-+instance FromJSON DepositResponse where+    parseJSON = withObject "deposit response" $ \o ->+        DepositResponse+        <$> o .: "id"+        <*> (read <$> o .: "amount")+        <*> o .: "currency"+        <*> o .: "payout_at"  data AddressInfo = AddressInfo     { aiAddress        :: Text
src/lib/CoinbasePro/Authenticated/Orders.hs view
@@ -24,7 +24,7 @@ import           Data.Text         (pack, toLower, unpack) import           Web.HttpApiData   (ToHttpApiData (..)) -import           CoinbasePro.Types (ClientOrderId, CreatedAt, OrderId,+import           CoinbasePro.Types (ClientOrderId, CreatedAt, Funds, OrderId,                                     OrderType, Price, ProductId, Side, Size,                                     filterOrderFieldName) @@ -132,19 +132,21 @@ deriveJSON defaultOptions {fieldLabelModifier = filterOrderFieldName . snakeCase} ''Order  ++ data PlaceOrderBody = PlaceOrderBody     { bClientOid   :: Maybe ClientOrderId     , bProductId   :: ProductId     , bSide        :: Side-    , bSize        :: Size-    , bPrice       :: Price-    , bPostOnly    :: Bool+    , bSize        :: Maybe Size+    , bFunds       :: Maybe Funds+    , bPrice       :: Maybe Price+    , bPostOnly    :: Maybe Bool     , bOrderType   :: Maybe OrderType     , bStp         :: Maybe STP     , bTimeInForce :: Maybe TimeInForce     , bStop        :: Maybe StopLossSide     , bStopPrice   :: Maybe Price     } deriving (Eq, Show)-  deriveJSON defaultOptions {fieldLabelModifier = snakeCase . drop 1, omitNothingFields = True} ''PlaceOrderBody
src/lib/CoinbasePro/Authenticated/Transfer.hs view
@@ -4,6 +4,9 @@ module CoinbasePro.Authenticated.Transfer     ( TransferType (..)     , Transfer (..)+    , TransferDetails (..)+    , WithdrawalTransfer (..)+    , DepositTransfer (..)     ) where  import           Data.Aeson                           (FromJSON (..), ToJSON,@@ -40,7 +43,7 @@     { tId          :: Text     , tType        :: Text     , tCreatedAt   :: CreatedAt-    , tCompletedAt :: UTCTime+    , tCompletedAt :: Maybe UTCTime     , tCanceledAt  :: Maybe UTCTime     , tProcessedAt :: Maybe UTCTime     , tAccountId   :: AccountId@@ -55,7 +58,7 @@     <$> (o .: "id")     <*> (o .: "type")     <*> (o .: "created_at")-    <*> (o .: "completed_at")+    <*> (o .:? "completed_at")     <*> (o .:? "canceled_at")     <*> (o .:? "processed_at")     <*> (o .: "account_id")
src/lib/CoinbasePro/Authenticated/Withdrawal.hs view
@@ -22,18 +22,20 @@  import           CoinbasePro.Authenticated.Accounts (AccountId) import           CoinbasePro.Authenticated.Payment  (PaymentMethodId)+import           Control.Applicative+import           Text.Read                          (readMaybe)   data WithdrawalDetails = WithdrawalDetails-    { destinationTag        :: Maybe Text-    , sentToAddress         :: Maybe Text-    , coinbaseAccountId     :: Text-    , destinationTagName    :: Maybe Text-    , coinbaseWithdrawalId  :: Maybe Text-    , coinbaseTransactionId :: Text-    , cryptoPaymentMethodId :: Text-    , fee                   :: Maybe Double-    , subtotal              :: Maybe Double+    { destinationTag          :: Maybe Text+    , sentToAddress           :: Maybe Text+    , coinbaseAccountId       :: Text+    , destinationTagName      :: Maybe Text+    , coinbaseWithdrawalId    :: Maybe Text+    , coinbaseTransactionId   :: Maybe Text+    , coinbasePaymentMethodId :: Text+    , fee                     :: Maybe Double+    , subtotal                :: Maybe Double     } deriving (Eq, Show)  @@ -44,10 +46,10 @@     <*> o .: "coinbase_account_id"     <*> o .:? "destination_tag_name"     <*> o .:? "coinbase_withdrawal_id"-    <*> o .: "coinbase_transaction_id"+    <*> o .:? "coinbase_transaction_id"     <*> o .: "coinbase_payment_method_id"-    <*> (maybe Nothing read <$> o .:? "fee")-    <*> (maybe Nothing read <$> o .:? "subtotal")+    <*> (maybe Nothing readMaybe <$> o .:? "fee")+    <*> (maybe Nothing readMaybe <$> o .:? "subtotal")   data WithdrawalRequest = WithdrawalRequest@@ -110,8 +112,9 @@     <$> o .: "id"     <*> (read <$> o .: "amount")     <*> o .: "currency"-    <*> (read <$> o .: "fee")-    <*> (read <$> o .: "subtotal")+    <*> ((read <$> o .: "fee") <|> (o .: "fee"))+    <*> ((read <$> o .: "subtotal") <|> (o .: "subtotal"))+   newtype WithdrawalFeeEstimateResponse = WithdrawalFeeEstimateResponse
src/lib/CoinbasePro/Types.hs view
@@ -15,7 +15,7 @@     , Size (..)     , Volume (..)     , TradeId (..)-    , Funds+    , Funds (..)     , OrderType (..)     , CreatedAt (..)     , Candle (..)
+ src/test/data/list-orders.json view
@@ -0,0 +1,50 @@+[+    {+        "id": "d0c5340b-6d6c-49d9-b567-48c4bfca13d2",+        "price": "0.10000000",+        "size": "0.01000000",+        "product_id": "BTC-USD",+        "side": "buy",+        "stp": "dc",+        "type": "limit",+        "time_in_force": "GTC",+        "post_only": false,+        "created_at": "2016-12-08T20:02:28.53864Z",+        "fill_fees": "0.0000000000000000",+        "filled_size": "0.00000000",+        "executed_value": "0.0000000000000000",+        "status": "open",+        "settled": false+    },+    {+        "id": "8b99b139-58f2-4ab2-8e7a-c11c846e3022",+        "price": "1.00000000",+        "size": "1.00000000",+        "product_id": "BTC-USD",+        "side": "buy",+        "stp": "dc",+        "type": "limit",+        "time_in_force": "GTC",+        "post_only": false,+        "created_at": "2016-12-08T20:01:19.038644Z",+        "fill_fees": "0.0000000000000000",+        "filled_size": "0.00000000",+        "executed_value": "0.0000000000000000",+        "status": "open",+        "settled": false+    },+    {+        "id": "b227e691-365c-470f-a860-a9b4a37dd1d8",+        "price": "1.00000000",+        "size": "1.00000000",+        "product_id": "BTC-USD",+        "side": "buy",+        "type": "limit",+        "created_at": "2016-12-08T20:01:19.038644Z",+        "fill_fees": "0.0000000000000000",+        "filled_size": "0.00000000",+        "executed_value": "0.0000000000000000",+        "status": "pending",+        "settled": false+    }+]