diff --git a/financepy/products/fx/fx_digital_option.py b/financepy/products/fx/fx_digital_option.py index 0271c9ff..54527a47 100644 --- a/financepy/products/fx/fx_digital_option.py +++ b/financepy/products/fx/fx_digital_option.py @@ -218,8 +218,9 @@ def value_mc( spot_dt = value_dt.add_weekdays(self.spot_days) - t_del = option_years(spot_dt, self.delivery_dt) - t_exp = option_years(spot_dt, self.expiry_dt) + t_spot = option_years(value_dt, spot_dt) + t_del = option_years(value_dt, self.delivery_dt) + t_exp = option_years(value_dt, self.expiry_dt) # ------------------------------------------------------------------ # Market parameters @@ -227,12 +228,16 @@ def value_mc( t = max(t_exp, 1.0e-10) - dom_df = domestic_curve.df_t(t) - - r_d = domestic_curve.zero_rate_cc(self.expiry_dt) - r_f = foreign_curve.zero_rate_cc(self.expiry_dt) + # As in value(): the forward grows from the spot date to delivery and + # the payment is discounted from delivery. + dom_df = domestic_curve.df_t(t_del) + dom_fwd_df = dom_df / domestic_curve.df_t(t_spot) + for_fwd_df = foreign_curve.df_t(t_del) / foreign_curve.df_t(t_spot) - mu = r_d - r_f + if t_exp == 0.0: + f = spot_fx_rate + else: + f = spot_fx_rate * for_fwd_df / dom_fwd_df v = model.volatility @@ -245,7 +250,7 @@ def value_mc( rng = np.random.default_rng(seed) g = rng.standard_normal(num_paths) - s = spot_fx_rate * np.exp((mu - v * v / 2.0) * t) + s = f * np.exp(-v * v / 2.0 * t) m = np.exp(g * np.sqrt(t) * v) s_1 = s * m diff --git a/tests/unit/test_fx_double_digital_option.py b/tests/unit/test_fx_double_digital_option.py index 0c1a3abc..49cfb678 100644 --- a/tests/unit/test_fx_double_digital_option.py +++ b/tests/unit/test_fx_double_digital_option.py @@ -114,3 +114,23 @@ def test_digitals_with_spot_lag_decompose_the_vanilla_call(): expected = _lag_value(vanilla)["v"] assert np.isclose(_lag_value(asset) - k * _lag_value(cash), expected, rtol=1e-6) + + +def test_digital_monte_carlo_with_spot_lag_uses_the_delivery_forward_and_discount(): + """A digital call plus a digital put at the same strike pays one unit for sure, so + in Monte Carlo the pair is worth the value of that unit paid on the delivery date, + the same as in the analytic value.""" + for prem_currency in ("USD", "EUR"): + options = [ + FXDigitalOption(lag_expiry_dt, 1.10, "EURUSD", opt_type, 1.0, prem_currency, 2) + for opt_type in (OptionTypes.DIGITAL_CALL, OptionTypes.DIGITAL_PUT) + ] + mc = sum( + option.value_mc( + lag_value_dt, spot_fx_rate, lag_domestic_curve, lag_foreign_curve, model, + num_paths=200000, + ) + for option in options + ) + analytic = sum(_lag_value(option) for option in options) + assert np.isclose(mc, analytic, rtol=1e-4)