F# for Trading

25
F# for Trading Phillip Trelford Trayport

description

Strangeloop 2012 presentation

Transcript of F# for Trading

Page 1: F# for Trading

F# for TradingPhillip TrelfordTrayport

Page 2: F# for Trading

F# Community

Page 3: F# for Trading

F# Language

• Strongly Typed• Functional First• Object Orientated• Open Source• First Class .Net language• In Visual Studio

Page 4: F# for Trading

Visual Studio

Page 5: F# for Trading

Joule Energy Trading Screen

Page 6: F# for Trading

Leverage

• Existing code• Domain modelling• Computation• Concurrency• Libraries

Page 7: F# for Trading

Specification by Example

Page 8: F# for Trading

TickSpec: Breakpoint in text file

Page 9: F# for Trading

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#.”

Page 10: F# for Trading

Order – Record type

type Order = { Side : Side LimitPrice : Price Quantity : Quantity IsAllOrNone : bool }

Page 11: F# for Trading

Time in Force – Union type

type TimeInForce = | Immediate | GoodForDay | GoodTillDate of DateTime

Page 12: F# for Trading

Units of Measure

Page 13: F# for Trading

Excel – Type ProviderExcel Visual Studio

Page 14: F# for Trading

F# for Computation

•Standard F# tools▫F# language and core libraries

•Workstation libraries▫Math.NET Numerics (open source)▫StatFactory FCore

•Distributed libraries▫Microsoft Cloud Numerics▫Nessos {m}brace cloud

Page 15: F# for Trading

Monte Carlo estimation of Pi

Page 16: F# for Trading

R – Type Provider

Page 17: F# for Trading

ShowDialog – Async workflows

Page 18: F# for Trading

Rx

notifications.    BufferWithTimeOrCount(    TimeSpan.FromSeconds(0.01),    50);

Page 19: F# for Trading

MiniRx

int closure = i; mouseMove .Select(e => e.GetPosition(canvas)) .Delay(closure * 100) .OnDispatcher() .Subscribe(pos => { Canvas.SetLeft(label, pos.X + closure * 10); Canvas.SetTop(label, pos.Y); });

Page 20: F# for Trading

F# Agents – MailboxProcessor typeAgent.Start (fun inbox -> async {    while true do        let! instruction =

instruction.Receive()        instruction         |> market.Update         |> notify } )

Page 21: F# for Trading

•Programming model that looks sequential but executes distributed▫async { }▫…▫cloud { }

The future – {m}brace the cloud

Page 22: F# for Trading

.Net 4.5 Garbage CollectorLatency Mode Application Scenarios

Batch Command lineServer Side

Interactive LOB applications

LowLatency Trading Screens

SustainedLowLatency Financial Applications

Page 23: F# for Trading

Meet the F#ers

@rickasaurus

@tomaspetricek

@dmohl

Page 24: F# for Trading

Try F#: http://tryfsharp.org

Page 25: F# for Trading

Questions?Me F#

Twitter: @ptrelfordFeed: http://trelford.com/blog

Twitter: #fsharpFeed: http://fpound.net