public interface IHistory
IHistory
interface represents API for historical data access.Modifier and Type | Method and Description |
---|---|
IBar |
getBar(IFinancialInstrument financialInstrument,
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. |
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(IFinancialInstrument financialInstrument,
Period period,
OfferSide side,
Filter filter,
int numberOfCandlesBefore,
long time,
int numberOfCandlesAfter)
Returns bars for specified instrument, period and side.
|
List<IBar> |
getBars(IFinancialInstrument financialInstrument,
Period period,
OfferSide side,
Filter filter,
long from,
long to)
Returns bars for specified instrument, period, side and filter.
|
List<IBar> |
getBars(IFinancialInstrument financialInstrument,
Period period,
OfferSide side,
long from,
long to)
Returns bars for specified instrument, period and side.
|
List<IBar> |
getBars(Instrument instrument,
Period period,
OfferSide side,
Filter filter,
int numberOfCandlesBefore,
long time,
int numberOfCandlesAfter)
Returns bars for specified instrument, period and side.
|
List<IBar> |
getBars(Instrument instrument,
Period period,
OfferSide side,
Filter filter,
long from,
long to)
Returns bars for specified instrument, period, side and filter.
|
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 |
double |
getEquity()
Returns current equity calculated for every tick
|
ITimedData |
getFeedData(IFeedDescriptor feedDescriptor,
int shift)
Returns bar for specified feed descriptor, that is shifted back in time for number in bars specified in
shift
parameter, 0 - current bar (currently generated), 1 - previous bar (last formed bar) If there is no bar loaded at that
position, then function returns null. |
List<ITimedData> |
getFeedData(IFeedDescriptor feedDescriptor,
int numberOfFeedBarsBefore,
long time,
int numberOfFeedBarsAfter)
Returns bars for specified feedDescriptor.
|
List<ITimedData> |
getFeedData(IFeedDescriptor feedDescriptor,
long from,
long to)
Returns bars for specified feed descriptor.
|
<T extends ITimedData> |
getFeedData(ITailoredFeedDescriptor<T> feedDescriptor,
int shift)
A type-safe feed data retrieval for the specified feed
|
<T extends ITimedData> |
getFeedData(ITailoredFeedDescriptor<T> feedDescriptor,
int numberOfFeedBarsBefore,
long time,
int numberOfFeedBarsAfter)
A type-safe feed data retrieval for the specified feed
|
<T extends ITimedData> |
getFeedData(ITailoredFeedDescriptor<T> feedDescriptor,
long from,
long to)
A type-safe feed data retrieval for the specified feed
|
IOrder |
getHistoricalOrderById(String id)
Returns historical (closed) order by position id for the given user account.
|
ITick |
getLastTick(IFinancialInstrument financialInstrument)
Returns last tick for specified instrument
|
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 |
List<IOrder> |
getOrdersHistory(IFinancialInstrument financialInstrument,
long from,
long to)
Returns orders for specified instrument and time interval.
|
List<IOrder> |
getOrdersHistory(Instrument instrument,
long from,
long to)
Returns orders for specified instrument and time interval.
|
IPointAndFigure |
getPointAndFigure(Instrument instrument,
OfferSide offerSide,
PriceRange boxSize,
ReversalAmount reversalAmount,
int shift)
Deprecated.
|
List<IPointAndFigure> |
getPointAndFigures(Instrument instrument,
OfferSide offerSide,
PriceRange boxSize,
ReversalAmount reversalAmount,
int numberOfBarsBefore,
long time,
int numberOfBarsAfter)
Deprecated.
|
List<IPointAndFigure> |
getPointAndFigures(Instrument instrument,
OfferSide offerSide,
PriceRange boxSize,
ReversalAmount reversalAmount,
long from,
long to)
Deprecated.
|
long |
getPreviousBarStart(Period period,
long barTime)
Returns starting time of the bar previous to the bar that includes time specified in
barTime parameter |
IRangeBar |
getRangeBar(Instrument instrument,
OfferSide offerSide,
PriceRange priceRange,
int shift)
Deprecated.
|
List<IRangeBar> |
getRangeBars(Instrument instrument,
OfferSide offerSide,
PriceRange priceRange,
int numberOfBarsBefore,
long time,
int numberOfBarsAfter)
Deprecated.
|
List<IRangeBar> |
getRangeBars(Instrument instrument,
OfferSide offerSide,
PriceRange priceRange,
long from,
long to)
Deprecated.
|
IRenkoBar |
getRenkoBar(Instrument instrument,
OfferSide offerSide,
PriceRange brickSize,
int shift)
Deprecated.
|
List<IRenkoBar> |
getRenkoBars(Instrument instrument,
OfferSide offerSide,
PriceRange brickSize,
int numberOfBarsBefore,
long time,
int numberOfBarsAfter)
Deprecated.
|
List<IRenkoBar> |
getRenkoBars(Instrument instrument,
OfferSide offerSide,
PriceRange brickSize,
long from,
long to)
Deprecated.
|
long |
getStartTimeOfCurrentBar(IFinancialInstrument financialInstrument,
Period period)
Returns starting time of the current bar (bar currently generated from ticks) for specified instrument and period.
|
long |
getStartTimeOfCurrentBar(Instrument instrument,
Period period)
Returns starting time of the current bar (bar currently generated from ticks) for specified instrument and period.
|
ITick |
getTick(IFinancialInstrument financialInstrument,
int shift)
Returns tick for specified instrument, that is shifted back in time for number in ticks specified in
shift
parameter, 0 - current tick, 1 - previous tick. |
ITick |
getTick(Instrument instrument,
int shift)
Returns tick for specified instrument, that is shifted back in time for number in ticks specified in
shift
parameter, 0 - current tick, 1 - previous tick. |
ITickBar |
getTickBar(Instrument instrument,
OfferSide offerSide,
TickBarSize tickBarSize,
int shift)
Deprecated.
|
List<ITickBar> |
getTickBars(Instrument instrument,
OfferSide offerSide,
TickBarSize tickBarSize,
int numberOfBarsBefore,
long time,
int numberOfBarsAfter)
Deprecated.
|
List<ITickBar> |
getTickBars(Instrument instrument,
OfferSide offerSide,
TickBarSize tickBarSize,
long from,
long to)
Deprecated.
|
List<ITick> |
getTicks(IFinancialInstrument financialInstrument,
int numberOfOneSecondIntervalsBefore,
long time,
int numberOfOneSecondIntervalsAfter)
Returns ticks for specified instrument, time and count.
|
List<ITick> |
getTicks(IFinancialInstrument financialInstrument,
long from,
long to)
Returns ticks for specified instrument and time interval.
|
List<ITick> |
getTicks(Instrument instrument,
int numberOfOneSecondIntervalsBefore,
long time,
int numberOfOneSecondIntervalsAfter)
Returns ticks for specified instrument, time and count.
|
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(IFinancialInstrument financialInstrument)
Returns time of last tick received for specified instrument.
|
long |
getTimeOfLastTick(Instrument instrument)
Returns time of last tick received for specified instrument.
|
void |
readBars(IFinancialInstrument financialInstrument,
Period period,
OfferSide side,
Filter filter,
int numberOfCandlesBefore,
long time,
int numberOfCandlesAfter,
DataLoadingListener barListener,
LoadingProgressListener loadingProgress)
Reads bars from the local cache in the background.
|
void |
readBars(IFinancialInstrument financialInstrument,
Period period,
OfferSide side,
Filter filter,
long from,
long to,
DataLoadingListener barListener,
LoadingProgressListener loadingProgress)
Reads bars from the local cache in the background.
|
void |
readBars(IFinancialInstrument financialInstrument,
Period period,
OfferSide side,
long from,
long to,
DataLoadingListener barListener,
LoadingProgressListener loadingProgress)
Reads bars from the local cache in the background.
|
void |
readBars(Instrument instrument,
Period period,
OfferSide side,
Filter filter,
int numberOfCandlesBefore,
long time,
int numberOfCandlesAfter,
LoadingDataListener barListener,
LoadingProgressListener loadingProgress)
Reads bars from the local cache in the background.
|
void |
readBars(Instrument instrument,
Period period,
OfferSide side,
Filter filter,
long from,
long to,
LoadingDataListener barListener,
LoadingProgressListener loadingProgress)
Reads bars from the local cache in the background.
|
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 |
readFeedData(IFeedDescriptor feedDescriptor,
int numberOfFeedDataBefore,
long time,
int numberOfFeedDataAfter,
IFeedListener feedListener,
LoadingProgressListener loadingProgress)
Reads feed data from the local cache in the background.
|
void |
readFeedData(IFeedDescriptor feedDescriptor,
long from,
long to,
IFeedListener feedListener,
LoadingProgressListener loadingProgress)
Reads feed data from the local cache in the background.
|
<T extends ITimedData> |
readFeedData(ITailoredFeedDescriptor<T> feedDescriptor,
int numberOfFeedDataBefore,
long time,
int numberOfFeedDataAfter,
ITailoredFeedListener<T> feedListener,
LoadingProgressListener loadingProgress)
A type-safe feed data retrieval for the specified feed
|
<T extends ITimedData> |
readFeedData(ITailoredFeedDescriptor<T> feedDescriptor,
long from,
long to,
ITailoredFeedListener<T> feedListener,
LoadingProgressListener loadingProgress)
A type-safe feed data retrieval for the specified feed
|
void |
readOrdersHistory(IFinancialInstrument financialInstrument,
long from,
long to,
LoadingOrdersListener ordersListener,
LoadingProgressListener loadingProgress)
Loads orders from the server in the background.
|
void |
readOrdersHistory(Instrument instrument,
long from,
long to,
LoadingOrdersListener ordersListener,
LoadingProgressListener loadingProgress)
Loads orders from the server in the background.
|
void |
readPointAndFigures(Instrument instrument,
OfferSide offerSide,
PriceRange boxSize,
ReversalAmount reversalAmount,
int numberOfBarsBefore,
long time,
int numberOfBarsAfter,
IPointAndFigureFeedListener listener,
LoadingProgressListener loadingProgress)
|
void |
readPointAndFigures(Instrument instrument,
OfferSide offerSide,
PriceRange boxSize,
ReversalAmount reversalAmount,
long from,
long to,
IPointAndFigureFeedListener listener,
LoadingProgressListener loadingProgress)
|
void |
readRangeBars(Instrument instrument,
OfferSide offerSide,
PriceRange priceRange,
int numberOfBarsBefore,
long time,
int numberOfBarsAfter,
IRangeBarFeedListener listener,
LoadingProgressListener loadingProgress)
|
void |
readRangeBars(Instrument instrument,
OfferSide offerSide,
PriceRange priceRange,
long from,
long to,
IRangeBarFeedListener listener,
LoadingProgressListener loadingProgress)
|
void |
readRenkoBars(Instrument instrument,
OfferSide offerSide,
PriceRange brickSize,
int numberOfBarsBefore,
long time,
int numberOfBarsAfter,
IRenkoBarFeedListener listener,
LoadingProgressListener loadingProgress)
|
void |
readRenkoBars(Instrument instrument,
OfferSide offerSide,
PriceRange brickSize,
long from,
long to,
IRenkoBarFeedListener listener,
LoadingProgressListener loadingProgress)
|
void |
readTickBars(Instrument instrument,
OfferSide offerSide,
TickBarSize tickBarSize,
int numberOfBarsBefore,
long time,
int numberOfBarsAfter,
ITickBarFeedListener listener,
LoadingProgressListener loadingProgress)
|
void |
readTickBars(Instrument instrument,
OfferSide offerSide,
TickBarSize tickBarSize,
long from,
long to,
ITickBarFeedListener listener,
LoadingProgressListener loadingProgress)
|
void |
readTicks(IFinancialInstrument financialInstrument,
int numberOfOneSecondIntervalsBefore,
long time,
int numberOfOneSecondIntervalsAfter,
LoadingDataListener tickListener,
LoadingProgressListener loadingProgress)
Reads ticks from the local cache in the background.
|
void |
readTicks(IFinancialInstrument financialInstrument,
long from,
long to,
DataLoadingListener tickListener,
LoadingProgressListener loadingProgress)
Reads ticks from the local cache in the background.
|
void |
readTicks(Instrument instrument,
int numberOfOneSecondIntervalsBefore,
long time,
int numberOfOneSecondIntervalsAfter,
LoadingDataListener tickListener,
LoadingProgressListener loadingProgress)
Reads ticks 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.
|
long getTimeOfLastTick(Instrument instrument) throws JFException
instrument
- instrument of the tickJFException
- when instrument is not active (not opened in platform)long getTimeOfLastTick(IFinancialInstrument financialInstrument) throws JFException
financialInstrument
- instrument of the tickJFException
- when instrument is not active (not opened in platform)ITick getLastTick(Instrument instrument) throws JFException
instrument
- instrument of the tickJFException
- when instrument is not active (not opened in platform)ITick getLastTick(IFinancialInstrument financialInstrument) throws JFException
financialInstrument
- instrument of the tickJFException
- when instrument is not active (not opened in platform)long getStartTimeOfCurrentBar(Instrument instrument, Period period) throws JFException
instrument
- instrument of the barperiod
- period of the barJFException
- when period is not supported or instrument is not active (not opened in platform)long getStartTimeOfCurrentBar(IFinancialInstrument financialInstrument, Period period) throws JFException
financialInstrument
- instrument of the barperiod
- period of the barJFException
- when period is not supported or instrument is not active (not opened in platform)IBar getBar(Instrument instrument, Period period, OfferSide side, int shift) throws JFException
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.
consider getting the previous one hour bar
IBar prevBar = history.getBar(Instrument.EURUSD, Period.ONE_HOUR, OfferSide.BID, 1); console.getOut().println(prevBar);
instrument
- instrument of the barperiod
- period of the barside
- bid or ask side of the barshift
- number of candle back in time staring from current bar. 1 - previous bar, 2 - current bar minus 2 bars and so onJFException
- when period is not supported or instrument is not active (not opened in platform)IBar getBar(IFinancialInstrument financialInstrument, Period period, OfferSide side, int shift) throws JFException
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.
consider getting the previous one hour bar
private IHistory history; private IConsole console; Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); IFinancialInstrumentProvider instrumentProvider = context.getFinancialInstrumentProvider(); IFinancialInstrument financialInstrument = instrumentProvider.getFinancialInstrument("EUR/USD"); IBar prevBar = history.getBar(financialInstrument, Period.ONE_HOUR, OfferSide.BID, 1); console.getOut().println(prevBar); }
financialInstrument
- instrument of the barperiod
- period of the barside
- bid or ask side of the barshift
- number of candle back in time staring from current bar. 1 - previous bar, 2 - current bar minus 2 bars and so onJFException
- when period is not supported or instrument is not active (not opened in platform)void readTicks(Instrument instrument, long from, long to, LoadingDataListener tickListener, LoadingProgressListener loadingProgress) throws JFException
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
Consider analyzing the last days ticks - namely calculating the average ask price and the maximum bid
private IHistory history; private IConsole console; double maxBid = Double.MIN_VALUE, avgAsk = 0; int tickCount =0; private Instrument instrument = Instrument.EURUSD; @Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); context.setSubscribedInstruments(Collections.singleton(instrument), true); final long from = history.getLastTick(instrument).getTime() - Period.DAILY.getInterval(); final long to = history.getLastTick(instrument).getTime(); history.readTicks(instrument, from, to, new LoadingDataListener() { @Override public void newTick(Instrument instrument, long time, double ask, double bid, double askVol, double bidVol) { tickCount++; maxBid = Math.max(bid, maxBid); avgAsk = tickCount == 1 ? ask : round(avgAsk + ((avgAsk - ask) / (double)tickCount)); } private double round(double amount) { return (new BigDecimal(amount)).setScale(instrument.getPipScale(), BigDecimal.ROUND_HALF_UP).doubleValue(); } @Override public void newBar(Instrument instrument, Period period, OfferSide side, long time, double open, double close, double low, double high, double vol) { // no bars expected } }, new LoadingProgressListener() { @Override public void dataLoaded(long start, long end, long currentPosition, String information) { } @Override public void loadingFinished(boolean allDataLoaded, long start, long end, long currentPosition) { console.getOut().format("Loaded %s ticks %s - %s max Bid=%.5f average ask=%.5f", tickCount, DateUtils.format(from), DateUtils.format(to), maxBid, avgAsk).println(); context.stop(); } @Override public boolean stopJob() { return false; } }); }
instrument
- instrument of the ticksfrom
- start of the time interval for which ticks should be loadedto
- 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 welltickListener
- receives data about requested ticksloadingProgress
- used to control loading processJFException
- when some error occurs while creating internal request for datavoid readTicks(IFinancialInstrument financialInstrument, long from, long to, DataLoadingListener tickListener, LoadingProgressListener loadingProgress) throws JFException
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
Consider analyzing the last days ticks - namely calculating the average ask price and the maximum bid
private IHistory history; private IConsole console; double maxBid = Double.MIN_VALUE; double avgAsk = 0; int tickCount = 0; @Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); IFinancialInstrumentProvider instrumentProvider = context.getFinancialInstrumentProvider(); final IFinancialInstrument financialInstrument = instrumentProvider.getFinancialInstrument("EUR/USD"); context.setSubscribedFinancialInstruments(Collections.singleton(financialInstrument), true); final long from = history.getLastTick(financialInstrument).getTime() - Period.DAILY.getInterval(); final long to = history.getLastTick(financialInstrument).getTime(); history.readTicks(financialInstrument, from, to, new LoadingFinancialDataListener() { @Override public void newTick(IFinancialInstrument financialInstrument, long time, double ask, double bid, double askVol, double bidVol) { tickCount++; maxBid = Math.max(bid, maxBid); avgAsk = tickCount == 1 ? ask : round(avgAsk + ((avgAsk - ask) / (double)tickCount)); } private double round(double amount) { return (new BigDecimal(amount)).setScale(financialInstrument.getPipScale(), BigDecimal.ROUND_HALF_UP).doubleValue(); } @Override public void newBar(IFinancialInstrument financialInstrument, Period period, OfferSide side, long time, double open, double close, double low, double high, double vol) { // no bars expected } }, new LoadingProgressListener() { @Override public void dataLoaded(long start, long end, long currentPosition, String information) { } @Override public void loadingFinished(boolean allDataLoaded, long start, long end, long currentPosition) { console.getOut().format("Loaded %s ticks %s - %s max Bid=%.5f average ask=%.5f", tickCount, DateUtils.format(from), DateUtils.format(to), maxBid, avgAsk).println(); context.stop(); } @Override public boolean stopJob() { return false; } }); }
financialInstrument
- instrument of the ticksfrom
- start of the time interval for which ticks should be loadedto
- 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 welltickListener
- receives data about requested ticksloadingProgress
- used to control loading processJFException
- when some error occurs while creating internal request for datavoid readTicks(Instrument instrument, int numberOfOneSecondIntervalsBefore, long time, int numberOfOneSecondIntervalsAfter, LoadingDataListener tickListener, LoadingProgressListener loadingProgress) throws JFException
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 processinginstrument
- instrument of the ticksnumberOfOneSecondIntervalsBefore
- how much one second interval of ticks to load before and including one second interval of ticks with time specified in time
parametertime
- time of the last one second tick interval in period specified in numberOfOneSecondIntervalsBefore
parameter or/and
time of the one second tick interval prior first one second tick interval in period specified with numberOfOneSecondIntervalsAfter
parameternumberOfOneSecondIntervalsAfter
- how much one second tick intervals to load after (not including) one second tick interval with time specified in time
parametertickListener
- receives data about requested ticksloadingProgress
- used to control loading progressJFException
- when some errors occursvoid readTicks(IFinancialInstrument financialInstrument, int numberOfOneSecondIntervalsBefore, long time, int numberOfOneSecondIntervalsAfter, LoadingDataListener tickListener, LoadingProgressListener loadingProgress) throws JFException
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 processingfinancialInstrument
- financial instrument of the ticksnumberOfOneSecondIntervalsBefore
- how much one second interval of ticks to load before and including one second interval of ticks with time specified in time
parametertime
- time of the last one second tick interval in period specified in numberOfOneSecondIntervalsBefore
parameter or/and
time of the one second tick interval prior first one second tick interval in period specified with numberOfOneSecondIntervalsAfter
parameternumberOfOneSecondIntervalsAfter
- how much one second tick intervals to load after (not including) one second tick interval with time specified in time
parametertickListener
- receives data about requested ticksloadingProgress
- used to control loading progressJFException
- when some errors occursvoid readBars(Instrument instrument, Period period, OfferSide side, long from, long to, LoadingDataListener barListener, LoadingProgressListener loadingProgress) throws JFException
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
Consider analyzing the last weeks 1 minute bars - namely calculating the average close price and the maximum bar size
private IHistory history; private IConsole console; double maxHeight = Double.MIN_VALUE, avgClose = 0; int barCount, greenCount; private Instrument instrument = Instrument.EURUSD; private Period period = Period.ONE_MIN; @Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); context.setSubscribedInstruments(Collections.singleton(instrument), true); long lastTickTime = history.getLastTick(instrument).getTime(); final long from = history.getBarStart(period, lastTickTime - Period.DAILY.getInterval() * 7); final long to = history.getTimeForNBarsBack(period, lastTickTime, 2); history.readBars(instrument, period, OfferSide.BID, from, to, new LoadingDataListener() { @Override public void newTick(Instrument instrument, long time, double ask, double bid, double askVol, double bidVol) {} @Override public void newBar(Instrument instrument, Period period, OfferSide side, long time, double open, double close, double low, double high, double vol) { barCount++; maxHeight = Math.max(Math.abs(open - close), maxHeight); avgClose = barCount == 1 ? close : round(avgClose + ((close - avgClose) / (double)barCount)); if(close - open > 0){ greenCount++; } } private double round(double amount) { return (new BigDecimal(amount)).setScale(instrument.getPipScale() + 1, BigDecimal.ROUND_HALF_UP).doubleValue(); } }, new LoadingProgressListener() { @Override public void dataLoaded(long start, long end, long currentPosition, String information) { } @Override public void loadingFinished(boolean allDataLoaded, long start, long end, long currentPosition) { console.getOut().format("Loaded %s %s candles (%s green, %s red) %s - %s max bar height=%.1fpips average close=%.5f" barCount, period, greenCount, barCount - greenCount, DateUtils.format(from), DateUtils.format(to), maxHeight/instrument.getPipValue(), avgClose).println(); context.stop(); } @Override public boolean stopJob() { return false; } }); }
instrument
- instrument of the barsperiod
- period of the barsside
- side of the barsfrom
- 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 timeto
- end time of the time interval for which bars should be loaded. This is the starting time of the last bar to be loadedbarListener
- receives data about requested barsloadingProgress
- used to control loading progressJFException
- when period is not supported or time interval is not valid for specified periodgetBarStart(Period, long)
void readBars(IFinancialInstrument financialInstrument, Period period, OfferSide side, long from, long to, DataLoadingListener barListener, LoadingProgressListener loadingProgress) throws JFException
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
Consider analyzing the last weeks 1 minute bars - namely calculating the average close price and the maximum bar size
private IHistory history; private IConsole console; double maxHeight = Double.MIN_VALUE, avgClose = 0; int barCount, greenCount; private Period period = Period.ONE_MIN; @Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); IFinancialInstrumentProvider instrumentProvider = context.getFinancialInstrumentProvider(); final IFinancialInstrument financialInstrument = instrumentProvider.getFinancialInstrument("EUR/USD"); context.setSubscribedFinancialInstruments(Collections.singleton(financialInstrument), true); long lastTickTime = history.getLastTick(financialInstrument).getTime(); final long from = history.getBarStart(period, lastTickTime - Period.DAILY.getInterval() * 7); final long to = history.getTimeForNBarsBack(period, lastTickTime, 2); history.readBars(financialInstrument, period, OfferSide.BID, from, to, new LoadingFinancialDataListener() { @Override public void newTick(IFinancialInstrument financialInstrument, long time, double ask, double bid, double askVol, double bidVol) {} @Override public void newBar(IFinancialInstrument financialInstrument, Period period, OfferSide side, long time, double open, double close, double low, double high, double vol) { barCount++; maxHeight = Math.max(Math.abs(open - close), maxHeight); avgClose = barCount == 1 ? close : round(avgClose + ((close - avgClose) / (double)barCount)); if(close - open > 0){ greenCount++; } } private double round(double amount) { return (new BigDecimal(amount)).setScale(financialInstrument.getPipScale() + 1, BigDecimal.ROUND_HALF_UP).doubleValue(); } }, new LoadingProgressListener() { @Override public void dataLoaded(long start, long end, long currentPosition, String information) { } @Override public void loadingFinished(boolean allDataLoaded, long start, long end, long currentPosition) { console.getOut().format("Loaded %s %s candles (%s green, %s red) %s - %s max bar height=%.1fpips average close=%.5f", barCount, period, greenCount, barCount - greenCount, DateUtils.format(from), DateUtils.format(to), maxHeight/financialInstrument.getPipValue(), avgClose).println(); context.stop(); } @Override public boolean stopJob() { return false; } }); }
financialInstrument
- instrument of the barsperiod
- period of the barsside
- side of the barsfrom
- 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 timeto
- end time of the time interval for which bars should be loaded. This is the starting time of the last bar to be loadedbarListener
- receives data about requested barsloadingProgress
- used to control loading progressJFException
- when period is not supported or time interval is not valid for specified periodgetBarStart(Period, long)
void readBars(Instrument instrument, Period period, OfferSide side, Filter filter, long from, long to, LoadingDataListener barListener, LoadingProgressListener loadingProgress) throws JFException
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
Consider analyzing the last weeks 1 minute bars - namely calculating the average close price and the maximum bar size
private IHistory history; private IConsole console; double maxHeight = Double.MIN_VALUE, avgClose = 0; int barCount, greenCount; private Instrument instrument = Instrument.EURUSD; private Period period = Period.ONE_MIN; @Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); context.setSubscribedInstruments(Collections.singleton(instrument), true); long lastTickTime = history.getLastTick(instrument).getTime(); final long from = history.getBarStart(period, lastTickTime - Period.DAILY.getInterval() * 7); final long to = history.getTimeForNBarsBack(period, lastTickTime, 2); history.readBars(instrument, period, OfferSide.BID, Filter.WEEKENDS, from, to, new LoadingDataListener() { @Override public void newTick(Instrument instrument, long time, double ask, double bid, double askVol, double bidVol) {} @Override public void newBar(Instrument instrument, Period period, OfferSide side, long time, double open, double close, double low, double high, double vol) { barCount++; maxHeight = Math.max(Math.abs(open - close), maxHeight); avgClose = barCount == 1 ? close : round(avgClose + ((close - avgClose) / (double)barCount)); if(close - open > 0){ greenCount++; } } private double round(double amount) { return (new BigDecimal(amount)).setScale(instrument.getPipScale() + 1, BigDecimal.ROUND_HALF_UP).doubleValue(); } }, new LoadingProgressListener() { @Override public void dataLoaded(long start, long end, long currentPosition, String information) { } @Override public void loadingFinished(boolean allDataLoaded, long start, long end, long currentPosition) { console.getOut().format("Loaded %s %s candles (%s green, %s red) %s - %s max bar height=%.1fpips average close=%.5f" barCount, period, greenCount, barCount - greenCount, DateUtils.format(from), DateUtils.format(to), maxHeight/instrument.getPipValue(), avgClose).println(); context.stop(); } @Override public boolean stopJob() { return false; } }); }
instrument
- instrument of the barsperiod
- period of the barsside
- side of the barsfilter
- bars filtering method see Filter
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 timeto
- end time of the time interval for which bars should be loaded. This is the starting time of the last bar to be loadedbarListener
- receives data about requested barsloadingProgress
- used to control loading progressJFException
- when period is not supported or time interval is not valid for specified periodgetBarStart(Period, long)
void readBars(IFinancialInstrument financialInstrument, Period period, OfferSide side, Filter filter, long from, long to, DataLoadingListener barListener, LoadingProgressListener loadingProgress) throws JFException
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
Consider analyzing the last weeks 1 minute bars - namely calculating the average close price and the maximum bar size
int barCount = 0; int greenCount = 0; @Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); IFinancialInstrumentProvider instrumentProvider = context.getFinancialInstrumentProvider(); final IFinancialInstrument financialInstrument = instrumentProvider.getFinancialInstrument("EUR/USD"); context.setSubscribedFinancialInstruments(Collections.singleton(financialInstrument), true); long lastTickTime = history.getLastTick(financialInstrument).getTime(); final long from = history.getBarStart(period, lastTickTime - Period.DAILY.getInterval() * 7); final long to = history.getTimeForNBarsBack(period, lastTickTime, 2); history.readBars(financialInstrument, period, OfferSide.BID, Filter.WEEKENDS, from, to, new LoadingFinancialDataListener() { @Override public void newTick(IFinancialInstrument financialInstrument, long time, double ask, double bid, double askVol, double bidVol) {} @Override public void newBar(IFinancialInstrument financialInstrument, Period period, OfferSide side, long time, double open, double close, double low, double high, double vol) { barCount++; maxHeight = Math.max(Math.abs(open - close), maxHeight); avgClose = barCount == 1 ? close : round(avgClose + ((close - avgClose) / (double)barCount)); if(close - open > 0){ greenCount++; } } private double round(double amount) { return (new BigDecimal(amount)).setScale(financialInstrument.getPipScale() + 1, BigDecimal.ROUND_HALF_UP).doubleValue(); } }, new LoadingProgressListener() { @Override public void dataLoaded(long start, long end, long currentPosition, String information) { } @Override public void loadingFinished(boolean allDataLoaded, long start, long end, long currentPosition) { console.getOut().format("Loaded %s %s candles (%s green, %s red) %s - %s max bar height=%.1fpips average close=%.5f", barCount, period, greenCount, barCount - greenCount, DateUtils.format(from), DateUtils.format(to), maxHeight/financialInstrument.getPipValue(), avgClose).println(); context.stop(); } @Override public boolean stopJob() { return false; } } ); }
financialInstrument
- instrument of the barsperiod
- period of the barsside
- side of the barsfilter
- bars filtering method see Filter
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 timeto
- end time of the time interval for which bars should be loaded. This is the starting time of the last bar to be loadedbarListener
- receives data about requested barsloadingProgress
- used to control loading progressJFException
- when period is not supported or time interval is not valid for specified periodgetBarStart(Period, long)
void readBars(Instrument instrument, Period period, OfferSide side, Filter filter, int numberOfCandlesBefore, long time, int numberOfCandlesAfter, LoadingDataListener barListener, LoadingProgressListener loadingProgress) throws JFException
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
Consider analyzing the 100000 1 minute bars - namely calculating the average close price and the maximum bar size
private IHistory history; private IConsole console; double maxHeight = Double.MIN_VALUE, avgClose = 0; int barCount, greenCount; private Instrument instrument = Instrument.EURUSD; private Period period = Period.ONE_MIN; @Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); context.setSubscribedInstruments(Collections.singleton(instrument), true); long lastTickTime = history.getLastTick(instrument).getTime(); final long to = history.getTimeForNBarsBack(period, lastTickTime, 2); history.readBars(instrument, period, OfferSide.BID, Filter.WEEKENDS, 100000, to, 0, new LoadingDataListener() { @Override public void newTick(Instrument instrument, long time, double ask, double bid, double askVol, double bidVol) {} @Override public void newBar(Instrument instrument, Period period, OfferSide side, long time, double open, double close, double low, double high, double vol) { barCount++; maxHeight = Math.max(Math.abs(open - close), maxHeight); avgClose = barCount == 1 ? close : round(avgClose + ((close - avgClose) / (double)barCount)); if(close - open > 0){ greenCount++; } } private double round(double amount) { return (new BigDecimal(amount)).setScale(instrument.getPipScale() + 1, BigDecimal.ROUND_HALF_UP).doubleValue(); } }, new LoadingProgressListener() { @Override public void dataLoaded(long start, long end, long currentPosition, String information) { } @Override public void loadingFinished(boolean allDataLoaded, long start, long end, long currentPosition) { console.getOut().format("Loaded %s %s candles (%s green, %s red) till %s max bar height=%.1fpips average close=%.5f", barCount, period, greenCount, barCount - greenCount, DateUtils.format(to), maxHeight/instrument.getPipValue(), avgClose).println(); context.stop(); } @Override public boolean stopJob() { return false; } }); }
instrument
- instrument of the barsperiod
- period of the barsside
- side of the barsfilter
- allows to filter candlesnumberOfCandlesBefore
- how much candles to load before and including candle with time specified in time
parametertime
- time of the last candles in period specified in numberOfCandlesBefore
parameter or/and
time of the candle prior first candle in period specified with numberOfCandlesAfter
parameternumberOfCandlesAfter
- how much candles to load after (not including) candle with time specified in time
parameterbarListener
- receives data about requested barsloadingProgress
- used to control loading progressJFException
- when period is not supported or time interval is not valid for specified periodgetBarStart(Period, long)
void readBars(IFinancialInstrument financialInstrument, Period period, OfferSide side, Filter filter, int numberOfCandlesBefore, long time, int numberOfCandlesAfter, DataLoadingListener barListener, LoadingProgressListener loadingProgress) throws JFException
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
Consider analyzing the 100000 1 minute bars - namely calculating the average close price and the maximum bar size
private IHistory history; private IConsole console; double maxHeight = Double.MIN_VALUE, avgClose = 0; int barCount, greenCount; private Period period = Period.ONE_MIN; @Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); IFinancialInstrumentProvider instrumentProvider = context.getFinancialInstrumentProvider(); final IFinancialInstrument financialInstrument = instrumentProvider.getFinancialInstrument("EUR/USD"); context.setSubscribedFinancialInstruments(Collections.singleton(financialInstrument), true); long lastTickTime = history.getLastTick(financialInstrument).getTime(); final long to = history.getTimeForNBarsBack(period, lastTickTime, 2); history.readBars(financialInstrument, period, OfferSide.BID, Filter.WEEKENDS, 100000, to, 0, new LoadingFinancialDataListener() { @Override public void newTick(IFinancialInstrument financialInstrument, long time, double ask, double bid, double askVol, double bidVol) {} @Override public void newBar(IFinancialInstrument financialInstrument, Period period, OfferSide side, long time, double open, double close, double low, double high, double vol) { barCount++; maxHeight = Math.max(Math.abs(open - close), maxHeight); avgClose = barCount == 1 ? close : round(avgClose + ((close - avgClose) / (double)barCount)); if(close - open > 0){ greenCount++; } } private double round(double amount) { return (new BigDecimal(amount)).setScale(financialInstrument.getPipScale() + 1, BigDecimal.ROUND_HALF_UP).doubleValue(); } }, new LoadingProgressListener() { @Override public void dataLoaded(long start, long end, long currentPosition, String information) { } @Override public void loadingFinished(boolean allDataLoaded, long start, long end, long currentPosition) { console.getOut().format("Loaded %s %s candles (%s green, %s red) till %s max bar height=%.1fpips average close=%.5f", barCount, period, greenCount, barCount - greenCount, DateUtils.format(to), maxHeight/financialInstrument.getPipValue(), avgClose).println(); context.stop(); } @Override public boolean stopJob() { return false; } }); }
financialInstrument
- instrument of the barsperiod
- period of the barsside
- side of the barsfilter
- allows to filter candlesnumberOfCandlesBefore
- how much candles to load before and including candle with time specified in time
parametertime
- time of the last candles in period specified in numberOfCandlesBefore
parameter or/and
time of the candle prior first candle in period specified with numberOfCandlesAfter
parameternumberOfCandlesAfter
- how much candles to load after (not including) candle with time specified in time
parameterbarListener
- receives data about requested barsloadingProgress
- used to control loading progressJFException
- when period is not supported or time interval is not valid for specified periodgetBarStart(Period, long)
List<ITick> getTicks(Instrument instrument, long from, long to) throws JFException
OutOfMemoryException
ITick lastTick = history.getLastTick(Instrument.EURUSD); List<ITick> ticks = history.getTicks(Instrument.EURUSD, lastTick.getTime() - 10 * 1000, lastTick.getTime()); int last = ticks.size() - 1; console.getOut().format( "Tick count=%s; Latest bid price=%.5f, time=%s; Oldest bid price=%.5f, time=%s", ticks.size(), ticks.get(last).getBid(), DateUtils.format(ticks.get(last).getTime()), ticks.get(0).getBid(), DateUtils.format(ticks.get(last).getTime()) ).println();
instrument
- instrument of the ticksfrom
- start of the time interval for which ticks should be loadedto
- 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 wellJFException
- when some error occurs when loading dataList<ITick> getTicks(IFinancialInstrument financialInstrument, long from, long to) throws JFException
OutOfMemoryException
@Override public void onStart(final IContext context) throws JFException { this.history = context.getHistory(); this.console = context.getConsole(); IFinancialInstrumentProvider instrumentProvider = context.getFinancialInstrumentProvider(); IFinancialInstrument financialInstrument = instrumentProvider.getFinancialInstrument("EUR/USD"); ITick lastTick = history.getLastTick(financialInstrument); List<ITick> = history.getTicks(financialInstrument, lastTick.getTime() - 10 * 1000, lastTick.getTime()); int last = ticks.size() - 1; console.getOut().format("Tick count=%s; Latest bid price=%.5f, time=%s; Oldest bid price=%.5f, time=%s", ticks.size(), ticks.get(last).getBid(), DateUtils.format(ticks.get(last).getTime()), ticks.get(0).getBid(), DateUtils.format(ticks.get(last).getTime()) ).println(); }
financialInstrument
- instrument of the ticksfrom
- start of the time interval for which ticks should be loadedto
- 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 wellJFException
- when some error occurs when loading dataList<ITick> getTicks(Instrument instrument, int numberOfOneSecondIntervalsBefore, long time, int numberOfOneSecondIntervalsAfter) throws JFException
OutOfMemoryException
instrument
- instrument of the ticksnumberOfOneSecondIntervalsBefore
- how much one second interval of ticks to load before and including one second interval of ticks with time specified in time
parametertime
- time of the last one second tick interval in period specified in numberOfOneSecondIntervalsBefore
parameter or/and
time of the one second tick interval prior first one second tick interval in period specified with numberOfOneSecondIntervalsAfter
parameternumberOfOneSecondIntervalsAfter
- how much one second tick intervals to load after (not including) one second tick interval with time specified in time
parameterJFException
- when some error occurs when loading dataList<ITick> getTicks(IFinancialInstrument financialInstrument, int numberOfOneSecondIntervalsBefore, long time, int numberOfOneSecondIntervalsAfter) throws JFException
OutOfMemoryException
financialInstrument
- instrument of the ticksnumberOfOneSecondIntervalsBefore
- how much one second interval of ticks to load before and including one second interval of ticks with time specified in time
parametertime
- time of the last one second tick interval in period specified in numberOfOneSecondIntervalsBefore
parameter or/and
time of the one second tick interval prior first one second tick interval in period specified with numberOfOneSecondIntervalsAfter
parameternumberOfOneSecondIntervalsAfter
- how much one second tick intervals to load after (not including) one second tick interval with time specified in time
parameterJFException
- when some error occurs when loading dataList<IBar> getBars(Instrument instrument, Period period, OfferSide side, long from, long to) throws JFException
OutOfMemoryException
Consider getting 5 bars over a time interval:
long prevBarTime = history.getPreviousBarStart(Period.ONE_HOUR, history.getLastTick(Instrument.EURUSD).getTime()); long startTime = history.getTimeForNBarsBack(Period.ONE_HOUR, prevBarTime, 5); List<IBar> bars = history.getBars(Instrument.EURUSD, Period.ONE_HOUR, OfferSide.BID, startTime, prevBarTime); int last = bars.size() - 1; console.getOut().format( "Previous bar close price=%.5f; 4th to previous bar close price=%.5f", bars.get(last).getClose(), bars.get(0).getClose() ).println();Consider getting daily bars over several months:
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyy HH:mm:ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); Date dateFrom, dateTo; try { dateFrom = dateFormat.parse("04/06/2013 00:00:00"); dateTo = dateFormat.parse("04/10/2013 00:00:00"); } catch (ParseException e) { e.printStackTrace(); return; } Listbars = history.getBars(Instrument.EURUSD, Period.DAILY, OfferSide.ASK, dateFrom.getTime(), dateTo.getTime()); console.getOut().format("bar FROM=%s; bar TO=%s", bars.get(0), bars.get(bars.size() - 1)).println();
instrument
- instrument of the barsperiod
- period of the barsside
- side of the barsfrom
- 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 timeto
- end time of the time interval for which bars should be loaded. This is the starting time of the last candle to be loadedJFException
- when period is not supported or some error occurs when loading dataList<IBar> getBars(IFinancialInstrument financialInstrument, Period period, OfferSide side, long from, long to) throws JFException
OutOfMemoryException
Consider getting 5 bars over a time interval:
private IHistory history; private IConsole console; @Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); IFinancialInstrumentProvider instrumentProvider = context.getFinancialInstrumentProvider(); final IFinancialInstrument financialInstrument = instrumentProvider.getFinancialInstrument("EUR/USD"); long prevBarTime = history.getPreviousBarStart(Period.ONE_HOUR, history.getLastTick(financialInstrument).getTime()); long startTime = history.getTimeForNBarsBack(Period.ONE_HOUR, prevBarTime, 5); List<IBar> bars = history.getBars(financialInstrument, Period.ONE_HOUR, OfferSide.BID, startTime, prevBarTime); int last = bars.size() - 1; console.getOut().format( "Previous bar close price=%.5f; 4th to previous bar close price=%.5f", bars.get(last).getClose(), bars.get(0).getClose() ).println(); }
financialInstrument
- instrument of the barsperiod
- period of the barsside
- side of the barsfrom
- 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 timeto
- end time of the time interval for which bars should be loaded. This is the starting time of the last candle to be loadedJFException
- when period is not supported or some error occurs when loading dataList<IBar> getBars(Instrument instrument, Period period, OfferSide side, Filter filter, long from, long to) throws JFException
OutOfMemoryException
instrument
- instrument of the barsperiod
- period of the barsside
- side of the barsfilter
- bars filtering method see Filter
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 timeto
- end time of the time interval for which bars should be loaded. This is the starting time of the last candle to be loadedJFException
- when period is not supported or some error occurs when loading dataList<IBar> getBars(IFinancialInstrument financialInstrument, Period period, OfferSide side, Filter filter, long from, long to) throws JFException
OutOfMemoryException
financialInstrument
- instrument of the barsperiod
- period of the barsside
- side of the barsfilter
- bars filtering method see Filter
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 timeto
- end time of the time interval for which bars should be loaded. This is the starting time of the last candle to be loadedJFException
- when period is not supported or some error occurs when loading dataList<IBar> getBars(Instrument instrument, Period period, OfferSide side, Filter filter, int numberOfCandlesBefore, long time, int numberOfCandlesAfter) throws JFException
OutOfMemoryException
. If the requested period includes the bar that is not fully
formed yet (in-progress bar), then it is included even if it's flat
Consider getting 5 bars over a candle interval:
long prevBarTime = history.getPreviousBarStart(Period.ONE_HOUR, history.getLastTick(Instrument.EURUSD).getTime()); List<IBar> bars = history.getBars(Instrument.EURUSD, Period.ONE_HOUR, OfferSide.BID, Filter.NO_FILTER, 5, prevBarTime, 0); int last = bars.size() - 1; console.getOut().format( "Previous bar close price=%.5f; 4th to previous bar close price=%.5f", bars.get(last).getClose(), bars.get(0).getClose()).println();
instrument
- instrument of the barsperiod
- period of the barsside
- side of the barsfilter
- allows to filter candlesnumberOfCandlesBefore
- how much candles to load before and including candle with time specified in time
parametertime
- time of the last candle in period specified in numberOfCandlesBefore
parameter, or
time of the first candle in period specified with numberOfCandlesAfter
parameter if numberOfCandlesBefore
is 0, or
time of the candle prior to first candle in period specified with numberOfCandlesAfter
if numberOfCandlesBefore
is > 0numberOfCandlesAfter
- how much candles to load after (not including) candle with time specified in time
parameterJFException
- when period is not supported or some error occurs when loading dataList<IBar> getBars(IFinancialInstrument financialInstrument, Period period, OfferSide side, Filter filter, int numberOfCandlesBefore, long time, int numberOfCandlesAfter) throws JFException
OutOfMemoryException
. If the requested period includes the bar that is not fully
formed yet (in-progress bar), then it is included even if it's flat
Consider getting 5 bars over a candle interval:
private IHistory history; private IConsole console; @Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); IFinancialInstrumentProvider instrumentProvider = context.getFinancialInstrumentProvider(); IFinancialInstrument financialInstrument = instrumentProvider.getFinancialInstrument("EUR/USD"); context.setSubscribedFinancialInstruments(Collections.singleton(financialInstrument), true); long prevBarTime = history.getPreviousBarStart(Period.ONE_HOUR, history.getLastTick(financialInstrument).getTime()); List<IBar> bars = history.getBars(financialInstrument, Period.ONE_HOUR, OfferSide.BID, Filter.NO_FILTER, 5, prevBarTime, 0); int last = bars.size() - 1; console.getOut().format( "Previous bar close price=%.5f; 4th to previous bar close price=%.5f", bars.get(last).getClose(), bars.get(0).getClose()).println(); }
financialInstrument
- instrument of the barsperiod
- period of the barsside
- side of the barsfilter
- allows to filter candlesnumberOfCandlesBefore
- how much candles to load before and including candle with time specified in time
parametertime
- time of the last candle in period specified in numberOfCandlesBefore
parameter, or
time of the first candle in period specified with numberOfCandlesAfter
parameter if numberOfCandlesBefore
is 0, or
time of the candle prior to first candle in period specified with numberOfCandlesAfter
if numberOfCandlesBefore
is > 0numberOfCandlesAfter
- how much candles to load after (not including) candle with time specified in time
parameterJFException
- when period is not supported or some error occurs when loading datalong getBarStart(Period period, long time) throws JFException
time
parameterperiod
- period of the bartime
- time that is included by the barJFException
- when period is not supportedlong getNextBarStart(Period period, long barTime) throws JFException
barTime
parameterperiod
- period of the barbarTime
- time that is included by the bar previous to the returnedJFException
- when period is not supportedlong getPreviousBarStart(Period period, long barTime) throws JFException
barTime
parameterperiod
- period to the barbarTime
- time that is included by the bar next to the returnedJFException
- when period is not supportedlong getTimeForNBarsBack(Period period, long to, int numberOfBars) throws JFException
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 loadedperiod
- period of the barsto
- time of the last barnumberOfBars
- 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)
methodJFException
- when period is not supportedlong getTimeForNBarsForward(Period period, long from, int numberOfBars) throws JFException
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 loadedperiod
- period of the barsfrom
- time of the first barnumberOfBars
- 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)
methodJFException
- when period is not supportedvoid readOrdersHistory(Instrument instrument, long from, long to, LoadingOrdersListener ordersListener, LoadingProgressListener loadingProgress) throws JFException
ordersListener
. 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 can be used for orders loading without blocking strategy execution
NB! Only one order history request can be sent at a time. If there is another request sent method will throw JFExceptioninstrument
- instrument of the ordersfrom
- start of the time interval for which orders should be loadedto
- end time of the time interval for which orders should be loadedordersListener
- receives data about requested ordersloadingProgress
- used to control loading progressJFException
- in case of any system errorgetOrdersHistory(Instrument instrument, long from, long to)
void readOrdersHistory(IFinancialInstrument financialInstrument, long from, long to, LoadingOrdersListener ordersListener, LoadingProgressListener loadingProgress) throws JFException
ordersListener
. 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 can be used for orders loading without blocking strategy execution
NB! Only one order history request can be sent at a time. If there is another request sent method will throw JFExceptionfinancialInstrument
- instrument of the ordersfrom
- start of the time interval for which orders should be loadedto
- end time of the time interval for which orders should be loadedordersListener
- receives data about requested ordersloadingProgress
- used to control loading progressJFException
- in case of any system errorgetOrdersHistory(IFinancialInstrument financialInstrument, long from, long to)
List<IOrder> getOrdersHistory(Instrument instrument, long from, long to) throws JFException
instrument
- instrument of the ordersfrom
- start of the time interval for which orders should be loadedto
- end time of the time interval for which orders should be loadedJFException
- in case of any system errorList<IOrder> getOrdersHistory(IFinancialInstrument financialInstrument, long from, long to) throws JFException
financialInstrument
- instrument of the ordersfrom
- start of the time interval for which orders should be loadedto
- end time of the time interval for which orders should be loadedJFException
- in case of any system errorIOrder getHistoricalOrderById(String id) throws JFException
id
- closed order's position idnull
if there is no one.JFException
- in case of any system errordouble getEquity()
ITick getTick(Instrument instrument, int shift) throws JFException
shift
parameter, 0 - current tick, 1 - previous tick.
ITick tick0 = history.getTick(Instrument.EURUSD, 0); ITick tick1 = history.getTick(Instrument.EURUSD, 1); console.getOut().format("last tick: %s; previous tick: %s", tick0, tick1).println();
instrument
- instrument of the tickshift
- number of tick back in time staring from current tick. 1 - previous tick, 2 - current tick minus 2 ticks and so onJFException
- when instrument is not active (not opened in platform) or other errorsITick getTick(IFinancialInstrument financialInstrument, int shift) throws JFException
shift
parameter, 0 - current tick, 1 - previous tick.
IFinancialInstrumentProvider instrumentProvider = context.getFinancialInstrumentProvider(); final IFinancialInstrument financialInstrument = instrumentProvider.getFinancialInstrument("EUR/USD"); ITick tick0 = history.getTick(financialInstrument, 0); ITick tick1 = history.getTick(financialInstrument, 1); console.getOut().format("last tick: %s; previous tick: %s", tick0, tick1).println();
financialInstrument
- instrument of the tickshift
- number of tick back in time staring from current tick. 1 - previous tick, 2 - current tick minus 2 ticks and so onJFException
- when instrument is not active (not opened in platform) or other errorsITimedData getFeedData(IFeedDescriptor feedDescriptor, int shift) throws JFException
shift
parameter, 0 - current bar (currently generated), 1 - previous bar (last formed bar) If there is no bar loaded at that
position, then function returns null.feedDescriptor
- holds parameters: data type, instrument, offer side, etc (depends on bar type), and describes what kind of bars must be loadedshift
- number of bars back in time staring from current bar. 1 - previous bar, 2 - current bar minus 2 bars and so onFeedDescriptor.getDataType()
JFException
- when some error occurs when loading data<T extends ITimedData> T getFeedData(ITailoredFeedDescriptor<T> feedDescriptor, int shift) throws JFException
JFException
getFeedData(IFeedDescriptor, int)
List<ITimedData> getFeedData(IFeedDescriptor feedDescriptor, long from, long to) throws JFException
OutOfMemoryException
feedDescriptor
- holds parameters: data type, instrument, offer side, etc (depends on bar type), and describes what kind of bars must be loadedfrom
- start of the time interval for which bars should be loadedto
- end time of the time interval for which bars should be loaded. If there is bar with time equals to the time in to
parameter then it will be loaded as wellJFException
- when incorrect time interval is passed or some error occurs when loading data<T extends ITimedData> List<T> getFeedData(ITailoredFeedDescriptor<T> feedDescriptor, long from, long to) throws JFException
JFException
getFeedData(IFeedDescriptor, long, long)
List<ITimedData> getFeedData(IFeedDescriptor feedDescriptor, int numberOfFeedBarsBefore, long time, int numberOfFeedBarsAfter) throws JFException
OutOfMemoryException
.feedDescriptor
- holds parameters: data type, instrument, offer side, etc (depends on bar type), and describes what kind of bars must be loadednumberOfFeedBarsBefore
- how much bars to load before and including bar with time specified in time
parametertime
- the time of the last bar in period specified in numberOfFeedBarsBefore
parameter, or
the time of the first bar in period specified with numberOfFeedBarsAfter
parameter if numberOfFeedBarsBefore
is 0, or
the time of the bar prior to the first bar in period specified with numberOfFeedBarsAfter
if numberOfFeedBarsBefore
is > 0numberOfFeedBarsAfter
- how much bars to load after (not including) bar with time specified in time
parameterJFException
- when some error occurs when loading data<T extends ITimedData> List<T> getFeedData(ITailoredFeedDescriptor<T> feedDescriptor, int numberOfFeedBarsBefore, long time, int numberOfFeedBarsAfter) throws JFException
JFException
getFeedData(ITailoredFeedDescriptor, int, long, int)
void readFeedData(IFeedDescriptor feedDescriptor, long from, long to, IFeedListener feedListener, LoadingProgressListener loadingProgress) throws JFException
feedListener
. 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
Consider analyzing the last weeks renko bricks - namely calculating the average close price
private IHistory history; private IConsole console; private Instrument instrument = Instrument.EURUSD; private IFeedDescriptor feedDescriptor = new RenkoFeedDescriptor(instrument, PriceRange.TWO_PIPS, OfferSide.ASK); private double avgPrice = 0; private int itemCount = 0; @Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); context.setSubscribedInstruments(Collections.singleton(instrument), true); final long to = history.getFeedData(feedDescriptor, 1).getTime(); final long from = to - Period.DAILY.getInterval() * 7; history.readFeedData( feedDescriptor, from, to, new IFeedListener() { @Override public void onFeedData(IFeedDescriptor feedDescriptor, ITimedData feedData) { itemCount++; double price = feedDescriptor.getDataType() == DataType.TICKS ? ((ITick)feedData).getBid() : ((IBar)feedData).getClose(); avgPrice = itemCount == 1 ? price : round(avgPrice + ((price - avgPrice) / (double)itemCount)); } private double round(double amount) { return (new BigDecimal(amount)).setScale(instrument.getPipScale() + 1, BigDecimal.ROUND_HALF_UP).doubleValue(); } }, new LoadingProgressListener() { @Override public void dataLoaded(long start, long end, long currentPosition, String information) { } @Override public void loadingFinished(boolean allDataLoaded, long start, long end, long currentPosition) { console.getOut().format("Loaded %s %s %s - %s average %s=%.5f feed descriptor=%s", itemCount, feedDescriptor.getDataType(), DateUtils.format(from), DateUtils.format(to), feedDescriptor.getDataType() == DataType.TICKS ? "bid" : "close", avgPrice, feedDescriptor ).println(); context.stop(); } @Override public boolean stopJob() { return false; } } ); }
feedDescriptor
- feed descriptor of the feed datafrom
- start of the time interval for which feed data items should be loaded.to
- end time of the time interval for which feed data items should be loaded.feedListener
- receives data about requested feed data itemsloadingProgress
- used to control loading progressJFException
- when some errors occurs<T extends ITimedData> void readFeedData(ITailoredFeedDescriptor<T> feedDescriptor, long from, long to, ITailoredFeedListener<T> feedListener, LoadingProgressListener loadingProgress) throws JFException
private IHistory history; private IConsole console; Instrument instrument = Instrument.EURUSD; ITailoredFeedDescriptor<IRenkoBar> feedDescriptor = new RenkoFeedDescriptor(instrument, PriceRange.TWO_PIPS, OfferSide.ASK); double avgPrice = 0; int itemCount = 0; @Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); context.setSubscribedInstruments(Collections.singleton(instrument), true); final long to = history.getFeedData(feedDescriptor, 1).getTime(); final long from = to - Period.DAILY.getInterval() * 7; history.readFeedData( feedDescriptor, from, to, new ITailoredFeedListener<IRenkoBar>() { @Override public void onFeedData(ITailoredFeedDescriptor<IRenkoBar> feedDescriptor, IRenkoBar renko) { itemCount++; double price = renko.getClose(); avgPrice = itemCount == 1 ? price : round(avgPrice + ((price - avgPrice) / (double)itemCount)); } private double round(double amount) { return (new BigDecimal(amount)).setScale(instrument.getPipScale() + 1, BigDecimal.ROUND_HALF_UP).doubleValue(); } }, new LoadingProgressListener() { @Override public void dataLoaded(long start, long end, long currentPosition, String information) { } @Override public void loadingFinished(boolean allDataLoaded, long start, long end, long currentPosition) { console.getOut().format("Loaded %s Renkos %s - %s average close=%.5f feed descriptor=%s", itemCount, DateUtils.format(from), DateUtils.format(to), avgPrice, feedDescriptor ).println(); context.stop(); } @Override public boolean stopJob() { return false; } } ); }
void readFeedData(IFeedDescriptor feedDescriptor, int numberOfFeedDataBefore, long time, int numberOfFeedDataAfter, IFeedListener feedListener, LoadingProgressListener loadingProgress) throws JFException
feedListener
. 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 feed data without keeping them all in memory, and second is asynchronous processing
Consider analyzing the last 1000 renko bricks - namely calculating the average close price
private IHistory history; private IConsole console; private Instrument instrument = Instrument.EURUSD; private IFeedDescriptor feedDescriptor = new RenkoFeedDescriptor(Instrument.EURUSD, PriceRange.TWO_PIPS, OfferSide.ASK); private double avgPrice = 0; private int itemCount = 0; @Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); context.setSubscribedInstruments(Collections.singleton(instrument), true); final long to = history.getFeedData(feedDescriptor, 1).getTime(); history.readFeedData( feedDescriptor, 1000, to, 0, new IFeedListener() { @Override public void onFeedData(IFeedDescriptor feedDescriptor, ITimedData feedData) { itemCount++; double price = feedDescriptor.getDataType() == DataType.TICKS ? ((ITick)feedData).getBid() : ((IBar)feedData).getClose(); avgPrice = itemCount == 1 ? price : round(avgPrice + ((price - avgPrice) / (double)itemCount)); } private double round(double amount) { return (new BigDecimal(amount)).setScale(instrument.getPipScale() + 1, BigDecimal.ROUND_HALF_UP).doubleValue(); } }, new LoadingProgressListener() { @Override public void dataLoaded(long start, long end, long currentPosition, String information) { } @Override public void loadingFinished(boolean allDataLoaded, long start, long end, long currentPosition) { console.getOut().format("Loaded %s %s till %s average %s=%.5f feed descriptor=%s", itemCount, feedDescriptor.getDataType(), DateUtils.format(to), feedDescriptor.getDataType() == DataType.TICKS ? "bid" : "close", avgPrice, feedDescriptor ).println(); context.stop(); } @Override public boolean stopJob() { return false; } } ); }
feedDescriptor
- feed descriptor of the feed datanumberOfFeedDataBefore
- how much feed data items to load before and including feed data item with time specified in time
parametertime
- time of the last feed data item in period specified in numberOfFeedDataBefore
parameter or/and
time of the feed data item prior first feed data item in period specified with numberOfFeedDataAfter
parameternumberOfFeedDataAfter
- how much feed data items to load after (not including) feed data item with time specified in time
parameterfeedListener
- receives feed dataloadingProgress
- used to control loading progressJFException
- when some errors occurs<T extends ITimedData> void readFeedData(ITailoredFeedDescriptor<T> feedDescriptor, int numberOfFeedDataBefore, long time, int numberOfFeedDataAfter, ITailoredFeedListener<T> feedListener, LoadingProgressListener loadingProgress) throws JFException
private IHistory history; private IConsole console; private Instrument instrument = Instrument.EURUSD; private ITailoredFeedDescriptor<IRenkoBar> feedDescriptor = new RenkoFeedDescriptor(Instrument.EURUSD, PriceRange.TWO_PIPS, OfferSide.ASK); private double avgPrice = 0; private int itemCount = 0; @Override public void onStart(final IContext context) throws JFException { history = context.getHistory(); console = context.getConsole(); context.setSubscribedInstruments(Collections.singleton(instrument), true); final long to = history.getFeedData(feedDescriptor, 1).getTime(); history.readFeedData( feedDescriptor, 1000, to, 0, new ITailoredFeedListener<IRenkoBar>() { @Override public void onFeedData(ITailoredFeedDescriptor<IRenkoBar> feedDescriptor, IRenkoBar renko) { itemCount++; double price = renko.getClose(); avgPrice = itemCount == 1 ? price : round(avgPrice + ((price - avgPrice) / (double)itemCount)); } private double round(double amount) { return (new BigDecimal(amount)).setScale(instrument.getPipScale() + 1, BigDecimal.ROUND_HALF_UP).doubleValue(); } }, new LoadingProgressListener() { @Override public void dataLoaded(long start, long end, long currentPosition, String information) { } @Override public void loadingFinished(boolean allDataLoaded, long start, long end, long currentPosition) { console.getOut().format("Loaded %s Renkos till %s average close=%.5f feed descriptor=%s", itemCount, DateUtils.format(to), avgPrice, feedDescriptor ).println(); context.stop(); } @Override public boolean stopJob() { return false; } } ); }
@Deprecated IPointAndFigure getPointAndFigure(Instrument instrument, OfferSide offerSide, PriceRange boxSize, ReversalAmount reversalAmount, int shift) throws JFException
getFeedData(ITailoredFeedDescriptor, int)
.shift
parameter, 0 - current bar, 1 - previous bar (last formed bar) If there is no bar loaded at that
position, then function returns null. This method uses default base period IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone and default
data interpolation descriptor (DataInterpolationDescriptor.DEFAULT
).
To indicate specific base period and/or data interpolation descriptor, use getFeedData(ITailoredFeedDescriptor, int)
.instrument
- instrument of P&FofferSide
- bid or ask side of P&FboxSize
- box size of the P&FreversalAmount
- reversal amount of the P&Fshift
- number of P&F back in time staring from current P&F. 1 - previous P&F, 2 - current P&F minus 2 bars and so onJFException
- when shift value is negative or instrument is not active (not opened in platform)@Deprecated List<IPointAndFigure> getPointAndFigures(Instrument instrument, OfferSide offerSide, PriceRange boxSize, ReversalAmount reversalAmount, long from, long to) throws JFException
getFeedData(ITailoredFeedDescriptor, long, long)
.IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone and default
data interpolation descriptor (DataInterpolationDescriptor.DEFAULT
).
To indicate specific base period and/or data interpolation descriptor, use getFeedData(ITailoredFeedDescriptor, long, long)
.
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
If the requested period includes the bar that is not fully formed yet (in-progress bar), then it is included in result too
Subscribe to Point and Figure live notification first, before call this method.instrument
- of P&FsofferSide
- offer side of P&FsboxSize
- box size of P&FsreversalAmount
- reversal amount of P&Fsfrom
- start time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the first loaded barto
- end time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the last loaded barJFException
- when incorrect time interval is passed or some error occurs when loading data@Deprecated List<IPointAndFigure> getPointAndFigures(Instrument instrument, OfferSide offerSide, PriceRange boxSize, ReversalAmount reversalAmount, int numberOfBarsBefore, long time, int numberOfBarsAfter) throws JFException
getFeedData(ITailoredFeedDescriptor, int, long, int)
.IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone and default
data interpolation descriptor (DataInterpolationDescriptor.DEFAULT
).
To indicate specific base period and/or data interpolation descriptor, use getFeedData(ITailoredFeedDescriptor, int, long, int)
.
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
.
If the requested period includes the bar that is not fully formed yet (in-progress bar), then it is included in result too
Subscribe to Point and Figure live notification first, before call this method.instrument
- instrument of the P&FsofferSide
- offer side of the P&FsboxSize
- price range of the P&FsnumberOfBarsBefore
- how much bars to load before and including bar with time specified in time
parametertime
- time of the last bar in period specified in numberOfBarsBefore
parameter, or
time of the first bar in period specified with numberOfBarsAfter
parameter if numberOfBarsBefore
is 0, or
time of the candle prior to first candle in period specified with numberOfBarsAfter
if numberOfBarsBefore
is > 0numberOfBarsAfter
- how much bars to load after (not including) bar with time specified in time
parameterJFException
- when desired data amount is negative, etc; or some error occurs when loading data@Deprecated void readPointAndFigures(Instrument instrument, OfferSide offerSide, PriceRange boxSize, ReversalAmount reversalAmount, long from, long to, IPointAndFigureFeedListener listener, LoadingProgressListener loadingProgress) throws JFException
readFeedData(ITailoredFeedDescriptor, long, long, ITailoredFeedListener, LoadingProgressListener)
.listener
. 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.
This method uses default base period IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone and default
data interpolation descriptor (DataInterpolationDescriptor.DEFAULT
).
instrument
- of P&FsofferSide
- offer side of P&FsboxSize
- box size of P&FsreversalAmount
- reversal amount of P&Fsfrom
- start time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the first loaded barto
- end time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the last loaded barlistener
- receives data about requested barsloadingProgress
- used to control loading progressJFException
- when incorrect time interval is passed or some error occurs when loading data@Deprecated void readPointAndFigures(Instrument instrument, OfferSide offerSide, PriceRange boxSize, ReversalAmount reversalAmount, int numberOfBarsBefore, long time, int numberOfBarsAfter, IPointAndFigureFeedListener listener, LoadingProgressListener loadingProgress) throws JFException
readFeedData(ITailoredFeedDescriptor, int, long, int, ITailoredFeedListener, LoadingProgressListener)
.listener
. 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
This method uses default base period IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone and default
data interpolation descriptor (DataInterpolationDescriptor.DEFAULT
).
instrument
- of P&FsofferSide
- offer side of P&FsboxSize
- box size of P&FsreversalAmount
- reversal amount of P&FsnumberOfBarsBefore
- how much bars to load before and including bar with time specified in time
parametertime
- time of the last bar in period specified in numberOfBarsBefore
parameter, or
time of the first bar in period specified with numberOfBarsAfter
parameter if numberOfBarsBefore
is 0, or
time of the candle prior to first candle in period specified with numberOfBarsAfter
if numberOfBarsBefore
is > 0numberOfBarsAfter
- how much bars to load after (not including) bar with time specified in time
parameterlistener
- receives data about requested barsloadingProgress
- used to control loading progressJFException
- when incorrect time interval is passed or some error occurs when loading data@Deprecated ITickBar getTickBar(Instrument instrument, OfferSide offerSide, TickBarSize tickBarSize, int shift) throws JFException
getFeedData(ITailoredFeedDescriptor, int)
.shift
parameter, 0 - current bar, 1 - previous bar (last formed bar) If there is no bar loaded at that
position, then function returns null. This method uses default base period IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone.
To indicate specific base period, use getFeedData(ITailoredFeedDescriptor, int)
.instrument
- instrument of the tick barofferSide
- bid or ask side of the tick bartickBarSize
- tick bar size of the tick barshift
- number of tick bar back in time staring from current tick bar. 1 - previous tick bar, 2 - current tick bar minus 2 bars and so onJFException
- when shift value is negative or instrument is not active (not opened in platform)@Deprecated List<ITickBar> getTickBars(Instrument instrument, OfferSide offerSide, TickBarSize tickBarSize, long from, long to) throws JFException
getFeedData(ITailoredFeedDescriptor, long, long)
.IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone.
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
If the requested period includes the bar that is not fully formed yet (in-progress bar), then it is included in result too
Subscribe to Tick Bar live notification first, before call this method.instrument
- of Tick BarsofferSide
- offer side of Tick BarstickBarSize
- tick bar size of Tick Barsfrom
- start time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the first loaded barto
- end time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the last loaded barJFException
- when incorrect time interval is passed or some error occurs when loading data@Deprecated List<ITickBar> getTickBars(Instrument instrument, OfferSide offerSide, TickBarSize tickBarSize, int numberOfBarsBefore, long time, int numberOfBarsAfter) throws JFException
getFeedData(ITailoredFeedDescriptor, int, long, int)
.IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone.
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
.
If the requested period includes the bar that is not fully formed yet (in-progress bar), then it is included in result too
Subscribe to Tick Bar live notification first, before call this method.instrument
- instrument of the tick barsofferSide
- offer side of the tick barstickBarSize
- tick bar size of the tick barsnumberOfBarsBefore
- how much bars to load before and including bar with time specified in time
parametertime
- time of the last bar in period specified in numberOfBarsBefore
parameter, or
time of the first bar in period specified with numberOfBarsAfter
parameter if numberOfBarsBefore
is 0, or
time of the candle prior to first candle in period specified with numberOfBarsAfter
if numberOfBarsBefore
is > 0numberOfBarsAfter
- how much bars to load after (not including) bar with time specified in time
parameterJFException
- when desired data amount is negative, etc; or some error occurs when loading data@Deprecated void readTickBars(Instrument instrument, OfferSide offerSide, TickBarSize tickBarSize, long from, long to, ITickBarFeedListener listener, LoadingProgressListener loadingProgress) throws JFException
readFeedData(ITailoredFeedDescriptor, long, long, ITailoredFeedListener, LoadingProgressListener)
.listener
. 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
This method uses default base period IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone.
instrument
- of Tick BarsofferSide
- offer side of Tick BarstickBarSize
- tick bar size of Tick Barsfrom
- start time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the first loaded barto
- end time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the last loaded barlistener
- receives data about requested barsloadingProgress
- used to control loading progressJFException
- when incorrect time interval is passed or some error occurs when loading data@Deprecated void readTickBars(Instrument instrument, OfferSide offerSide, TickBarSize tickBarSize, int numberOfBarsBefore, long time, int numberOfBarsAfter, ITickBarFeedListener listener, LoadingProgressListener loadingProgress) throws JFException
readFeedData(ITailoredFeedDescriptor, int, long, int, ITailoredFeedListener, LoadingProgressListener)
.listener
. 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
This method uses default base period IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone.
instrument
- of Tick BarsofferSide
- offer side of Tick BarstickBarSize
- tick bar size of Tick BarsnumberOfBarsBefore
- how much bars to load before and including bar with time specified in time
parametertime
- time of the last bar in period specified in numberOfBarsBefore
parameter, or
time of the first bar in period specified with numberOfBarsAfter
parameter if numberOfBarsBefore
is 0, or
time of the candle prior to first candle in period specified with numberOfBarsAfter
if numberOfBarsBefore
is > 0numberOfBarsAfter
- how much bars to load after (not including) bar with time specified in time
parameterlistener
- receives data about requested barsloadingProgress
- used to control loading progressJFException
- when incorrect time interval is passed or some error occurs when loading data@Deprecated List<IRangeBar> getRangeBars(Instrument instrument, OfferSide offerSide, PriceRange priceRange, long from, long to) throws JFException
getFeedData(ITailoredFeedDescriptor, long, long)
.IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone and default
data interpolation descriptor (DataInterpolationDescriptor.DEFAULT
).
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
If the requested period includes the bar that is not fully formed yet (in-progress bar), then it is included in result too
Subscribe to Range Bar live notification first, before call this method.instrument
- of Range BarsofferSide
- offer side of Range BarspriceRange
- price range of Range Barsfrom
- start time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the first loaded barto
- end time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the last loaded barJFException
- when incorrect time interval is passed or some error occurs when loading data@Deprecated List<IRangeBar> getRangeBars(Instrument instrument, OfferSide offerSide, PriceRange priceRange, int numberOfBarsBefore, long time, int numberOfBarsAfter) throws JFException
getFeedData(ITailoredFeedDescriptor, int, long, int)
.IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone and default
data interpolation descriptor (DataInterpolationDescriptor.DEFAULT
).
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
.
If the requested period includes the bar that is not fully formed yet (in-progress bar), then it is included in result too
Subscribe to Range Bar live notification first, before call this method.instrument
- instrument of the Range barsofferSide
- offer side of the Range barspriceRange
- price range of the Range barsnumberOfBarsBefore
- how much bars to load before and including bar with time specified in time
parametertime
- time of the last bar in period specified in numberOfBarsBefore
parameter, or
time of the first bar in period specified with numberOfBarsAfter
parameter if numberOfBarsBefore
is 0, or
time of the candle prior to first candle in period specified with numberOfBarsAfter
if numberOfBarsBefore
is > 0numberOfBarsAfter
- how much bars to load after (not including) bar with time specified in time
parameterJFException
- when desired data amount is negative, etc; or some error occurs when loading data@Deprecated void readRangeBars(Instrument instrument, OfferSide offerSide, PriceRange priceRange, long from, long to, IRangeBarFeedListener listener, LoadingProgressListener loadingProgress) throws JFException
readFeedData(ITailoredFeedDescriptor, long, long, ITailoredFeedListener, LoadingProgressListener)
.listener
. 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
This method uses default base period IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone and default
data interpolation descriptor (DataInterpolationDescriptor.DEFAULT
).
instrument
- of Range BarsofferSide
- offer side of Range BarspriceRange
- price range of Range Barsfrom
- start time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the first loaded barto
- end time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the last loaded barlistener
- receives data about requested barsloadingProgress
- used to control loading progressJFException
- when incorrect time interval is passed or some error occurs when loading data@Deprecated void readRangeBars(Instrument instrument, OfferSide offerSide, PriceRange priceRange, int numberOfBarsBefore, long time, int numberOfBarsAfter, IRangeBarFeedListener listener, LoadingProgressListener loadingProgress) throws JFException
readFeedData(ITailoredFeedDescriptor, int, long, int, ITailoredFeedListener, LoadingProgressListener)
.listener
. 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
This method uses default base period IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone and default
data interpolation descriptor (DataInterpolationDescriptor.DEFAULT
).
instrument
- of Range BarsofferSide
- offer side of Range BarspriceRange
- price range of Range BarsnumberOfBarsBefore
- how much bars to load before and including bar with time specified in time
parametertime
- time of the last bar in period specified in numberOfBarsBefore
parameter, or
time of the first bar in period specified with numberOfBarsAfter
parameter if numberOfBarsBefore
is 0, or
time of the candle prior to first candle in period specified with numberOfBarsAfter
if numberOfBarsBefore
is > 0numberOfBarsAfter
- how much bars to load after (not including) bar with time specified in time
parameterlistener
- receives data about requested barsloadingProgress
- used to control loading progressJFException
- when incorrect time interval is passed or some error occurs when loading data@Deprecated IRangeBar getRangeBar(Instrument instrument, OfferSide offerSide, PriceRange priceRange, int shift) throws JFException
getFeedData(ITailoredFeedDescriptor, int)
.shift
parameter, 0 - current bar, 1 - previous bar (last formed bar) If there is no bar loaded at that
position, then function returns null. This method uses default base period IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone and default
data interpolation descriptor (DataInterpolationDescriptor.DEFAULT
).instrument
- instrument of the range barofferSide
- bid or ask side of the range barpriceRange
- price range of the range barshift
- number of range bar back in time staring from current range bar. 1 - previous range bar, 2 - current range bar minus 2 bars and so onJFException
- when shift value is negative or instrument is not active (not opened in platform)@Deprecated IRenkoBar getRenkoBar(Instrument instrument, OfferSide offerSide, PriceRange brickSize, int shift) throws JFException
getFeedData(ITailoredFeedDescriptor, int)
.shift
parameter, 0 - current bar, 1 - previous bar (last formed bar) If there is no bar loaded at that
position, then function returns null.
This method uses default base period IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone, default renko session (Period.ONE_MIN
) and
default price point (RenkoCreationPoint.CLOSE
).
instrument
- instrument of the Renko barofferSide
- bid or ask side of the Renko barbrickSize
- price range of the Renko barshift
- number of bar back in time staring from current bar. 1 - previous bar, 2 - current bar minus 2 bars and so onJFException
- when shift value is negative or instrument is not active (not opened in platform)@Deprecated List<IRenkoBar> getRenkoBars(Instrument instrument, OfferSide offerSide, PriceRange brickSize, long from, long to) throws JFException
getFeedData(ITailoredFeedDescriptor, long, long)
.OutOfMemoryException
If the requested period includes the bar that is not fully formed yet (in-progress bar), then it is included in result too
This method uses default base period IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone, default renko session (Period.ONE_MIN
) and
default price point (RenkoCreationPoint.CLOSE
).
instrument
- of Renko BarsofferSide
- offer side of Renko BarsbrickSize
- price range of Renko Barsfrom
- start time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the first loaded barto
- end time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the last loaded barJFException
- when incorrect time interval is passed or some error occurs when loading data@Deprecated List<IRenkoBar> getRenkoBars(Instrument instrument, OfferSide offerSide, PriceRange brickSize, int numberOfBarsBefore, long time, int numberOfBarsAfter) throws JFException
getFeedData(ITailoredFeedDescriptor, int, long, int)
.OutOfMemoryException
.
If the requested period includes the bar that is not fully formed yet (in-progress bar), then it is included in result too
This method uses default base period IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone, default renko session (Period.ONE_MIN
) and
default price point (RenkoCreationPoint.CLOSE
).
instrument
- instrument of the Renko barsofferSide
- offer side of the Renko barsbrickSize
- price range of the Renko barsnumberOfBarsBefore
- how much bars to load before and including bar with time specified in time
parametertime
- time of the last bar in period specified in numberOfBarsBefore
parameter, or
time of the first bar in period specified with numberOfBarsAfter
parameter if numberOfBarsBefore
is 0, or
time of the candle prior to first candle in period specified with numberOfBarsAfter
if numberOfBarsBefore
is > 0numberOfBarsAfter
- how much bars to load after (not including) bar with time specified in time
parameterJFException
- when desired data amount is negative, etc; or some error occurs when loading data@Deprecated void readRenkoBars(Instrument instrument, OfferSide offerSide, PriceRange brickSize, long from, long to, IRenkoBarFeedListener listener, LoadingProgressListener loadingProgress) throws JFException
readFeedData(ITailoredFeedDescriptor, long, long, ITailoredFeedListener, LoadingProgressListener)
.listener
. 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
This method uses default base period IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone, default renko session (Period.ONE_MIN
) and
default price point (RenkoCreationPoint.CLOSE
).
instrument
- of Renko BarsofferSide
- offer side of Renko BarsbrickSize
- price range of Renko Barsfrom
- start time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the first loaded barto
- end time of the time interval for which bars should be loaded. This time is included in interval [start; end] of the last loaded barlistener
- receives data about requested barsloadingProgress
- used to control loading progressJFException
- when incorrect time interval is passed or some error occurs when loading data@Deprecated void readRenkoBars(Instrument instrument, OfferSide offerSide, PriceRange brickSize, int numberOfBarsBefore, long time, int numberOfBarsAfter, IRenkoBarFeedListener listener, LoadingProgressListener loadingProgress) throws JFException
readFeedData(ITailoredFeedDescriptor, int, long, int, ITailoredFeedListener, LoadingProgressListener)
.listener
. 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
This method uses default base period IFeedDescriptor.DEFAULT_BASE_PERIOD
, which has EET time zone, default renko session (Period.ONE_MIN
) and
default price point (RenkoCreationPoint.CLOSE
).
instrument
- of Renko BarsofferSide
- offer side of Renko BarsbrickSize
- price range of Renko BarsnumberOfBarsBefore
- how much bars to load before and including bar with time specified in time
parametertime
- time of the last bar in period specified in numberOfBarsBefore
parameter, or
time of the first bar in period specified with numberOfBarsAfter
parameter if numberOfBarsBefore
is 0, or
time of the candle prior to first candle in period specified with numberOfBarsAfter
if numberOfBarsBefore
is > 0numberOfBarsAfter
- how much bars to load after (not including) bar with time specified in time
parameterlistener
- receives data about requested barsloadingProgress
- used to control loading progressJFException
- when incorrect time interval is passed or some error occurs when loading dataCopyright © 2016. All rights reserved.