diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2020-02-21 16:36:32 -0500 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2020-02-21 16:36:32 -0500 |
| commit | c59f0796f75f825eb272ab3fce8649e0dd42deb6 (patch) | |
| tree | 60ef1f7554b992454fe303823ccd39ee0d1191aa | |
| parent | 08de733ea74154acb36c1f6bfa836acebfc2071c (diff) | |
| download | pyisda-c59f0796f75f825eb272ab3fce8649e0dd42deb6.tar.gz | |
keep map order
| -rw-r--r-- | pyisda/credit_index.pyx | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/pyisda/credit_index.pyx b/pyisda/credit_index.pyx index 1071e80..4a83090 100644 --- a/pyisda/credit_index.pyx +++ b/pyisda/credit_index.pyx @@ -145,11 +145,15 @@ cdef class CurveList: @property def tickers(self): - cdef np.npy_intp shape = self.names.size() - cdef pair[CurveName, size_t] p - cdef np.ndarray out = np.PyArray_EMPTY(1, &shape, np.NPY_OBJECT, 1) + cdef: + np.npy_intp shape = self.names.size() + pair[CurveName, size_t] p + np.ndarray out = np.PyArray_EMPTY(1, &shape, np.NPY_OBJECT, 1) + int j = 0 + for p in self.names: - out[p.second] = p.first.ticker + out[j] = p.first.ticker + j += 1 return out @property @@ -627,7 +631,7 @@ cdef class CreditIndex(CurveList): pair[CurveName, size_t] p np.npy_intp[2] n const TDate* schedule_ptr - size_t i + size_t i, j = 0 if schedule is None: schedule_ptr = self._maturities.const_data() @@ -648,7 +652,8 @@ cdef class CreditIndex(CurveList): for p in self.names: if self.defaulted[p.second] != -1: for i in range(n[1]): - spreads_view[p.second, i] = nan("") + spreads_view[j, i] = nan("") + j += 1 continue sc = self._curves[p.second] JpmcdsCdsParSpreads( @@ -697,12 +702,11 @@ cdef class CreditIndex(CurveList): JpmcdsStringToStubMethod(b"f/s", &stub_type) with nogil: - - for p in self.names: - if self.defaulted[p.second] != -1: + for j in range(self._curves.size()): + if self.defaulted[j] != -1: continue - sc = self._curves[p.second] - w = self._weights[p.second] + sc = self._curves[j] + w = self._weights[j] JpmcdsCdsParSpreads( self.base_date, self.base_date + 1, @@ -717,7 +721,7 @@ cdef class CreditIndex(CurveList): b'NONE', get_TCurve(yc), sc.get(), - self.recovery_rates[p.second].get(), + self.recovery_rates[j].get(), spreads) if first_time: |
