Files
FOUR-QUADRANT_BALANCE_SHEET…/tests/test_fx_parity.py
2026-02-22 23:39:47 -08:00

43 lines
1021 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Tests for Sheet 4: FX parity (Part IIIIV)."""
import pytest
from fqbm.state import FQBMState
from fqbm.sheets.fx_parity import (
covered_interest_parity_fwd,
uncovered_interest_parity_ds,
dornbusch_s,
fx_pass_through_inflation,
fx_parity_step,
FXParams,
)
def test_cip():
F = covered_interest_parity_fwd(1.0, 0.05, 0.03)
assert F > 1.0
assert abs(F - 1.0 * (1.05 / 1.03)) < 1e-6
def test_uip():
ds = uncovered_interest_parity_ds(1.0, 0.05, 0.03)
assert abs(ds - 0.02) < 1e-6
def test_dornbusch():
s = dornbusch_s(1.0, 0.05, 0.03, 1.5)
assert s > 1.0
assert abs(s - 1.0 - 1.5 * 0.02) < 1e-6
def test_fx_pass_through():
pi = fx_pass_through_inflation(0.1, 0.2)
assert pi == pytest.approx(0.02)
def test_fx_parity_step():
state = FQBMState(S=1.0)
params = FXParams(s_star=1.0, i_d=0.05, i_f=0.03, lambda_dornbusch=2.0)
out = fx_parity_step(state, params)
assert out.S != 1.0
assert out.S == pytest.approx(1.0 + 2.0 * 0.02)