43 lines
1021 B
Python
43 lines
1021 B
Python
"""Tests for Sheet 4: FX parity (Part III–IV)."""
|
||
|
||
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)
|