public class OrderBase extends MarketEvent implements IndexedEvent<String>
Order
, AnalyticOrder
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.
AnalyticOrder
event represents market depth for a specific symbol extended with an analytic
information, for example, whether particular order represent an iceberg or not.
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 |
---|---|
OrderAction |
getAction()
Returns order action if available, otherwise -
OrderAction.UNDEFINED . |
long |
getActionTime()
Returns time of the last
action . |
long |
getAuxOrderId()
Returns auxiliary order ID if available:
in
OrderAction.NEW - ID of the order replaced by this new order
in OrderAction.DELETE - ID of the order that replaces this deleted order
in OrderAction.PARTIAL - ID of the aggressor order
in OrderAction.EXECUTE - ID of the aggressor order
|
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.
|
double |
getExecutedSize()
Returns executed size of this order.
|
long |
getIndex()
Returns unique per-symbol index of this order.
|
int |
getLevel()
Deprecated.
use
getScope() instead |
long |
getOrderId()
Returns order ID if available.
|
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.
|
long |
getTradeId()
Returns trade (order execution) ID for events containing trade-related action.
|
double |
getTradePrice()
Returns trade price for events containing trade-related action.
|
double |
getTradeSize()
Returns trade size for events containing trade-related action.
|
boolean |
hasSize()
|
void |
setAction(OrderAction action)
Changes action of this order.
|
void |
setActionTime(long actionTime)
Changes time of the last action
|
void |
setAuxOrderId(long auxOrderId)
Changes auxiliary order ID.
|
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 |
setExecutedSize(double executedSize)
Changes executed size 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 |
setOrderId(long orderId)
Changes order ID.
|
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.
|
void |
setTradeId(long tradeId)
Changes trade ID.
|
void |
setTradePrice(double tradePrice)
Changes trade price.
|
void |
setTradeSize(double tradeSize)
Changes trade size.
|
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 OrderAction getAction()
OrderAction.UNDEFINED
.
This field is a part of the FOB support.
OrderAction.UNDEFINED
.public void setAction(OrderAction action)
action
- side of this order.public long getActionTime()
public void setActionTime(long actionTime)
actionTime
- last order action time.public long getOrderId()
OrderAction.TRADE
,
OrderAction.BUST
) have no order ID since they are not related to any order in Order book.
This field is a part of the FOB support.
public void setOrderId(long orderId)
orderId
- order ID.public long getAuxOrderId()
OrderAction.NEW
- ID of the order replaced by this new orderOrderAction.DELETE
- ID of the order that replaces this deleted orderOrderAction.PARTIAL
- ID of the aggressor orderOrderAction.EXECUTE
- ID of the aggressor orderThis field is a part of the FOB support.
public void setAuxOrderId(long auxOrderId)
auxOrderId
- auxiliary order ID.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 double getExecutedSize()
public void setExecutedSize(double executedSize)
executedSize
- executed size of this order.public long getCount()
public void setCount(long count)
count
- number of individual orders in this aggregate order.public long getTradeId()
This field is a part of the FOB support.
public void setTradeId(long tradeId)
tradeId
- trade ID.public double getTradePrice()
This field is a part of the FOB support.
public void setTradePrice(double tradePrice)
tradePrice
- trade price.public double getTradeSize()
This field is a part of the FOB support.
public void setTradeSize(double tradeSize)
tradeSize
- trade size.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–2023 Devexperts LLC. All rights reserved.