public class OrderBase extends MarketEvent implements IndexedEvent<String>
Order
and SpreadOrder
events.
Order events represent a snapshot for a full available market depth for a symbol.
The collection of order events of a symbol represents the most recent information that is
available about orders on the market at any given moment of time.
Order
event represents market depth for a specific symbol.
SpreadOrder
event represents market depth for
all spreads on a given underlying symbol.
Order events arrive from
multiple sources for the same market symbol and are distinguished by their
index
. Index is a unique per symbol identifier of the event.
It is unique across all the sources of depth information for the symbol.
The event with sizeAsDouble
either 0
or NaN
is a signal to remove previously received order for the corresponding index.
The method hasSize
is a convenient method to test for size presence.
eventFlags
property.
The logic behind this property is detailed in IndexedEvent
class documentation.
The event source
identifier for an order is a part of the unique event index
.
It occupies highest bits of the index
(index is not-negative).
The lowest bits of
index
contain source-specific event index which is always zero in
an event that is marked with IndexedEvent.SNAPSHOT_END
bit in eventFlags
.
Note that for an order with IndexedEvent.REMOVE_EVENT
bit in eventFlags
it is always the case that sizeAsDouble
is either 0
or NaN
,
so no additional logic to process this bit is required for orders.
Transactions and snapshots may include orders with sizeAsDouble
of 0
.
The filtering that distinguishes those events as removals of orders shall be performed after
all transactions and snapshot processing.
Some aggregated feeds (like CME market depth) are mapped into two distinct source ids (one for
buy orders and one for sell orders), but updates and transactions may span both. It is important to keep a
separate track of transactional state for each source id, but, at the same time, when
DXFeedEventListener.eventsReceived
method is called for a list
of events, the order book shall be considered complete and consistent only when all events from the given
list are processed.
OrderBookModel
class contains all the appropriate logic to deal with transactions and snapshots
for Order
events. The client-visible changes to the model are reported only when the snapshot for the
specific source id is received completely and when there is no ongoing transaction for the specific source id.
It relies on the code of AbstractIndexedEventModel
to handle this logic.
Use the source code of AbstractIndexedEventModel
for clarification on transactions and snapshot logic.
Modifier and Type | Field and Description |
---|---|
static int |
LEVEL_AGGREGATE
Deprecated.
use
Scope.AGGREGATE instead. |
static int |
LEVEL_COMPOSITE
Deprecated.
use
Scope.COMPOSITE instead. |
static int |
LEVEL_ORDER
Deprecated.
use
Scope.ORDER instead. |
static int |
LEVEL_REGIONAL
Deprecated.
use
Scope.REGIONAL instead. |
static int |
MAX_SEQUENCE
Maximum allowed sequence value.
|
static int |
SIDE_BUY
Deprecated.
use
Side.BUY instead. |
static int |
SIDE_SELL
Deprecated.
use
Side.SELL instead. |
REMOVE_EVENT, SNAPSHOT_BEGIN, SNAPSHOT_END, SNAPSHOT_MODE, SNAPSHOT_SNIP, TX_PENDING
Modifier and Type | Method and Description |
---|---|
long |
getCount()
Returns number of individual orders in this aggregate order.
|
int |
getEventFlags()
Returns transactional event flags.
|
char |
getExchangeCode()
Returns exchange code of this order.
|
long |
getIndex()
Returns unique per-symbol index of this order.
|
int |
getLevel()
Deprecated.
use
getScope() instead |
Side |
getOrderSide()
Returns side of this order.
|
double |
getPrice()
Returns price of this order.
|
Scope |
getScope()
Returns scope of this order.
|
int |
getSequence()
Returns sequence number of this order to distinguish orders that have the same
time . |
int |
getSide()
Deprecated.
use
getOrderSide() instead |
long |
getSize()
Returns size of this order as integer number (rounded toward zero).
|
double |
getSizeAsDouble()
Returns size of this order as floating number with fractions.
|
OrderSource |
getSource()
Returns source of this event.
|
long |
getTime()
Returns time of this order.
|
int |
getTimeNanoPart()
Returns microseconds and nanoseconds time part of this order.
|
long |
getTimeNanos()
Returns time of this order in nanoseconds.
|
long |
getTimeSequence()
Returns time and sequence of this order packaged into single long value.
|
boolean |
hasSize()
|
void |
setCount(long count)
Changes number of individual orders in this aggregate order.
|
void |
setEventFlags(int eventFlags)
Changes transactional event flags.
|
void |
setExchangeCode(char exchangeCode)
Changes exchange code of this order.
|
void |
setIndex(long index)
Changes unique per-symbol index of this order.
|
void |
setLevel(int level)
Deprecated.
use
setScope(com.dxfeed.event.market.Scope) instead |
void |
setOrderSide(Side side)
Changes side of this order.
|
void |
setPrice(double price)
Changes price of this order.
|
void |
setScope(Scope scope)
Changes scope of this order.
|
void |
setSequence(int sequence)
Changes
getSequence() sequence number} of this order. |
void |
setSide(int side)
Deprecated.
use
setOrderSide(com.dxfeed.event.market.Side) instead |
void |
setSize(long size)
Changes size of this order as integer number (rounded toward zero).
|
void |
setSizeAsDouble(double size)
Changes size of this order as floating number with fractions.
|
void |
setSource(OrderSource source)
Changes source of this event.
|
void |
setTime(long time)
Changes time of this order.
|
void |
setTimeNanoPart(int timeNanoPart)
Changes microseconds and nanoseconds time part of this order.
|
void |
setTimeNanos(long timeNanos)
Changes time of this order.
|
void |
setTimeSequence(long timeSequence)
Changes time and sequence of this order.
|
String |
toString()
Returns string representation of this order.
|
getEventSymbol, getEventTime, setEventSymbol, setEventTime
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getEventSymbol, getEventTime, setEventSymbol, setEventTime
@Deprecated public static final int SIDE_BUY
Side.BUY
instead.@Deprecated public static final int SIDE_SELL
Side.SELL
instead.@Deprecated public static final int LEVEL_COMPOSITE
Scope.COMPOSITE
instead.@Deprecated public static final int LEVEL_REGIONAL
Scope.REGIONAL
instead.@Deprecated public static final int LEVEL_AGGREGATE
Scope.AGGREGATE
instead.@Deprecated public static final int LEVEL_ORDER
Scope.ORDER
instead.public static final int MAX_SEQUENCE
setSequence(int)
,
Constant Field Valuespublic OrderSource getSource()
index
of this event.getSource
in interface IndexedEvent<String>
public void setSource(OrderSource source)
index
of this event.source
- source of this event.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()
getIndex
in interface IndexedEvent<String>
public void setIndex(long index)
source
, whose id occupies highest bits of index.
Use setSource
after invocation of this method to set the
desired value of source.setIndex
in interface IndexedEvent<String>
index
- unique per-symbol index of this order.IllegalArgumentException
- when index is negative.public long getTimeSequence()
public void setTimeSequence(long timeSequence)
time
and/or sequence
.timeSequence
- the time and sequence.getTimeSequence()
public long getTime()
public void setTime(long time)
time
- time of this order.public void setTimeNanoPart(int timeNanoPart)
timeNanoPart
- microseconds and nanoseconds time part of this order.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 order.sequence
- the sequence.IllegalArgumentException
- if sequence is below zero or above MAX_SEQUENCE
.getSequence()
public long getTimeNanos()
public void setTimeNanos(long timeNanos)
timeNanos
- time of this order in nanoseconds..public double getPrice()
public void setPrice(double price)
price
- price of this order.public long getSize()
public void setSize(long size)
size
- size of this order as integer number (rounded toward zero).public double getSizeAsDouble()
public void setSizeAsDouble(double size)
size
- size of this order as floating number with fractions.public boolean hasSize()
true
if this order has some size (sizeAsDouble is neither 0
nor NaN
).public long getCount()
public void setCount(long count)
count
- number of individual orders in this aggregate order.public char getExchangeCode()
public void setExchangeCode(char exchangeCode)
exchangeCode
- exchange code of this order.IllegalArgumentException
- if exchange code is greater than 127public Side getOrderSide()
public void setOrderSide(Side side)
side
- side of this order.public Scope getScope()
public void setScope(Scope scope)
scope
- scope of this order.@Deprecated public int getSide()
getOrderSide()
instead@Deprecated public void setSide(int side)
setOrderSide(com.dxfeed.event.market.Side)
instead@Deprecated public int getLevel()
getScope()
instead@Deprecated public void setLevel(int level)
setScope(com.dxfeed.event.market.Scope)
insteadlevel
- detail level of this order.Copyright © 2002-2019 Devexperts LLC. All Rights Reserved.