com.dukascopy.api
Interface JFUtils


public interface JFUtils


Method Summary
 double convert(Instrument instrumentFrom, Instrument instrumentTo, double amount)
          Converts the amount from one instrument to another with precision of 0.1 instrumentTo pips.
 double convert(Instrument instrumentFrom, Instrument instrumentTo, double amount, int decimalPlaces)
          Converts the amount from one instrument to another.
 double convert(Instrument instrumentFrom, Instrument instrumentTo, double amount, int decimalPlaces, OfferSide offerSide)
          Converts the amount from one instrument to another.
 double convertPipToCurrency(Instrument instrument, java.util.Currency currency)
          Converts the cost of one pip for particular instrument to specified currency.
 double convertPipToCurrency(Instrument instrument, java.util.Currency currency, OfferSide offerSide)
          Converts the cost of one pip for particular instrument to specified currency
 long getTimeForNPeriodsBack(Period period, long to, int numberOfPeriods)
          Returns starting time point of the time period that is (numberOfPeriods - 1) back in time to the time period that includes time specified in to parameter.
 long getTimeForNPeriodsForward(Period period, long from, int numberOfPeriods)
          Returns starting time point of the time period that is + (numberOfPeriods - 1) in the future to the time period that includes time specified in from parameter.
 

Method Detail

convert

double convert(Instrument instrumentFrom,
               Instrument instrumentTo,
               double amount)
               throws JFException
Converts the amount from one instrument to another with precision of 0.1 instrumentTo pips. For conversion median price (between OfferSide.ASK and OfferSide.BID) gets used.

Parameters:
instrumentFrom - the instrument from which the amount to be converted
instrumentTo - the instrument to which the amount to be converted
amount - the amount in instrumentFrom
Throws:
JFException - if instrumentFrom or instrumentTo are null or not subscribed, if amount is 0 or less, if there is no active subscribed inter-instrument that could be used in conversion (e.g. for conversion between NZD/CHF and GBP/USD none of the instruments GBP/NZD, NZD/USD, GBP/CHF, USD/CHF are subscribed and active)

convert

double convert(Instrument instrumentFrom,
               Instrument instrumentTo,
               double amount,
               int decimalPlaces)
               throws JFException
Converts the amount from one instrument to another. For conversion median price (between OfferSide.ASK and OfferSide.BID) gets used.

Parameters:
instrumentFrom - the instrument from which the amount to be converted
instrumentTo - the instrument to which the amount to be converted
amount - the amount in instrumentFrom
decimalPlaces - decimal places of the returned result
Throws:
JFException - if instrumentFrom or instrumentTo are null or not subscribed, if amount is 0 or less, if there is no active subscribed inter-instrument that could be used in conversion (e.g. for conversion between NZD/CHF and GBP/USD none of the instruments GBP/NZD, NZD/USD, GBP/CHF, USD/CHF are subscribed and active)

convert

double convert(Instrument instrumentFrom,
               Instrument instrumentTo,
               double amount,
               int decimalPlaces,
               OfferSide offerSide)
               throws JFException
Converts the amount from one instrument to another.

Parameters:
instrumentFrom - the instrument from which the amount to be converted
instrumentTo - the instrument to which the amount to be converted
amount - the amount in instrumentFrom
decimalPlaces - decimal places of the returned result
offerSide - the price used for conversion - BID or ASK. If the value is null, the median price between BID and ASK is used
Throws:
JFException - if instrumentFrom or instrumentTo are null or not subscribed, if amount is 0 or less, if there is no active subscribed inter-instrument that could be used in conversion (e.g. for conversion between NZD/CHF and GBP/USD none of the instruments GBP/NZD, NZD/USD, GBP/CHF, USD/CHF are subscribed and active)

convertPipToCurrency

double convertPipToCurrency(Instrument instrument,
                            java.util.Currency currency)
                            throws JFException
Converts the cost of one pip for particular instrument to specified currency. For conversion median price (between OfferSide.ASK and OfferSide.BID) gets used.

Parameters:
instrument - Instrument which pip value will be converted
currency - the target currency of conversion
Returns:
the price of Instrument's pip value in specified currency.
NOTE: the result price is unrounded, i.e. result has unlimited precision (as many digits as are required)
Throws:
JFException

convertPipToCurrency

double convertPipToCurrency(Instrument instrument,
                            java.util.Currency currency,
                            OfferSide offerSide)
                            throws JFException
Converts the cost of one pip for particular instrument to specified currency

Parameters:
instrument - Instrument which pip value will be converted
currency - the target currency of conversion
offerSide - the price used for conversion - BID or ASK. If the value is null, the median price between BID and ASK is used
Returns:
the price of Instrument's pip value in specified currency.
NOTE: the result price is unrounded, i.e. result has unlimited precision (as many digits as are required)
Throws:
JFException

getTimeForNPeriodsBack

long getTimeForNPeriodsBack(Period period,
                            long to,
                            int numberOfPeriods)
                            throws JFException
Returns starting time point of the time period that is (numberOfPeriods - 1) back in time to the time period that includes time specified in to parameter.

Parameters:
period - Period time period (Tick period is not supported).
to - time included to the last period unit
numberOfPeriods - number of time periods back
Returns:
starting time of the first period unit ((numberOfPeriods - 1) backward from the to time point)
Throws:
JFException - when period is not supported
See Also:
IDataService.getFXSentimentIndex(Currency, long), IDataService.getFXSentimentIndex(Instrument, long), IHistory.getTimeForNBarsBack(Period, long, int), IHistory.getTimeForNBarsForward(Period, long, int)

getTimeForNPeriodsForward

long getTimeForNPeriodsForward(Period period,
                               long from,
                               int numberOfPeriods)
                               throws JFException
Returns starting time point of the time period that is + (numberOfPeriods - 1) in the future to the time period that includes time specified in from parameter.

Parameters:
period - Period time period (Tick period is not supported).
from - time included to the first period unit
numberOfPeriods - number of time periods forward
Returns:
starting time of the last period unit ((numberOfPeriods - 1) forward from the from time point)
Throws:
JFException - when period is not supported
See Also:
IDataService.getFXSentimentIndex(Currency, long), IDataService.getFXSentimentIndex(Instrument, long), IHistory.getTimeForNBarsBack(Period, long, int), IHistory.getTimeForNBarsForward(Period, long, int)