Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public final class Quote
- Object
- Quote
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.Constructors
public Quote(String base, String quote, double price, long timestamp, String source) | A quote. |
Methods
public String getBase() | The asset priced, upper case. |
public String getQuote() | The currency of the price, upper case. |
public double getPrice() | The price of one whole unit of the base asset. |
public long getTimestamp() | When the source updated the price, in epoch milliseconds. |
public String getSource() | The feed that answered. |
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. |
public Quote invert() | The quote with base and quote swapped. |
public String toString() | Returns a string representation of the object. |
Inherited methods
Constructor details
Quote
public Quote(String base, String quote, double price, long timestamp, String source)A quote.
Parameters
baseString- the asset priced, such as
BTC quoteString- the currency of the price, such as
USD pricedouble- the price of one unit of
base timestamplong- when the source last updated it, in epoch milliseconds
sourceString- 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()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())