public interface JFUtils
Modifier and Type | Method and Description |
---|---|
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,
Currency currency)
Deprecated.
use
convertPipToCurrency(Instrument, ICurrency) instead |
double |
convertPipToCurrency(Instrument instrument,
Currency currency,
OfferSide offerSide)
Deprecated.
|
double |
convertPipToCurrency(Instrument instrument,
ICurrency currency)
Converts the cost of one pip for particular instrument to specified currency.
|
double |
convertPipToCurrency(Instrument instrument,
ICurrency currency,
OfferSide offerSide)
Converts the cost of one pip for particular instrument to specified currency
|
BigDecimal |
getAmountPerContract(Instrument instrument)
Obtains the "amount per contract" information for specified
Instrument |
BigDecimal |
getMinTradeAmount(Instrument instrument)
Obtains the "minimum trade amount" information for specified
Instrument |
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. |
Future<IEmailResponse> |
sendMail(String to,
String subject,
String content)
Sends an e-mail to the given addressee.
|
void |
sendMail(String smtpServer,
String from,
String to,
String subject,
String content)
Deprecated.
please use
sendMail(String, String, String) |
double convert(Instrument instrumentFrom, Instrument instrumentTo, double amount) throws JFException
OfferSide.ASK
and OfferSide.BID
) gets used.instrumentFrom
- the instrument from which the amount to be convertedinstrumentTo
- the instrument to which the amount to be convertedamount
- the amount in instrumentFromJFException
- 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)double convert(Instrument instrumentFrom, Instrument instrumentTo, double amount, int decimalPlaces) throws JFException
OfferSide.ASK
and OfferSide.BID
) gets used.instrumentFrom
- the instrument from which the amount to be convertedinstrumentTo
- the instrument to which the amount to be convertedamount
- the amount in instrumentFromdecimalPlaces
- decimal places of the returned resultJFException
- 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)double convert(Instrument instrumentFrom, Instrument instrumentTo, double amount, int decimalPlaces, OfferSide offerSide) throws JFException
instrumentFrom
- the instrument from which the amount to be convertedinstrumentTo
- the instrument to which the amount to be convertedamount
- the amount in instrumentFromdecimalPlaces
- decimal places of the returned resultofferSide
- the price used for conversion - BID or ASK. If the value is null, the median price between BID and ASK is usedJFException
- 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)@Deprecated double convertPipToCurrency(Instrument instrument, Currency currency) throws JFException
convertPipToCurrency(Instrument, ICurrency)
insteadJFException
double convertPipToCurrency(Instrument instrument, ICurrency currency) throws JFException
OfferSide.ASK
and OfferSide.BID
) gets used.instrument
- Instrument
which pip value will be convertedcurrency
- the target currency of conversionInstrument
's pip value in specified currency.JFException
@Deprecated double convertPipToCurrency(Instrument instrument, Currency currency, OfferSide offerSide) throws JFException
convertPipToCurrency(Instrument, ICurrency, OfferSide)
insteadJFException
double convertPipToCurrency(Instrument instrument, ICurrency currency, OfferSide offerSide) throws JFException
instrument
- Instrument
which pip value will be convertedcurrency
- the target currency of conversionofferSide
- the price used for conversion - BID or ASK. If the value is null, the median price between BID and ASK is usedInstrument
's pip value in specified currency.JFException
long getTimeForNPeriodsBack(Period period, long to, int numberOfPeriods) throws JFException
(numberOfPeriods - 1)
back in time to the time period that
includes time specified in to
parameter.period
- Period
time period (Tick period is not supported).to
- time included to the last period unitnumberOfPeriods
- number of time periods back(numberOfPeriods - 1)
backward from the to
time point)JFException
- when period is not supportedIDataService.getFXSentimentIndex(ICurrency, long)
,
IDataService.getFXSentimentIndex(Instrument, long)
,
IHistory.getTimeForNBarsBack(Period, long, int)
,
IHistory.getTimeForNBarsForward(Period, long, int)
long getTimeForNPeriodsForward(Period period, long from, int numberOfPeriods) throws JFException
(numberOfPeriods - 1)
in the future to the time period that
includes time specified in from
parameter.period
- Period
time period (Tick period is not supported).from
- time included to the first period unitnumberOfPeriods
- number of time periods forward(numberOfPeriods - 1)
forward from the from
time point)JFException
- when period is not supportedIDataService.getFXSentimentIndex(ICurrency, long)
,
IDataService.getFXSentimentIndex(Instrument, long)
,
IHistory.getTimeForNBarsBack(Period, long, int)
,
IHistory.getTimeForNBarsForward(Period, long, int)
@Deprecated void sendMail(String smtpServer, String from, String to, String subject, String content) throws JFException
sendMail(String, String, String)
JFException
Future<IEmailResponse> sendMail(String to, String subject, String content) throws JFException
The following restrictions apply:
JFException
gets thrown,
if on server side - find the details in the returned IEmailResponse
.
//sending an e-mail without processing the server response context.getUtils().sendMail("[email protected]", "Test mail subject", "Test mail html contents \n Bye.") //sending an e-mail and processing the server response try { // Note: not to hold up the strategy execution, consider calling the sending logic from another thread Futurefuture = utils.sendMail("[email protected]", "Test mail subject", "Test mail \n Bye."); console.getOut().println("Waiting on response"); IEmailResponse response = future.get(30, TimeUnit.SECONDS); if (response.isError()) { console.getErr().println(response); } else { console.getOut().println("e-mail successfully sent!"); } } catch (Exception e) { e.printStackTrace(console.getErr()); }
to
- receiver's addresssubject
- e-mail subjectcontent
- e-mail content as html textFuture
of the e-mail response IEmailResponse
JFException
- when:
BigDecimal getAmountPerContract(Instrument instrument)
Instrument
instrument
- Instrument
which amount per contract information should be obtainedBigDecimal getMinTradeAmount(Instrument instrument)
Instrument
instrument
- Instrument
which minimum trade amount information should be obtainedCopyright © 2016. All rights reserved.