fsprojects / ExcelFinancialFunctions

.NET Standard library providing the full set of financial functions from Excel.
https://fsprojects.github.io/ExcelFinancialFunctions
Other
195 stars 66 forks source link

Can't calculate price with a negative yield #13

Closed thatsjohnson closed 2 years ago

thatsjohnson commented 7 years ago

Description

Can't calculate price with a negative yield. This matches current Excel capabilities, but this is a valid calculation for computing price of a bond.

Repro steps

Please provide the steps required to reproduce the problem

  1. Call Calculators.CalcPrice(settlement, maturity, coupon, yield, 100), using a negative yield value (-0.002)

Expected behavior

return value of Price. http://www.investopedia.com/ask/answers/06/negativeyieldbond.asp

Actual behavior

Exception thrown: 'System.Exception' in ExcelFinancialFunctions.dll Additional information: yld must be more than 0

Known workarounds

None.

Related information

luajalla commented 7 years ago

Hi @thatsjohnson, would submitting a PR be an option for you? I'd be glad to merge it, but can't promise I'll be able to find time for a fix in the nearest future...

Thanks, Natallie

jcoliz commented 2 years ago

Labeling as "enhancement", as current behavior meets the stated goal of matching excel behavior. However, I can see how it would be useful to additionally cover this situation.

jcoliz commented 2 years ago

@thatsjohnson , Hi I know it's been a long time since you filed this. If you're still interested, would you mind trying out the issue-13 branch? https://github.com/fsprojects/ExcelFinancialFunctions/tree/feature/issue-13 . I created a new API "PriceAllowNegativeYield" which is just the old "Price" API with the yield > 0 check removed. It would be interesting to see if this gives the results you expect.

jcoliz commented 2 years ago

Update: I did manage to create a 10,000-item data set in Excel, following the spirit of the other tests. Spot checks of that data set passed, so I believe this change is correct. Still to do, need to create a test like the other large data set tests to be sure.

thatsjohnson commented 2 years ago

Thank you. Will check it out.

On Thu, Dec 16, 2021 at 3:22 PM James Coliz @.***> wrote:

Closed #13 https://github.com/fsprojects/ExcelFinancialFunctions/issues/13 via #63 https://github.com/fsprojects/ExcelFinancialFunctions/pull/63.

— Reply to this email directly, view it on GitHub https://github.com/fsprojects/ExcelFinancialFunctions/issues/13#event-5780805891, or unsubscribe https://github.com/notifications/unsubscribe-auth/AESRUAHUYMOXJYSF62KTV2LURJC7JANCNFSM4C7IARWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.*** .com>