bitx-bitcoin-0.2.0.0: A Haskell library for working with the BitX bitcoin exchange.

CopyrightNo Rights Reserved
LicensePublic Domain
MaintainerTebello Thejane <zyxoas+hackage@gmail.com>
StabilityExperimental
Portabilitynon-portable (GHC Extensions)
Safe HaskellNone
LanguageHaskell2010

Network.Bitcoin.BitX.Types

Description

The types used for the various BitX API calls.

Note that these are all record types, as provided by Nikita Volkov's Record library. The main motivation for using the record library was to avoid using record field prefixes and other awkward hacks to get around the fact that Haskell does not yet have a real records' system.

For example, the declaration of BitXAuth is

type BitXAuth =
    [record|
        {id :: Text,
         secret :: Text} |]

To declare a BitXAuth, one might use

myAuth :: BitXAuth
myAuth =
    [record|
        {id = "46793",
         secret = "387ffBd56eEAA7C59"} |]

and to read the fields you would use

theID = view [lens| id |] myAuth

Note that all uses of Volkov's records requires importing Record and enabling the DataKinds and QuasiQuotes extensions.

See http://nikita-volkov.github.io/record/

Synopsis

Documentation

type Ticker = Record6 "ask" Scientific "bid" Scientific "lastTrade" Scientific "pair" CcyPair "rolling24HourVolume" Scientific "timestamp" UTCTime Source

The state of a single market, identified by the currency pair. As usual, the ask/sell price is the price of the last filled ask order, and the bid/buy price is the price of the last filled bid order. Necessarily bid <= ask.

type Ticker =
    [record|
        {ask :: Scientific,
         timestamp :: UTCTime,
         bid :: Scientific,
         rolling24HourVolume :: Scientific,
         lastTrade :: Scientific,
         pair :: CcyPair} |]
 

data CcyPair Source

A currency pair

Constructors

XBTZAR

Bitcoin vs. ZAR

XBTNAD

Bitcoin vs. Namibian Dollar

ZARXBT

ZAR vs. Namibian Dollar

NADXBT

Namibian Dollar vs. Bitcoin

XBTKES

Bitcoin vs. Kenyan Shilling

KESXBT

Kenyan Shilling vs Bitcoin

XBTMYR

Bitcoin vs. Malaysian Ringgit

MYRXBT

Malaysian Ringgit vs. Bitcoin

type Orderbook = Record3 "asks" [Ask] "bids" [Bid] "timestamp" UTCTime Source

The current state of the publically accessible orderbook. Bid orders are requests to buy, ask orders are requests to sell.

type Orderbook =
    [record|
        {timestamp :: UTCTime,
         bids :: [Bid],
         asks :: [Ask]} |]
 

type Order = Record2 "price" Scientific "volume" Scientific Source

A single placed order in the orderbook

type Order =
    [record|
        {volume :: Scientific,
         price :: Scientific} |]
 

type Bid = Order Source

Convenient type alias for a bid order

type Ask = Order Source

Convenient type alias for an ask order

type Trade = Record3 "price" Scientific "timestamp" UTCTime "volume" Scientific Source

type BitXAuth = Record2 "id" Text "secret" Text Source

An auth type used by all private API calls, after authorisation.

type BitXAuth =
    [record|
        {id :: Text,
         secret :: Text} |]
 

type PrivateOrder = Record12 "base" Scientific "counter" Scientific "creationTimestamp" UTCTime "expirationTimestamp" UTCTime "feeBase" Scientific "feeCounter" Scientific "id" OrderID "limitPrice" Scientific "limitVolume" Scientific "pair" CcyPair "state" RequestStatus "type" OrderType Source

A recently placed (private) order, containing a lot more information than is available on the public order book.

type PrivateOrder =
    [record|
        {base :: Scientific,
         counter :: Scientific,
         creationTimestamp :: UTCTime,
         expirationTimestamp :: UTCTime,
         feeBase :: Scientific,
         feeCounter :: Scientific,
         limitPrice :: Scientific,
         limitVolume :: Scientific,
         id :: OrderID,
         pair :: CcyPair,
         state :: RequestStatus,
         type :: OrderType } |]
 

data OrderType Source

The type of a placed order.

Constructors

ASK

A request to sell

BID

A request to buy

data RequestStatus Source

The state of a (private) placed request -- either an order or a withdrawal request.

Constructors

PENDING

Not yet completed. An order will stay in PENDING state even as it is partially filled, and will move to COMPLETE once it has been completely filled.

COMPLETE

Completed.

CANCELLED

Cancelled. Note that an order cannot be in CANCELLED state, since cancelling an order removes it from the orderbook.

type OrderRequest = Record4 "pair" CcyPair "price" Scientific "type" OrderType "volume" Scientific Source

A request to place an order.

type OrderRequest =
    [record|
        {pair :: CcyPair,
         type :: OrderType,
         volume :: Scientific,
         price :: Scientific } |]
 

type BitXError = Record2 "error" Text "errorCode" Text Source

A possible error which the BitX API might return, instead of returning the requested data. Note that as yet there is no exhaustive list of error codes available, so comparisons will have to be done via Text comparisons (as opposed to typed pattern matching). Sorry...

type BitXError =
    [record|
        {error :: Text,
         errorCode :: Text} |]
 

type PrivateOrderWithTrades = Record13 "base" Scientific "counter" Scientific "creationTimestamp" UTCTime "expirationTimestamp" UTCTime "feeBase" Scientific "feeCounter" Scientific "id" OrderID "limitPrice" Scientific "limitVolume" Scientific "pair" CcyPair "state" RequestStatus "trades" [Trade] "type" OrderType Source

A recently placed (private) order, containing a lot more information than is available on the public order book, together with details of any trades which have (partially) filled it.

type PrivateOrderWithTrades =
    [record|
        {base :: Scientific,
         counter :: Scientific,
         creationTimestamp :: UTCTime,
         expirationTimestamp :: UTCTime,
         feeBase :: Scientific,
         feeCounter :: Scientific,
         limitPrice :: Scientific,
         limitVolume :: Scientific,
         id :: OrderID,
         pair :: CcyPair,
         state :: RequestStatus,
         type :: OrderType,
         trades :: [Trade] } |]
 

data Asset Source

A trade-able asset. Essentially, a currency.

Constructors

ZAR

South African Rand

NAD

Namibian Dollar

XBT

Bitcoin

KES

Kenyan Shilling

MYR

Malaysian Ringgit

type Balance = Record5 "asset" Asset "balance" Scientific "id" AccountID "reserved" Scientific "unconfirmed" Scientific Source

The current balance of a private account.

type Balance =
    [record|
        {id :: AccountID,
         asset :: Asset,
         balance :: Scientific,
         reserved :: Scientific,
         unconfirmed :: Scientific } |]
 

type FundingAddress = Record4 "address" Text "asset" Asset "totalReceived" Scientific "totalUnconfirmed" Scientific Source

A registered address for an acocunt.

type FundingAddress =
    [record|
        {asset :: Asset,
         address :: Text,
         totalReceived :: Scientific,
         totalUnconfirmed :: Scientific} |]
 

type WithdrawalRequest = Record2 "id" Text "status" RequestStatus Source

The state of a request to withdraw from an account.

type WithdrawalRequest =
    [record|
        {status :: RequestStatus,
         id :: Text } |]
 

type NewWithdrawal = Record2 "amount" Scientific "type" WithdrawalType Source

A request to withdraw from an account.

type NewWithdrawal =
    [record|
        {type :: WithdrawalType,
         amount :: Scientific } |]
 

data WithdrawalType Source

The type of a withdrawal request.

Constructors

ZAR_EFT

ZAR by Electronic Funds Transfer

NAD_EFT

Namibian Dollar by EFT

KES_MPESA

Kenyan Shilling by Vodafone MPESA

MYR_IBG

Malaysian Ringgit by Interbank GIRO (?)

IDR_LLG

Indonesian Rupiah by Lalu Lintas Giro (??)

type BitcoinSendRequest = Record5 "address" Text "amount" Scientific "currency" Asset "description" (Maybe Text) "message" (Maybe Text) Source

A request to send bitcoin to a bitcoin address or email address.

type BitcoinSendRequest =
    [record|
        {amount :: Scientific,
         currency :: Asset,
         address :: Text,
         description :: Maybe Text,
         message :: Maybe Text} |]
 

type QuoteRequest = Record3 "baseAmount" Scientific "pair" CcyPair "type" QuoteType Source

A request to lock in a quote.

type QuoteRequest =
    [record|
        {type :: QuoteType,
         pair :: CcyPair,
         baseAmount :: Scientific} |]
 

type OrderQuote = Record9 "baseAmount" Scientific "counterAmount" Scientific "createdAt" UTCTime "discarded" Bool "exercised" Bool "expiresAt" UTCTime "id" Text "pair" CcyPair "type" QuoteType Source

A temporarily locked in quote.

type OrderQuote =
    [record|
        {id :: Text,
         type :: QuoteType,
         pair :: CcyPair,
         baseAmount :: Scientific,
         counterAmount :: Scientific,
         createdAt :: UTCTime,
         expiresAt :: UTCTime,
         discarded :: Bool,
         exercised :: Bool} |]
 

type Transaction = Record8 "available" Scientific "availableDelta" Scientific "balance" Scientific "balanceDelta" Scientific "currency" Asset "description" Text "rowIndex" Int "timestamp" UTCTime Source

A transaction on a private user account.

type Transaction =
    [record|
        {rowIndex :: Int,
         timestamp :: UTCTime,
         balance :: Scientific,
         available :: Scientific,
         balanceDelta :: Scientific,
         availableDelta :: Scientific,
         currency :: Asset,
         description :: Text}|]
 

type Account = Record3 "currency" Asset "id" Text "name" Text Source

A registered account.

type Account =
    [record|
        {id :: Text,
         name :: Text,
         currency :: Asset} |]