aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics/option.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics/option.py')
-rw-r--r--python/analytics/option.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/python/analytics/option.py b/python/analytics/option.py
index 2c41f1be..148e0e34 100644
--- a/python/analytics/option.py
+++ b/python/analytics/option.py
@@ -548,7 +548,7 @@ class ProbSurface(QuoteSurface):
quotedate, source = surface_id
quotes = self._quotes[(self._quotes.quotedate == quotedate) &
(self._quotes.quote_source == source)]
- self._index.ref = quotes.ref[0]
+ self._index.ref = quotes.ref.iat[0]
quotes = quotes.assign(time=((quotes.expiry - self.trade_date).dt.days + 0.25) / 365,
pay_mid=quotes[['pay_bid','pay_offer']].mean(1),
rec_mid=quotes[['rec_bid','rec_offer']].mean(1),
@@ -559,9 +559,10 @@ class ProbSurface(QuoteSurface):
quotes = quotes.sort_values(['expiry', 'strike'])
prob_pay = np.concatenate([-np.gradient(df.pay_mid, df.strike)
for _, df in quotes.groupby('expiry')])
- prob_rec = np.concatenate([1-np.gradient(df.rec_mid, df.strike)
+ prob_rec = np.concatenate([1 - np.gradient(df.rec_mid, df.strike)
for _, df in quotes.groupby('expiry')])
prob = bn.nanmean(np.stack([prob_pay, prob_rec]), axis=0)
+ prob = np.clip(prob, 1e-10, None, out=prob)
f = SmoothBivariateSpline(quotes.time.values[~np.isnan(prob)],
quotes.strike.values[~np.isnan(prob)],
logit(prob[~np.isnan(prob)]))