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 size
of 0
is a signal to remove
previously received order for the corresponding index.
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 the most significant 23 bits of the index
excluding sign bit (index is not-negative).
The least significant 40 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 it is always the case that size
is 0
for an order with IndexedEvent.REMOVE_EVENT
bit in eventFlags
,
so no additional logic to process this bit is required for orders.
Transactions and snapshots may include orders with size
of 0
. The filtering that
distinguishes those events as removals of orders shall be performed after all the 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. |
static int |
SOURCE_ID_SHIFT
|
REMOVE_EVENT, SNAPSHOT_BEGIN, SNAPSHOT_END, SNAPSHOT_SNIP, TX_PENDING
Modifier and Type | Method and Description |
---|---|
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.
|
OrderSource |
getSource()
Returns source of this event.
|
long |
getTime()
Returns time of this order.
|
long |
getTimeSequence()
Returns time and sequence of this order packaged into single long value.
|
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.
|
void |
setSource(OrderSource source)
Changes source of this event.
|
void |
setTime(long time)
Changes time of this order.
|
void |
setTimeSequence(long timeSequence)
Changes time and sequence of this order.
|
getEventSymbol, setEventSymbol
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getEventSymbol, setEventSymbol
public static final int SOURCE_ID_SHIFT
@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()
OrderSource
.valueOf
((int)(getIndex
()
>>> SOURCE_ID_SHIFT
))
.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 23 most significant bits of index excluding sign bit.
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 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 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.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 © 2015 Devexperts. All Rights Reserved.