"""Check a European option parity identity.

The relation requires consistent strike, expiry, underlying and carry assumptions.
All inputs are synthetic teaching examples. Run: python 38_put-call-parity.py
"""
from tv_math import *

c=bs_price(100,100,1,.05,.2,'C')
p=bs_price(100,100,1,.05,.2,'P')
assert abs(c-p-(100-100*math.exp(-.05)))<1e-10
print(c-p)
