Skip to content
All library documents

Scala’s Role in Trading Systems and Quantitative Finance

Article Quant Q&A · Author: efalcao

Summary

The discussion surveys whether Scala is used in trading and how it compares with other languages for financial software. Contributors report Scala use at a trading firm and describe JVM integration as a practical advantage for teams with Java systems. Several answers identify functional languages such as OCaml, F#, and Haskell as tools for financial applications and domain-specific languages, including prototyping or describing complex trades. They suggest that carefully designed domain-specific languages may enable compiler optimizations.

The answers disagree about Scala’s suitability for performance-critical trading. Some characterize C++ as the common choice where speed matters most, with Java also used, while others mention Scala in production or new projects. One answer cites benchmark comparisons showing lower execution speed and greater memory use than C++, alongside shorter code. These are dated practitioner opinions and examples, not a systematic survey or controlled assessment of current trading systems. Language choice depends on workload, existing infrastructure, performance needs, and team expertise; the thread does not establish a universal best choice.

Key ideas

  • Scala can integrate with Java systems because both target the JVM.\nFinancial firms use functional languages to build domain-specific languages for trading and derivatives.\nSome contributors report Scala use in trading projects, while others describe it mainly as a prototyping tool.\nThe answers generally associate C++ with performance-critical applications but offer no comprehensive or current industry survey.

Tags

Full text
# Is Scala used in trading systems


# Is Scala used in trading systems












I'm curious about high performance computing and consider algo/program trading as an interesting source of information about what are performant technologies that are used to trade the markets.

Is scala being used out there? Is it a viable language for a startup prop shop? Would it be considered an advantageous language given it's more expressive syntax (and thus less code) as compared to java/c++ but be just as speedy?

## Answer by Todd Schiller (score 20, accepted)

https://quant.stackexchange.com/a/308

EDF Trading uses it (or used it): http://cufp.org/videos/scala-edf-trading-implementing-domain-specific-language-derivative-p

In general, many financial institutions use functional programming languages. Andrei is correct in that they often are used to develop domain-specific languages (DSLs).

Some examples:

- Credit Suisse uses F# http://cufp.org/archive/2008/abstracts.html#MansellHoward (they had toyed around with Haskell for a bit to create a DSL called Paradise http://urchin.earth.li/~ganesh/icfp08.pdf)

- Jane Street Capital uses OCaml ( http://ocaml.janestreet.com/?q=node/61 )

- Barclays uses a DSL in Haskell for descibing exotic trades ( https://web.archive.org/web/20160313025331/http://www.lexifi.com/files/resources/frankau.pdf )

A "complete" list can be found by exploring proceedings from Commercial Users of Functional Programming workshop proceedings: http://cufp.org/conference

If you are smart about DSL creation, the programs you write can actually have better performance because you can perform smarter compiler optimizations (e.g., http://infoscience.epfl.ch/record/148814/files/paper.pdf)

One last note, since Scala targets the JVM, you could always integrate the Java and Scala code (or even make native calls to C++ code via the Java Native Interface).

## Answer by Shane (score 14)

https://quant.stackexchange.com/a/304

We can play these language wars until pigs fly, but there are a few very basic things that most people agree on:

- As has already been said, C++ is the standard language where performance is really important (and Java comes in second). An example of how this shows up: C++ is taught in the Wilmott quant finance certificate and in MFE programs. It also appears the most often in job postings.

- For other areas, where performance is the top priority, a wide variety of other languages undoubtedly get used. For instance, Jane Street is very public about their OCaml implementation. Many hedge funds use languages like R, matlab, and Python, even in their production environments.

Are firms using Scala? Probably. Do you want to become a Scala expert in the hope of using it in quantitative finance? Not a good bet.

## Answer by Dirk Eddelbuettel (score 9)

https://quant.stackexchange.com/a/299

Empirics should count for something, and the (awesome) Language Shootout does show that C++ still very clearly dominates Scala in execution time and memory use -- though Scala looks better in code size.

Shops that have existing investment in Java like Scala as a next-generation Java given that the latter hasn't moved all that much of late. I also heard some startups betting on it. I am not in the Java camp, so my money is still on C++ (especially when performance really matters).

## Answer by Alexander Temerev (score 8)

https://quant.stackexchange.com/a/641

My company currently uses Scala for all new projects in algorithmic trading. We also have an internal portfolio management / monitoring application written in Scala (with Circumflex web framework).

## Answer by gappy (score 5)

https://quant.stackexchange.com/a/300

To the best of my knowledge, there is no Scala implementation of execution platforms. C/C++ is still the language of choice for mission-critical financial applications, followed by Java, for those more recent shops that didn't have the burden of much legacy C++ code. I cannot imagine Scala taking hold, given that is slower and not nearly as robust as C++ and Java.

For UIs, everything is fair game, from Java to Python to C# to Ruby. But choosing the right language of a UI has never been the competitive advantage of any investment firm, I believe.

## Answer by Andrey Taptunov (score 5)

https://quant.stackexchange.com/a/302

Yes, it's used. However its purpose for now is mainly limited by creation of Domain Specific Languages for prototyping because of easy integration with existing infrastructure in Java. Here Scala also competes with another JVM based language - Groovy and F# because of its relatively easy interaction with Excel.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.