public class Candle extends Object implements TimeSeriesEvent<CandleSymbol>, LastingEvent<CandleSymbol>
CandlePeriod
using a specified CandlePrice
type
with a data taken from the specified CandleExchange
from the specified CandleSession
with further details of aggregation provided by CandleAlignment
.
Event symbol of the candle is represented with CandleSymbol
class.
Since the Candle
is a time-series event, it is typically subscribed to using
DXFeedTimeSeriesSubscription
class that handles the necessarily wrapping
of the symbol into TimeSeriesSubscriptionSymbol
to specify a subscription
time range.
Candle
event has the following properties:
eventSymbol
- candle event symbol;
eventFlags
- transactional event flags;
index
- unique per-symbol index of this candle;
time
- timestamp of this candle in milliseconds;
sequence
- sequence number of this candle; distinguishes candles with same time
;
count
- total number of original trade (or quote) events in this candle;
open
- the first (open) price of this candle;
high
- the maximal (high) price of this candle;
low
- the minimal (low) price of this candle;
close
- the last (close) price of this candle;
volume
- total volume in this candle;
volumeAsDouble
- total volume in this candle as floating number with fractions;
vwap
- volume-weighted average price (VWAP) in this candle;
bidVolume
- bid volume in this candle;
bidVolumeAsDouble
- bid volume in this candle as floating number with fractions;
askVolume
- bid volume in this candle;
askVolumeAsDouble
- bid volume in this candle as floating number with fractions;
impVolatility
- implied volatility;
openInterest
- open interest;
getOpenInterestAsDouble()
() openInterestAsDouble} - open interest as floating number with fractions;
eventFlags
property.
The logic behind this property is detailed in IndexedEvent
class documentation.
Multiple event sources for the same symbol are not supported for candles, thus
source
property is always DEFAULT
.
TimeSeriesEventModel
class handles all the snapshot and transaction logic and conveniently represents
a list current of time-series events order by their time
.
It relies on the code of AbstractIndexedEventModel
to handle this logic.
Use the source code of AbstractIndexedEventModel
for clarification on transactions and snapshot logic.
TimeSeriesEvent
class
documentation.
TradeHistory
for tick candles
with CandlePeriod.TICK
, records Trade.<period>
for
a certain set of popular periods, and QDS record Candle
for arbitrary custom
periods, with a set of Candle{<attributes>}
records for a popular combinations of custom
candle symbol attributes like CandlePrice
for an efficient support of bid-ask charting.Modifier and Type | Field and Description |
---|---|
static int |
MAX_SEQUENCE
Maximum allowed sequence value.
|
REMOVE_EVENT, SNAPSHOT_BEGIN, SNAPSHOT_END, SNAPSHOT_MODE, SNAPSHOT_SNIP, TX_PENDING
Constructor and Description |
---|
Candle()
Creates new candle with default values.
|
Candle(CandleSymbol eventSymbol)
Creates new candle with the specified candle event symbol.
|
Modifier and Type | Method and Description |
---|---|
long |
getAskVolume()
Returns ask volume in this candle.
|
double |
getAskVolumeAsDouble()
Returns ask volume in this candle as floating number with fractions.
|
long |
getBidVolume()
Returns bid volume in this candle.
|
double |
getBidVolumeAsDouble()
Returns bid volume in this candle as floating number with fractions.
|
double |
getClose()
Returns the last (close) price of this candle.
|
long |
getCount()
Returns total number of original trade (or quote) events in this candle.
|
int |
getEventFlags()
Returns transactional event flags.
|
CandleSymbol |
getEventSymbol()
Returns candle event symbol.
|
long |
getEventTime()
Returns time when event was created or zero when time is not available.
|
double |
getHigh()
Returns the maximal (high) price of this candle.
|
double |
getImpVolatility()
Returns implied volatility.
|
long |
getIndex()
Returns unique per-symbol index of this candle event.
|
double |
getLow()
Returns the minimal (low) price of this candle.
|
double |
getOpen()
Returns the first (open) price of this candle.
|
long |
getOpenInterest()
Returns open interest.
|
double |
getOpenInterestAsDouble()
Returns open interest as floating number with fractions.
|
int |
getSequence()
Returns sequence number of this event to distinguish events that have the same
time . |
IndexedEventSource |
getSource()
Returns a source identifier for this event, which is always
DEFAULT for time-series events. |
long |
getTime()
Returns timestamp of the candle in milliseconds.
|
long |
getVolume()
Returns total volume in this candle.
|
double |
getVolumeAsDouble()
Returns total volume in this candle as floating number with fractions.
|
double |
getVWAP()
Returns volume-weighted average price (VWAP) in this candle.
|
void |
setAskVolume(long askVolume)
Changes ask volume in this candle.
|
void |
setAskVolumeAsDouble(double askVolume)
Changes ask volume in this candle as floating number with fractions.
|
void |
setBidVolume(long bidVolume)
Changes bid volume in this candle.
|
void |
setBidVolumeAsDouble(double bidVolume)
Changes bid volume in this candle as floating number with fractions.
|
void |
setClose(double close)
Changes the last (close) price of this candle.
|
void |
setCount(long count)
Changes total number of original trade (or quote) events in this candle.
|
void |
setEventFlags(int eventFlags)
Changes transactional event flags.
|
void |
setEventId(long index)
Deprecated.
Use
setIndex(long) |
void |
setEventSymbol(CandleSymbol eventSymbol)
Changes candle event symbol.
|
void |
setEventTime(long eventTime)
Changes event creation time.
|
void |
setHigh(double high)
Changes the maximal (high) price of this candle.
|
void |
setImpVolatility(double impVolatility)
Changes implied volatility.
|
void |
setIndex(long index)
Changes unique per-symbol index of this candle event.
|
void |
setLow(double low)
Changes the minimal (low) price of this candle.
|
void |
setOpen(double open)
Changes the first (open) price of this candle.
|
void |
setOpenInterest(long openInterest)
Changes open interest.
|
void |
setOpenInterestAsDouble(double openInterest)
Changes open interest as floating number with fractions.
|
void |
setSequence(int sequence)
Changes
getSequence() sequence number} of this event. |
void |
setTime(long time)
Changes timestamp of the candle in milliseconds.
|
void |
setVolume(long volume)
Changes total volume in this candle.
|
void |
setVolumeAsDouble(double volume)
Changes total volume in this candle as floating number with fractions.
|
void |
setVWAP(double vwap)
Changes volume-weighted average price (VWAP) in this candle.
|
String |
toString()
Returns string representation of this candle.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getEventId
public static final int MAX_SEQUENCE
setSequence(int)
,
Constant Field Valuespublic Candle()
public Candle(CandleSymbol eventSymbol)
eventSymbol
- candle event symbol.public CandleSymbol getEventSymbol()
getEventSymbol
in interface EventType<CandleSymbol>
public void setEventSymbol(CandleSymbol eventSymbol)
setEventSymbol
in interface EventType<CandleSymbol>
eventSymbol
- candle event symbol.public long getEventTime()
This event time is available only when the corresponding DXEndpoint
is created
with DXENDPOINT_EVENT_TIME_PROPERTY
and
the data source has embedded event times. This is typically true only for data events
that are read from historical tape files and from OnDemandService
.
Events that are coming from a network connections do not have an embedded event time information and
this method will return zero for them, meaning that event was received just now.
getEventTime
in interface EventType<CandleSymbol>
public void setEventTime(long eventTime)
setEventTime
in interface EventType<CandleSymbol>
eventTime
- the difference, measured in milliseconds,
between the event creation time and midnight, January 1, 1970 UTC.public IndexedEventSource getSource()
DEFAULT
for time-series events.getSource
in interface IndexedEvent<CandleSymbol>
getSource
in interface TimeSeriesEvent<CandleSymbol>
DEFAULT
for time-series events.public int getEventFlags()
getEventFlags
in interface IndexedEvent<CandleSymbol>
public void setEventFlags(int eventFlags)
setEventFlags
in interface IndexedEvent<CandleSymbol>
eventFlags
- transactional event flags.public long getIndex()
time
and sequence
.
Changing either time or sequence changes event index.getIndex
in interface IndexedEvent<CandleSymbol>
getIndex
in interface TimeSeriesEvent<CandleSymbol>
public void setIndex(long index)
time
and sequence
and
invocation of this method changes time and sequence.
Do not use this method directly.
Change time
and/or sequence
.setIndex
in interface IndexedEvent<CandleSymbol>
index
- the event index.getIndex()
public void setEventId(long index)
setIndex(long)
index
- the event index.public long getTime()
getTime
in interface TimeSeriesEvent<CandleSymbol>
System.currentTimeMillis()
public void setTime(long time)
time
- timestamp of the candle in milliseconds.getTime()
public int getSequence()
time
. This sequence number does not have to be unique and
does not need to be sequential. Sequence can range from 0 to MAX_SEQUENCE
.public void setSequence(int sequence)
getSequence()
sequence number} of this event.sequence
- the sequence.IllegalArgumentException
- if sequence is below zero or above MAX_SEQUENCE
.getSequence()
public long getCount()
public void setCount(long count)
count
- total number of original trade (or quote) events in this candle.public double getOpen()
public void setOpen(double open)
open
- the first (open) price of this candle.public double getHigh()
public void setHigh(double high)
high
- the maximal (high) price of this candle.public double getLow()
public void setLow(double low)
low
- the minimal (low) price of this candle.public double getClose()
public void setClose(double close)
close
- the last (close) price of this candle.public long getVolume()
public void setVolume(long volume)
volume
- total volume in this candle.public double getVolumeAsDouble()
public void setVolumeAsDouble(double volume)
volume
- total volume in this candle as floating number with fractions.public double getVWAP()
getVWAP() * getVolume
()
.public void setVWAP(double vwap)
vwap
- volume-weighted average price (VWAP) in this candle.public long getBidVolume()
public void setBidVolume(long bidVolume)
bidVolume
- bid volume in this candle.public double getBidVolumeAsDouble()
public void setBidVolumeAsDouble(double bidVolume)
bidVolume
- bid volume in this candle as floating number with fractions.public long getAskVolume()
public void setAskVolume(long askVolume)
askVolume
- ask volume in this candle.public double getAskVolumeAsDouble()
public void setAskVolumeAsDouble(double askVolume)
askVolume
- ask volume in this candle as floating number with fractions.public double getImpVolatility()
public void setImpVolatility(double impVolatility)
impVolatility
- implied volatility.public long getOpenInterest()
public void setOpenInterest(long openInterest)
openInterest
- open interest.public double getOpenInterestAsDouble()
public void setOpenInterestAsDouble(double openInterest)
openInterest
- open interest as floating number with fractions.Copyright © 2002–2023 Devexperts LLC. All rights reserved.