1. Home
  2. /
  3. Fsharp-finance
  4. /
  5. Discount Cash Flows

Discount Cash Flows - Fsharp-finance Typing CST Test

Loading…

Discount Cash Flows — Fsharp-finance Code

Compute present value of future cash flows.

let discountCashFlows cashFlows r =
	List.mapi (fun i cf -> cf / ((1.0 + r) ** float (i+1))) cashFlows |> List.sum

let pv = discountCashFlows [100.0;100.0;100.0] 0.05
printfn "Present Value: %f" pv

Fsharp-finance Language Guide

F# is a functional-first programming language on the .NET platform, widely used in finance for quantitative modeling, risk analysis, and algorithmic trading due to its strong type system, immutability, and functional programming paradigms.

Primary Use Cases

  • ▸Algorithmic trading and backtesting
  • ▸Derivatives pricing and financial modeling
  • ▸Portfolio optimization and risk analysis
  • ▸Time series analysis for financial data
  • ▸Integrating functional code with enterprise .NET systems

Notable Features

  • ▸Functional-first language with strong type inference
  • ▸Immutable data structures and pattern matching
  • ▸Seamless .NET integration for libraries and tools
  • ▸Supports async programming for real-time computations
  • ▸Powerful data processing with F# Data, Deedle, and Math.NET

Origin & Creator

Developed by Microsoft Research in 2005, evolving from OCaml to provide functional-first programming on .NET for both academic and industry applications.

Industrial Note

Extensively used in investment banks, hedge funds, and fintech for quantitative analytics, derivatives pricing, portfolio optimization, and real-time risk management.

More Fsharp-finance Typing Exercises

Calculate Compound InterestBlack-Scholes Option PricingSimulate Stock Price PathCalculate Portfolio ReturnCompute Portfolio VarianceCompute Portfolio Standard DeviationCalculate Sharpe RatioSimulate Multiple Stock PathsCalculate Forward Price

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher