com.dxfeed.schedule
Class Day

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

public final class Day
extends Object

Day represents a continuous period of time approximately 24 hours long. The day is aligned to the start and the end of business activities of a certain business entity or business process. For example, the day may be aligned to a trading schedule of a particular instrument on an exchange. Thus, different days may start and end at various local times depending on the related trading schedules.

The length of the day depends on the trading schedule and other circumstances. For example, it is possible that day for Monday is longer than 24 hours because it includes part of Sunday; consequently, the day for Sunday will be shorter than 24 hours to avoid overlapping with Monday.

Days 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 day that starts there.

Each day consists of sessions that cover entire duration of the day. If day contains at least one trading session (i.e. session within which trading activity is allowed), then the day is considered trading day. Otherwise the day is considered non-trading day (e.g. weekend or holiday).

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. Day may have zero duration as well - e.g. when all time within it is transferred to other days.


Method Summary
 boolean containsTime(long time)
          Returns true if specified time belongs to this day.
 boolean equals(Object object)
           
 Session findFirstSession(SessionFilter filter)
          Returns first session belonging to this day accepted by specified filter.
 Session findLastSession(SessionFilter filter)
          Returns last session belonging to this day accepted by specified filter.
 Day findNextDay(DayFilter filter)
          Returns following day accepted by specified filter.
 Day findPrevDay(DayFilter filter)
          Returns previous day accepted by specified filter.
 int getDayId()
          Number of this day since January 1, 1970 (that day has identifier of 0 and previous days have negative identifiers).
 int getDayOfMonth()
          Returns ordinal day number in the month starting with 1 for the first day of month.
 int getDayOfWeek()
          Returns ordinal day number in the week starting with 1=Monday and ending with 7=Sunday.
 long getEndTime()
          Returns end time of this day (exclusive).
 Session getFirstSession(SessionFilter filter)
          Returns first session belonging to this day accepted by specified filter.
 Session getLastSession(SessionFilter filter)
          Returns last session belonging to this day accepted by specified filter.
 int getMonthOfYear()
          Returns calendar month number in the year starting with 1=January and ending with 12=December.
 Day getNextDay(DayFilter filter)
          Returns following day accepted by specified filter.
 Day getPrevDay(DayFilter filter)
          Returns previous day accepted by specified filter.
 long getResetTime()
          Returns reset time for this day.
 Schedule getSchedule()
          Returns schedule to which this day belongs.
 Session getSessionByTime(long time)
          Returns session belonging to this day that contains specified time.
 List<Session> getSessions()
          Returns list of sessions that constitute this day.
 long getStartTime()
          Returns start time of this day (inclusive).
 int getYear()
          Returns calendar year - i.e. it returns 1977 for the year 1977.
 int getYearMonthDay()
          Returns year, month and day numbers decimally packed in the following way: YearMonthDay = year * 10000 + month * 100 + day For example, September 28, 1977 has value 19770928.
 int hashCode()
           
 boolean isHoliday()
          Returns true if this day is an exchange holiday.
 boolean isShortDay()
          Returns true if this day is a short day.
 boolean isTrading()
          Returns true if trading activity is allowed within this day.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getSchedule

public Schedule getSchedule()
Returns schedule to which this day belongs.


getDayId

public int getDayId()
Number of this day since January 1, 1970 (that day has identifier of 0 and previous days have negative identifiers).


getYearMonthDay

public int getYearMonthDay()
Returns year, month and day numbers decimally packed in the following way:
YearMonthDay = year * 10000 + month * 100 + day
For example, September 28, 1977 has value 19770928.


getYear

public int getYear()
Returns calendar year - i.e. it returns 1977 for the year 1977.


getMonthOfYear

public int getMonthOfYear()
Returns calendar month number in the year starting with 1=January and ending with 12=December.


getDayOfMonth

public int getDayOfMonth()
Returns ordinal day number in the month starting with 1 for the first day of month.


getDayOfWeek

public int getDayOfWeek()
Returns ordinal day number in the week starting with 1=Monday and ending with 7=Sunday.


isHoliday

public boolean isHoliday()
Returns true if this day is an exchange holiday. Usually there are no trading takes place on an exchange holiday.


isShortDay

public boolean isShortDay()
Returns true if this day is a short day. Usually trading stops earlier on a short day.


isTrading

public boolean isTrading()
Returns true if trading activity is allowed within this day. Positive result assumes that day has at least one trading session.


getStartTime

public long getStartTime()
Returns start time of this day (inclusive).


getEndTime

public long getEndTime()
Returns end time of this day (exclusive).


containsTime

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


getResetTime

public long getResetTime()
Returns reset time for this day. Reset of daily data is performed on trading days only, the result has no meaning for non-trading days.


getSessions

public List<Session> getSessions()
Returns list of sessions that constitute this day. The list is ordered according to natural order of sessions - how they occur one after another.


getSessionByTime

public Session getSessionByTime(long time)
Returns session belonging to this day that contains specified time. If no such session was found within this day this method will throw NoSuchElementException.

Parameters:
time - the time to search for
Returns:
session that contains specified time
Throws:
NoSuchElementException - if no such session was found within this day

getFirstSession

public Session getFirstSession(SessionFilter filter)
Returns first session belonging to this day accepted by specified filter. This method does not cross the day boundary. If no such session was found within this day this method will throw NoSuchElementException.

To find first trading session of any type use this code:

Session session = day.getFirstSession(SessionFilter.TRADING);
To find first regular trading session use this code:
Session session = day.getFirstSession(SessionFilter.REGULAR);

Parameters:
filter - the filter to test sessions
Returns:
first session that is accepted by the filter
Throws:
NoSuchElementException - if no such session was found within this day

getLastSession

public Session getLastSession(SessionFilter filter)
Returns last session belonging to this day accepted by specified filter. This method does not cross the day boundary. If no such session was found within this day this method will throw NoSuchElementException.

To find last trading session of any type use this code:

Session session = day.getLastSession(SessionFilter.TRADING);
To find last regular trading session use this code:
Session session = day.getLastSession(SessionFilter.REGULAR);

Parameters:
filter - the filter to test sessions
Returns:
last session that is accepted by the filter
Throws:
NoSuchElementException - if no such session was found within this day

findFirstSession

public Session findFirstSession(SessionFilter filter)
Returns first session belonging to this day accepted by specified filter. This method does not cross the day boundary. If no such session was found within this day this method will return null.

To find first trading session of any type use this code:

Session session = day.findFirstSession(SessionFilter.TRADING);
To find first regular trading session use this code:
Session session = day.findFirstSession(SessionFilter.REGULAR);

Parameters:
filter - the filter to test sessions
Returns:
first session that is accepted by the filter

findLastSession

public Session findLastSession(SessionFilter filter)
Returns last session belonging to this day accepted by specified filter. This method does not cross the day boundary. If no such session was found within this day this method will return null.

To find last trading session of any type use this code:

Session session = day.findLastSession(SessionFilter.TRADING);
To find last regular trading session use this code:
Session session = day.findLastSession(SessionFilter.REGULAR);

Parameters:
filter - the filter to test sessions
Returns:
last session that is accepted by the filter

getPrevDay

public Day getPrevDay(DayFilter filter)
Returns previous day accepted by specified filter. This method looks for appropriate day up to a year back in time. If no such day was found within one year this method will throw NoSuchElementException.

Parameters:
filter - the filter to test days
Returns:
nearest previous day that is accepted by the filter
Throws:
NoSuchElementException - if no such day was found within one year

getNextDay

public Day getNextDay(DayFilter filter)
Returns following day accepted by specified filter. This method looks for appropriate day up to a year in the future. If no such day was found within one year this method will throw NoSuchElementException.

Parameters:
filter - the filter to test days
Returns:
nearest following day that is accepted by the filter
Throws:
NoSuchElementException - if no such day was found within one year

findPrevDay

public Day findPrevDay(DayFilter filter)
Returns previous day accepted by specified filter. This method looks for appropriate day up to a year back in time. If no such day was found within one year this method will return null.

Parameters:
filter - the filter to test days
Returns:
nearest previous day that is accepted by the filter

findNextDay

public Day findNextDay(DayFilter filter)
Returns following day accepted by specified filter. This method looks for appropriate day up to a year in the future. If no such day was found within one year this method will return null.

Parameters:
filter - the filter to test days
Returns:
nearest following day that is accepted by the filter

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object object)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013 Devexperts. All Rights Reserved.