public class FxRateCalculatorBuilder extends Object
final FxRateCalculatorBuilder builder = new FxRateCalculatorBuilder() // .addRateSnapshot(new FxRateImpl(CurrencyPair.of("EUR", "USD"), null, true, BigDecimalUtil.bd("1.6"), BigDecimalUtil.bd("1.61")))// .addRateSnapshot(new FxRateImpl(CurrencyPair.of("GBP", "CHF"), null, true, BigDecimalUtil.bd("2.1702"), BigDecimalUtil.bd("2.1707")))// .addRateSnapshot(new FxRateImpl(CurrencyPair.of("EUR", "GBP"), null, true, BigDecimalUtil.bd("0.7374"), BigDecimalUtil.bd("0.7379")))// .orderedCurrenciesForCross(Lists.newArrayList("GBP", "USD")) // Use GBP as the first cross ccy, if that doesn't work use USD .majorCurrencyRanking(StandardMajorCurrencyRanking.getdefault()) .precisionForFxRate(6) .precisionForInverseFxRate(12) .currencyProvider(new JdkCurrencyProvider()) // use the JDK currency .cacheResults(true) // only calculate a cross Fx once, cache for subsequent requests .cacheBaseRates(true); // if a BaseFxRateRateProvider is used, cache the rates instead of calling again for same currency pair
Constructor and Description |
---|
FxRateCalculatorBuilder() |
Modifier and Type | Method and Description |
---|---|
FxRateCalculatorBuilder |
addRateSnapshot(FxRate rate)
Snapshot of FxRate, typically they are the Base FX Rates (e.g.
|
FxRateCalculatorBuilder |
askRounding(int askRounding)
Rounding for BID calculations.
|
FxRateCalculatorBuilder |
baseFxRateProvider(BaseFxRateProvider baseFxRateProvider)
If it is important for you to get the latest rates every time, you can provide a rate provider using this interface.
|
FxRateCalculatorBuilder |
bidRounding(int bidRounding)
Rounding for BID calculations.
|
FxRateCalculatorBuilder |
cacheBaseRates(boolean cacheBaseRates)
If using the baseFxRateProvider, should the rate be cached in the calculator, defaulted to true.
|
FxRateCalculatorBuilder |
cacheResults(boolean cacheResults)
Once a new rate has been calculated, should it be cached for any further request?
|
void |
checkValid()
Check if the builder is valid i.e.
|
FxRateCalculatorBuilder |
currencyProvider(CurrencyProvider currencyProvider)
The interface to determine Currency details.
|
int |
getAskRounding() |
BaseFxRateProvider |
getBaseFxRateProvider() |
int |
getBidRounding() |
CurrencyProvider |
getCurrencyProvider() |
MajorCurrencyRanking |
getMajorCurrencyRanking() |
List<String> |
getOrderedCurrenciesForCross() |
int |
getPrecisionForFxRate() |
int |
getPrecisionForInverseFxRate() |
Map<CurrencyPair,FxRate> |
getRatesSnapshot() |
boolean |
isCacheBaseRates() |
boolean |
isCacheResults() |
FxRateCalculatorBuilder |
majorCurrencyRanking(MajorCurrencyRanking majorCurrencyRanking)
The interface to determine which currency is major, defaults to StandardMajorCurrencyRanking.
|
FxRateCalculatorBuilder |
orderedCurrenciesForCross(List<String> orderedCurrenciesForCross)
If the rate required from the calculator is not immediately available, use a cross currency to calculate it; this
gives you the opportunity to select which currencies to use in which order.
|
FxRateCalculatorBuilder |
precisionForFxRate(int precisionForFxRate)
Number of decimal places to use on a rate, defaulted to 6.
|
FxRateCalculatorBuilder |
precisionForInverseFxRate(int precisionForInverseFxRate)
Number of decimal places to use for a calculation involving an inversed rate, defaulted to 12
|
FxRateCalculatorBuilder |
ratesSnapshot(Collection<FxRate> rates)
Snapshot of FxRate, typically they are the Base FX Rates (e.g.
|
public void checkValid()
IllegalArgumentException
- if the validation fails.public FxRateCalculatorBuilder baseFxRateProvider(BaseFxRateProvider baseFxRateProvider)
public MajorCurrencyRanking getMajorCurrencyRanking()
public int getPrecisionForFxRate()
public int getPrecisionForInverseFxRate()
public boolean isCacheResults()
public boolean isCacheBaseRates()
public BaseFxRateProvider getBaseFxRateProvider()
public FxRateCalculatorBuilder cacheResults(boolean cacheResults)
public FxRateCalculatorBuilder cacheBaseRates(boolean cacheBaseRates)
public FxRateCalculatorBuilder precisionForFxRate(int precisionForFxRate)
public FxRateCalculatorBuilder precisionForInverseFxRate(int precisionForInverseFxRate)
public FxRateCalculatorBuilder bidRounding(int bidRounding)
public FxRateCalculatorBuilder askRounding(int askRounding)
public FxRateCalculatorBuilder orderedCurrenciesForCross(List<String> orderedCurrenciesForCross)
public FxRateCalculatorBuilder majorCurrencyRanking(MajorCurrencyRanking majorCurrencyRanking)
public FxRateCalculatorBuilder currencyProvider(CurrencyProvider currencyProvider)
public FxRateCalculatorBuilder ratesSnapshot(Collection<FxRate> rates)
public FxRateCalculatorBuilder addRateSnapshot(FxRate rate)
public Map<CurrencyPair,FxRate> getRatesSnapshot()
public int getBidRounding()
public int getAskRounding()
public CurrencyProvider getCurrencyProvider()
Copyright © 2006–2022 Appendium - Portfolio Financing Platform. All rights reserved.