QuoteResponse

public class QuoteResponse

A single ticker's latest quote, or the message Alpha Vantage returned in place of one.

This is the answer to a com.crazzyghost.alphavantage.timeseries.request.QuoteRequest — one snapshot rather than a series, so it is a flat set of fields with no metadata header and no unit list. The prices describe the most recent trading day, which is not necessarily today: getLatestTradingDay says which day they belong to, and over a weekend or holiday it lags.

A response carries a quote or an error, never both. On failure getErrorMessage is set and every price is left at 0.0, which is indistinguishable from a genuine zero — so the error message is what tells the two apart.

For the same snapshot across many tickers in one call, see RealtimeBulkQuoteResponse.

Author

Sylvester Sefa-Yeboah

Since

1.3.0

Constructors

Link copied to clipboard
public void QuoteResponse(String symbol, double open, double high, double low, double price, double volume, String latestTradingDay, double previousClose, double change, double changePercent)
Creates a successful quote from the values a response carried.
public void QuoteResponse(String errorMessage)
Creates a failed quote carrying only a message, with every price left at 0.0 and the ticker and trading day left null.

Types

Link copied to clipboard
public class QuoteParser extends Parser<QuoteResponse>
Turns a decoded GLOBAL_QUOTE payload into a QuoteResponse.

Properties

Link copied to clipboard
public double change
Link copied to clipboard
public double changePercent
Link copied to clipboard
Link copied to clipboard
public double high
Link copied to clipboard
Link copied to clipboard
public double low
Link copied to clipboard
public double open
Link copied to clipboard
public double previousClose
Link copied to clipboard
public double price
Link copied to clipboard
public String symbol
Link copied to clipboard
public double volume

Functions

Link copied to clipboard
public double getChange()
Gets how far the latest price has moved from the previous close, signed so that a negative value is a fall.
Link copied to clipboard
public double getChangePercent()
Gets the same move as getChange expressed against the previous close, in percentage points rather than as a fraction: a value of 1.5 means the price rose 1.5%.
Link copied to clipboard
Gets the reason no quote was returned, as reported by the API.
Link copied to clipboard
public double getHigh()
Gets the highest price reached during the latest trading day.
Link copied to clipboard
Gets the day the quote's prices belong to, which lags the calendar day over weekends, holidays and before the session opens.
Link copied to clipboard
public double getLow()
Gets the lowest price reached during the latest trading day.
Link copied to clipboard
public double getOpen()
Gets the price at which the latest trading day opened.
Link copied to clipboard
public double getPreviousClose()
Gets the price at which the trading day before the latest one closed.
Link copied to clipboard
public double getPrice()
Gets the latest traded price, which is what the quote is normally read for.
Link copied to clipboard
public String getSymbol()
Gets the ticker this quote covers, echoed back as the API resolved it rather than as the request spelled it.
Link copied to clipboard
public double getVolume()
Gets how many shares changed hands over the latest trading day.
Link copied to clipboard
public static QuoteResponse of(Map<String, Object> stringObjectMap)
Builds a response from a decoded GLOBAL_QUOTE payload.