Repository navigation
Functions: ODDFPRICE, ODDFYIELD, ODDLPRICE, ODDLYIELD (#275) - #276
Merged
Merged
Conversation
Odd first and last coupon periods via quasi-coupon periods, from the formulas on Microsoft's public function pages. ODDLYIELD is closed form; ODDFYIELD bisects ODDFPRICE (bounded). Financial is now 55 / 55. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 11, 2026
Member
|
Merged — thank you for the contribution! If you haven't already, come join us on the ArtCraft Discord: https://discord.gg/artcraft |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #275
What was added
The four odd-period bond functions, in
crates/functions/src/financial.rsnext to PRICE/YIELD. Financial is now 55 / 55.first_coupon; price = redemption and regular coupons discounted overN + Nq + DSC/NLperiods, plus the odd first coupon100·rate/freq · Σ DCi/NLidiscounted overNq + DSC/NL, minus accrued interest100·rate/freq · Σ Ai/NLi. With one quasi-period this is the documented odd-short formula (A, DFC, DSC, E, N).#NUM!when no bracket is found. Microsoft's page says Excel uses Newton; the root is the same.last_interest;(red + C·ΣDCi/NLi) / (1 + ΣDSCi/NLi · yld/freq) − C·ΣAi/NLiand its closed-form inverse.maturity > first_coupon > settlement > issue,maturity > settlement > last_interest), rate < 0, yld < 0, pr ≤ 0, redemption ≤ 0, frequency not 1/2/4, basis outside 0–4 →#NUM!; non-numeric →#VALUE!. Every quasi-period walk is capped (40,000 periods, more than the date range allows).Source: the ODDFPRICE, ODDFYIELD, ODDLPRICE and ODDLYIELD pages on support.microsoft.com (syntax, remarks, variable definitions, worked examples). No GPL code was consulted.
Tests
financial::tests::odd_periodsandodd_periods_survive_hostile_input:Commands run:
Docs
docs/function-parity.md(Financial 55 / 55; 505 / 523 by name, 496 working; scope table and revision row),docs/gaps.md§15,docs/target-app-parity.md,ROADMAP.md(numbers and a progress-log row) and the count inREADME.md.Not done / unverified
E − A. Both give the same results for the documented examples, but they can differ at month ends. This needs confirmation in Excel.first_couponthat is not on maturity's coupon schedule is accepted: N is counted on maturity's schedule. Excel's behaviour there is unverified.#NUM!, because the walk cannot step before 1900-01-01.#NUM!here (the crate's existing convention for PRICE, YIELD and the rest). Microsoft documents#VALUE!for invalid dates.🤖 Generated with Claude Code