Skip to content

Commit 7c0b8f0

Browse files
committed
Minor changes
1 parent c26b59b commit 7c0b8f0

4 files changed

Lines changed: 22 additions & 20 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
- Extended inheritance of DiscountCurves to all curves
1515
- All inheriting classes have a bump_parallel method
1616
- Removed alternative calculations of zero, par, swap and forward rates so all such calls use DiscountCurve methods
17-
- Added argument to determine day count rule for converting dates to times
17+
- Added discount curve level property to determine day count rule for converting dates to times
1818
- Set default value of time_dc_type to ACT_365F - which means we divide by 365
1919
- Fixed bug in swap_float_leg so we use specifed accrual basis and not index curve basis
2020
- Set all references to call directly discountCurve._dfs and ._times to avoid copying using accessor methods

regression_tests/TestFinBond.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,10 @@ def test_cpn_types():
813813

814814
def test_stack_exchange():
815815

816+
# https://quant.stackexchange.com/questions/66508/schedule-yield-to-maturity-and-npv-of-fixed-rate-bond-from-quantlib-python
817+
818+
# Unable to reconcile with strange example
819+
816820
issue_dt = Date(28, 9, 2019)
817821
maturity_dt = Date(28, 9, 2024)
818822
coupon = 0.05
@@ -823,9 +827,9 @@ def test_stack_exchange():
823827

824828
value_dt = Date(31, 7, 2020)
825829
settle_dt = value_dt.add_days(100)
826-
print(settle_dt)
830+
# print(settle_dt)
827831

828-
print(bond.print_payments(settle_dt, 100))
832+
# print(bond.print_payments(settle_dt, 100))
829833

830834
spot_dts = [Date(31, 7, 2020), Date(1, 1, 2027)]
831835
spot_rates = [0.01, 0.02]
@@ -839,15 +843,15 @@ def test_stack_exchange():
839843
DayCountTypes.ACT_360,
840844
)
841845

842-
print(
843-
"Dirty Price = %12.7f"
844-
% bond.dirty_price_from_discount_curve(settle_dt, zero_curve)
845-
)
846+
# print(
847+
# "Dirty Price = %12.7f"
848+
# % bond.dirty_price_from_discount_curve(settle_dt, zero_curve)
849+
# )
846850

847-
print(
848-
"Clean Price = %12.7f"
849-
% bond.clean_price_from_discount_curve(settle_dt, zero_curve)
850-
)
851+
# print(
852+
# "Clean Price = %12.7f"
853+
# % bond.clean_price_from_discount_curve(settle_dt, zero_curve)
854+
# )
851855

852856

853857
###############################################################################

regression_tests/TestFinBondFittedYieldCurve.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@
2828

2929
def test_bond_fitted_yield_curve():
3030

31-
path = os.path.join(os.path.dirname(__file__),
32-
"./data/gilt_bond_prices.txt")
31+
path = os.path.join(os.path.dirname(__file__), "./data/gilt_bond_prices.txt")
3332
bond_dataframe = pd.read_csv(path, sep="\t")
34-
bond_dataframe["mid"] = 0.5 * \
35-
(bond_dataframe["bid"] + bond_dataframe["ask"])
33+
bond_dataframe["mid"] = 0.5 * (bond_dataframe["bid"] + bond_dataframe["ask"])
3634

3735
freq_type = FrequencyTypes.SEMI_ANNUAL
3836
dc_type = DayCountTypes.ACT_ACT_ICMA
@@ -101,7 +99,7 @@ def test_bond_fitted_yield_curve():
10199
test_cases.print("tau_2", fitted_curve4.curve_fit.tau_2)
102100

103101
maturity_dt = Date(19, 9, 2030)
104-
interp_yield = fitted_curve5.interp_rate(maturity_dt)
102+
interp_yield = fitted_curve5.interp_yield(maturity_dt)
105103
test_cases.print(maturity_dt, interp_yield)
106104

107105

regression_tests/TestFinFXBarrierOption.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from financepy.utils.date import Date
88
from financepy.market.curves.discount_curve_flat import DiscountCurveFlat
99
from financepy.products.fx.fx_barrier_option import FXBarrierOption
10-
from financepy.products.fx.fx_barrier_option import BarrierTypes
10+
from financepy.products.fx.fx_barrier_option import FXBarrierTypes
1111
from financepy.models.black_scholes import BlackScholes
1212
from financepy.models.process_simulator import FinGBMNumericalScheme
1313
from financepy.models.process_simulator import ProcessTypes
@@ -28,7 +28,7 @@ def test_fin_fx_barrier_option():
2828
volatility = 0.20
2929
dom_interest_rate = 0.05
3030
for_interest_rate = 0.02
31-
opt_type = BarrierTypes.DOWN_AND_OUT_CALL
31+
opt_type = FXBarrierTypes.DOWN_AND_OUT_CALL
3232
notional = 100.0
3333
notional_currency = "USD"
3434

@@ -42,7 +42,7 @@ def test_fin_fx_barrier_option():
4242
start = time.time()
4343
num_obs_per_year = 100
4444

45-
for opt_type in BarrierTypes:
45+
for opt_type in FXBarrierTypes:
4646

4747
test_cases.header("Type", "K", "B", "S", "Value", "ValueMC", "TIME", "Diff")
4848

@@ -141,7 +141,7 @@ def test_fin_fx_barrier_option():
141141

142142
test_cases.header("Type", "K", "B", "S:", "Value", "Delta", "Vega", "Theta")
143143

144-
for opt_type in BarrierTypes:
144+
for opt_type in FXBarrierTypes:
145145
for spot_fx_rate in spot_fx_rates:
146146
barrier_option = FXBarrierOption(
147147
expiry_dt,

0 commit comments

Comments
 (0)