5 ms·
I made a similar presentation a year ago to a bunch of fellow quants at the bank. I chose Scala, and my presentation was mostly code. Quant Finance tends to be
by dxbydt 14y ago
I made a similar presentation a year ago to a bunch of fellow quants at the bank. I chose Scala, and my presentation was mostly code. Quant Finance tends to be one of those areas where Scala really excels. For example, a time series is just a running fold. So instead of having an imperative for block with various indices & guards, you can write a 1-line prefix scan to price a 5 year CDS. My examples also included bond pricing, vanilla calls and puts, binomial trees, monte carlo generators, portfolio optimization, risk calculations ( VaR & CVaR ) and a few graphics. My manager was very open-minded when it came to technology choice, and my fellow quants were somewhat tough on the 2 hour presentation, but the end result was what I believe is called a win-win. We've since pushed a bunch of apps coded in Scala into production, and the group has embraced the language quite enthusiastically.
- dons 14y ago> where Scala really excels. Functional programming in general. An awful lot of finance (that used to run in Excel) is just side-effect free, compute-centric transformations over data. Time series, for example, have a relatively nice algebra that makes it easy to manipulate in terms of maps, scans and folds. And anything that makes it easier to avoid off-by-one errors is a big win, especially if your traders and quants aren't trained software engineers.
- dxbydt 14y ago>An awful lot of finance (that used to run in Excel) is just side-effect free, compute-centric transformations over data true dat. For example, in Excel, checkout PV ( Click on Formulas->Financial->PV ) Given a $1K@par 10Y bond paying $50 annual coupon at 2% interest, Excel says the Present Value (PV) of the bond must be $1269.48 scala> (0.0 /: (1 to 10).map(x => 50/math.pow(1.02, x)))(_+_) + 1000/math.pow(1.02, 10) scala> 1269.477 Getting rid of the fold produces the list of discounted coupons and the discounted principal...just a trivial teaser example, but most quants look at that & go, wow if you could do all that in 1 line, imagine the possibilities if you are pricing a mortgage with tranches...you could get rid of 4 page spreadsheets & replace with a paragraph of straight math & it would just work...and they'd be right, too.
- ansgri 14y agoFor offline analysis, I'd eagerly agree. But have you had any success with FP for online analysis? E.g. you have 100 time series updating every second, and must yield some other series and events.
- dons 14y agoYep. We use Haskell for all systems, online and offline, including the soft-real time stuff that watches the live feeds.
- dllthomas 14y agoAn eager functional language would probably die here, but it seems like a fine fit for a lazy one: compose a list of the other series/events as you scan.
- kfk 14y agoWhat about datasets that don't fit in memory? How can a functional language deal with those (let's say we don't want to use a database)? Lazy sequences? I mean, I loved clojure when I tried it out, I just do not know if I can use it to process data as with other languages with really good libraries (python, for example).
- TylerE 14y agoIn the Finance sector, I suspect the answer would be "doesn't exist". RAM is incredibly cheap.
- JoshCole 14y agoClojure is very lazy about computation and the loading of values. You can work with sequences of infinite size. Lazy sequences are actually the default. As to processing data like you would with other really good libraries... if you want to do it like that you can. Clojure gives you easy access to Java.
- kfk 14y agoLet's say I want to do an SQL group by implementation. Are there examples like this?
- dtwhitney 14y agoCan I be so bold as to ask where you work?
- rcamera 14y agoYou could have checked his profile beforehand. It's there...
- beambot 14y agoCan you share the presentation? I'd love to see some code samples.
- dkhenry 14y agoI moved from C++ to scala for my Quaint work and I have been nothing but happy. The other fun thing to use is Akka for easy migration to multi-threaded code. Nothing like generating a bunch of Futures and then collecting the results. I was able to process two quarters of tick data as part of a test routine simply because I had the cores and an easy way to excersize them.
- joncooper 14y agoI'd love to see the presentation. Will you please post it?