diff options
Diffstat (limited to 'python/analytics/portfolio.py')
| -rw-r--r-- | python/analytics/portfolio.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/python/analytics/portfolio.py b/python/analytics/portfolio.py index 2c83b8f0..809b49a2 100644 --- a/python/analytics/portfolio.py +++ b/python/analytics/portfolio.py @@ -1,12 +1,9 @@ from .index import Index from .option import BlackSwaption, BlackSwaptionVolSurface -from db import dbengine from warnings import warn import pandas as pd import numpy as np -serenitasdb = dbengine('serenitasdb') - def portf_repr(method): def f(*args): obj = args[0] @@ -28,6 +25,7 @@ def portf_repr(method): return header + s return f + class Portfolio: def __init__(self, trades): self.trades = trades @@ -78,7 +76,7 @@ class Portfolio: self._value_date = d def mark(self, source_list=[], option_type=None, model="black", surface_id=None): - #add None so that we always try everything + # add None so that we always try everything source_list = source_list + [None] for index, (index_type, series, tenor) in zip(self.indices, self._keys): index.mark() @@ -114,8 +112,8 @@ class Portfolio: if len(self.indices) == 1: self.indices[0].ref = val elif len(self.indices) == 0: - ##no index, so set the individual refs - for t in trades: + # no index, so set the individual refs + for t in self.swaptions: t.index.ref = val elif len(self.indices) == len(val): for index, val in zip(self.indices, val): @@ -135,8 +133,8 @@ class Portfolio: if len(self.indices) == 1: self.indices[0].spread = val elif len(self.indices) == 0: - ##no index, so set the individual refs - for t in trades: + # no index, so set the individual refs + for t in self.swaptions: t.index.spread = val elif len(self.indices) == len(val): for index, val in zip(self.indices, val): @@ -164,8 +162,8 @@ class Portfolio: return sum(t.theta for t in self.trades) def _todf(self): - headers = ["Product", "Index", "Notional", "Ref", "Strike", "Direction", "Expiry", - "Vol", "PV", "Delta", "Gamma", "Theta", "Vega"] + headers = ["Product", "Index", "Notional", "Ref", "Strike", "Direction", + "Expiry", "Vol", "PV", "Delta", "Gamma", "Theta", "Vega"] rec = [] for t in self.trades: if isinstance(t, Index): |
