com.dxfeed.schedule
Class Schedule

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

public final class Schedule
extends Object

Schedule class provides API to retrieve and explore trading schedules of different exchanges and different classes of financial instruments. Each instance of schedule covers separate trading schedule of some class of instruments, i.e. NYSE stock trading schedule or CME corn futures trading schedule. Each schedule splits entire time scale into separate days that are aligned to the specific trading hours of covered trading schedule.


Method Summary
static void downloadDefaults(String downloadConfig)
          Downloads defaults using specified download config and optionally start periodic download.
 Session findNearestSessionByTime(long time, SessionFilter filter)
          Returns session that is nearest to the specified time and that is accepted by specified filter.
 Day getDayById(int dayId)
          Returns day for specified day identifier.
 Day getDayByTime(long time)
          Returns day that contains specified time.
 Day getDayByYearMonthDay(int yearMonthDay)
          Returns day for specified year, month and day numbers.
static Schedule getInstance(InstrumentProfile profile)
          Returns default schedule instance for specified instrument profile.
static Schedule getInstance(InstrumentProfile profile, String venue)
          Returns schedule instance for specified instrument profile and trading venue.
static Schedule getInstance(String scheduleDefinition)
          Returns default schedule instance for specified schedule definition.
 String getName()
          Returns name of this schedule.
 Session getNearestSessionByTime(long time, SessionFilter filter)
          Returns session that is nearest to the specified time and that is accepted by specified filter.
 Session getSessionByTime(long time)
          Returns session that contains specified time.
 TimeZone getTimeZone()
          Returns time zone in which this schedule is defined.
static List<String> getTradingVenues(InstrumentProfile profile)
          Returns trading venues for specified instrument profile.
static void setDefaults(byte[] data)
          Sets shared defaults that are used by individual schedule instances.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static Schedule getInstance(InstrumentProfile profile)
Returns default schedule instance for specified instrument profile.

Parameters:
profile - instrument profile those schedule is requested
Returns:
default schedule instance for specified instrument profile

getInstance

public static Schedule getInstance(String scheduleDefinition)
Returns default schedule instance for specified schedule definition.

Parameters:
scheduleDefinition - schedule definition of requested schedule
Returns:
default schedule instance for specified schedule definition

getInstance

public static Schedule getInstance(InstrumentProfile profile,
                                   String venue)
Returns schedule instance for specified instrument profile and trading venue.

Parameters:
profile - instrument profile those schedule is requested
venue - trading venue those schedule is requested
Returns:
schedule instance for specified instrument profile and trading venue

getTradingVenues

public static List<String> getTradingVenues(InstrumentProfile profile)
Returns trading venues for specified instrument profile.

Parameters:
profile - instrument profile those trading venues are requested
Returns:
trading venues for specified instrument profile

downloadDefaults

public static void downloadDefaults(String downloadConfig)
Downloads defaults using specified download config and optionally start periodic download. The specified config can be one of the following:

Parameters:
downloadConfig - download config

setDefaults

public static void setDefaults(byte[] data)
                        throws IOException
Sets shared defaults that are used by individual schedule instances.

Parameters:
data - content of default data
Throws:
IOException - If an I/O error occurs

getSessionByTime

public Session getSessionByTime(long time)
Returns session that contains specified time. This method will throw IllegalArgumentException if specified time falls outside of valid date range from 0001-01-02 to 9999-12-30.

Parameters:
time - the time to search for
Returns:
session that contains specified time
Throws:
IllegalArgumentException - if specified time falls outside of valid date range

getDayByTime

public Day getDayByTime(long time)
Returns day that contains specified time. This method will throw IllegalArgumentException if specified time falls outside of valid date range from 0001-01-02 to 9999-12-30.

Parameters:
time - the time to search for
Returns:
day that contains specified time
Throws:
IllegalArgumentException - if specified time falls outside of valid date range

getDayById

public Day getDayById(int dayId)
Returns day for specified day identifier. This method will throw IllegalArgumentException if specified day identifier falls outside of valid date range from 0001-01-02 to 9999-12-30.

Parameters:
dayId - day identifier to search for
Returns:
day for specified day identifier
Throws:
IllegalArgumentException - if specified day identifier falls outside of valid date range
See Also:
Day.getDayId()

getDayByYearMonthDay

public Day getDayByYearMonthDay(int yearMonthDay)
Returns day for specified year, month and day numbers. Year, month, and day numbers shall be decimally packed in the following way:
YearMonthDay = year * 10000 + month * 100 + day
For example, September 28, 1977 has value 19770928.

If specified day does not exist then this method returns day with the lowest valid YearMonthDay that is greater than specified one. This method will throw IllegalArgumentException if specified year, month and day numbers fall outside of valid date range from 0001-01-02 to 9999-12-30.

Parameters:
yearMonthDay - year, month and day numbers to search for
Returns:
day for specified year, month and day numbers
Throws:
IllegalArgumentException - if specified year, month and day numbers fall outside of valid date range
See Also:
Day.getYearMonthDay()

getNearestSessionByTime

public Session getNearestSessionByTime(long time,
                                       SessionFilter filter)
Returns session that is nearest to the specified time and that is accepted by specified filter. This method will throw IllegalArgumentException if specified time falls outside of valid date range from 0001-01-02 to 9999-12-30. If no sessions acceptable by specified filter are found within one year this method will throw NoSuchElementException.

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

session = schedule.getNearestSessionByTime(time, SessionFilter.TRADING);
To find nearest regular trading session use this code:
session = schedule.getNearestSessionByTime(time, SessionFilter.REGULAR);

Parameters:
time - the time to search for
filter - the filter to test sessions
Returns:
session that is nearest to the specified time and that is accepted by specified filter
Throws:
IllegalArgumentException - if specified time falls outside of valid date range
NoSuchElementException - if no such day was found within one year

findNearestSessionByTime

public Session findNearestSessionByTime(long time,
                                        SessionFilter filter)
Returns session that is nearest to the specified time and that is accepted by specified filter. This method will throw IllegalArgumentException if specified time falls outside of valid date range from 0001-01-02 to 9999-12-30. If no sessions acceptable by specified filter are found within one year this method will return null.

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

session = schedule.findNearestSessionByTime(time, SessionFilter.TRADING);
To find nearest regular trading session use this code:
session = schedule.findNearestSessionByTime(time, SessionFilter.REGULAR);

Parameters:
time - the time to search for
filter - the filter to test sessions
Returns:
session that is nearest to the specified time and that is accepted by specified filter
Throws:
IllegalArgumentException - if specified time falls outside of valid date range

getName

public String getName()
Returns name of this schedule.

Returns:
name of this schedule

getTimeZone

public TimeZone getTimeZone()
Returns time zone in which this schedule is defined.

Returns:
time zone in which this schedule is defined

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013 Devexperts. All Rights Reserved.