@@ -26,7 +26,7 @@ class DiscountCurveFlat(DiscountCurve):
2626 """A very simple discount curve based on a single zero rate with its
2727 own specified compounding method. Hence, the curve is assumed to be flat.
2828 It is used for quick and dirty analysis and when limited information is
29- available. It inherits several methods from FinDiscountCurve ."""
29+ available. It inherits several methods from DiscountCurve ."""
3030
3131 ###############################################################################
3232
@@ -44,7 +44,7 @@ def __init__(
4444 As the curve is flat, no interpolation scheme is required.
4545 """
4646
47- # super().__init__()
47+ super ().__init__ (value_dt )
4848
4949 check_argument_types (self .__init__ , locals ())
5050
@@ -56,25 +56,24 @@ def __init__(
5656 # This is used by some inherited functions, so we choose the simplest
5757 self ._interp_type = InterpTypes .FLAT_FWD_RATES
5858
59- # Need to set up a grid of times and discount factors
59+ # Need to set up a 3M grid of times and discount factors
60+ # Those beyond 10 years are extrapolated
6061 years = np .linspace (0.0 , 10.0 , 41 )
6162 dts = self .value_dt .add_years (years )
6263
63- # Set up a grid of times and discount factors for functions
64- self ._dfs = self .df (dts )
64+ # Set up a grid of dc adjusted times and discount factors for functions
6565 self ._times = times_from_dates (dts , self .value_dt , dc_type )
66+ self ._dfs = self .df (dts )
6667
6768 ###############################################################################
6869
69- def bump (self , bump_size : float ) :
70- """Create a new FinDiscountCurveFlat object with the entire curve
71- bumped up by the bumpsize. All other parameters are preserved."""
70+ def times (self ) -> np . ndarray :
71+ """Return the cached grid of times."""
72+ return self . _times
7273
73- rate_bumped = self .flat_rate + bump_size
74- disc_curve = DiscountCurveFlat (
75- self .value_dt , rate_bumped , freq_type = self .freq_type , dc_type = self .dc_type
76- )
77- return disc_curve
74+ def dfs (self ) -> np .ndarray :
75+ """Return the cached grid of discount factors."""
76+ return self ._dfs
7877
7978 ###############################################################################
8079
@@ -99,6 +98,18 @@ def df(self, dts: Union[Date, list]):
9998
10099 ###############################################################################
101100
101+ def bump (self , bump_size : float ):
102+ """Create a new FinDiscountCurveFlat object with the entire curve
103+ bumped up by the bumpsize. All other parameters are preserved."""
104+
105+ rate_bumped = self .flat_rate + bump_size
106+ disc_curve = DiscountCurveFlat (
107+ self .value_dt , rate_bumped , freq_type = self .freq_type , dc_type = self .dc_type
108+ )
109+ return disc_curve
110+
111+ ###############################################################################
112+
102113 def __repr__ (self ):
103114 s = label_to_string ("OBJECT TYPE" , type (self ).__name__ )
104115 s += label_to_string ("VALUE DATE" , (self .value_dt ))
0 commit comments