Giter VIP home page Giter VIP logo

Comments (4)

domokane avatar domokane commented on June 20, 2024

Can you give me all of the code you used ?

from financepy.

DominicHong avatar DominicHong commented on June 20, 2024
class TestBond:
    @pytest.fixture(scope='class')
    def global_data(self):
        # A 3 months treasure with 0 coupon per year.
        bill = Bond(
            issue_date=Date(25, 7, 2022),
            maturity_date=Date(24, 10, 2022),
            coupon=0,
            freq_type=FrequencyTypes.SIMPLE,
            accrual_type=DayCountTypes.ACT_ACT_ICMA
        )

        settlement_date = Date(8, 8, 2022)
        return {
                'bill': bill,
                'date': settlement_date
        }

    def test_yield_to_maturity_no_coupon(self, global_data):
        bond = global_data['bill']
        assess_date = global_data['date']
        clean_price = 99.7056
        assert bond.yield_to_maturity(assess_date, clean_price, YTMCalcType.US_STREET) * 100 == \
               pytest.approx(1.3998)

If I change the freq_type=FrequencyTypes.MONTHLY, the code ran well. The resulted ytm was close but still not precise.
If freq_type=FrequencyTypes.ANNUAL, the ytm was far away from the correct answer(1.3998)

from financepy.

domokane avatar domokane commented on June 20, 2024

Hi - this has been fixed. I added your test

https://github.com/domokane/FinancePy/blob/master/tests_golden/TestFinBondZeroCoupon.py

You will need to build it yourself or wait until the weekend and I will push a new version of financepy to PYPI.

from financepy.

DominicHong avatar DominicHong commented on June 20, 2024

Thank you for your quick fix.
It seems to me that it would be better to use the ACT_ACT_ISDA convention for Zero Coupon Bond, in case that the period crosses a leap year and a non-leap-year.
What's your opinion?
Do you mind if I change the DayCountTypes.ZERO algorithm in year_frac() to ACT_ACT_ISDA ?

from financepy.

Related Issues (20)

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.