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 event;
time
- timestamp of the candle in milliseconds;
sequence
- sequence number of this event to distinguish events that have the 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;
vwap
- volume-weighted average price (VWAP) in this candle;
bidVolume
- bid volume in this candle;
askVolume
- bid volume in this candle.
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, 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.
|
long |
getBidVolume()
Returns bid volume in this candle.
|
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.
|
long |
getEventId()
Deprecated.
Use
getIndex() |
CandleSymbol |
getEventSymbol()
Returns candle event symbol.
|
double |
getHigh()
Returns the maximal (high) price of this candle.
|
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.
|
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 |
getVWAP()
Returns volume-weighted average price (VWAP) in this candle.
|
void |
setAskVolume(long askVolume)
Changes ask volume in this candle.
|
void |
setBidVolume(long bidVolume)
Changes bid volume in this candle.
|
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 |
setHigh(double high)
Changes the maximal (high) price of this candle.
|
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 |
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 |
setVWAP(double vwap)
Changes volume-weighted average price (VWAP) in this candle.
|
String |
toString()
Returns string representation of this candle.
|
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 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 long getEventId()
getIndex()
getEventId
in interface TimeSeriesEvent<CandleSymbol>
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 getVWAP()
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 long getAskVolume()
public void setAskVolume(long askVolume)
askVolume
- ask volume in this candle.Copyright © 2015 Devexperts. All Rights Reserved.