coinbase-pro: Client for Coinbase Pro

[ finance, library, mit, program, web ] [ Propose Tags ]

Client for Coinbase Pro REST and Websocket APIs


[Skip to Readme]

Modules

[Last Documentation]

  • CoinbasePro
    • CoinbasePro.Authenticated
      • CoinbasePro.Authenticated.API
      • CoinbasePro.Authenticated.Accounts
      • CoinbasePro.Authenticated.Fills
      • CoinbasePro.Authenticated.Headers
      • CoinbasePro.Authenticated.Orders
      • CoinbasePro.Authenticated.Request
    • CoinbasePro.Headers
    • MarketData
      • CoinbasePro.MarketData.AggregateOrderBook
      • CoinbasePro.MarketData.FullOrderBook
      • CoinbasePro.MarketData.Types
    • CoinbasePro.Request
    • CoinbasePro.Types
    • CoinbasePro.Unauthenticated
      • CoinbasePro.Unauthenticated.API
    • CoinbasePro.WebSocketFeed
      • CoinbasePro.WebSocketFeed.Channel
        • Full
          • CoinbasePro.WebSocketFeed.Channel.Full.Activate
          • CoinbasePro.WebSocketFeed.Channel.Full.Change
          • CoinbasePro.WebSocketFeed.Channel.Full.Done
          • CoinbasePro.WebSocketFeed.Channel.Full.Match
          • CoinbasePro.WebSocketFeed.Channel.Full.Open
          • CoinbasePro.WebSocketFeed.Channel.Full.Received
        • CoinbasePro.WebSocketFeed.Channel.Heartbeat
        • CoinbasePro.WebSocketFeed.Channel.Level2
        • CoinbasePro.WebSocketFeed.Channel.Ticker
      • CoinbasePro.WebSocketFeed.Request
      • CoinbasePro.WebSocketFeed.Response

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.5.0.0, 0.6.0.0, 0.7.0.0, 0.7.1.0, 0.7.2.0, 0.8.0.0, 0.9.0.0, 0.9.1.0, 0.9.2.0, 0.9.2.2, 0.9.3.0, 0.9.3.1, 0.9.3.2
Dependencies aeson (>=1.2 && <1.5), aeson-casing (>=0.1 && <0.2), async (>=2.1 && <2.3), base (>=4.7 && <5), binary (>=0.8 && <0.9), bytestring (>=0.10 && <0.11), coinbase-pro, containers (>=0.5 && <0.7), cryptonite (>=0.24 && <0.27), HsOpenSSL (>=0.11 && <0.12), http-api-data (>=0.3 && <0.5), http-client (>=0.5 && <0.6), http-client-tls (>=0.3 && <0.4), http-streams (>=0.8 && <0.9), http-types (>=0.12 && <0.13), io-streams (>=1.5 && <1.6), memory (>=0.14 && <0.16), network (>=2.6 && <2.9), servant (>=0.14 && <0.17), servant-client (>=0.14 && <0.17), servant-client-core (>=0.14 && <0.17), text (>=1.2 && <1.3), time (>=1.8 && <1.9), transformers (>=0.5 && <0.6), unagi-streams (>=0.2 && <0.3), unordered-containers (>=0.2 && <0.3), vector (>=0.12 && <0.13), websockets (>=0.12 && <0.13), wuss (>=1.1 && <1.2) [details]
License MIT
Copyright 2019 Michael Dunn <michaelsdunn1@gmail.com>
Author Michael Dunn <michaelsdunn1@gmail.com>
Maintainer Michael Dunn <michaelsdunn1@gmail.com>
Category Web, Finance
Home page https://github.com/mdunnio/coinbase-pro#readme
Bug tracker https://github.com/mdunnio/coinbase-pro/issues
Source repo head: git clone https://github.com/https://github.com/mdunnio/coinbase-pro
Uploaded by mdunnio at 2019-10-19T18:41:12Z
Distributions Arch:0.9.3.2
Executables test-stream, test-request
Downloads 3482 total (62 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2019-10-19 [all 2 reports]

Readme for coinbase-pro-0.6.0.0

[back to package description]

coinbase-pro

Request API

{-# LANGUAGE OverloadedStrings #-}

module Main where

import           Control.Monad.IO.Class             (liftIO)

import           CoinbasePro.Authenticated
import           CoinbasePro.Authenticated.Accounts
import           CoinbasePro.Authenticated.Orders
import           CoinbasePro.Headers
import           CoinbasePro.MarketData.Types       hiding (time)
import           CoinbasePro.Request
import           CoinbasePro.Types                  hiding (time)
import           CoinbasePro.Unauthenticated


main :: IO ()
main = do
    stats btcusd >>= print
    candles btcusd Nothing Nothing Minute >>= print
    trades btcusd >>= print
    time >>= print
    products >>= print
    aggregateOrderBook btcusd (Just Best) >>= print
    aggregateOrderBook btcusd (Just TopFifty) >>= print
    fullOrderBook btcusd >>= print
    runCbAuthT cpc $ do
        accounts >>= liftIO . print
        account accountId >>= liftIO . print
        fills (Just btcusd) Nothing >>= liftIO . print
        listOrders (Just [All]) (Just btcusd) >>= liftIO . print
        placeOrder btcusd Sell (Size 0.001) (Price 99999.00) True Nothing Nothing Nothing >>= liftIO . print
        placeOrder btcusd Buy (Size 1.0) (Price 1.00) True Nothing Nothing Nothing >>= liftIO . print
        cancelOrder (OrderId "<cancel-order-id>")
        cancelAll (Just btcusd) >>= liftIO . print
  where
    accessKey  = CBAccessKey "<access-key>"
    secretKey  = CBSecretKey "<secret-key>"
    passphrase = CBAccessPassphrase "<passphrase>"
    cpc        = CoinbaseProCredentials accessKey secretKey passphrase
    accountId  = AccountId "<account-id>"
    btcusd     = ProductId "BTC-USD"

Websocket API

To print out all of the full order book updates for BTC-USD:

{-# LANGUAGE OverloadedStrings #-}

module Main where

import           Control.Monad                     (forever)
import qualified System.IO.Streams                 as Streams

import           CoinbasePro.Types                 (ProductId (..))
import           CoinbasePro.WebSocketFeed         (subscribeToFeed)
import           CoinbasePro.WebSocketFeed.Request (ChannelName (..))

main :: IO ()
main = do
    msgs <- subscribeToFeed [ProductId "BTC-USD"] [Ticker]
    forever $ Streams.read msgs >>= print

Example

Example execs can be found in src/example/