com.dxfeed.schedule
Class Session

java.lang.Object
  extended by com.dxfeed.schedule.Session

public final class Session
extends java.lang.Object

Session represents a continuous period of time during which apply same rules regarding trading activity. For example, regular trading session is a period of time consisting of one day of business activities in a financial market, from the opening bell to the closing bell, when regular trading occurs.

Sessions can be either trading or non-trading, with different sets of rules and reasons to exist. Sessions do not overlap with each other - rather they form consecutive chain of adjacent periods of time that cover entire time scale. The point on a border line is considered to belong to following session that starts there. Each session completely fits inside a certain day. Day may contain sessions with zero duration - e.g. indices that post value once a day. Such sessions can be of any appropriate type, trading or non-trading.


Method Summary
 boolean containsTime(long time)
          Returns true if specified time belongs to this session.
 boolean equals(java.lang.Object object)
           
 Day getDay()
          Returns day to which this session belongs.
 long getEndTime()
          Returns end time of this session (exclusive).
 Session getNextSession(SessionFilter filter)
          Returns following session accepted by specified filter.
 Session getPrevSession(SessionFilter filter)
          Returns previous session accepted by specified filter.
 long getStartTime()
          Returns start time of this session (inclusive).
 SessionType getType()
          Returns type of this session.
 int hashCode()
           
 boolean isEmpty()
          Returns true if this session has zero duration.
 boolean isTrading()
          Returns true if trading activity is allowed within this session.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getDay

public Day getDay()
Returns day to which this session belongs.


getType

public SessionType getType()
Returns type of this session.


isTrading

public boolean isTrading()
Returns true if trading activity is allowed within this session. This method is equivalent to expression getType().isTrading().

Some sessions may have zero duration - e.g. indices that post value once a day. Such sessions can be of any appropriate type, trading or non-trading.


isEmpty

public boolean isEmpty()
Returns true if this session has zero duration. Empty sessions can be used for indices that post value once a day or for convenience. Such sessions can be of any appropriate type, trading or non-trading.


getStartTime

public long getStartTime()
Returns start time of this session (inclusive). For normal sessions the start time is less than the end time, for empty sessions they are equal.


getEndTime

public long getEndTime()
Returns end time of this session (exclusive). For normal sessions the end time is greater than the start time, for empty sessions they are equal.


containsTime

public boolean containsTime(long time)
Returns true if specified time belongs to this session.


getPrevSession

public Session getPrevSession(SessionFilter filter)
Returns previous session accepted by specified filter. This method may cross the day boundary and return appropriate session from previous days - up to a year back in time. If no such session was found within one year this method will throw NoSuchElementException.

Please be careful when selecting appropriate filter - you may find non-trading session using filter that ignores trading attribute. For example, to find previous regular trading session use this code:

Session prevRTH = curSession.getPrevSession(SessionFilter.REGULAR_TRADING);

Parameters:
filter - the filter to test sessions
Returns:
nearest previous session that is accepted by the filter
Throws:
java.util.NoSuchElementException - if no such session was found within one year

getNextSession

public Session getNextSession(SessionFilter filter)
Returns following session accepted by specified filter. This method may cross the day boundary and return appropriate session from following days - up to a year in the future. If no such session was found within one year this method will throw NoSuchElementException.

Please be careful when selecting appropriate filter - you may find non-trading session using filter that ignores trading attribute. For example, to find following regular trading session use this code:

Session nextRTH = curSession.getNextSession(SessionFilter.REGULAR_TRADING);

Parameters:
filter - the filter to test sessions
Returns:
nearest following session that is accepted by the filter
Throws:
java.util.NoSuchElementException - if no such session was found within one year

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object