Class Quote

java.lang.Object
com.codename1.crypto.market.Quote

public final class Quote extends Object
A price: one unit of base costs price units of quote, as a source reported it at a time. Prices are floating point, as every price API publishes them; amounts stay exact in UInt256 and only their display value is computed through a quote.
  • Constructor Details

    • Quote

      public Quote(String base, String quote, double price, long timestamp, String source)

      A quote.

      Parameters
      • base: the asset priced, such as BTC
      • quote: the currency of the price, such as USD
      • price: the price of one unit of base
      • timestamp: when the source last updated it, in epoch milliseconds
      • source: a short name of the feed
  • Method Details

    • getBase

      public String getBase()
      The asset priced, upper case.
    • getQuote

      public String getQuote()
      The currency of the price, upper case.
    • getPrice

      public double getPrice()
      The price of one whole unit of the base asset.
    • getTimestamp

      public long getTimestamp()
      When the source updated the price, in epoch milliseconds.
    • getSource

      public String getSource()
      The feed that answered.
    • valueOf

      public double valueOf(UInt256 amount, int decimals)
      The value of an amount in base units (wei, satoshis, lamports, token units) with the asset's decimals, in the quote currency.
    • invert

      public Quote invert()
      The quote with base and quote swapped.
    • toString

      public String toString()
      Description copied from class: Object
      Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
      Overrides:
      toString in class Object