The xweld-finance project includes foundational classes that provide the basic building blocks useful to support the creation of financial applications.

Primary Features

The core functionality supported through <xweld/>’s finance module includes:

  • Business centers that specify company office or business unit localities and regions
  • Holiday calendars across multiple localities and time zones
  • Handling money, currency and configurable currency conversion
  • Discount factors, FX, and price quotations
  • Daycount calculators and DateRoll conventions
  • Countries, Regions and Business Centers
  • Lightweight Date and DateTime classes
  • Extensions to the core conversion mechanism to support conversion between strings and money and java Dates and xweld Dates

Packages and Classes

A currency is represented as an enumeration of ISO 4217 Currency Codes. class diagram

Money is an amount of money in a specific currency. An interface IMoney is defined such that multiple implementaitons of money can be supported. There are two built-in implementations, one based on BigDecimal amounts and one based on Double. Converters are also available to enable the ConversionManager to convert between implementations of the IMoney interface. class diagram

A factory pattern MoneyFactory may be used to define which implementation of IMoney you wish to use in your application. The system property MoneyFactory.COM_XWELD_MONEY_PROPERTY ("") may be set to the value of an alternative implementation. The default is Below is an example of setting the property to SmallMoney:

IMoney<?> ten = MoneyFactory.create(10.0, CurrencyCode.USD);

The <xweld/> RoundingMethod class is used to round an amount of money to specific conventions and numbers of decimal places. For example, a US Dollar value typically uses two decimal places, while quoted interest rates use five. The default number of decimal places is configured and maintained in the currency defaults ( class. This class associates a currency code with a rounding method and default number of decimal places. The RoundingMethod class is used to round a Money amount according to a rounding type, which is an enumerated list defined in All of these associations are maintained by the setup tool for your application.

The basic operations on Money - such as add, multiply, divide and subtract - are mutable. This means that a + b changes the internal value of a. The arithmetic operations check to ensure that the currencies of the operand are the same, and if they are not, an exception is thrown.

Converting Amounts Of Money Between Currency Denominations

Money values may be converted between currencies using implemenations of the ICurrencyConverter class. The default implementation is
the class, but all <xweld/> applications are free to override this implementation in two ways:

  • if your application uses the runtime module and the dependency injection framework, you can set the value of the property in your RuntimeContext to refer to your implementation of the interface and use the Inject attribute to intitialize instances of a converter
  • similarly, if you don't use the runtime injection framework then you can simply set the above property and use the CurrencyConverterFactory to create instances if ICurrencyConverters as ICurrencyConverter<BigDecimal> converter = CurrencyConverterFactory<BigDecimal>.create();

com.xweld.currency.conversion class diagram

For example:

 ICurrencyConverter<BigDecimal> converter = 
 Money original = 
    new Money(new BigDecimal("50000.123"), CurrencyCode.USD);
 Money converted = 
    converter.convert(("Reuters", QuoteSide.CLOSE, original, 
                        CurrencyCode.CAD, time, ResolutionType.LATEST);

Or by injection:

 RuntimeContext contex = ContextFactory.get();
 Injector injector = context.getInjector();

 /* get the converter directly from the Injector or use the @Inject attribute on a class field */
 ICurrencyConverter<?> converter = injector.get(ICurrencyConverter.class);
 Money original = 
    new Money(new BigDecimal("50000.123"), CurrencyCode.USD);
 Money converted = 
         converter.convert("Reuters", QuoteSide.CLOSE, original, 
                            CurrencyCode.CAD, time, ResolutionType.LATEST);

Note that the convert method returns a new copy of the original amount converted to the specified currency. The original value is unchanged.

Dates And Times

The calendar package contains Date and DateTime classes which are used in <xweld/> applications to represent Date and points in time using an extremely lightweight implementation. class diagram

Holidays and Holiday Calendars

Holiday Calendars are used to determine whether a specific day is a holiday for a given business center. Holiday Calendars are also used to answer questions such as "What is the last business day of the month?". class diagram

Daycount Calculators are used to calculate the number of days or fractions of years between any two dates, according to the standard convention used in the financial industry. The daycount class hierarchy supports an extensible number of daycount calculators using a pluggable factory pattern. There are many built-in calculators for the common set of conventions, but application developers are free to add their own by extending the factory pattern. class diagram

The quote package defines the framework for returning quoted values. The values may be prices, discount factors, or FX rates. class diagram

Contact Us

For more information, please contact us at .


Copyright © 1999-2012 Free North Alliance Inc. All Rights Reserved.

The contents of this web site, including all images, text, graphics and software, are the sole property of Free North Alliance Inc. and its agents. Unauthorized use or transmission is strictly forbidden by international copyright law. View - class diagram (78.8 KB) John Free, 01 September 2011 10:34 AM View - class diagram (162 KB) John Free, 01 September 2011 12:15 PM View - class diagram (89.5 KB) John Free, 01 September 2011 12:32 PM View - class diagram (70.5 KB) John Free, 01 September 2011 12:40 PM View - class diagram (109 KB) John Free, 01 September 2011 12:50 PM View - class diagram (121 KB) John Free, 01 September 2011 01:11 PM View - com.xweld.currency.conversion class diagram (37.7 KB) John Free, 12 January 2012 10:46 AM