Package org.jquantlib.currencies

Examples of org.jquantlib.currencies.ExchangeRate


        final Money m2 = Money.multiple(100000.0 , EUR);
        final Money m3 = Money.multiple(500000.0 , USD);


        ExchangeRateManager.getInstance().clear();
        final ExchangeRate eur_usd = new  ExchangeRate(EUR, USD, 1.2042);
        final ExchangeRate eur_gbp = new ExchangeRate(EUR, GBP, 0.6612);
        ExchangeRateManager.getInstance().add(eur_usd);
        ExchangeRateManager.getInstance().add(eur_gbp);


        Money.conversionType = Money.ConversionType.BaseCurrencyConversion;
        Money.baseCurrency = EUR;

        //divided the steps for tracing...
        final Money calculated0 = m1.mul(3.0);
        final Money calculated1 = (m2.mul(2.5));
        final Money calculated2 = m3.div(5.0);

        final Money calculated3 = calculated0.add(calculated1).sub(calculated2);

        QL.info("Calculated value: " + calculated3.value());


        final Rounding round = Money.baseCurrency.rounding();
        /*@Decimal*/final double x = round.operator(m1.value()*3.0/eur_gbp.rate()) + 2.5*m2.value() -
        round.operator(m3.value()/(5.0*eur_usd.rate()));
        QL.info("Expected value: " + x);

        final Money expected = new Money(x, EUR);

View Full Code Here

TOP

Related Classes of org.jquantlib.currencies.ExchangeRate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.