Quantitative finance related R functions