F Sharp and the Excel Financial Functions
With my focus on LINQ, I have been considering the functional implications of the changes to the standard imparitive languages. As a result, I've been trying to watch the changes coming with the new F# Functional programming language which will be part of VS 2010. When thinking about the use cases for F#, areas with heavy computational needs are often the best use case. In many ways, I would think one ideal place for using F# would be in Excel where many business people have no problems chaining function calls together with complex nested If() functions.
The team has gone one better and taken the financial functions in Excel and re-written them in F#. The code is available on the MSDN Code Gallery. While this may be a nice feature, I'm not sure it was absolutely needed other than proof of concept. Why? Because most of the typical financial functions are already available in the VisualBasic.Financial namespace. Indeed, when I started my most recent project, I had the choice of language and choose VB.Net in part because it supported a number of the functions I needed in the banking industry out of the box.
Below is a comparison of the methods included in each library. I do find it interesting that the F# implementation chose not to implement the Rate function which is one of the trickier functions to implement because it is essentially a goal-seek.
VisualBasic.Financial | F# Library |
PV | PV |
FV | FV |
PMT | PMT |
NPER | NPER |
IPMT | IPMT |
PPMT | PPMT |
CUMIPMT | |
CUMPRINC | |
ISPMT | |
FVSCHEDULE | |
IRR | IRR |
NPV | NPV |
MIRR | MIRR |
XIRR | |
DB | |
SLN | SLN |
SYD | SYD |
DDB | DDB |
VDB | |
AMORLINC | |
AMORDEGRC | |
COUPDAYS | |
COUPDAYSBS | |
COUPDAYSNC | |
COUPNUM | |
COUPPCD | |
COUPNCD | |
ACCRINTM | |
ACCRINTM | |
PRICE | |
PRICEMAT | |
YIELDMAT | |
YEARFRAC | |
INTRATE | |
RECEIVED | |
DISC | |
PRICEDISC | |
YIELDDISC | |
TBILLEQ | |
TBILLYIELD | |
TBILLPrice | |
DOLLARDE | |
DOLLARFR | |
EFFECT | |
NOMINAL | |
DURATION | |
MDURATION | |
ODDFPRICE | |
ODDLPRICE | |
ODDLYIELD | |
RATE |