public class TimeAndSale extends MarketEvent implements TimeSeriesEvent<String>
Trade
events which are supposed to provide snapshot about the current last trade).
Time and Sale events have unique index
which can be used for later
correction/cancellation processing.
TimeAndSale
event has the following properties:
eventSymbol
- symbol of this event;
eventFlags
- transactional event flags;
index
- unique per-symbol index of this time and sale event;
time
- timestamp of the original event;
timeNanoPart
- microseconds and nanoseconds time part of event;
sequence
- sequence number of this event to distinguish events that have the same
time
;
exchangeCode
- exchange code of this time and sale event;
price
- price of this time and sale event;
size
- size of this time and sale event as integer number (rounded toward zero);
sizeAsDouble
- size of this time and sale event as floating number with fractions;
bidPrice
- the current bid price on the market when this time and sale event had occurred;
askPrice
- the current ask price on the market when this time and sale event had occurred;
exchangeSaleConditions
- sale conditions provided for this event by data feed;
aggressorSide
- aggressor side of this time and sale event;
spreadLeg
- whether this event represents a spread leg;
extendedTradingHours
- whether this event represents an extended trading hours sale;
validTick
- whether this event represents a valid intraday tick;
type
- type of this time and sale event.
DXFeedTimeSeriesSubscription
.
The corresponding information is carried in eventFlags
property.
The logic behind this property is detailed in IndexedEvent
class documentation.
Multiple event sources for the same symbol are not supported for time and sales, thus
source
property is always DEFAULT
.
Regular subscription via DXFeedSubscription
produces a stream of time and
sale events as they happen and their eventFlags
are always zero.
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.
TimeAndSale
.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 |
---|
TimeAndSale()
Creates new time and sale event with default values.
|
TimeAndSale(String eventSymbol)
Creates new time and sale event with the specified event symbol.
|
Modifier and Type | Method and Description |
---|---|
Side |
getAggressorSide()
Returns aggressor side of this time and sale event.
|
double |
getAskPrice()
Returns the current ask price on the market when this time and sale event had occurred.
|
double |
getBidPrice()
Returns the current bid price on the market when this time and sale event had occurred.
|
String |
getBuyer()
Returns buyer of this time and sale event.
|
int |
getEventFlags()
Returns transactional event flags.
|
char |
getExchangeCode()
Returns exchange code of this time and sale event.
|
String |
getExchangeSaleConditions()
Returns sale conditions provided for this event by data feed.
|
long |
getIndex()
Returns unique per-symbol index of this time and sale event.
|
double |
getPrice()
Returns price of this time and sale event.
|
String |
getSeller()
Returns seller of this time and sale event.
|
int |
getSequence()
Returns sequence number of this event to distinguish events that have the same
time . |
long |
getSize()
Returns size of this time and sale event as integer number (rounded toward zero).
|
double |
getSizeAsDouble()
Returns size of this time and sale event as floating number with fractions.
|
IndexedEventSource |
getSource()
Returns a source identifier for this event, which is always
DEFAULT for time-series events. |
long |
getTime()
Returns timestamp of the original event.
|
int |
getTimeNanoPart()
Returns microseconds and nanoseconds time part of event.
|
long |
getTimeNanos()
Returns timestamp of the original event in nanoseconds.
|
char |
getTradeThroughExempt()
Returns TradeThroughExempt flag of this time and sale event.
|
TimeAndSaleType |
getType()
Returns type of this time and sale event.
|
boolean |
isCancel()
Returns whether this is a cancellation of a previous event.
|
boolean |
isCorrection()
Returns whether this is a correction of a previous event.
|
boolean |
isExtendedTradingHours()
Returns whether this event represents an extended trading hours sale.
|
boolean |
isNew()
Returns whether this is a new event (not cancellation or correction).
|
boolean |
isSpreadLeg()
Returns whether this event represents a spread leg.
|
boolean |
isValidTick()
Returns whether this event represents a valid intraday tick.
|
void |
setAggressorSide(Side side)
Changes aggressor side of this time and sale event.
|
void |
setAskPrice(double askPrice)
Changes the current ask price on the market when this time and sale event had occurred.
|
void |
setBidPrice(double bidPrice)
Changes the current bid price on the market when this time and sale event had occurred.
|
void |
setBuyer(String buyer)
Changes buyer of this time and sale event.
|
void |
setCancel()
Deprecated.
use
setType(TimeAndSaleType.CANCEL) instead. |
void |
setCorrection()
Deprecated.
use
setType(TimeAndSaleType.CORRECTION) instead. |
void |
setEventFlags(int eventFlags)
Changes transactional event flags.
|
void |
setEventId(long index)
Deprecated.
Use
setIndex(long) |
void |
setExchangeCode(char exchangeCode)
Changes exchange code of this time and sale event.
|
void |
setExchangeSaleConditions(String exchangeSaleConditions)
Changes sale conditions provided for this event by data feed.
|
void |
setExtendedTradingHours(boolean extendedTradingHours)
Changes whether this event represents an extended trading hours sale.
|
void |
setIndex(long index)
Changes unique per-symbol index of this time and sale event.
|
void |
setNew()
Deprecated.
use
setType(TimeAndSaleType.NEW) instead. |
void |
setPrice(double price)
Changes price of this time and sale event.
|
void |
setSeller(String seller)
Changes seller of this time and sale event.
|
void |
setSequence(int sequence)
Changes
getSequence() sequence number} of this event. |
void |
setSize(long size)
Changes size of this time and sale event as integer number (rounded toward zero).
|
void |
setSizeAsDouble(double size)
Changes size of this time and sale event as floating number with fractions.
|
void |
setSpreadLeg(boolean spreadLeg)
Changes whether this event represents a spread leg.
|
void |
setTime(long time)
Changes timestamp of event in milliseconds.
|
void |
setTimeNanoPart(int timeNanoPart)
Changes microseconds and nanoseconds time part of event.
|
void |
setTimeNanos(long timeNanos)
Changes timestamp of event.
|
void |
setTradeThroughExempt(char tradeThroughExempt)
Changes TradeThroughExempt flag of this time and sale event.
|
void |
setType(TimeAndSaleType type)
Changes type of this time and sale event.
|
void |
setValidTick(boolean validTick)
Changes whether this event represents a valid intraday tick.
|
String |
toString()
Returns string representation of this time and sale event.
|
getEventSymbol, getEventTime, setEventSymbol, setEventTime
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getEventId
getEventSymbol, getEventTime, setEventSymbol, setEventTime
public static final int MAX_SEQUENCE
setSequence(int)
,
Constant Field Valuespublic TimeAndSale()
public TimeAndSale(String eventSymbol)
eventSymbol
- event symbol.public IndexedEventSource getSource()
DEFAULT
for time-series events.getSource
in interface IndexedEvent<String>
getSource
in interface TimeSeriesEvent<String>
DEFAULT
for time-series events.public int getEventFlags()
getEventFlags
in interface IndexedEvent<String>
public void setEventFlags(int eventFlags)
setEventFlags
in interface IndexedEvent<String>
eventFlags
- transactional event flags.public long getIndex()
time
and sequence
.
Changing either time or sequence changes event index.getIndex
in interface IndexedEvent<String>
getIndex
in interface TimeSeriesEvent<String>
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<String>
index
- the event index.getIndex()
@Deprecated public void setEventId(long index)
setIndex(long)
index
- the event index.public long getTime()
getTime
in interface TimeSeriesEvent<String>
System.currentTimeMillis()
public void setTime(long time)
time
- timestamp in milliseconds.getTime()
public long getTimeNanos()
public void setTimeNanos(long timeNanos)
timeNanos
- timestamp in nanoseconds.public void setTimeNanoPart(int timeNanoPart)
timeNanoPart
- microseconds and nanoseconds time part of event.public int getTimeNanoPart()
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 char getExchangeCode()
public void setExchangeCode(char exchangeCode)
exchangeCode
- exchange code of this time and sale event.public double getPrice()
public void setPrice(double price)
price
- price of this time and sale event.public long getSize()
public void setSize(long size)
size
- size of this time and sale event as integer number (rounded toward zero).public double getSizeAsDouble()
public void setSizeAsDouble(double size)
size
- size of this time and sale event as floating number with fractions.public double getBidPrice()
public void setBidPrice(double bidPrice)
bidPrice
- the current bid price on the market when this time and sale event had occurred.public double getAskPrice()
public void setAskPrice(double askPrice)
askPrice
- the current ask price on the market when this time and sale event had occurred.public String getExchangeSaleConditions()
public void setExchangeSaleConditions(String exchangeSaleConditions)
exchangeSaleConditions
- sale conditions.public char getTradeThroughExempt()
public void setTradeThroughExempt(char tradeThroughExempt)
tradeThroughExempt
- TradeThroughExempt flag of this time and sale event.public Side getAggressorSide()
public void setAggressorSide(Side side)
side
- aggressor side of this time and sale event.public boolean isSpreadLeg()
true
if this event represents a spread leg.public void setSpreadLeg(boolean spreadLeg)
spreadLeg
- true
if this event represents a spread leg.public boolean isExtendedTradingHours()
true
if this event represents an extended trading hours sale.public void setExtendedTradingHours(boolean extendedTradingHours)
extendedTradingHours
- true
if this event represents an extended trading hours sale.public boolean isValidTick()
true
if this event represents a valid intraday tick.public void setValidTick(boolean validTick)
validTick
- true
if this event represents a valid intraday tick.public TimeAndSaleType getType()
public void setType(TimeAndSaleType type)
type
- type of this time and sale event.public boolean isNew()
true
for newly created time and sale event.true
if this is a new event (not cancellation or correction).@Deprecated public void setNew()
setType(TimeAndSaleType.NEW)
instead.isCancel()
and isCorrection()
false.public boolean isCorrection()
false
for newly created time and sale event.true
if this is a correction of a previous event@Deprecated public void setCorrection()
setType(TimeAndSaleType.CORRECTION)
instead.isNew()
and isCancel()
false.public boolean isCancel()
false
for newly created time and sale event.true
if this is a cancellation of a previous event@Deprecated public void setCancel()
setType(TimeAndSaleType.CANCEL)
instead.isNew()
and isCorrection()
false.public String getBuyer()
public void setBuyer(String buyer)
buyer
- buyer of this time and sale event.public String getSeller()
public void setSeller(String seller)
seller
- seller of this time and sale event.Copyright © 2002–2023 Devexperts LLC. All rights reserved.