com.dukascopy.api
Interface IDataService


public interface IDataService

Provide with system state:


Method Summary
 void addDailyHighLowListener(Instrument instrument, IDailyHighLowListener listener)
          The method adds daily high/low listener After addition listener will be notified with the current best daily high/low (If in progress daily candle exists in the system) If in progress candle doesn't exist in the system listener will be notified as soon as candle arrives
 void addHighLowListener(Period period, Instrument instrument, IHighLowListener listener)
          The method adds high/low listener.
 java.util.Map<Instrument,java.util.Collection<IDailyHighLowListener>> getDailyHighLowListeners()
          Returns all daily high/low listeners
 java.util.Collection<IDailyHighLowListener> getDailyHighLowListeners(Instrument instrument)
          Returns all daily high/low listeners subscribed on the passed instrument
 IFXSentimentIndex getFXSentimentIndex(java.util.Currency currency)
          Returns last updated Forex Sentiment Index for specified Currency.
 IFXSentimentIndex getFXSentimentIndex(java.util.Currency currency, long time)
          Returns Forex Sentiment Index which was most up-to-date at a point of specified time
 java.util.List<IFXSentimentIndexBar> getFXSentimentIndex(java.util.Currency currency, Period period, long from, long to)
          Returns the list of sentiment indices which were most up-to-date at the specified time frame.
 IFXSentimentIndex getFXSentimentIndex(Instrument instrument)
          Returns last updated Forex Sentiment Index for specified Instrument.
 IFXSentimentIndex getFXSentimentIndex(Instrument instrument, long time)
          Returns Forex Sentiment Index which was most up-to-date at a point of specified time
 java.util.List<IFXSentimentIndexBar> getFXSentimentIndex(Instrument instrument, Period period, long from, long to)
          Returns the list of sentiment indices which were most up-to-date at the specified time frame.
 java.util.Map<Period,java.util.Map<Instrument,java.util.Collection<IHighLowListener>>> getHighLowListeners()
          Returns all high/low listeners
 java.util.Map<Instrument,java.util.Collection<IHighLowListener>> getHighLowListeners(Period period)
          Returns all high/low listeners subscribed to the passed period and grouped by instrument
 java.util.Collection<IHighLowListener> getHighLowListeners(Period period, Instrument instrument)
          Returns all high/low listeners subscribed to the passed period and instrument
 ITimeDomain getOfflineTimeDomain()
          Returns either present, current offline (weekend) time interval or the next approximate upcoming one.
 ITimeDomain getOfflineTimeDomain(int shift)
          Returns offline (weekend) time interval that is shifted back or forward for number of offline intervals specified in shift parameter.
 java.util.Set<ITimeDomain> getOfflineTimeDomains(long from, long to)
          Returns the set of offline (weekend) time intervals ascending ordered by time which are within the limits of from and to parameters.
 java.util.Map<java.lang.String,java.lang.Object> getServerProperties()
          Return unmodifiable map of server properties
 long getTimeOfFirstCandle(IFeedDescriptor feedDescriptor)
          Returns the time of first feed data specified in IFeedDescriptor.
 long getTimeOfFirstCandle(Instrument instrument, Period period)
          Returns the time of first candles for specified Instrument and Period
 long getTimeOfFirstPointAndFigure(Instrument instrument, PriceRange priceRange, ReversalAmount reversalAmount)
          Returns the time of first point & figures for specified Instrument, PriceRange and ReversalAmount
 long getTimeOfFirstRangeBar(Instrument instrument, PriceRange priceRange)
          Returns the time of first price range bars for specified Instrument and PriceRange
 long getTimeOfFirstRenko(Instrument instrument, PriceRange priceRange)
          Returns the time of first renko for specified Instrument and PriceRange
 long getTimeOfFirstTick(Instrument instrument)
          Returns the time of first ticks for specified Instrument
 long getTimeOfFirstTickBar(Instrument instrument)
          Returns the time of first tick bars for specified Instrument
 IWLabelData getWhiteLabelData()
           
 boolean isOfflineTime(long time)
          Returns true if specified time is within the limits of offline (weekend) period.
 void removeAllDailyHighLowListeners()
          Removes all high/low listeners
 void removeAllHighLowListeners()
          Removes all high/low listeners NOTE: shared instance of listeners will be unsubscribed from every period and/or instrument.
 void removeDailyHighLowListener(IDailyHighLowListener listener)
          Removes daily high/low listener
 void removeHighLowListener(IHighLowListener listener)
          Removes high/low listener.
 

Method Detail

addDailyHighLowListener

void addDailyHighLowListener(Instrument instrument,
                             IDailyHighLowListener listener)
The method adds daily high/low listener After addition listener will be notified with the current best daily high/low (If in progress daily candle exists in the system) If in progress candle doesn't exist in the system listener will be notified as soon as candle arrives

Parameters:
instrument -
listener -
See Also:
#addHighLowListener(Period.DAILY, Instrument, IHighLowListener)

removeDailyHighLowListener

void removeDailyHighLowListener(IDailyHighLowListener listener)
Removes daily high/low listener

Parameters:
listener -
See Also:
removeHighLowListener(IHighLowListener)

getDailyHighLowListeners

java.util.Collection<IDailyHighLowListener> getDailyHighLowListeners(Instrument instrument)
Returns all daily high/low listeners subscribed on the passed instrument

Parameters:
instrument -
Returns:
all daily high/low listeners subscribed on the passed instrument
See Also:
#getHighLowListeners(Period.DAILY, Instrument)

getDailyHighLowListeners

java.util.Map<Instrument,java.util.Collection<IDailyHighLowListener>> getDailyHighLowListeners()
Returns all daily high/low listeners

Returns:
all daily high/low listeners
See Also:
#getHighLowListeners(Period.DAILY)

removeAllDailyHighLowListeners

void removeAllDailyHighLowListeners()
Removes all high/low listeners

See Also:
removeAllHighLowListeners()

addHighLowListener

void addHighLowListener(Period period,
                        Instrument instrument,
                        IHighLowListener listener)
The method adds high/low listener.
After addition, listener will be notified with the current best period's high/low (If in progress candle exists in the system) If in progress candle doesn't exist in the system listener will be notified as soon as candle arrives

Parameters:
period - Candles' Period to listen to. Period.TICK isn't supported.
instrument - Candles Instrument to listen to.
listener - instance of IHighLowListener

removeHighLowListener

void removeHighLowListener(IHighLowListener listener)
Removes high/low listener.
NOTE: shared instance of listener will be unsubscribed from every period and/or instrument.

Parameters:
listener - instance of IHighLowListener

getHighLowListeners

java.util.Collection<IHighLowListener> getHighLowListeners(Period period,
                                                           Instrument instrument)
Returns all high/low listeners subscribed to the passed period and instrument

Parameters:
period - listener's Period
instrument - listener's Instrument
Returns:
all high/low listeners subscribed to the passed period and instrument

getHighLowListeners

java.util.Map<Instrument,java.util.Collection<IHighLowListener>> getHighLowListeners(Period period)
Returns all high/low listeners subscribed to the passed period and grouped by instrument

Parameters:
instrument - listener's Instrument
Returns:
a map of all high/low listeners subscribed to the passed period and grouped by instrument

getHighLowListeners

java.util.Map<Period,java.util.Map<Instrument,java.util.Collection<IHighLowListener>>> getHighLowListeners()
Returns all high/low listeners

Returns:
all high/low listeners grouped by period and instrument

removeAllHighLowListeners

void removeAllHighLowListeners()
Removes all high/low listeners NOTE: shared instance of listeners will be unsubscribed from every period and/or instrument.


getTimeOfFirstCandle

long getTimeOfFirstCandle(IFeedDescriptor feedDescriptor)
Returns the time of first feed data specified in IFeedDescriptor.

Parameters:
feedDescriptor - the IFeedDescriptor specifies the feed data the first time must be returned.
IFeedDescriptor.getDataType() determines the required properties of IFeedDescriptor must be set and
the specifies the method will be invoked:
Returns:
Returns the time of first feed data specified in IFeedDescriptor or Long.MAX_VALUE if there is no one.

getTimeOfFirstTick

long getTimeOfFirstTick(Instrument instrument)
Returns the time of first ticks for specified Instrument

Parameters:
instrument - the Instrument the first tick's time must be returned.
Returns:
the time of first ticks for specified Instrument or Long.MAX_VALUE if there is no one.
See Also:
DataType.TICKS

getTimeOfFirstTickBar

long getTimeOfFirstTickBar(Instrument instrument)
Returns the time of first tick bars for specified Instrument

Parameters:
instrument - the Instrument the first Tick Bars' time must be returned.
Returns:
the time of first tick bars for specified Instrument or Long.MAX_VALUE if there is no one.
See Also:
DataType.TICK_BAR

getTimeOfFirstCandle

long getTimeOfFirstCandle(Instrument instrument,
                          Period period)
Returns the time of first candles for specified Instrument and Period

Parameters:
instrument - the Instrument the first candles' time must be returned.
period - the Period the first candles' time must be returned.
Returns:
the time of first candles for specified Instrument and Period or Long.MAX_VALUE if there is no one.
See Also:
DataType.TIME_PERIOD_AGGREGATION

getTimeOfFirstRangeBar

long getTimeOfFirstRangeBar(Instrument instrument,
                            PriceRange priceRange)
Returns the time of first price range bars for specified Instrument and PriceRange

Parameters:
instrument - the Instrument the first price range bars' time must be returned.
priceRange - the PriceRange the first price range bars' time must be returned.
Returns:
the time of first price range bars for specified Instrument and PriceRange or Long.MAX_VALUE if there is no one.
See Also:
DataType.PRICE_RANGE_AGGREGATION

getTimeOfFirstPointAndFigure

long getTimeOfFirstPointAndFigure(Instrument instrument,
                                  PriceRange priceRange,
                                  ReversalAmount reversalAmount)
Returns the time of first point & figures for specified Instrument, PriceRange and ReversalAmount

Parameters:
instrument - the Instrument the first point & figures' time must be returned.
priceRange - the PriceRange the first point & figures' time must be returned.
reversalAmount - the ReversalAmount the first point & figures' time must be returned.
Returns:
the time of first point & figures for specified Instrument, PriceRange and ReversalAmount or Long.MAX_VALUE if there is no one.
See Also:
DataType.POINT_AND_FIGURE

getTimeOfFirstRenko

long getTimeOfFirstRenko(Instrument instrument,
                         PriceRange priceRange)
Returns the time of first renko for specified Instrument and PriceRange

Parameters:
instrument - the Instrument the first renko' time must be returned.
priceRange - the PriceRange the first renko' time must be returned.
Returns:
the time of first renko for specified Instrument and PriceRange or Long.MAX_VALUE if there is no one.
See Also:
DataType.RENKO

getFXSentimentIndex

IFXSentimentIndex getFXSentimentIndex(Instrument instrument)
Returns last updated Forex Sentiment Index for specified Instrument.
Equivalent to the #getFXSentimentIndex(instrument, System.currentTimeMillis) for live data and #getFXSentimentIndex(instrument, pseudo_current_historical_tester_time) for historical data.

Parameters:
instrument - Instrument of sentiment index
Returns:
the last updated sentiment index or null if there is no such

getFXSentimentIndex

IFXSentimentIndex getFXSentimentIndex(Instrument instrument,
                                      long time)
Returns Forex Sentiment Index which was most up-to-date at a point of specified time

Parameters:
instrument - Instrument of sentiment index
time - the point of time in the past in milliseconds.
To calculate the right time point one can use either
Returns:
the sentiment index which was most up-to-date at a point of specified time or null if there is no such.
See Also:
JFUtils.getTimeForNPeriodsBack(Period, long, int), JFUtils.getTimeForNPeriodsForward(Period, long, int)

getFXSentimentIndex

java.util.List<IFXSentimentIndexBar> getFXSentimentIndex(Instrument instrument,
                                                         Period period,
                                                         long from,
                                                         long to)
                                                         throws JFException
Returns the list of sentiment indices which were most up-to-date at the specified time frame.

Parameters:
instrument - Instrument of sentiment index
period - period between the sentiment indices
from - start of the time interval for which bars should be loaded. Should be the exact starting time of the bar for specified period. See #getBarStart(Period, long) description if you want to get bar starting time for candle that includes specific time
to - end time of the time interval for which bars should be loaded. This is the starting time of the last candle to be loaded
Returns:
the list of sentiment indices which were most up-to-date at the specified time frame or null if there is no such.
Throws:
JFException - if time is not divisible by the interval of period or the period is not among Period.THIRTY_MINS, Period.ONE_HOUR, Period.FOUR_HOURS, Period.DAILY, Period.WEEKLY

getFXSentimentIndex

IFXSentimentIndex getFXSentimentIndex(java.util.Currency currency)
Returns last updated Forex Sentiment Index for specified Currency.
Equivalent to the #getFXSentimentIndex(currency, System.currentTimeMillis) for live data and #getFXSentimentIndex(currency, pseudo_current_historical_tester_time) for historical data.

Parameters:
currency - Currency of sentiment index.
Returns:
the last updated sentiment index or null if there is no such

getFXSentimentIndex

IFXSentimentIndex getFXSentimentIndex(java.util.Currency currency,
                                      long time)
Returns Forex Sentiment Index which was most up-to-date at a point of specified time

Parameters:
currency - Currency of sentiment index.
time - the point of time in the past in milliseconds.
To calculate the right time point one can use either
Returns:
the sentiment index which was most up-to-date at a point of specified time or null if there is no such.
See Also:
JFUtils.getTimeForNPeriodsBack(Period, long, int), JFUtils.getTimeForNPeriodsForward(Period, long, int)

getFXSentimentIndex

java.util.List<IFXSentimentIndexBar> getFXSentimentIndex(java.util.Currency currency,
                                                         Period period,
                                                         long from,
                                                         long to)
                                                         throws JFException
Returns the list of sentiment indices which were most up-to-date at the specified time frame.

Parameters:
currency - Currency of sentiment index
period - period between the sentiment indices
from - start of the time interval for which bars should be loaded. Should be the exact starting time of the bar for specified period. See #getBarStart(Period, long) description if you want to get bar starting time for candle that includes specific time
to - end time of the time interval for which bars should be loaded. This is the starting time of the last candle to be loaded
Returns:
the list of sentiment indices which were most up-to-date at the specified time frame or null if there is no such.
Throws:
JFException - if time is not divisible by the interval of period or the period is not among Period.THIRTY_MINS, Period.ONE_HOUR, Period.FOUR_HOURS, Period.DAILY, Period.WEEKLY

isOfflineTime

boolean isOfflineTime(long time)
Returns true if specified time is within the limits of offline (weekend) period.

Parameters:
time - time in milliseconds
Returns:
true if specified time is within the limits of offline (weekend) period, false - otherwise

getOfflineTimeDomain

ITimeDomain getOfflineTimeDomain()
                                 throws JFException
Returns either present, current offline (weekend) time interval or the next approximate upcoming one.
The same as #getOfflineTimeDomain(shift) with shift == 0

Returns:
either present, current offline (weekend) time interval or the next approximate upcoming one.
Throws:
JFException - when some error occurs
See Also:
getOfflineTimeDomain(int)

getOfflineTimeDomain

ITimeDomain getOfflineTimeDomain(int shift)
                                 throws JFException
Returns offline (weekend) time interval that is shifted back or forward for number of offline intervals specified in shift parameter.

Parameters:
shift - number of offline intervals back or forward in time staring from current one. E.g.:
  • 0 - current or next approximate offline period,
  • -1 - previous offline (last finished one),
  • 1 - next approximate after current one, etc.
Returns:
offline (weekend) time interval that is shifted back or forward for number of offline intervals specified in shift parameter
Throws:
JFException - when some error occurs

getOfflineTimeDomains

java.util.Set<ITimeDomain> getOfflineTimeDomains(long from,
                                                 long to)
                                                 throws JFException
Returns the set of offline (weekend) time intervals ascending ordered by time which are within the limits of from and to parameters.

Parameters:
from - start of the time interval for which offline periods should be loaded. If start time is within the limits of offline period - this period will be returned as first element of resulting set.
to - end of the time interval for which offline periods should be loaded. If end time is within the limits of offline period - this period will be returned as last element of resulting set.
Returns:
the set of offline (weekend) time intervals ascending ordered by time which are within the limits of from and to parameters.
Throws:
JFException - when some error occurs

getServerProperties

java.util.Map<java.lang.String,java.lang.Object> getServerProperties()
Return unmodifiable map of server properties

Returns:
unmodifiable map of server properties

getWhiteLabelData

IWLabelData getWhiteLabelData()
Returns:
IWLabelData information