Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Calculates the difference between two dates based on the 360 day year used in interest calculations.
This gems aims to provide full compatibility to calculations based on Excel or Calc. The testsuite thus uses over a thousand date combinations especially picked to highlight problems in the days360 calculation. The reference values were calculated with different office suites using their provided methods (more information in test/data). Additional calculation methods are also provided. See the Notes section to learn more about the different calculation methods and their history.
The following table gives an overview on which functions are supported and what their equivalents in Excel or Calc are.
Method | days360 gem | Excel | Calc |
---|---|---|---|
US/NASD Method (30US/360) (Excel compatible) | days360(date_a, date_b) | DAYS360(date_a, date_b) | DAYS360(date_a, date_b) |
US/NASD Method (30US/360) | days360(date_a, date_b, :US_NASD) | not available | not available |
European method (30E/360) | days360(date_a, date_b, :EU) | DAYS360(date_a, date_b, 1) | DAYS360(date_a, date_b, 1) |
tested on all major ruby versions.
Add this line to your application's Gemfile:
gem 'days360'
And then execute:
$ bundle
Or install it yourself as:
$ gem install days360
class MyFinancialCalculation
include Days360
def interest_using_US_method(from, till)
interest_days = days360(from, till)
#equals
#interest_days = days360_us(from, till)
interest = balance * interest_rate * (interest_days / 360)
interest
end
Nowadays it seems senseless to calculate interest based on some fictional year instead of simply using the number of days between two dates. The reason (i believe) for different calculation methods to still be in use are:
Discussion of bug in Calc compared to Excel (including several spreadsheet attachments). https://issues.apache.org/ooo/show_bug.cgi?id=84934
Documentation explaining how calc/excel differ from NASD method http://wiki.openoffice.org/wiki/Documentation/How_Tos/Calc:_Date_%26_Time_functions#Financial_date_systems
Page explaining different calculation methods and laws (in german) http://zinsmethoden.de/
ISDA Page containing several documents related to interest calculation (including one document showing different 30/360 30E/360 variants) http://www.isda.org/c_and_a/trading_practice.html
There are a huge amount of different calculation methods out there (see ISDA page for a beginning). If you need a different one you are invited to add it. Please make sure you have some kind of documentation and ideally a test vector (see test/data) with reference results.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that days360 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.