aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/mark_swaptions.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/python/mark_swaptions.py b/python/mark_swaptions.py
index 7b2a1127..1623a181 100644
--- a/python/mark_swaptions.py
+++ b/python/mark_swaptions.py
@@ -58,30 +58,35 @@ def mark_trades(date, engine):
trade.index, trade.series, '5yr', date))
underlying = Index.from_name(trade.index, trade.series, '5yr', date,
trade.notional)
- sigma = get_swaptionvol(trade.index, trade.series, trade.strike, trade.expiration_date.date(),
+ quote = get_swaptionvol(trade.index, trade.series, trade.strike, trade.expiration_date.date(),
date, serenitas_engine)
- if sigma is None:
+ if quote is None:
continue
- if trade.index == "IG":
- underlying.spread = sigma.ref
- elif trade.index == "HY":
- underlying.price = sigma.ref
+ underlying.ref = quote.ref
swaption = Swaption(underlying, trade.expiration_date.date(),
trade.strike, trade.swaption_type.lower())
- swaption.sigma = getattr(sigma, swaption.option_type)
+ if swaption.option_type == "payer":
+ if quote.payer is None:
+ swaption.sigma = quote.receiver
+ else:
+ swaption.sigma = quote.payer
+ else:
+ if quote.receiver is None:
+ swaption.sigma = quote.payer
+ else:
+ swaption.sigma = quote.receiver
direction = 1. if trade.buysell else -1.
market_value = swaption.pv * trade.notional * direction
- market_value += swaption.DV01 * (closespread-sigma.ref) * trade.notional * direction
+ market_value += swaption.DV01 * (closespread - quote.ref) * trade.notional * direction
#compute the greeks at index mark
swaption.index.spread = closespread
swaption._update()
try:
- test = (trade.Index, date, market_value, swaption.delta, swaption.gamma,
- swaption.vega)
+ to_insert = (trade.Index, date, market_value, swaption.delta, swaption.gamma,
+ swaption.vega)
engine.execute("INSERT INTO swaption_marks VALUES(%s, %s, %s, %s, %s, %s)",
- (trade.Index, date, market_value, swaption.delta, swaption.gamma,
- swaption.vega))
+ to_insert)
except exc.DataError as e:
logging.error(e)
finally: