nxt.ce

## Class CoinExchange

- java.lang.Object
- - nxt.ce.CoinExchange

-     public final class CoinExchange
      extends java.lang.Object

  Coin exchange home

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `CoinExchange.Event`
    `static class` | `CoinExchange.Order` Define a coin exchange order 'id' and 'fullHash' identify the coin exchange order 'chainId' is the chain identifier for the coin being exchanged 'exchangeId' is the chain identifier for the requested coin 'quantity' is the number of coins being exchanged (updated after each trade) 'bidPrice' is the bid price for the requested coin and is the exchange order price 'askPrice' is the ask price for coin being exchanged and is 1/bidPrice
    `static class` | `CoinExchange.Trade` Define a coin exchange trade A coin exchange consists of two trades.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `addListener(Listener<CoinExchange.Trade> listener, CoinExchange.Event eventType)`
    `static CoinExchange.Order` | `getOrder(long orderId)` Return a coin exchange order
    `static int` | `getOrderCount()` Return the number of coin exchange orders
    `static DbIterator<CoinExchange.Order>` | `getOrders(long accountId, int chainId, int exchangeId, int from, int to)` Return orders matching the supplied criteria.
    `static CoinExchange.Trade` | `getTrade(byte[] orderFullHash, byte[] matchFullHash)` Return a coin exchange trade
    `static int` | `getTradeCount()` Return the number of coin exchange trades
    `static DbIterator<CoinExchange.Trade>` | `getTrades(long accountId, int chainId, int exchangeId, byte[] orderFullHash, int from, int to)` Return trades matching the supplied criteria.
    `static void` | `init()`
    `static boolean` | `removeListener(Listener<CoinExchange.Trade> listener, CoinExchange.Event eventType)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### addListener

          public static boolean addListener(Listener<CoinExchange.Trade> listener,
                                            CoinExchange.Event eventType)

    - #### removeListener

          public static boolean removeListener(Listener<CoinExchange.Trade> listener,
                                               CoinExchange.Event eventType)

    - #### init

          public static void init()

    - #### getOrderCount

          public static int getOrderCount()

      Return the number of coin exchange orders
      Returns:
        Order count

    - #### getOrder

          public static CoinExchange.Order getOrder(long orderId)

      Return a coin exchange order
      Parameters:
        `orderId` - Order identifier
      Returns:
        Coin exchange order or null if not found

    - #### getOrders

          public static DbIterator<CoinExchange.Order> getOrders(long accountId,
                                                                 int chainId,
                                                                 int exchangeId,
                                                                 int from,
                                                                 int to)

      Return orders matching the supplied criteria. All orders will be returned if no search criteria are provided. The returned results will be sorted by price in descending order.
      Parameters:
        `accountId` - Account identifier (0 if no account criteria)
        `chainId` - Chain identifier (0 if no chain criteria)
        `exchangeId` - Exchange identifier (0 if no exchange criteria)
        `from` - Starting index within search results
        `to` - Ending index within search results
      Returns:
        Database iterator

    - #### getTrade

          public static CoinExchange.Trade getTrade(byte[] orderFullHash,
                                                    byte[] matchFullHash)

      Return a coin exchange trade
      Parameters:
        `orderFullHash` - Coin exchange order full hash
        `matchFullHash` - Matching order full hash
      Returns:
        Coin exchange trade or null if not found

    - #### getTradeCount

          public static int getTradeCount()

      Return the number of coin exchange trades
      Returns:
        Trade coin

    - #### getTrades

          public static DbIterator<CoinExchange.Trade> getTrades(long accountId,
                                                                 int chainId,
                                                                 int exchangeId,
                                                                 byte[] orderFullHash,
                                                                 int from,
                                                                 int to)

      Return trades matching the supplied criteria. All trades will be returned if no search criteria are provided. The returned results will be sorted by block height in descending order.
      Parameters:
        `accountId` - Account identifier (0 if no account criteria)
        `chainId` - Chain identifier (0 if no chain criteria)
        `exchangeId` - Exchange identifier (0 if no exchange criteria)
        `orderFullHash` - Coin exchange order full hash (null or zero-length if no order criteria)
        `from` - Starting index within search results
        `to` - Ending index within search results
      Returns:
        Database iterator