Giter Club home page Giter Club logo

scala-finance's Introduction

Financial Functions

This is a library of commonly used financial function implementation in Scala.

Usage

Include the following dependency in build.sbt

"com.praphull" %% "scala-finance" % "0.0.1"

The library cross compiles to Scala 2.11, 2.12 and 2.13. Use sbt +test to run the tests.

The functions can be accessed in various manners:

  • By importing package com.praphull.finance (see XIRR for example)
  • By extending the trait FinancialFunctionsin your own class/function library (see XNPV for example)

To work with dates, a helper representation DateRep is provided, which can be constructed in the following manners:

  • DateRep(year: Int, month: Int, date: Int)
  • DateRep(date: DateTime) - From org.joda.time.DateTime (Joda Time)
  • DateRep(date: Long) - milliseconds since 1970-01-01T00:00:00 UTC+0000
  • DateRep(date: Date) - From java.util.Date
  • DateRep(string: String) - From date string (Uses DateTime.parse internally)

Implemented methods

XIRR

Usage:

import com.praphull.finance.{DateRep, _}
xirr(List(
  DateRep(2008, 1, 1) -> -10000,
  DateRep(2008, 10, 30) -> 4250,
  DateRep(2008, 3, 1) -> 2750,
  DateRep(2009, 4, 1) -> 2750,
  DateRep(2009, 2, 15) -> 3250
), Some(0.05))
Reference

Microsoft Support - XIRR

XNPV

Usage:

import com.praphull.finance.{DateRep, FinancialFunctions}

object MyLibrary extends FinancialFunctions {
  def myOwnFunction = ???
}

MyLibrary.xnpv(List(
  DateRep(2008, 1, 1) -> -10000,
  DateRep(2008, 10, 30) -> 4250,
  DateRep(2008, 3, 1) -> 2750,
  DateRep(2009, 4, 1) -> 2750,
  DateRep(2009, 2, 15) -> 3250
), 0.45)
Reference

Microsoft Support - XNPV

scala-finance's People

Contributors

praphull-purohit avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

kaesler

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.