public interface JFUtils
Modifier and Type | Method and Description |
---|---|
double |
convert(IFinancialInstrument instrumentFrom,
IFinancialInstrument instrumentTo,
double amount)
Deprecated.
|
double |
convert(IFinancialInstrument instrumentFrom,
IFinancialInstrument instrumentTo,
double amount,
int decimalPlaces)
Deprecated.
|
double |
convert(IFinancialInstrument instrumentFrom,
IFinancialInstrument instrumentTo,
double amount,
int decimalPlaces,
OfferSide offerSide)
Deprecated.
|
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(IFinancialInstrument financialInstrument,
ICurrency currency)
Deprecated.
|
double |
convertPipToCurrency(IFinancialInstrument financialInstrument,
ICurrency currency,
OfferSide offerSide)
Deprecated.
|
double |
convertPipToCurrency(Instrument instrument,
java.util.Currency currency)
Deprecated.
use
convertPipToCurrency(Instrument, ICurrency) instead |
double |
convertPipToCurrency(Instrument instrument,
java.util.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
|
java.math.BigDecimal |
convertProfitLoss(java.math.BigDecimal profitLoss,
ICurrency sourceCurrency,
ICurrency targetCurrency,
int scale)
Converts profit/loss value from one currency to another.
|
double |
convertProfitLoss(double profitLoss,
ICurrency sourceCurrency,
ICurrency targetCurrency,
int scale)
Converts profit/loss value from one currency to another.
|
java.math.BigDecimal |
getAmountPerContract(Instrument instrument)
Deprecated.
|
java.lang.String |
getFormattedAmount(java.math.BigDecimal amount,
Instrument instrument)
Returns formatted amount value with units corresponding to instrument type.
|
java.text.DecimalFormat |
getLocalizedDecimalFormat()
Returns localized number format corresponding to system settings.
|
java.math.BigDecimal |
getMinTradeAmount(Instrument instrument)
Deprecated.
use
Instrument.getMinTradeAmount() which returns amount in units. |
double |
getRate(ICurrency from,
ICurrency to)
Gets exchange rate between two currencies.
|
double |
getRate(ICurrency from,
ICurrency to,
OfferSide offerSide)
Gets exchange rate between two currencies.
|
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. |
java.util.concurrent.Future<IEmailResponse> |
sendMail(java.lang.String to,
java.lang.String subject,
java.lang.String content)
Sends an e-mail to the given addressee.
|
void |
sendMail(java.lang.String smtpServer,
java.lang.String from,
java.lang.String to,
java.lang.String subject,
java.lang.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)double getRate(ICurrency from, ICurrency to) throws JFException
from
- source the target currency of conversionto
- the target currency of conversionJFException
- if an error occurreddouble getRate(ICurrency from, ICurrency to, OfferSide offerSide) throws JFException
from
- source the target currency of conversionto
- 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 usedJFException
- if an error occurreddouble 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
- if an error occurreddouble 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
- if an error occurreddouble convertProfitLoss(double profitLoss, ICurrency sourceCurrency, ICurrency targetCurrency, int scale)
profitLoss
- profit/loss valuesourceCurrency
- source currencytargetCurrency
- target currencyscale
- calculation precisionjava.math.BigDecimal convertProfitLoss(java.math.BigDecimal profitLoss, ICurrency sourceCurrency, ICurrency targetCurrency, int scale)
profitLoss
- profit/loss valuesourceCurrency
- source currencytargetCurrency
- target currencyscale
- calculation precisionjava.text.DecimalFormat getLocalizedDecimalFormat()
java.lang.String getFormattedAmount(java.math.BigDecimal amount, Instrument instrument)
amount
- amount valueinstrument
- instrumentlong 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)
java.util.concurrent.Future<IEmailResponse> sendMail(java.lang.String to, java.lang.String subject, java.lang.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 <b>mail</b> 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
Future<IEmailResponse> future = utils.sendMail("[email protected]", "Test mail subject", "Test <b>mail</b> \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:
@Deprecated java.math.BigDecimal getAmountPerContract(Instrument instrument)
Instrument.getAmountPerContract()
Instrument
instrument
- Instrument
which amount per contract information should be obtained@Deprecated java.math.BigDecimal getMinTradeAmount(Instrument instrument)
Instrument.getMinTradeAmount()
which returns amount in units.Instrument
instrument
- Instrument
which minimum trade amount information should be obtained@Deprecated double convert(IFinancialInstrument instrumentFrom, IFinancialInstrument 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)@Deprecated double convert(IFinancialInstrument instrumentFrom, IFinancialInstrument 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)@Deprecated double convert(IFinancialInstrument instrumentFrom, IFinancialInstrument 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, java.util.Currency currency) throws JFException
convertPipToCurrency(Instrument, ICurrency)
insteadOfferSide.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
- if an error occurred@Deprecated double convertPipToCurrency(IFinancialInstrument financialInstrument, ICurrency currency) throws JFException
OfferSide.ASK
and OfferSide.BID
) gets used.financialInstrument
- IFinancialInstrument
which pip value will be convertedcurrency
- the target currency of conversionInstrument
's pip value in specified currency.JFException
- if an error occurred@Deprecated double convertPipToCurrency(Instrument instrument, java.util.Currency currency, OfferSide offerSide) throws JFException
convertPipToCurrency(Instrument, ICurrency, OfferSide)
insteadinstrument
- 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
- if an error occurred@Deprecated double convertPipToCurrency(IFinancialInstrument financialInstrument, ICurrency currency, OfferSide offerSide) throws JFException
financialInstrument
- IFinancialInstrument
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
- if an error occurred@Deprecated void sendMail(java.lang.String smtpServer, java.lang.String from, java.lang.String to, java.lang.String subject, java.lang.String content) throws JFException
sendMail(String, String, String)
smtpServer
- SMTP serverfrom
- sender addressto
- receiver's addresssubject
- e-mail subjectcontent
- e-mail content as html textJFException
- when:
Copyright © 2024. All rights reserved.