congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Currency.getMinorUnitDigits
Code IndexAdd Tabnine to your IDE (free)

How to use
getMinorUnitDigits
method
in
com.opengamma.strata.basics.currency.Currency

Best Java code snippets using com.opengamma.strata.basics.currency.Currency.getMinorUnitDigits (Showing top 9 results out of 315)

origin: OpenGamma/Strata

/**
 * Obtains an instance that rounds to the number of minor units in the currency.
 * <p>
 * This returns a convention that rounds for the specified currency.
 * Rounding follows the normal {@link RoundingMode#HALF_UP} convention.
 * 
 * @param currency  the currency
 * @return the rounding convention
 */
public static Rounding of(Currency currency) {
 return HalfUpRounding.ofDecimalPlaces(currency.getMinorUnitDigits());
}
origin: OpenGamma/Strata

/**
 * Gets the number of digits in the rate.
 * <p>
 * If this rate is a conventional currency pair defined in configuration,
 * then the number of digits in a market FX rate quote is returned.
 * <p>
 * If the currency pair is not defined in configuration the sum of the
 * {@link Currency#getMinorUnitDigits() minor unit digits} from the two currencies is returned.
 * 
 * @return the number of digits in the FX rate
 */
public int getRateDigits() {
 Integer digits = CONFIGURED.get(this);
 if (digits != null) {
  return digits;
 }
 Integer inverseDigits = CONFIGURED.get(inverse());
 if (inverseDigits != null) {
  return inverseDigits;
 }
 return base.getMinorUnitDigits() + counter.getMinorUnitDigits();
}
origin: OpenGamma/Strata

/**
 * Obtains an instance from the currency.
 * <p>
 * This sets the tick size and tick value to the minor unit of the currency.
 * For example, for USD this will set the tick size to 0.01 and the tick value to $0.01.
 * This typically matches the conventions of equities and bonds.
 * 
 * @param currency  the currency to derive the price information from
 * @return the security price information
 */
public static SecurityPriceInfo ofCurrencyMinorUnit(Currency currency) {
 int digits = currency.getMinorUnitDigits();
 double unitAmount = Math.pow(10, -digits);
 return new SecurityPriceInfo(unitAmount, CurrencyAmount.of(currency, unitAmount), 1);
}
origin: OpenGamma/Strata

public void test_minorUnits() {
 assertEquals(Currency.of("USD").getMinorUnitDigits(), 2);
 assertEquals(Currency.of("EUR").getMinorUnitDigits(), 2);
 assertEquals(Currency.of("JPY").getMinorUnitDigits(), 0);
 assertEquals(Currency.of("GBP").getMinorUnitDigits(), 2);
 assertEquals(Currency.of("CHF").getMinorUnitDigits(), 2);
 assertEquals(Currency.of("AUD").getMinorUnitDigits(), 2);
 assertEquals(Currency.of("CAD").getMinorUnitDigits(), 2);
}
origin: OpenGamma/Strata

@Override
public String formatForDisplay(CurrencyAmount amount) {
 return doubleFormatter.formatForDisplay(amount.getAmount(), amount.getCurrency().getMinorUnitDigits());
}
origin: OpenGamma/Strata

/**
 * Converts an FX exchange to a string.
 * 
 * @param base  the base currency amount
 * @param counter  the counter currency amount
 * @return the string form
 */
public static String fx(CurrencyAmount base, CurrencyAmount counter) {
 BigDecimal rateDec = BigDecimal.valueOf(
   counter.getAmount() / base.getAmount()).setScale(base.getCurrency().getMinorUnitDigits() + 2, RoundingMode.HALF_UP).abs();
 FxRate rate = FxRate.of(base.getCurrency(), counter.getCurrency(), rateDec.doubleValue());
 BigDecimal baseDec = BigDecimal.valueOf(base.getAmount()).stripTrailingZeros();
 BigDecimal counterDec = BigDecimal.valueOf(counter.getAmount()).stripTrailingZeros();
 boolean roundBase = baseDec.scale() < counterDec.scale();
 CurrencyAmount round = roundBase ? base : counter;
 return (round.getAmount() < 0 ? "Pay " : "Rec ") +
   SummarizerUtils.amount(round.mapAmount(a -> Math.abs(a))) + " " + "@ " + rate;
}
origin: OpenGamma/Strata

public void test_of_String_unknownCurrencyCreated() {
 Currency test = Currency.of("AAA");
 assertEquals(test.getCode(), "AAA");
 assertEquals(test.getMinorUnitDigits(), 0);
 assertSame(test, Currency.of("AAA"));
}
origin: OpenGamma/Strata

public void test_parse_String_unknownCurrencyCreated() {
 Currency test = Currency.parse("zyx");
 assertEquals(test.getCode(), "ZYX");
 assertEquals(test.getMinorUnitDigits(), 0);
 assertSame(test, Currency.of("ZYX"));
}
origin: OpenGamma/Strata

public void test_of_String_historicCurrency() {
 Currency test = Currency.of("BEF");
 assertEquals(test.getCode(), "BEF");
 assertEquals(test.getMinorUnitDigits(), 2);
 assertEquals(test.getTriangulationCurrency(), Currency.EUR);
 assertSame(test, Currency.of("BEF"));
}
com.opengamma.strata.basics.currencyCurrencygetMinorUnitDigits

Javadoc

Gets the number of digits in the minor unit.

For example, 'USD' will return 2, indicating that there are two digits, corresponding to cents in the dollar.

Popular methods of Currency

  • equals
    Checks if this currency equals another currency. The comparison checks the three letter currency cod
  • getCode
    Gets the three letter ISO code.
  • of
    Obtains an instance for the specified ISO-4217 three letter currency code. A currency is uniquely id
  • parse
    Parses a string to obtain a Currency. The parse is identical to #of(String) except that it will conv
  • compareTo
    Compares this currency to another. The comparison sorts alphabetically by the three letter currency
  • getTriangulationCurrency
    Gets the preferred triangulation currency. When obtaining a market quote for a currency, the triangu
  • roundMinorUnits
    Rounds the specified amount according to the minor units. For example, 'USD' has 2 minor digits, so
  • toString
    Returns a string representation of the currency, which is the three letter code.
  • <init>
    Restricted constructor, called only by CurrencyProperties.
  • addCode
  • getAvailableCurrencies
    Obtains the set of configured currencies. This contains all the currencies that have been defined in
  • hashCode
    Returns a suitable hash code for the currency.
  • getAvailableCurrencies,
  • hashCode

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • getResourceAsStream (ClassLoader)
  • setContentView (Activity)
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now