com.dukascopy.api
Interface IHistory


public interface IHistory

The IHistory interface represents API for historical data access.

Author:
Dmitry Shohov, Denis Larka

Method Summary
 IBar getBar(Instrument instrument, Period period, OfferSide side, int shift)
          Returns bar for specified instrument, period and side, that is shifted back in time for number in bars specified in shift parameter, 0 - current bar (currently generated from ticks), 1 - previous bar (last formed bar) If there is no bar loaded at that position, then function returns null.
 List<IBar> getBars(Instrument instrument, Period period, OfferSide side, long from, long to)
          Returns bars for specified instrument, period and side.
 long getBarStart(Period period, long time)
          Returns starting time of the bar that includes time specified in time parameter
 ITick getLastTick(Instrument instrument)
          Returns last tick for specified instrument
 long getNextBarStart(Period period, long barTime)
          Returns starting time of the bar next to the bar that includes time specified in barTime parameter
 long getPreviousBarStart(Period period, long barTime)
          Returns starting time of the bar previous to the bar that includes time specified in barTime parameter
 long getStartTimeOfCurrentBar(Instrument instrument, Period period)
          Returns starting time of the current bar (bar currently generated from ticks) for specified instrument and period.
 List<ITick> getTicks(Instrument instrument, long from, long to)
          Returns ticks for specified instrument and time interval.
 long getTimeForNBarsBack(Period period, long to, int numberOfBars)
          Returns starting time of the bar that is numberOfBars - 1 back in time to the bar that includes time specified in to parameter.
 long getTimeForNBarsForward(Period period, long from, int numberOfBars)
          Returns starting time of the bar that is + numberOfBars - 1 in the future to the bar that includes time specified in from parameter.
 long getTimeOfLastTick(Instrument instrument)
          Returns time of last tick received for specified instrument.
 void readBars(Instrument instrument, Period period, OfferSide side, long from, long to, LoadingDataListener barListener, LoadingProgressListener loadingProgress)
          Reads bars from the local cache in the background.
 void readTicks(Instrument instrument, long from, long to, LoadingDataListener tickListener, LoadingProgressListener loadingProgress)
          Reads ticks from the local cache in the background.
 

Method Detail

getTimeOfLastTick

long getTimeOfLastTick(Instrument instrument)
                       throws JFException
Returns time of last tick received for specified instrument. Returns -1 if no tick was received yet.

Parameters:
instrument - instrument of the tick
Returns:
time of last tick or -1 if no tick was received
Throws:
JFException - when instrument is not active (not opened in platform)

getLastTick

ITick getLastTick(Instrument instrument)
                  throws JFException
Returns last tick for specified instrument

Parameters:
instrument - instrument of the tick
Returns:
tick
Throws:
JFException - when instrument is not active (not opened in platform)

getStartTimeOfCurrentBar

long getStartTimeOfCurrentBar(Instrument instrument,
                              Period period)
                              throws JFException
Returns starting time of the current bar (bar currently generated from ticks) for specified instrument and period. If no tick was received for this instrument, then returns -1.

Parameters:
instrument - instrument of the bar
period - period of the bar
Returns:
starting time of the current bar or -1 if no tick was received
Throws:
JFException - when period is not supported or instrument is not active (not opened in platform)

getBar

IBar getBar(Instrument instrument,
            Period period,
            OfferSide side,
            int shift)
            throws JFException
Returns bar for specified instrument, period and side, that is shifted back in time for number in bars specified in shift parameter, 0 - current bar (currently generated from ticks), 1 - previous bar (last formed bar) If there is no bar loaded at that position, then function returns null.

Parameters:
instrument - instrument of the bar
period - period of the bar
side - bid or ask side of the bar
shift - number of candle back in time staring from current bar. 1 - previous bar, 2 - current bar minus 2 bars and so on
Returns:
bar or null if no bar is loaded
Throws:
JFException - when period is not supported or instrument is not active (not opened in platform)

readTicks

void readTicks(Instrument instrument,
               long from,
               long to,
               LoadingDataListener tickListener,
               LoadingProgressListener loadingProgress)
               throws JFException
Reads ticks from the local cache in the background. Method returns fast after creating request for data not waiting for any data to be read from local cache. After internal request is sent, ticks will be returned by calling methods in tickListener. LoadingProgressListener is used to receive feedback about loading progress, to cancel loading and its method LoadingProgressListener.loadingFinished(boolean, long, long, long) is called when loading is finished or as a result of error. This method has two main purposes: one is to load a lot of ticks without keeping them all in memory, and second is asynchronous processing

Parameters:
instrument - instrument of the ticks
from - start of the time interval for which ticks should be loaded
to - end time of the time interval for which ticks should be loaded. If there is tick with time equals to the time in to parameter then it will be loaded as well
tickListener - receives data about requested ticks
loadingProgress - used to control loading process
Throws:
JFException - when some error occurs while creating internal request for data

readBars

void readBars(Instrument instrument,
              Period period,
              OfferSide side,
              long from,
              long to,
              LoadingDataListener barListener,
              LoadingProgressListener loadingProgress)
              throws JFException
Reads bars from the local cache in the background. Method returns fast after creating request for data not waiting for any data to be read from local cache. After internal request is sent, bars will be returned by calling method in barListener. LoadingProgressListener is used to receive feedback about loading progress, to cancel loading and its method LoadingProgressListener.loadingFinished(boolean, long, long, long) is called when loading is finished or as a result of error This method has two main purposes: one is to load a lot of bars without keeping them all in memory, and second is asynchronous processing

Parameters:
instrument - instrument of the bars
period - period of the bars
side - side of the bars
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 bar 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 bar to be loaded
barListener - receives data about requested bars
loadingProgress - used to control loading progress
Throws:
JFException - when period is not supported or time interval is not valid for specified period
See Also:
getBarStart(Period, long)

getTicks

List<ITick> getTicks(Instrument instrument,
                     long from,
                     long to)
                     throws JFException
Returns ticks for specified instrument and time interval. Method blocks until all data will be loaded from the server into local cache and then read and stored in collection. Because all the data is loaded into the memory, this method should be used with caution to not load too much data which can lead to OutOfMemoryException

Parameters:
instrument - instrument of the ticks
from - start of the time interval for which ticks should be loaded
to - end time of the time interval for which ticks should be loaded. If there is tick with time equals to the time in to parameter then it will be loaded as well
Returns:
loaded ticks
Throws:
JFException - when some error occurs when loading data

getBars

List<IBar> getBars(Instrument instrument,
                   Period period,
                   OfferSide side,
                   long from,
                   long to)
                   throws JFException
Returns bars for specified instrument, period and side. Method blocks until all data will be loaded from the server into local cache and then read and stored in collection. Because all the data is loaded into the memory, this method should be used with caution to not load too much data which can lead to OutOfMemoryException

Parameters:
instrument - instrument of the bars
period - period of the bars
side - side of the bars
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:
loaded bars
Throws:
JFException - when period is not supported or some error occurs when loading data

getBarStart

long getBarStart(Period period,
                 long time)
                 throws JFException
Returns starting time of the bar that includes time specified in time parameter

Parameters:
period - period of the bar
time - time that is included by the bar
Returns:
starting time of the bar
Throws:
JFException - when period is not supported

getNextBarStart

long getNextBarStart(Period period,
                     long barTime)
                     throws JFException
Returns starting time of the bar next to the bar that includes time specified in barTime parameter

Parameters:
period - period of the bar
barTime - time that is included by the bar previous to the returned
Returns:
starting time of the bar
Throws:
JFException - when period is not supported

getPreviousBarStart

long getPreviousBarStart(Period period,
                         long barTime)
                         throws JFException
Returns starting time of the bar previous to the bar that includes time specified in barTime parameter

Parameters:
period - period to the bar
barTime - time that is included by the bar next to the returned
Returns:
staring time of the bar
Throws:
JFException - when period is not supported

getTimeForNBarsBack

long getTimeForNBarsBack(Period period,
                         long to,
                         int numberOfBars)
                         throws JFException
Returns starting time of the bar that is numberOfBars - 1 back in time to the bar that includes time specified in to parameter. Method can be used to get time for the from parameter for getBars(com.dukascopy.api.Instrument, com.dukascopy.api.Period, com.dukascopy.api.OfferSide, long, long) method when is known time of the last bar and number of candles that needs to be loaded

Parameters:
period - period of the bars
to - time of the last bar
numberOfBars - number of bars that could be loaded when passing returned time and time specified in to parameter in getBars(com.dukascopy.api.Instrument, com.dukascopy.api.Period, com.dukascopy.api.OfferSide, long, long) method
Returns:
starting time of the bar
Throws:
JFException - when period is not supported

getTimeForNBarsForward

long getTimeForNBarsForward(Period period,
                            long from,
                            int numberOfBars)
                            throws JFException
Returns starting time of the bar that is + numberOfBars - 1 in the future to the bar that includes time specified in from parameter. Method can be used to get time for the to parameter for getBars(com.dukascopy.api.Instrument, com.dukascopy.api.Period, com.dukascopy.api.OfferSide, long, long) method when is known time of the first bar and number of candles that needs to be loaded

Parameters:
period - period of the bars
from - time of the first bar
numberOfBars - number of bars that could be loaded when passing returned time and time specified in from parameter in getBars(com.dukascopy.api.Instrument, com.dukascopy.api.Period, com.dukascopy.api.OfferSide, long, long) method
Returns:
starting time of the last bar
Throws:
JFException - when period is not supported


Copyright © 2009. All Rights Reserved.