This document discusses using the F# programming language for financial trading applications. It provides examples of how F# can be used to model financial domains like orders, time in force, and currency conversions. It also discusses benefits of F# for financial applications like increased productivity, efficiency, correctness, and managing complexity. Finally it shows examples of F# used in trading screens and with type providers to interface with data.
7. TIME TO MARKET
order of magnitude increase in productivity
GameSys
Source http://fsharp.org/testimonials
8. EFFICIENCY
performance is phenomenal. We can now re-calculate the entire bank
portfolio from scratch in less than a second
Handelsbanken
Source http://fsharp.org/testimonials
10. COMPLEXITY
F# is the night vision goggles I need when I go into the dark and attempt to
solve previously unsolved problems
Byron Cook
Source http://fsharp.org/testimonials
14. ORDER – RECORD TYPE
F#
type Order = {
LimitPrice : decimal
Quantity : int
Side : Side
}
C#
a
15. TIME IN FORCE – UNION
TYPE
type TimeInForce =
| GoodTillCancel
| GoodForDay
| GoodTillDate of DateTime
16. THOUGHTWORKS TECH
RADAR
MARCH 2012
F# is excellent at concisely expressing
business and domain logic.”
Developers trying to achieve explicit business logic within an application may
opt to
express their domain in F#
with the majority of plumbing code in C#
18. CURRENCY CONVERSIONS
[<Measure>] type EUR
[<Measure>] type GBP
let rateEurGbp = 0.783M<GBP/EUR>
// Converts amount in EUR to GBP
let euroToPounds (eur:decimal<EUR>) = eur * rateEurGbp
21. UNITS IN CELLS
type formula =
| Neg of formula
| Exp of formula * formula
| ArithmeticOp of
formula * arithmetic * formula
| LogicalOp of
formula * logical * formula
| Num of UnitValue
| Ref of int * int
| Range of int * int * int * int
| Fun of string * formula list
31. F# KOANS
[<Koan>]
let SquareEvenNumbersWithPipelineOperator() =
(* In F#, you can use the pipeline operator to get the benefit of
the parens style with the readability of the statement style. *)
let result =
[0..5]
|> List.filter isEven
|> List.map square
AssertEquality result __