Code Monkey home page Code Monkey logo

daycounts.jl's Introduction

DayCounts.jl

Stable Dev CI

Summary

Pricing fixed-income securities involves estimating year fractions between dates. However, the fraction of a year between two dates depends on factors such as leap years and there are various conventions for dealing with this.

In this package, we collect various day count conventions and provide a method yearfrac for computing the year fraction between dates.

Example

using DayCounts, Dates
import DayCounts: Thirty360, Actual360,Actual365Fixed,ActualActualISDA,ActualActualExcel, yearfrac

basis = [Thirty360(), Actual360(), Actual365Fixed(), ActualActualISDA(),ActualActualExcel()];

println("Year fraction between Jan 1 and April 1:\n")

for y in 2019:2020
    println("\n",y,isleapyear(y) ? " (Leap Year)" : " (No Leap Year)")
    
    for b in basis
       yf = yearfrac(Date(y,1,1),Date(y,4,1),b)
       println(b,": ",yf)
    end
end

The above code prints the following:

Year fraction between Jan 1 and April 1:

2019 (No Leap Year)
Thirty360(): 0.25
Actual360(): 0.25
Actual365Fixed(): 0.2465753424657534
ActualActualISDA(): 0.2465753424657534
ActualActualExcel(): 0.2465753424657534

2020 (Leap Year)
Thirty360(): 0.25
Actual360(): 0.25277777777777777
Actual365Fixed(): 0.2493150684931507
ActualActualISDA(): 0.24863387978142076
ActualActualExcel(): 0.24863387978142076

References

We used the following sources:

daycounts.jl's People

Contributors

alecloudenback avatar simonbyrne avatar ericforgy avatar felipenoris avatar

Stargazers

 avatar Peter Stokes avatar Matthew Caseres avatar M. Schulze avatar STYLIANOS IORDANIS avatar Thomas Zub avatar  avatar Antonio Saragga avatar Tl Yim avatar  avatar  avatar

Watchers

James Cloos avatar  avatar Fengyang Wang avatar

daycounts.jl's Issues

startdate after enddate

Should we have the property that:

yearfrac(startdate, enddate, dc) == -yearfrac(enddate, startdate, dc)

? If so, we should have tests for this.

(note that this is different from Excel, which gives the absolute value)

Remove Manifest?

Since this is a library and not a runnable project, should Manifest file be deleted?

rename Thirty360Excel to Thirty360US?

It matches what Wikipedia calls it "30/360 US":
https://en.wikipedia.org/wiki/Day_count_convention#30/360_US

It's not in the ISDA definition list, and I don't have access to the Mayle reference:

Mayle, Jan (1993), Standard Securities Calculation Methods: Fixed Income Securities Formulas for Price, Yield and Accrued Interest, 1 (3rd ed.), Securities Industry and Financial Markets Association, ISBN 1-882936-01-9.

For reference, OpenGamma Strata calls it "30U/360 EOM".

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.