module Network.Bitcoin.BitX.Types
(
Ticker(..),
CcyPair(..),
Orderbook(..),
Order(..),
Bid,
Ask,
Trade(..),
BitXAuth(..),
PrivateOrder(..),
OrderID,
OrderType(..),
RequestStatus(..),
OrderRequest(..),
MarketOrderRequest(..),
RequestSuccess,
BitXError(..),
PrivateOrderWithTrades(..),
AccountID,
Asset(..),
Balance(..),
FundingAddress(..),
WithdrawalRequest(..),
NewWithdrawal(..),
WithdrawalType(..),
BitcoinSendRequest(..),
QuoteRequest(..),
OrderQuote(..),
QuoteType(..),
BitXClientAuth,
Transaction(..),
Account(..),
mkBitXAuth,
mkAccount,
mkBitcoinSendRequest,
mkOrderRequest,
mkQuoteRequest,
mkNewWithdrawal,
mkMarketOrderRequest,
HasError(..),
HasErrorCode(..),
HasTimestamp(..),
HasBid(..),
HasAsk(..),
HasLastTrade(..),
HasRolling24HourVolume(..),
HasPair(..),
HasVolume(..),
HasPrice(..),
HasBids(..),
HasAsks(..),
HasSecret(..),
HasId(..),
HasBase(..),
HasCounter(..),
HasCreationTimestamp(..),
HasExpirationTimestamp(..),
HasFeeBase(..),
HasFeeCounter(..),
HasLimitPrice(..),
HasState(..),
HasOrderType(..),
HasLimitVolume(..),
HasTrades(..),
HasRowIndex(..),
HasBalance(..),
HasAvailable(..),
HasBalanceDelta(..),
HasAvailableDelta(..),
HasCurrency(..),
HasDescription(..),
HasAsset(..),
HasReserved(..),
HasUnconfirmed(..),
HasAddress(..),
HasTotalReceived(..),
HasTotalUnconfirmed(..),
HasAmount(..),
HasWithdrawalType(..),
HasMessage(..),
HasQuoteType(..),
HasBaseAmount(..),
HasCounterAmount(..),
HasCreatedAt(..),
HasExpiresAt(..),
HasDiscarded(..),
HasExercised(..),
HasName(..)
) where
import Data.Aeson (FromJSON(..))
import Data.Text (Text)
import Data.Time.Clock
import GHC.Generics (Generic)
import Data.Scientific (Scientific)
import Lens.Micro.TH (makeFields)
type OrderID = Text
data OrderType =
ASK
| BID
deriving (Show, Generic, Eq)
data RequestStatus =
PENDING
| COMPLETE
| CANCELLED
deriving (Show, Generic, Eq)
type AccountID = Text
data BitXError = BitXError {
bitXErrorError :: Text,
bitXErrorErrorCode :: Text
} deriving (Eq, Show)
makeFields ''BitXError
data CcyPair =
XBTZAR
| XBTNAD
| ZARXBT
| NADXBT
| XBTKES
| KESXBT
| XBTMYR
| MYRXBT
| XBTNGN
| NGNXBT
deriving (Show, Generic, Eq)
data Ticker = Ticker {
tickerTimestamp :: UTCTime,
tickerBid :: Int,
tickerAsk :: Int,
tickerLastTrade :: Int,
tickerRolling24HourVolume :: Scientific,
tickerPair :: CcyPair
} deriving (Eq, Show)
makeFields ''Ticker
data Asset =
ZAR
| NAD
| XBT
| KES
| MYR
| NGN
deriving (Show, Generic, Eq)
data WithdrawalType =
ZAR_EFT
| NAD_EFT
| KES_MPESA
| MYR_IBG
| IDR_LLG
deriving (Show, Generic, Eq)
data QuoteType = BUY | SELL deriving (Show, Generic, Eq)
type RequestSuccess = Bool
data Order = Order {
orderVolume :: Scientific,
orderPrice :: Int
} deriving (Eq, Show)
makeFields ''Order
type Bid = Order
type Ask = Order
data Orderbook = Orderbook {
orderbookTimestamp :: UTCTime,
orderbookBids :: [Bid],
orderbookAsks :: [Ask]
} deriving (Eq, Show)
makeFields ''Orderbook
data Trade = Trade {
tradeTimestamp :: UTCTime,
tradeVolume :: Scientific,
tradePrice :: Int
} deriving (Eq, Show)
makeFields ''Trade
data BitXAuth = BitXAuth
{bitXAuthId :: Text,
bitXAuthSecret :: Text} deriving (Eq, Show)
mkBitXAuth :: BitXAuth
mkBitXAuth = BitXAuth "" ""
makeFields ''BitXAuth
type BitXClientAuth = BitXAuth
data PrivateOrder = PrivateOrder
{privateOrderBase :: Scientific,
privateOrderCounter :: Scientific,
privateOrderCreationTimestamp :: UTCTime,
privateOrderExpirationTimestamp :: UTCTime,
privateOrderFeeBase :: Scientific,
privateOrderFeeCounter :: Scientific,
privateOrderLimitPrice :: Int,
privateOrderLimitVolume :: Scientific,
privateOrderId :: OrderID,
privateOrderPair :: CcyPair,
privateOrderState :: RequestStatus,
privateOrderOrderType :: OrderType } deriving (Eq, Show)
makeFields ''PrivateOrder
data PrivateOrderWithTrades = PrivateOrderWithTrades
{privateOrderWithTradesBase :: Scientific,
privateOrderWithTradesCounter :: Scientific,
privateOrderWithTradesCreationTimestamp :: UTCTime,
privateOrderWithTradesExpirationTimestamp :: UTCTime,
privateOrderWithTradesFeeBase :: Scientific,
privateOrderWithTradesFeeCounter :: Scientific,
privateOrderWithTradesLimitPrice :: Int,
privateOrderWithTradesLimitVolume :: Scientific,
privateOrderWithTradesId :: OrderID,
privateOrderWithTradesPair :: CcyPair,
privateOrderWithTradesState :: RequestStatus,
privateOrderWithTradesOrderType :: OrderType,
privateOrderWithTradesTrades :: [Trade] } deriving (Eq, Show)
makeFields ''PrivateOrderWithTrades
data Transaction = Transaction
{transactionRowIndex :: Int,
transactionTimestamp :: UTCTime,
transactionBalance :: Scientific,
transactionAvailable :: Scientific,
transactionBalanceDelta :: Scientific,
transactionAvailableDelta :: Scientific,
transactionCurrency :: Asset,
transactionDescription :: Text} deriving (Eq, Show)
makeFields ''Transaction
data OrderRequest = OrderRequest
{orderRequestPair :: CcyPair,
orderRequestOrderType :: OrderType,
orderRequestVolume :: Scientific,
orderRequestPrice :: Int } deriving (Eq, Show)
makeFields ''OrderRequest
mkOrderRequest :: OrderRequest
mkOrderRequest = OrderRequest ZARXBT BID 0 0
data MarketOrderRequest = MarketOrderRequest
{marketOrderRequestPair :: CcyPair,
marketOrderRequestOrderType :: OrderType,
marketOrderRequestVolume :: Scientific } deriving (Eq, Show)
makeFields ''MarketOrderRequest
mkMarketOrderRequest :: MarketOrderRequest
mkMarketOrderRequest = MarketOrderRequest ZARXBT BID 0
data Balance = Balance
{balanceId :: AccountID,
balanceAsset :: Asset,
balanceBalance :: Scientific,
balanceReserved :: Scientific,
balanceUnconfirmed :: Scientific } deriving (Eq, Show)
makeFields ''Balance
data FundingAddress = FundingAddress
{fundingAddressAsset :: Asset,
fundingAddressAddress :: Text,
fundingAddressTotalReceived :: Scientific,
fundingAddressTotalUnconfirmed :: Scientific} deriving (Eq, Show)
makeFields ''FundingAddress
data WithdrawalRequest = WithdrawalRequest
{withdrawalRequestStatus :: RequestStatus,
withdrawalRequestId :: Text } deriving (Eq, Show)
makeFields ''WithdrawalRequest
data NewWithdrawal = NewWithdrawal
{newWithdrawalWithdrawalType :: WithdrawalType,
newWithdrawalAmount :: Scientific } deriving (Eq, Show)
makeFields ''NewWithdrawal
mkNewWithdrawal :: NewWithdrawal
mkNewWithdrawal = NewWithdrawal ZAR_EFT 0
data BitcoinSendRequest = BitcoinSendRequest
{bitcoinSendRequestAmount :: Scientific,
bitcoinSendRequestCurrency :: Asset,
bitcoinSendRequestAddress :: Text,
bitcoinSendRequestDescription :: Maybe Text,
bitcoinSendRequestMessage :: Maybe Text} deriving (Eq, Show)
makeFields ''BitcoinSendRequest
mkBitcoinSendRequest :: BitcoinSendRequest
mkBitcoinSendRequest = BitcoinSendRequest 0 ZAR "" Nothing Nothing
data QuoteRequest = QuoteRequest
{quoteRequestQuoteType :: QuoteType,
quoteRequestPair :: CcyPair,
quoteRequestBaseAmount :: Scientific} deriving (Eq, Show)
makeFields ''QuoteRequest
mkQuoteRequest :: QuoteRequest
mkQuoteRequest = QuoteRequest BUY ZARXBT 0
data OrderQuote = OrderQuote
{orderQuoteId :: Text,
orderQuoteQuoteType :: QuoteType,
orderQuotePair :: CcyPair,
orderQuoteBaseAmount :: Scientific,
orderQuoteCounterAmount :: Scientific,
orderQuoteCreatedAt :: UTCTime,
orderQuoteExpiresAt :: UTCTime,
orderQuoteDiscarded :: Bool,
orderQuoteExercised :: Bool} deriving (Eq, Show)
makeFields ''OrderQuote
data Account = Account
{accountId :: Text,
accountName :: Text,
accountCurrency :: Asset} deriving (Eq, Show)
makeFields ''Account
mkAccount :: Account
mkAccount = Account "" "" ZAR
instance FromJSON CcyPair
instance FromJSON Asset
instance FromJSON OrderType
instance FromJSON WithdrawalType
instance FromJSON QuoteType