F# FOR TRADING

Øredev, Malmo, Sweden
Phillip Trelford 2013
F#UNCTIONAL
LONDONERS
600+ Members
Founded Feb 4, 2010

51 Meetings
NEW YORK
CITY F# USER
GROUP
550+ Members
Founded Nov 10, 2010

30 Meetings
FSHARP.ORG/GROUPS
WHO, WHY, WHAT

F# for Trading
WHO?
Prop
shops
Hedge
funds
Investment Banks

Utilities

Insurance
F# FOR PROFIT
Time to Market
Efficiency
Correctness
Complexity
TIME TO MARKET
speed development by 50 percent or more,
European IB

order of magnitude increase in productivity,
GameSys
EFFICIENCY
processes that used to require hours now take just minutes, Grange
Insurance

performance is 10× better than the C++ that it replaces, Aviva
CORRECTNESS
leads to virtually bug-free code,
Fixed Income

I am still waiting for the first bug to come in,
E-On
COMPLEXITY
everything becomes simple and clear when expressed in F#,
Byron Cook
SHOW ME THE MONEY

F# for Trading
JOULE ENERGY TRADING
SCREEN
TICKSPEC: DEBUG
EXAMPLES
ORDER TYPE
type Order = {
Side : Side
LimitPrice : Price

Quantity : Quantity
IsAllOrNone : bool
}
DOMAIN TIME IN FORCE
type TimeInForce =
| Immediate
| GoodForDay

| GoodTillDate of DateTime
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#
SPREADSHEETS

F# for Trading
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
UNITS OF MEASURE
TSUNAMI + FCELL = F# IN
EXCEL
SPREADSHEET HORROR
STORIES
anomaly, audit finding, bug, bungled, chaos, cockup, corrupt, damage, debug, defect, deficiency, disaster, dubious, embarrass
ment, error, erroneous, Excel, exposed, failed, failure, false, falsify, fault, fault
y, fiasco, flaw, foulup, fraud, fraudulent, fubar, garbage, GIGO, glitch, hell, horror
story, inaccurate, inadequate, inadvertent, incorrect, insecure, misunderstoo
d, nightmare, non-compliance, not
correct, oops, overestimate, overstatement, problem, risk, rogue, serious, sli
p, snafu, suspect, suspicious, trap, typo, unchecked, uncontrolled, uncorrect
ed, uncovered, underestimate, understatement, undetected, untested, violati
on, weak, weakness, wrong
TYPE PROVIDERS

F# for Trading
CSV TYPE PROVIDER
R – TYPE PROVIDER
WORLD BANK DATA
GARBAGE

F# in Finance
.NET 4.5 GARBAGE
COLLECTOR
Latency Mode

Application Scenarios

Batch

Command line
Server Side

Interactive

LOB applications

LowLatency

Trading Screens

SustainedLowLatency

Financial Applications
SGEN GC / MONO
Performance

Target

• Mac
• Linux
• Android
• iOS
• FreeBSD
SOLD

F# in Finance
TRY IT BEFORE YOU BUY IT
BUY THE BOOK
GET THE T-SHIRT
GET A JOB
QUESTIONS?
Community
F# Foundation http://fsharp.org
Twitter Tag: #fsharp

Upcoming conferences
F# in Finance (Microsoft London): http://fsharpinfinance.com Nov 25
CodeMesh London: http://codemesh.io Dec 3-5
NDC London: http://ndc-London.com Dec 2-6

F# for Trading - Øredev 2013

Editor's Notes

  • #5 Fsharp.org map
  • #14 Leverage
  • #25 http://fsharp.github.io/FSharp.Data/library/CsvProvider.htmlhttp://clear-lines.com/blog/post/Random-Forest-classification-in-F-first-cut.aspx