JAX Finance Blog

JAX FINANCE BLOG

JAX Finance, 3-6 April 2017
The Conference for Technology in Finance

14 Mar 2017

The advantages of Java recent progress for finance

Library. Source: Shutterstock

Spot the concrete advantages of the new functions of Java 8 and discover how they result in an increased scope of application in finance.

The Java platform has always been widely used in finance, but there is no doubt that Java SE 8 has helped reinvigorate the platform. Through blogs and conference talks, I’ve been trying to help developers make the shift to Java 8, emphasising that coding in Java 8 is different to coding in previous versions of Java. Coding standards need to be reconsidered and design patterns altered. But that change is very much worth it.

The most visible change was the introduction of lambdas and the associated streams API. They have definitely changed the feel of the language, allowing code to be written in a much more functional style. Abstractions that used to be verbose can now be done with ease, and this changes the way code is written and designed. But like all new features, there is a balance to be struck. Not all code reads better or performs as well when written using the streams API and lambdas. But where it does work well, it can result in much clearer code.

When lambdas were added, an associated change was to allow methods in interfaces. Thus an interface can now have three kinds of method – abstract, default and static. Where lambdas change code at the micro-level, methods on interfaces change code at the macro-level. New designs for subsystems become possible, and it can take a while to understand that potential. As an example, one pattern I have used frequently is to have an interface with one or more package-scoped implementations. Previously, this would have needed a factory utility class to create the instances, but now a static method on the interface can do the job. This can greatly reduce the amount of public code in an API if used correctly.

[..] Now a static method on the interface can do the job. This can greatly reduce the amount of public code in an API if used correctly.

Another feature of Java 8 is the new date and time library java.time.* (JSR-310). As the co-spec lead and primary author, I based the design on the principles of Joda-Time, the de facto standard library for versions of Java prior to 8. My goal with java.time.* was to make Joda-Time obsolete. Developers migrating their code to Java 8 should adopt java.time.* classes and remove Joda-Time where possible.

The great part about the new java.time.* classes is that they map so well onto the concepts found in finance. The `LocalDate` class represents a date without time or time-zone, and as such is a perfect fit for many business concepts, such as trade date, effective date and settlement date. Whereas `LocalTime`, a time without a date or time-zone, is a perfect fit to describe when the LIBOR fixing takes place, 11:00. And `Instant` is ideal for collecting a timestamp in monitoring and performance code. The key point here is that Java 8 has made finance in Java much easier – no need for the Joda-Time library any more.

To take advantage of Java 8 and the increasing use of Java in finance, I have spent the past few years at my day job building an open source library for market risk in finance. Strata, from OpenGamma, is a standard Java library available in Maven Central that allows anyone to create and manage financial instruments for the purpose of pricing and analytics. It has the potential to be a key building block for many organizations in the world of finance, with its open source nature ideal for the standardized products that the industry trades since the 2008 crisis. Strata has been written in Java 8 from the ground up, and makes full use of all the new features, with a strong focus on immutability and functional design.

 

Strata, from OpenGamma, is a standard Java library available in Maven Central that allows anyone to create and manage financial instruments for the purpose of pricing and analytics. 

 

Looking forward, Java SE 9 is on the horizon with its focus on modularization. This will be another big change to Java for developers to learn, but it is great to see the platform in such good health!

JAX Finance talks by Stephen Colebourne:
Java 9 modules
Wed. 05 APR 2017,
16:40 – 17:30

BEHIND THE TRACKS

CONTINUOUS DELIVERY & AUTOMATION
Automate delivery and boost productivity
CORE JAVA & PROGRAMMINGv
The joy of being a software engineer
AGILE & COMPANY CULTURE
The process of becoming fully agile
SOFTWARE ARCHITECTURE
the dos and don’ts
BLOCKCHAIN TECHNOLOGY & SOLUTIONS
Get started with the tech and build apps on the Ethereum blockchain.
FINTECH & INNOVATION
Insight into the FinTech movement
HIGH PERFORMANCE & LOW LATENCY
Squeeze the best performance from your system
Agile & Company Culture

Agile & Company Culture

FinTech & Innovation

FinTech & Innovation

Continuous Delivery & DevOps

Continuous Delivery & DevOps

Software Architecture

Software Architecture

Core Java & Programming

Core Java & Programming

High Performance & Low Latency

High Performance & Low Latency

Blockchain Technology & Solutions

Blockchain Technology & Solutions