aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/analytics/option.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/python/analytics/option.py b/python/analytics/option.py
index 4cf52140..79ba4d96 100644
--- a/python/analytics/option.py
+++ b/python/analytics/option.py
@@ -96,12 +96,12 @@ class BlackSwaption(ForwardIndex):
if rec is None:
return ValueError("trade_id doesn't exist")
index = Index.from_name(redcode=rec.security_id, maturity=rec.maturity, trade_date=rec.trade_date)
- index.spread = 62
+ index.spread = rec.indexref
instance = cls(index, rec.expiration_date, rec.strike, rec.swaption_type.lower(),
direction="Long" if rec.buysell else "Short")
instance.notional = rec.notional
- instance.pv = rec.price * 1e-2 * rec.notional
- instance._original_pv = rec.price * 1e-2 * rec.notional
+ instance.pv = rec.price * 1e-2 * rec.notional * (2 * rec.buysell - 1)
+ instance._original_pv = instance.pv
return instance
@property
@@ -168,8 +168,8 @@ class BlackSwaption(ForwardIndex):
return self._direction * intrinsic * self.notional
def __hash__(self):
- return hash((super().__hash__(),
- tuple(getattr(self, k) for k in BlackSwaption.__slots__[:-1])))
+ return hash((super().__hash__(), tuple(getattr(self, k) for k in \
+ BlackSwaption.__slots__)))
@property
def pv(self):
@@ -198,7 +198,7 @@ class BlackSwaption(ForwardIndex):
def handle(x):
self.sigma = x
- return self.pv - val
+ return self._direction * (self.pv - val)
eta = 1.01
a = 0.1
b = a * eta