Class CoinbaseMarketDataService

All Implemented Interfaces:
BaseService, MarketDataService

public class CoinbaseMarketDataService extends CoinbaseBaseService implements MarketDataService
Author:
jamespedwards42
  • Constructor Details

    • CoinbaseMarketDataService

      public CoinbaseMarketDataService(Exchange exchange)
      Constructor
      Parameters:
      exchange -
  • Method Details

    • getTicker

      public Ticker getTicker(CurrencyPair currencyPair, Object... args) throws IOException
      Description copied from interface: MarketDataService
      Get a ticker representing the current exchange rate
      Specified by:
      getTicker in interface MarketDataService
      Parameters:
      args - Optional Boolean. If true an additional call to retrieve the spot price history will be made and used to populate the 24 hour high and low values for the Ticker.
      Returns:
      A Ticker with Coinbase's current buy price as the best ask, sell price as the best bid, spot price as the last value, and can optionally use the spot price history to find the 24 hour high and low.
      Throws:
      IOException - - Indication that a networking error occurred while fetching JSON data
    • getOrderBook

      public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args)
      Description copied from interface: MarketDataService
      Get an order book representing the current offered exchange rates (market depth)
      Specified by:
      getOrderBook in interface MarketDataService
      Parameters:
      args - Optional arguments. Exchange-specific
      Returns:
      The OrderBook, null if some sort of error occurred. Implementers should log the error.
    • getTrades

      public Trades getTrades(CurrencyPair currencyPair, Object... args)
      Description copied from interface: MarketDataService
      Get the trades recently performed by the exchange
      Specified by:
      getTrades in interface MarketDataService
      Parameters:
      args - Optional arguments. Exchange-specific
      Returns:
      The Trades, null if some sort of error occurred. Implementers should log the error.
    • getCoinbaseCurrencyExchangeRates

      public Map<String,BigDecimal> getCoinbaseCurrencyExchangeRates() throws IOException
      Unauthenticated resource that returns BTC to fiat (and vice versus) exchange rates in various currencies.
      Returns:
      Map of lower case directional currency pairs, i.e. btc_to_xxx and xxx_to_btc, to exchange rates.
      Throws:
      IOException
      See Also:
    • getCoinbaseBuyPrice

      public CoinbasePrice getCoinbaseBuyPrice() throws IOException
      Unauthenticated resource that tells you the total price in USD to buy 1 Bitcoin.
      Returns:
      The price to buy 1 BTC.
      Throws:
      IOException
      See Also:
    • getCoinbaseBuyPrice

      public CoinbasePrice getCoinbaseBuyPrice(BigDecimal quantity) throws IOException
      Unauthenticated resource that tells you the total price in USD to buy some quantity of Bitcoin.
      Parameters:
      quantity - The quantity of Bitcoin you would like to buy (default is 1 if null).
      Returns:
      The price to buy the given quantity BTC.
      Throws:
      IOException
      See Also:
    • getCoinbaseBuyPrice

      public CoinbasePrice getCoinbaseBuyPrice(BigDecimal quantity, String currency) throws IOException
      Unauthenticated resource that tells you the total price to buy some quantity of Bitcoin.
      Parameters:
      quantity - The quantity of Bitcoin you would like to buy (default is 1 if null).
      currency - Default is USD. Right now this is the only value allowed.
      Returns:
      The price in the desired currency to buy the given quantity BTC.
      Throws:
      IOException
      See Also:
    • getCoinbaseSellPrice

      public CoinbasePrice getCoinbaseSellPrice() throws IOException
      Unauthenticated resource that tells you the total amount in USD you can get if you sell 1 Bitcoin.
      Returns:
      The price to sell 1 BTC.
      Throws:
      IOException
      See Also:
    • getCoinbaseSellPrice

      public CoinbasePrice getCoinbaseSellPrice(BigDecimal quantity) throws IOException
      Unauthenticated resource that tells you the total amount in USD you can get if you sell some quantity Bitcoin.
      Parameters:
      quantity - The quantity of Bitcoin you would like to sell (default is 1 if null).
      Returns:
      The price to sell the given quantity BTC.
      Throws:
      IOException
      See Also:
    • getCoinbaseSellPrice

      public CoinbasePrice getCoinbaseSellPrice(BigDecimal quantity, String currency) throws IOException
      Unauthenticated resource that tells you the total amount you can get if you sell some quantity Bitcoin.
      Parameters:
      quantity - The quantity of Bitcoin you would like to sell (default is 1 if null).
      currency - Default is USD. Right now this is the only value allowed.
      Returns:
      The price in the desired currency to sell the given quantity BTC.
      Throws:
      IOException
      See Also:
    • getCoinbaseSpotRate

      public CoinbaseMoney getCoinbaseSpotRate(String currency) throws IOException
      Unauthenticated resource that tells you the current price of Bitcoin. This is usually somewhere in between the buy and sell price, current to within a few minutes.
      Parameters:
      currency - ISO 4217 currency code. Default is USD if null.
      Returns:
      Throws:
      IOException
      See Also:
    • getCoinbaseHistoricalSpotRates

      public CoinbaseSpotPriceHistory getCoinbaseHistoricalSpotRates() throws IOException
      Unauthenticated resource that displays historical spot rates for Bitcoin in USD. This is a paged resource and will return the first page by default.
      Returns:
      One thousand historical spot prices representing page 1.
      Throws:
      IOException
      See Also:
    • getCoinbaseHistoricalSpotRates

      public CoinbaseSpotPriceHistory getCoinbaseHistoricalSpotRates(Integer page) throws IOException
      Unauthenticated resource that displays historical spot rates for Bitcoin in USD.
      Parameters:
      page - Optional parameter to request a desired page of results. Will return page 1 if the supplied page is null or less than 1.
      Returns:
      One thousand historical spot prices for the given page.
      Throws:
      IOException