Skip to content

Comment on Shall We Use Clojure?parent

Comments

>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.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.