F# and Functional Programming in Finance

Functional-first programming in F# is an effective tool for solving complex problems that often arise in financial computing. The strong typing of F# provides important correctness guarantees and means that numeric code written in F# runs efficiently. Furthermore, a number of case-studies show that F# significantly reduces time-to-market, especially in the financial domain.

The course is practically focused. Throughout the course, we look at examples of time-series analysis, modelling and pricing of stock options and more. Each lecture provides a number of fun exercises that guide you through the problem. Furthermore, F# and functional programming makes you a better programmer even if you do not end up using the language immediately after the course.


The course requires no prior functional programming knowledge and is designed for both software developers and quants or actuaries. You will learn:

  • How to approach problems from the functional perspective and capture your ideas using idiomatic F#.
  • Model a problem domain, such as stock options, using functional types and develop domain specific languages (DSLs) for processing such domains.
  • Use type providers to access data, perform interactive data and time-series analysis on financial data using the Deedle library and create charts to visualize the results.
  • How to use F# within a larger context, including interoperability with R and best practices for the encapsulation of F# components for .NET.

Course labs & exercises

A brief theoretical introduction to every concept will be followed by numerous practical demos and exercises. At the end of the first day, you’ll leave with a complete real-world F# application. In the second day, we’ll solve a number of complex problems in concurrent and data-oriented programming.

Course prerequisites

The course doesn’t require prior experience with F# or functional programming.

Course outline

Day 1 (Introduction and calculations)

  • Introducing F# and functional programming. We quickly look at the main reasons for adopting F#. Why is it becoming popular in the finance industry and what are some successful case studies? Then we introduce the fundamental F# language features such as immutability, tuples and pattern matching.
  • Working with collections and data structures. We introduce the most important functional pattern – processing of immutable data structures using higher-order functions. We finish the processing of historical stock prices from Yahoo! Finance, calculating statistics and visualizes the result with simple charts.
  • Implementing mathematical calculations F# makes it easy to turn mathematical equations to code. In this lecture we look at examples such as Monte-Carlo simulations, Black-Scholes equation and calculating historical volatility. You’ll learn how to avoid mistakes with units of measure, how to write efficient numerical code and how to use the rich Math.NET library.

Day 2 (Using F# in practice)

  • Domain specific languages for finance Domain specific languages (DSLs) are an effective way of solving recurring problems. In this lecture, we build a DSL for pricing financial options and for detecting patterns in changing prices. You’ll learn how to model problem domain using functional data structures and how to build an easy to use library on top of the model.

  • Explorative data and time-series analysis We look at F# type providers and Deedle. Type providers make it easy to access data from sources including CSV and XML files, Excel, SQL databases and Web and REST services. Using Deedle we can then align multiple time-series and perform interactive analysis – such as comparing different industry sectors or calculating daily returns.

  • F# in the larger context We wrap up by looking at the ways for integrating F# in the broader context. This lecture explores how to call advanced statistical libraries using the R provider, how to use object-oriented programming to integrate with .NET and how to use F# tools and libraries for unit testing, building and documenting code.

What attendees say