bitx-bitcoin-0.1.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 BitXError 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" Decimal "bid" Decimal "lastTrade" Decimal "pair" CcyPair "rolling24HourVolume" Decimal "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 :: Decimal,
         timestamp :: UTCTime,
         bid :: Decimal,
         rolling24HourVolume :: Decimal,
         lastTrade :: Decimal,
         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" Decimal "volume" Decimal Source

A single placed order in the orderbook

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

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" Decimal "timestamp" UTCTime "volume" Decimal 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" Decimal "counter" Decimal "creationTimestamp" UTCTime "expirationTimestamp" UTCTime "feeBase" Decimal "feeCounter" Decimal "id" OrderID "limitPrice" Decimal "limitVolume" Decimal "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 :: Decimal,
         counter :: Decimal,
         creationTimestamp :: UTCTime,
         expirationTimestamp :: UTCTime,
         feeBase :: Decimal,
         feeCounter :: Decimal,
         limitPrice :: Decimal,
         limitVolume :: Decimal,
         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" Decimal "type" OrderType "volume" Decimal Source

A request to place an order.

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

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" Decimal "counter" Decimal "creationTimestamp" UTCTime "expirationTimestamp" UTCTime "feeBase" Decimal "feeCounter" Decimal "id" OrderID "limitPrice" Decimal "limitVolume" Decimal "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 :: Decimal,
         counter :: Decimal,
         creationTimestamp :: UTCTime,
         expirationTimestamp :: UTCTime,
         feeBase :: Decimal,
         feeCounter :: Decimal,
         limitPrice :: Decimal,
         limitVolume :: Decimal,
         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" Decimal "id" AccountID "reserved" Decimal "unconfirmed" Decimal Source

The current balance of a private account.

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

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

A registered address for an acocunt.

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

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" Decimal "type" WithdrawalType Source

A request to withdraw from an account.

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

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" Decimal "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 :: Decimal,
         currency :: Asset,
         address :: Text,
         description :: Maybe Text,
         message :: Maybe Text} |]
 

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

A request to lock in a quote.

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

type OrderQuote = Record9 "baseAmount" Decimal "counterAmount" Decimal "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 :: Decimal,
         counterAmount :: Decimal,
         createdAt :: UTCTime,
         expiresAt :: UTCTime,
         discarded :: Bool,
         exercised :: Bool} |]
 

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

A transaction on a private user account.

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