Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

F# for Trading - QuantLabs 2014

Accompanying slides to talk

  • Login to see the comments

F# for Trading - QuantLabs 2014

  1. 1. F# FOR TRADING & FINANCE Phillip Trelford, SimCorp Ltd QuantLabs, 2014
  2. 2. F#UNCTIONAL LONDONERS Founded Feb 2010 800+ Members 80+ Meetups 4 Conferences Topics  Finance  Machine Learning  Functional Programming  GPU/OpenCL/LLVM
  4. 4. F# IN FINANCE Investment Banks Hedge funds Prop shops Utilities Insurance
  5. 5. F# FOR PROFIT F# for Trading
  6. 6. F# FOR PROFIT Time to Market Efficiency Correctness Complexity
  7. 7. TIME TO MARKET order of magnitude increase in productivity GameSys Source
  8. 8. EFFICIENCY performance is phenomenal. We can now re-calculate the entire bank portfolio from scratch in less than a second Handelsbanken Source
  9. 9. CORRECTNESS leads to virtually bug-free code Fixed Income Source
  10. 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
  11. 11. TYPE PROVIDERS F# for Trading
  13. 13. R – TYPE PROVIDER
  14. 14. XML TYPE PROVIDER <Order ClOrdID="123456" Side="2" TransactTm="2001-09-11T09:30:47-05:00" OrdTyp="2" Px="93.25" Acct="26522154"> <Hdr Snt="2001-09-11T09:30:47-05:00" PosDup="N" PosRsnd="N" SeqNum="521"> <Sndr ID="AFUNDMGR"/> <Tgt ID="ABROKER"/> </Hdr> <Instrmt Sym="IBM" ID="459200101" IDSrc="1"/> <OrdQty Qty="1000"/> </Order>
  15. 15. FSHARP.ORG/TESTIMONIALS - MICROSOFT For a machine learning scientist, speed of experimentation is the critical factor to optimize. Compiling is fast but loading large amounts of data in memory takes a long time. With F#’s REPL, you only need to load the data once and you can then code and explore in the interactive environment. Unlike C# and C++, F# was designed for this mode of interaction. - Patrice Simard, Microsoft
  16. 16. FSHARP.ORG/TESTIMONIALS - AMYRIS BIOTECH F# has been phenomenally useful. I would be writing a lot of this in Python otherwise and F# is more robust, 20x - 100x faster to run and for anything but the most trivial programs, faster to develop. - Darren Platt, Amyris Biotechnology
  17. 17. CALCULATIONS F# for Trading
  18. 18. SPREADSHEET HORROR STORIES anomaly, audit finding, bug, bungled, chaos, cock-up, corrupt, damage, debug, defect, deficiency, disaster, dubious, embarrassment, error, erroneous, Excel, exposed, failed, failure, false, falsify, fault, faulty, fiasco, flaw, foul-up, fraud, fraudulent, fubar, garbage, GIGO, glitch, hell, horror story, inaccurate, inadequate, inadvertent, incorrect, insecure, misunderstood, nightmare, non-compliance, not correct, oops, overestimate, overstatement, problem, risk, rogue, serious, slip, snafu, suspect, suspicious, trap, typo, unchecked, uncontrolled, uncorrected, uncovered, underestimate, understatement, undetected, untested, violation, weak, weakness, wrong
  20. 20. 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. 21. FCELL = F# IN EXCEL
  22. 22. 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
  23. 23. GARBAGE F# in Finance
  24. 24. .NET 4.5 GARBAGE COLLECTOR Latency Mode Application Scenarios Batch Command line Server Side Interactive LOB applications LowLatency Trading Screens SustainedLowLatency Financial Applications
  25. 25. MONO SGEN GC Run on • Android • iOS • Linux • Mac (Example from GraphDB)
  26. 26. SOLD F# in Finance
  27. 27. 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 |> square AssertEquality result __
  29. 29. BUY THE BOOK
  30. 30. GET THE T-SHIRT
  31. 31. GET A JOB
  32. 32. QUESTIONS? Community F# Foundation F#unctional Londoners Twitter #fsharp Me Blog Twitter @ptrelford