bitx-bitcoin

A Haskell library for working with the BitX bitcoin exchange. https://github.com/tebello-thejane/bitx.hs

Version on this page:0.12.0.0
LTS Haskell 12.22:0.12.0.0
Stackage Nightly 2018-12-10:0.12.0.0
Latest on Hackage:0.12.0.0

See all snapshots bitx-bitcoin appears in

BSD3 licensed by Tebello Thejane, Tristan Seligmann
Maintained by Tebello Thejane

Module documentation for 0.12.0.0

There are no documented modules for this package.

Build Status Hackage BSD3

(Hopefully useful) Haskell bindings to the Luno (formerly BitX) cryptocurrency exchange’s API.

As a minimal example, to get the current selling price (in South African Rand) of Bitcoin on the Luno exchange, do the following:

import Control.Lens ((^.))
import Network.Bitcoin.BitX (BitXAPIResponse(..), getTicker, CcyPair(..))
import qualified Network.Bitcoin.BitX as BitX
import Data.Text (unpack)
import Network.HTTP.Types.Status (Status(..))
import Network.HTTP.Client (responseStatus)

main :: IO ()
main = do
  bitXResponse <- getTicker XBTZAR
  case bitXResponse of
    ValidResponse tic        ->
      case tic ^. BitX.ask of
        Nothing              ->  putStrLn "The BTC-ZAR exchange not currently have an ask price..."
        Just p               ->  putStrLn ("1 Bitcoin will set you back ZAR" ++ show p ++ ".")
    ErrorResponse err        ->
        error $ "BitX error received: \"" ++ unpack (err ^. BitX.error) ++ "\""
    ExceptionResponse ex     ->
        error $ "Exception was thrown: \"" ++ show ex ++ "\""
    UnparseableResponse _ resp ->
        error $ "Bad HTTP response; HTTP status code was: \"" ++ (show . statusCode . responseStatus $ resp) ++ "\""

Note that the code snippet above depends on http-types, text, http-client, lens (or any lens-compatible package, such as microlens), and finally bitx-bitcoin.

This library is known to work on Windows, but if you wish to use it then you will have to do a bit more work due to the Network library not building on Windows out of the box. Your best bet might be to just use Stack.

Changes

v0.12.0.0
* We now handle nulls properly when deserialising JSON arrays.
* Luno has added Ethereum and an ETHXBT currency pair.
* Prices (bid, ask, and spot) are now consistently Scientific, rather than Int. BREAKING CHANGE.
* We no longer create a brand new connection manager on every API call, significatly improving performance.
* Luno's rate-limiting is now much more harsh.

v0.11.0.1
* Added new fee_info endpoint.

v0.11.0.0
* The BitX API no longer gives trades when returning private orders. BREAKING CHANGE.
* Due to the above change, a new function -- getAllTrades -- has been added to the private order API.
* The basic types now come with a large set of default typeclasses, to minimise the need for orphan instances.

v0.10.0.0
* New optional beneficiary ID field for withdrawal requests. BREAKING CHANGE.

v0.9.0.1
* Compatibility with http-client-0.5.0 and http-client-tls-0.3.0.
* The BitXAuth type can now be written as a string using the OverloadedStrings extension.

v0.9.0.0
* Use (strict) Text consistantly instead of random string-like types. BREAKING CHANGE.

v0.8.0.0
* Added Singapore Dollar.
* The UnparseableResponse now provides the Aeson error. BREAKING CHANGE.
* Last_trade and Bid and Ask prices don't always appear in the Ticker type. BREAKING CHANGE.
* GHC 8.0 is now officially supported.

v0.7.0.2
* Forgot to export "status" lens,

v0.7.0.1
* Added new "completed_timestamp" field to private order types.

v0.7.0.0
* Added new "since" option to public trades' endpoint. BREAKING CHANGE.
* Added is_buy field for trade record.
* Added Indonesian Rupiah.

v0.6.0.0
* Added the new endpoint for creating market (spot) orders.
* Replaced http-conduit with http-client and http-client-tls.
* Fixed broken rate limiting.

v0.5.0.1
* A few more major bugfixes w.r.t. to BitX number formatting.
* Fixed issue due to BitX's handling of ints as decimal.

v0.5.0.0
* Prices should be integers, not real. BREAKING CHANGE.
* Dropped support for versions of GHC lower than 7.8.1.

v0.4.0.1
* BitX expects decimals to have 6 places and no trailing zeros.
* Changed license to BSD3.
* Now builds on Stack LTS-3.

v0.4.0.0
* ExceptionResponse now holds the actual exception, rather than its text representation. BREAKING CHANGE.

v0.3.0.0
* Replaced Volkov records with (micro)lenses. BREAKING CHANGE.
* Implemented a (naive) mechanism to work around nginx rate limiting.

v0.2.0.2
* Added Nigerian Naira.

v0.2.0.1
* Record library dependency needs upper bound.

v0.2.0.0
* Replaced Decimal with Scientific. BREAKING CHANGE.
* Divided much of the Private module into smaller sub-modules. BREAKING CHANGE.
* Added the new endpoint for creating accounts.
* Remove ill-thought-out Auth module.
* Lots of internal improvements.

v0.1.0.0
* Initial release!
comments powered byDisqus