Replies: 1 comment 1 reply
-
| Hi - in the latest release I removed facevalue from the bond constructor - it is no longer a class member but is an additional input when calculating accrued and principal. Because you passed in a face value of 12500, it is using this as the number of ex-div dates and this is why the date error is thrown. Remove facevalue and it should be fine. | 
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I get an error with all the fctns that contain settlement_Date as a parameter, for instance bond.yield_to_maturity(settlementDate, cleanPrice).
This is the simple code and the error:
import numpy as np
import matplotlib.pyplot as plt
import datetime as dt
import financepy as fp
from financepy.utils import *
from financepy.products.bonds import *
issueDate = Date(15, 5, 2020)
maturityDate = Date(15, 5, 2035)
coupon = 0.02375
freqType = FrequencyTypes.SEMI_ANNUAL
accrualType = DayCountTypes.ACT_ACT_ICMA
face = 125000
Class bond
bond = Bond(issueDate, maturityDate, coupon, freqType, accrualType, face)
print(bond)
cleanPrice = 99.7808417 # if face is 1 then this must be 0.99780842
settlementDate = Date(15, 5, 2023)
print(bond.bond_payments(settlementDate, face))
#Bond Yield Measures
Current yield is the coupon over the price
current_yield = bond.current_yield(cleanPrice)*100
print("Current Yield %12.7f %%" % (current_yield))
ytm = bond.yield_to_maturity(settlementDate, cleanPrice)
print("Yield to maturity %12.7f %%" % (ytm))
the error:
File ~\AppData\Roaming\Python\Python39\site-packages\financepy\utils\date.py:244 in init
raise FinError("Year cannot be before 1900")
FinError: Year cannot be before 1900
Beta Was this translation helpful? Give feedback.
All reactions