diff options
Diffstat (limited to 'python/analytics')
| -rw-r--r-- | python/analytics/portfolio.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/python/analytics/portfolio.py b/python/analytics/portfolio.py index 5fd81ae8..e7abf0a2 100644 --- a/python/analytics/portfolio.py +++ b/python/analytics/portfolio.py @@ -36,27 +36,29 @@ class Portfolio: for index in self.indices: index.trade_date = d + def mark(self): + pass + @property def ref(self): if len(self.indices) == 1: return self.indices[0].ref else: - return [index.ref for for index in self.indices] + return [index.ref for index in self.indices] @ref.setter def ref(self, val): - if hasattr(self, 'index'): - self.index.ref = val - else: - if len(self.indices) == 0: + 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: - t.index.ref = val - else: - if len(val) != len(self.indices): - raise ValueError("The number of refs doesn't match the number of indices") - for index, val in zip(self.indices, val): - index.ref = val + for t in trades: + t.index.ref = val + elif len(self.indices) == len(val): + for index, val in zip(self.indices, val): + index.ref = val + else: + raise ValueError("The number of refs doesn't match the number of indices") @property def delta(self): |
