com.dxfeed.event.market
Class TimeAndSale

java.lang.Object
  extended by com.dxfeed.event.market.MarketEvent
      extended by com.dxfeed.event.market.TimeAndSale
All Implemented Interfaces:
TimeSeriesEvent, Serializable

public final class TimeAndSale
extends MarketEvent
implements TimeSeriesEvent

Time and Sale represents a trade (or other market event with price, e.g. market open/close price, etc.). Time and Sales are intended to provide information about trades in a continuous time slice (unlike Trade events which are supposed to provide snapshot about the current last trade).

Time and Sale events have unique event identifiers which can be used for later correction/cancellation processing.

See Also:
Serialized Form

Field Summary
static int MAX_SEQUENCE
           
 
Constructor Summary
TimeAndSale()
          Creates new time and sale event with default values.
TimeAndSale(String eventSymbol)
          Creates new time and sale event with the specified event symbol.
 
Method Summary
 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.
 long getEventId()
          Returns identifier of this event.
 char getExchangeCode()
          Returns exchange code of this time and sale event.
 String getExchangeSaleConditions()
          Returns sale conditions provided for this event by data feed.
 int getFlags()
          Returns implementation-specific flags.
 double getPrice()
          Returns price of this time and sale event.
 int getSequence()
          Returns sequence number of this event to distinguish events that has the same time.
 long getSize()
          Returns size of this time and sale event.
 long getTime()
          Returns timestamp of the original 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 isTrade()
          Deprecated. use isValidTick() instead.
 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 setCancel()
          Marks this event as a cancellation of a previous event.
 void setCorrection()
          Marks this is event as a correction of a previous event.
 void setEventId(long eventId)
          Changes identifier for this event.
 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 setFlags(int flags)
          Changes implementation-specific flags.
 void setNew()
          Marks this event as a new event (not cancellation or correction).
 void setPrice(double price)
          Changes price 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.
 void setSpreadLeg(boolean spreadLeg)
          Changes whether this event represents a spread leg.
 void setTime(long time)
          Changes timestamp of event in milliseconds.
 void setTrade(boolean validTick)
          Deprecated. use setValidTick(boolean) instead.
 void setValidTick(boolean validTick)
          Changes whether this event represents a valid intraday tick.
 String toString()
          Returns string representation of this time and sale event.
 
Methods inherited from class com.dxfeed.event.market.MarketEvent
getEventSymbol, setEventSymbol
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_SEQUENCE

public static final int MAX_SEQUENCE
See Also:
Constant Field Values
Constructor Detail

TimeAndSale

public TimeAndSale()
Creates new time and sale event with default values.


TimeAndSale

public TimeAndSale(String eventSymbol)
Creates new time and sale event with the specified event symbol.

Parameters:
eventSymbol - event symbol.
Method Detail

getEventId

public long getEventId()
Returns identifier of this event. Event identifiers are unique within event symbol. If this event is correction or cancel, then its identifier repeats original event identifier. Event identifier is composed of time and sequence. Changing either time or sequence changes event identifier.

Specified by:
getEventId in interface TimeSeriesEvent
Returns:
unique event identifier.

setEventId

public void setEventId(long eventId)
Changes identifier for this event. Because, event identifier is composed of time and sequence, invocation of this method changes time and sequence. Do not use this method directly. Change time and/or sequence.

Parameters:
eventId - the event identifier.
See Also:
getEventId()

getTime

public long getTime()
Returns timestamp of the original event. Time is measured in milliseconds between the current time and midnight, January 1, 1970 UTC.

Specified by:
getTime in interface TimeSeriesEvent
Returns:
timestamp of the original event.
See Also:
System.currentTimeMillis()

setTime

public void setTime(long time)
Changes timestamp of event in milliseconds. Time is measured in milliseconds between the current time and midnight, January 1, 1970 UTC.

Parameters:
time - timestamp in milliseconds.
See Also:
getTime()

getSequence

public int getSequence()
Returns sequence number of this event to distinguish events that has the same 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.


setSequence

public void setSequence(int sequence)
Changes getSequence() sequence number} of this event.

Parameters:
sequence - the sequence.
Throws:
IllegalArgumentException - if sequence is below zero or above MAX_SEQUENCE.
See Also:
getSequence()

getExchangeCode

public char getExchangeCode()
Returns exchange code of this time and sale event.

Returns:
exchange code of this time and sale event.

setExchangeCode

public void setExchangeCode(char exchangeCode)
Changes exchange code of this time and sale event.

Parameters:
exchangeCode - exchange code of this time and sale event.

getPrice

public double getPrice()
Returns price of this time and sale event.

Returns:
price of this time and sale event.

setPrice

public void setPrice(double price)
Changes price of this time and sale event.

Parameters:
price - price of this time and sale event.

getSize

public long getSize()
Returns size of this time and sale event.

Returns:
size of this time and sale event.

setSize

public void setSize(long size)
Changes size of this time and sale event.

Parameters:
size - size of this time and sale event.

getBidPrice

public double getBidPrice()
Returns the current bid price on the market when this time and sale event had occurred.

Returns:
the current bid price on the market when this time and sale event had occurred.

setBidPrice

public void setBidPrice(double bidPrice)
Changes the current bid price on the market when this time and sale event had occurred.

Parameters:
bidPrice - the current bid price on the market when this time and sale event had occurred.

getAskPrice

public double getAskPrice()
Returns the current ask price on the market when this time and sale event had occurred.

Returns:
the current ask price on the market when this time and sale event had occurred.

setAskPrice

public void setAskPrice(double askPrice)
Changes the current ask price on the market when this time and sale event had occurred.

Parameters:
askPrice - the current ask price on the market when this time and sale event had occurred.

getExchangeSaleConditions

public String getExchangeSaleConditions()
Returns sale conditions provided for this event by data feed. This field format is specific for every particular data feed.

Returns:
sale conditions.

setExchangeSaleConditions

public void setExchangeSaleConditions(String exchangeSaleConditions)
Changes sale conditions provided for this event by data feed.

Parameters:
exchangeSaleConditions - sale conditions.

getAggressorSide

public Side getAggressorSide()
Returns aggressor side of this time and sale event.

Returns:
aggressor side of this time and sale event.

setAggressorSide

public void setAggressorSide(Side side)
Changes aggressor side of this time and sale event.

Parameters:
side - aggressor side of this time and sale event.

isSpreadLeg

public boolean isSpreadLeg()
Returns whether this event represents a spread leg.

Returns:
true if this event represents a spread leg.

setSpreadLeg

public void setSpreadLeg(boolean spreadLeg)
Changes whether this event represents a spread leg.

Parameters:
spreadLeg - true if this event represents a spread leg.

isExtendedTradingHours

public boolean isExtendedTradingHours()
Returns whether this event represents an extended trading hours sale.

Returns:
true if this event represents an extended trading hours sale.

setExtendedTradingHours

public void setExtendedTradingHours(boolean extendedTradingHours)
Changes whether this event represents an extended trading hours sale.

Parameters:
extendedTradingHours - true if this event represents an extended trading hours sale.

isTrade

@Deprecated
public boolean isTrade()
Deprecated. use isValidTick() instead.

Returns whether this event represents a valid intraday tick. Note, that a correction for a previously distributed valid tick represents a new valid tick itself, but a cancellation of a previous valid tick does not.

Returns:
true if this event represents a valid intraday tick.

setTrade

@Deprecated
public void setTrade(boolean validTick)
Deprecated. use setValidTick(boolean) instead.

Sets whether this event represents a valid tick.

Parameters:
validTick - whether this event is a valid tick

isValidTick

public boolean isValidTick()
Returns whether this event represents a valid intraday tick. Note, that a correction for a previously distributed valid tick represents a new valid tick itself, but a cancellation of a previous valid tick does not.

Returns:
true if this event represents a valid intraday tick.

setValidTick

public void setValidTick(boolean validTick)
Changes whether this event represents a valid intraday tick.

Parameters:
validTick - true if this event represents a valid intraday tick.

isNew

public boolean isNew()
Returns whether this is a new event (not cancellation or correction). It is true for newly created time and sale event.

Returns:
true if this is a new event (not cancellation or correction).

setNew

public void setNew()
Marks this event as a new event (not cancellation or correction). This is a default state for newly created time and sale event. This method makes isCancel() and isCorrection() false.


isCorrection

public boolean isCorrection()
Returns whether this is a correction of a previous event. It is false for newly created time and sale event.

Returns:
true if this is a correction of a previous event

setCorrection

public void setCorrection()
Marks this is event as a correction of a previous event. This method makes isNew() and isCancel() false.


isCancel

public boolean isCancel()
Returns whether this is a cancellation of a previous event. It is false for newly created time and sale event.

Returns:
true if this is a cancellation of a previous event

setCancel

public void setCancel()
Marks this event as a cancellation of a previous event. This method makes isNew() and isCorrection() false.


getFlags

public int getFlags()
Returns implementation-specific flags. Do not use this method directly. It may be removed or changed in the future versions.

Returns:
flags.

setFlags

public void setFlags(int flags)
Changes implementation-specific flags. Do not use this method directly. It may be removed or changed in the future versions.

Parameters:
flags - flags.

toString

public String toString()
Returns string representation of this time and sale event.

Overrides:
toString in class Object
Returns:
string representation of this time and sale event.


Copyright © 2013 Devexperts. All Rights Reserved.