Generated by Cython 3.0.12
Yellow lines hint at Python interaction.
Click on a line that starts with a "+
" to see the C code that Cython generated for it.
Raw output: continuous_futures.c
+001: # cython: embedsignature=True
__pyx_t_5 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_5) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
002: #
003: # Copyright 2016 Quantopian, Inc.
004: #
005: # Licensed under the Apache License, Version 2.0 (the "License");
006: # you may not use this file except in compliance with the License.
007: # You may obtain a copy of the License at
008: #
009: # http://www.apache.org/licenses/LICENSE-2.0
010: #
011: # Unless required by applicable law or agreed to in writing, software
012: # distributed under the License is distributed on an "AS IS" BASIS,
013: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: # See the License for the specific language governing permissions and
015: # limitations under the License.
016:
017: """
018: Cythonized ContinuousFutures object.
019: """
020: cimport cython
021: from cpython.number cimport PyNumber_Index
022: from cpython.object cimport (
023: Py_EQ,
024: Py_NE,
025: Py_GE,
026: Py_LE,
027: Py_GT,
028: Py_LT,
029: )
030: from cpython cimport bool
031:
+032: from functools import partial
__pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_n_s_partial); __Pyx_GIVEREF(__pyx_n_s_partial); if (__Pyx_PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_partial)) __PYX_ERR(0, 32, __pyx_L1_error); __pyx_t_4 = __Pyx_Import(__pyx_n_s_functools, __pyx_t_7, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_partial); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_d, __pyx_n_s_partial, __pyx_t_7) < 0) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
033:
+034: from numpy import array, empty, iinfo
__pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_n_s_array); __Pyx_GIVEREF(__pyx_n_s_array); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_array)) __PYX_ERR(0, 34, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_empty); __Pyx_GIVEREF(__pyx_n_s_empty); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_empty)) __PYX_ERR(0, 34, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_iinfo); __Pyx_GIVEREF(__pyx_n_s_iinfo); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 2, __pyx_n_s_iinfo)) __PYX_ERR(0, 34, __pyx_L1_error); __pyx_t_7 = __Pyx_Import(__pyx_n_s_numpy, __pyx_t_4, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_array, __pyx_t_4) < 0) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_empty, __pyx_t_4) < 0) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_iinfo, __pyx_t_4) < 0) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
035: from numpy cimport longlong_t, int64_t
+036: from pandas import Timestamp
__pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_n_s_Timestamp); __Pyx_GIVEREF(__pyx_n_s_Timestamp); if (__Pyx_PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_Timestamp)) __PYX_ERR(0, 36, __pyx_L1_error); __pyx_t_4 = __Pyx_Import(__pyx_n_s_pandas, __pyx_t_7, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_Timestamp); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Timestamp, __pyx_t_7) < 0) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+037: from zipline.utils.calendar_utils import get_calendar
__pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_n_s_get_calendar); __Pyx_GIVEREF(__pyx_n_s_get_calendar); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_get_calendar)) __PYX_ERR(0, 37, __pyx_L1_error); __pyx_t_7 = __Pyx_Import(__pyx_n_s_zipline_utils_calendar_utils, __pyx_t_4, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_get_calendar); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_calendar, __pyx_t_4) < 0) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+038: import warnings
__pyx_t_7 = __Pyx_ImportDottedModule(__pyx_n_s_warnings, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_7) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
039:
040:
+041: def delivery_predicate(codes, contract):
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_1delivery_predicate(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7zipline_6assets_18continuous_futures_delivery_predicate, "delivery_predicate(codes, contract)"); static PyMethodDef __pyx_mdef_7zipline_6assets_18continuous_futures_1delivery_predicate = {"delivery_predicate", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_6assets_18continuous_futures_1delivery_predicate, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7zipline_6assets_18continuous_futures_delivery_predicate}; static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_1delivery_predicate(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_codes = 0; PyObject *__pyx_v_contract = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("delivery_predicate (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_codes,&__pyx_n_s_contract,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_codes)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 41, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_contract)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 41, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("delivery_predicate", 1, 2, 2, 1); __PYX_ERR(0, 41, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "delivery_predicate") < 0)) __PYX_ERR(0, 41, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_codes = values[0]; __pyx_v_contract = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("delivery_predicate", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 41, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("zipline.assets.continuous_futures.delivery_predicate", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_delivery_predicate(__pyx_self, __pyx_v_codes, __pyx_v_contract); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_delivery_predicate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_codes, PyObject *__pyx_v_contract) { PyObject *__pyx_v_delivery_code = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__11) __Pyx_TraceCall("delivery_predicate", __pyx_f[0], 41, 0, __PYX_ERR(0, 41, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("zipline.assets.continuous_futures.delivery_predicate", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_delivery_code); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__45 = PyTuple_Pack(3, __pyx_n_s_codes, __pyx_n_s_contract, __pyx_n_s_delivery_code); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__45); __Pyx_GIVEREF(__pyx_tuple__45); /* … */ __pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_6assets_18continuous_futures_1delivery_predicate, 0, __pyx_n_s_delivery_predicate, NULL, __pyx_n_s_zipline_assets_continuous_future, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_d, __pyx_n_s_delivery_predicate, __pyx_t_7) < 0) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline_assets_continuous_fu, __pyx_n_s_delivery_predicate, 41, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 41, __pyx_L1_error)
042: # This relies on symbols that are construct following a pattern of
043: # root symbol + delivery code + year, e.g. PLF16
044: # This check would be more robust if the future contract class had
045: # a 'delivery_month' member.
+046: delivery_code = contract.symbol[-3]
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_symbol); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, -3L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_delivery_code = __pyx_t_2; __pyx_t_2 = 0;
+047: return delivery_code in codes
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_v_delivery_code, __pyx_v_codes, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 47, __pyx_L1_error) __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
048:
+049: march_cycle_delivery_predicate = partial(delivery_predicate,
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_partial); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_delivery_predicate); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PySet_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PySet_Add(__pyx_t_5, __pyx_n_u_H) < 0) __PYX_ERR(0, 50, __pyx_L1_error) if (PySet_Add(__pyx_t_5, __pyx_n_u_M) < 0) __PYX_ERR(0, 50, __pyx_L1_error) if (PySet_Add(__pyx_t_5, __pyx_n_u_U) < 0) __PYX_ERR(0, 50, __pyx_L1_error) if (PySet_Add(__pyx_t_5, __pyx_n_u_Z) < 0) __PYX_ERR(0, 50, __pyx_L1_error) __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4)) __PYX_ERR(0, 49, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_5)) __PYX_ERR(0, 49, __pyx_L1_error); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_march_cycle_delivery_predicate, __pyx_t_5) < 0) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
050: set(['H', 'M', 'U', 'Z']))
051:
052: CHAIN_PREDICATES = {
+053: 'EL': march_cycle_delivery_predicate,
__pyx_t_5 = __Pyx_PyDict_NewPresized(12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_march_cycle_delivery_predicate); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_5, __pyx_n_u_EL, __pyx_t_9) < 0) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+054: 'ME': march_cycle_delivery_predicate,
__Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_march_cycle_delivery_predicate); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_5, __pyx_n_u_ME, __pyx_t_9) < 0) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+055: 'PL': partial(delivery_predicate, set(['F', 'J', 'N', 'V'])),
__Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_partial); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 55, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_delivery_predicate); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 55, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 55, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PySet_Add(__pyx_t_4, __pyx_n_u_F) < 0) __PYX_ERR(0, 55, __pyx_L1_error) if (PySet_Add(__pyx_t_4, __pyx_n_u_J) < 0) __PYX_ERR(0, 55, __pyx_L1_error) if (PySet_Add(__pyx_t_4, __pyx_n_u_N) < 0) __PYX_ERR(0, 55, __pyx_L1_error) if (PySet_Add(__pyx_t_4, __pyx_n_u_V) < 0) __PYX_ERR(0, 55, __pyx_L1_error) __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 55, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7)) __PYX_ERR(0, 55, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_4)) __PYX_ERR(0, 55, __pyx_L1_error); __pyx_t_7 = 0; __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 55, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_u_PL, __pyx_t_4) < 0) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+056: 'PA': march_cycle_delivery_predicate,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_march_cycle_delivery_predicate); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_5, __pyx_n_u_PA, __pyx_t_4) < 0) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
057:
058: # The majority of trading in these currency futures is done on a
059: # March quarterly cycle (Mar, Jun, Sep, Dec) but contracts are
060: # listed for the first 3 consecutive months from the present day. We
061: # want the continuous futures to be composed of just the quarterly
062: # contracts.
+063: 'JY': march_cycle_delivery_predicate,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_march_cycle_delivery_predicate); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_5, __pyx_n_u_JY, __pyx_t_4) < 0) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+064: 'CD': march_cycle_delivery_predicate,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_march_cycle_delivery_predicate); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_5, __pyx_n_u_CD, __pyx_t_4) < 0) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+065: 'AD': march_cycle_delivery_predicate,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_march_cycle_delivery_predicate); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_5, __pyx_n_u_AD, __pyx_t_4) < 0) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+066: 'BP': march_cycle_delivery_predicate,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_march_cycle_delivery_predicate); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 66, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_5, __pyx_n_u_BP, __pyx_t_4) < 0) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
067:
068: # Gold and silver contracts trade on an unusual specific set of months.
+069: 'GC': partial(delivery_predicate, set(['G', 'J', 'M', 'Q', 'V', 'Z'])),
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_partial); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_delivery_predicate); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_9 = PySet_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PySet_Add(__pyx_t_9, __pyx_n_u_G) < 0) __PYX_ERR(0, 69, __pyx_L1_error) if (PySet_Add(__pyx_t_9, __pyx_n_u_J) < 0) __PYX_ERR(0, 69, __pyx_L1_error) if (PySet_Add(__pyx_t_9, __pyx_n_u_M) < 0) __PYX_ERR(0, 69, __pyx_L1_error) if (PySet_Add(__pyx_t_9, __pyx_n_u_Q) < 0) __PYX_ERR(0, 69, __pyx_L1_error) if (PySet_Add(__pyx_t_9, __pyx_n_u_V) < 0) __PYX_ERR(0, 69, __pyx_L1_error) if (PySet_Add(__pyx_t_9, __pyx_n_u_Z) < 0) __PYX_ERR(0, 69, __pyx_L1_error) __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_10); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10)) __PYX_ERR(0, 69, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_9)) __PYX_ERR(0, 69, __pyx_L1_error); __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_u_GC, __pyx_t_9) < 0) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+070: 'XG': partial(delivery_predicate, set(['G', 'J', 'M', 'Q', 'V', 'Z'])),
__Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_partial); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_delivery_predicate); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PySet_Add(__pyx_t_4, __pyx_n_u_G) < 0) __PYX_ERR(0, 70, __pyx_L1_error) if (PySet_Add(__pyx_t_4, __pyx_n_u_J) < 0) __PYX_ERR(0, 70, __pyx_L1_error) if (PySet_Add(__pyx_t_4, __pyx_n_u_M) < 0) __PYX_ERR(0, 70, __pyx_L1_error) if (PySet_Add(__pyx_t_4, __pyx_n_u_Q) < 0) __PYX_ERR(0, 70, __pyx_L1_error) if (PySet_Add(__pyx_t_4, __pyx_n_u_V) < 0) __PYX_ERR(0, 70, __pyx_L1_error) if (PySet_Add(__pyx_t_4, __pyx_n_u_Z) < 0) __PYX_ERR(0, 70, __pyx_L1_error) __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7)) __PYX_ERR(0, 70, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_4)) __PYX_ERR(0, 70, __pyx_L1_error); __pyx_t_7 = 0; __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_u_XG, __pyx_t_4) < 0) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+071: 'SV': partial(delivery_predicate, set(['H', 'K', 'N', 'U', 'Z'])),
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_partial); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_delivery_predicate); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_9 = PySet_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PySet_Add(__pyx_t_9, __pyx_n_u_H) < 0) __PYX_ERR(0, 71, __pyx_L1_error) if (PySet_Add(__pyx_t_9, __pyx_n_u_K) < 0) __PYX_ERR(0, 71, __pyx_L1_error) if (PySet_Add(__pyx_t_9, __pyx_n_u_N) < 0) __PYX_ERR(0, 71, __pyx_L1_error) if (PySet_Add(__pyx_t_9, __pyx_n_u_U) < 0) __PYX_ERR(0, 71, __pyx_L1_error) if (PySet_Add(__pyx_t_9, __pyx_n_u_Z) < 0) __PYX_ERR(0, 71, __pyx_L1_error) __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_10); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10)) __PYX_ERR(0, 71, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_9)) __PYX_ERR(0, 71, __pyx_L1_error); __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_u_SV, __pyx_t_9) < 0) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+072: 'YS': partial(delivery_predicate, set(['H', 'K', 'N', 'U', 'Z'])),
__Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_partial); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_delivery_predicate); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PySet_Add(__pyx_t_4, __pyx_n_u_H) < 0) __PYX_ERR(0, 72, __pyx_L1_error) if (PySet_Add(__pyx_t_4, __pyx_n_u_K) < 0) __PYX_ERR(0, 72, __pyx_L1_error) if (PySet_Add(__pyx_t_4, __pyx_n_u_N) < 0) __PYX_ERR(0, 72, __pyx_L1_error) if (PySet_Add(__pyx_t_4, __pyx_n_u_U) < 0) __PYX_ERR(0, 72, __pyx_L1_error) if (PySet_Add(__pyx_t_4, __pyx_n_u_Z) < 0) __PYX_ERR(0, 72, __pyx_L1_error) __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7)) __PYX_ERR(0, 72, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_4)) __PYX_ERR(0, 72, __pyx_L1_error); __pyx_t_7 = 0; __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_u_YS, __pyx_t_4) < 0) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_CHAIN_PREDICATES, __pyx_t_5) < 0) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
073: }
074:
+075: ADJUSTMENT_STYLES = {'add', 'mul', None}
__pyx_t_5 = PySet_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PySet_Add(__pyx_t_5, __pyx_n_u_add) < 0) __PYX_ERR(0, 75, __pyx_L1_error) if (PySet_Add(__pyx_t_5, __pyx_n_u_mul) < 0) __PYX_ERR(0, 75, __pyx_L1_error) if (PySet_Add(__pyx_t_5, Py_None) < 0) __PYX_ERR(0, 75, __pyx_L1_error) if (PyDict_SetItem(__pyx_d, __pyx_n_s_ADJUSTMENT_STYLES, __pyx_t_5) < 0) __PYX_ERR(0, 75, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
076:
077:
+078: cdef class ContinuousFuture:
struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture { PyObject_HEAD struct __pyx_vtabstruct_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_vtab; __pyx_t_5numpy_longlong_t sid; __pyx_t_5numpy_longlong_t sid_hash; PyObject *root_symbol; int offset; PyObject *roll_style; PyObject *start_date; PyObject *end_date; PyObject *exchange_info; PyObject *adjustment; }; /* … */ struct __pyx_vtabstruct_7zipline_6assets_18continuous_futures_ContinuousFuture { PyObject *(*__pyx___reduce__)(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *, int __pyx_skip_dispatch); PyObject *(*to_dict)(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *, int __pyx_skip_dispatch); }; static struct __pyx_vtabstruct_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_vtabptr_7zipline_6assets_18continuous_futures_ContinuousFuture;
079: """
080: Represents a specifier for a chain of future contracts, where the
081: coordinates for the chain are:
082: root_symbol : str
083: The root symbol of the contracts.
084: offset : int
085: The distance from the primary chain.
086: e.g. 0 specifies the primary chain, 1 the secondary, etc.
087: roll_style : str
088: How rolls from contract to contract should be calculated.
089: Currently supports 'calendar'.
090:
091: Instances of this class are exposed to the algorithm.
092: """
093:
+094: cdef readonly longlong_t sid
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_3sid_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_3sid_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_3sid___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_3sid___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 94, 0, __PYX_ERR(0, 94, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_npy_longlong(__pyx_v_self->sid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.sid.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
095: # Cached hash of self.sid
096: cdef longlong_t sid_hash
097:
+098: cdef readonly object root_symbol
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_11root_symbol_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_11root_symbol_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_11root_symbol___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_11root_symbol___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 98, 0, __PYX_ERR(0, 98, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->root_symbol); __pyx_r = __pyx_v_self->root_symbol; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.root_symbol.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+099: cdef readonly int offset
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_6offset_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_6offset_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_6offset___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_6offset___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 99, 0, __PYX_ERR(0, 99, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.offset.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+100: cdef readonly object roll_style
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_10roll_style_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_10roll_style_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_10roll_style___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_10roll_style___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 100, 0, __PYX_ERR(0, 100, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->roll_style); __pyx_r = __pyx_v_self->roll_style; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.roll_style.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
101:
+102: cdef readonly object start_date
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_10start_date_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_10start_date_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_10start_date___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_10start_date___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 102, 0, __PYX_ERR(0, 102, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->start_date); __pyx_r = __pyx_v_self->start_date; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.start_date.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+103: cdef readonly object end_date
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_8end_date_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_8end_date_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_8end_date___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_8end_date___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 103, 0, __PYX_ERR(0, 103, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->end_date); __pyx_r = __pyx_v_self->end_date; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.end_date.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
104:
+105: cdef readonly object exchange_info
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_13exchange_info_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_13exchange_info_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_13exchange_info___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_13exchange_info___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 105, 0, __PYX_ERR(0, 105, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->exchange_info); __pyx_r = __pyx_v_self->exchange_info; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.exchange_info.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
106:
+107: cdef readonly object adjustment
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_10adjustment_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_10adjustment_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_10adjustment___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_10adjustment___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 107, 0, __PYX_ERR(0, 107, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->adjustment); __pyx_r = __pyx_v_self->adjustment; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.adjustment.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
108:
+109: _kwargnames = frozenset({
__pyx_t_5 = PySet_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PySet_Add(__pyx_t_5, __pyx_n_u_sid) < 0) __PYX_ERR(0, 110, __pyx_L1_error) if (PySet_Add(__pyx_t_5, __pyx_n_u_root_symbol) < 0) __PYX_ERR(0, 110, __pyx_L1_error) if (PySet_Add(__pyx_t_5, __pyx_n_u_offset) < 0) __PYX_ERR(0, 110, __pyx_L1_error) if (PySet_Add(__pyx_t_5, __pyx_n_u_start_date) < 0) __PYX_ERR(0, 110, __pyx_L1_error) if (PySet_Add(__pyx_t_5, __pyx_n_u_end_date) < 0) __PYX_ERR(0, 110, __pyx_L1_error) if (PySet_Add(__pyx_t_5, __pyx_n_u_exchange) < 0) __PYX_ERR(0, 110, __pyx_L1_error) __pyx_t_4 = __Pyx_PyFrozenSet_New(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture, __pyx_n_s_kwargnames, __pyx_t_4) < 0) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; PyType_Modified(__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture);
110: 'sid',
111: 'root_symbol',
112: 'offset',
113: 'start_date',
114: 'end_date',
115: 'exchange',
116: })
117:
+118: def __init__(self,
/* Python wrapper */ static int __pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { __pyx_t_5numpy_longlong_t __pyx_v_sid; PyObject *__pyx_v_root_symbol = 0; int __pyx_v_offset; PyObject *__pyx_v_roll_style = 0; PyObject *__pyx_v_start_date = 0; PyObject *__pyx_v_end_date = 0; PyObject *__pyx_v_exchange_info = 0; PyObject *__pyx_v_adjustment = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sid,&__pyx_n_s_root_symbol,&__pyx_n_s_offset,&__pyx_n_s_roll_style,&__pyx_n_s_start_date,&__pyx_n_s_end_date,&__pyx_n_s_exchange_info,&__pyx_n_s_adjustment,0}; PyObject* values[8] = {0,0,0,0,0,0,0,0}; /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture___init__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self, __pyx_t_5numpy_longlong_t __pyx_v_sid, PyObject *__pyx_v_root_symbol, int __pyx_v_offset, PyObject *__pyx_v_roll_style, PyObject *__pyx_v_start_date, PyObject *__pyx_v_end_date, PyObject *__pyx_v_exchange_info, PyObject *__pyx_v_adjustment) { int __pyx_r; __Pyx_TraceDeclarations __Pyx_TraceCall("__init__", __pyx_f[0], 118, 0, __PYX_ERR(0, 118, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_TraceReturn(Py_None, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
119: longlong_t sid, # sid is required
120: object root_symbol,
121: int offset,
122: object roll_style,
123: object start_date,
124: object end_date,
125: object exchange_info,
+126: object adjustment=None):
values[7] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 8: values[7] = __Pyx_Arg_VARARGS(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_VARARGS(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_VARARGS(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_VARARGS(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_VARARGS(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_VARARGS(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_sid)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 118, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_root_symbol)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 118, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 8, 1); __PYX_ERR(0, 118, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_offset)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 118, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 8, 2); __PYX_ERR(0, 118, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_roll_style)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[3]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 118, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 8, 3); __PYX_ERR(0, 118, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_start_date)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[4]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 118, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 8, 4); __PYX_ERR(0, 118, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (likely((values[5] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_end_date)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[5]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 118, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 8, 5); __PYX_ERR(0, 118, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (likely((values[6] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_exchange_info)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[6]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 118, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 8, 6); __PYX_ERR(0, 118, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_adjustment); if (value) { values[7] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 118, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "__init__") < 0)) __PYX_ERR(0, 118, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 8: values[7] = __Pyx_Arg_VARARGS(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_VARARGS(__pyx_args, 6); values[5] = __Pyx_Arg_VARARGS(__pyx_args, 5); values[4] = __Pyx_Arg_VARARGS(__pyx_args, 4); values[3] = __Pyx_Arg_VARARGS(__pyx_args, 3); values[2] = __Pyx_Arg_VARARGS(__pyx_args, 2); values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_sid = __Pyx_PyInt_As_npy_longlong(values[0]); if (unlikely((__pyx_v_sid == ((npy_longlong)-1)) && PyErr_Occurred())) __PYX_ERR(0, 119, __pyx_L3_error) __pyx_v_root_symbol = values[1]; __pyx_v_offset = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_offset == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L3_error) __pyx_v_roll_style = values[3]; __pyx_v_start_date = values[4]; __pyx_v_end_date = values[5]; __pyx_v_exchange_info = values[6]; __pyx_v_adjustment = values[7]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 7, 8, __pyx_nargs); __PYX_ERR(0, 118, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture___init__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self), __pyx_v_sid, __pyx_v_root_symbol, __pyx_v_offset, __pyx_v_roll_style, __pyx_v_start_date, __pyx_v_end_date, __pyx_v_exchange_info, __pyx_v_adjustment);
127:
+128: self.sid = sid
__pyx_v_self->sid = __pyx_v_sid;
+129: self.sid_hash = hash(sid)
__pyx_t_1 = __Pyx_PyInt_From_npy_longlong(__pyx_v_sid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_Hash(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_hash_t)-1))) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->sid_hash = __pyx_t_2;
+130: self.root_symbol = root_symbol
__Pyx_INCREF(__pyx_v_root_symbol); __Pyx_GIVEREF(__pyx_v_root_symbol); __Pyx_GOTREF(__pyx_v_self->root_symbol); __Pyx_DECREF(__pyx_v_self->root_symbol); __pyx_v_self->root_symbol = __pyx_v_root_symbol;
+131: self.roll_style = roll_style
__Pyx_INCREF(__pyx_v_roll_style); __Pyx_GIVEREF(__pyx_v_roll_style); __Pyx_GOTREF(__pyx_v_self->roll_style); __Pyx_DECREF(__pyx_v_self->roll_style); __pyx_v_self->roll_style = __pyx_v_roll_style;
+132: self.offset = offset
__pyx_v_self->offset = __pyx_v_offset;
+133: self.exchange_info = exchange_info
__Pyx_INCREF(__pyx_v_exchange_info); __Pyx_GIVEREF(__pyx_v_exchange_info); __Pyx_GOTREF(__pyx_v_self->exchange_info); __Pyx_DECREF(__pyx_v_self->exchange_info); __pyx_v_self->exchange_info = __pyx_v_exchange_info;
+134: self.start_date = start_date
__Pyx_INCREF(__pyx_v_start_date); __Pyx_GIVEREF(__pyx_v_start_date); __Pyx_GOTREF(__pyx_v_self->start_date); __Pyx_DECREF(__pyx_v_self->start_date); __pyx_v_self->start_date = __pyx_v_start_date;
+135: self.end_date = end_date
__Pyx_INCREF(__pyx_v_end_date); __Pyx_GIVEREF(__pyx_v_end_date); __Pyx_GOTREF(__pyx_v_self->end_date); __Pyx_DECREF(__pyx_v_self->end_date); __pyx_v_self->end_date = __pyx_v_end_date;
+136: self.adjustment = adjustment
__Pyx_INCREF(__pyx_v_adjustment); __Pyx_GIVEREF(__pyx_v_adjustment); __Pyx_GOTREF(__pyx_v_self->adjustment); __Pyx_DECREF(__pyx_v_self->adjustment); __pyx_v_self->adjustment = __pyx_v_adjustment;
137:
+138: @property
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_8exchange_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_8exchange_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_8exchange___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_8exchange___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 138, 0, __PYX_ERR(0, 138, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.exchange.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
139: def exchange(self):
+140: return self.exchange_info.canonical_name
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->exchange_info, __pyx_n_s_canonical_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
141:
+142: @property
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_13exchange_full_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_13exchange_full_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_13exchange_full___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_13exchange_full___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 142, 0, __PYX_ERR(0, 142, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.exchange_full.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
143: def exchange_full(self):
+144: return self.exchange_info.name
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->exchange_info, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
145:
+146: def __int__(self):
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_3__int__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_3__int__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__int__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_2__int__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_2__int__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__int__", __pyx_f[0], 146, 0, __PYX_ERR(0, 146, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.__int__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+147: return self.sid
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_npy_longlong(__pyx_v_self->sid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
148:
+149: def __index__(self):
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_5__index__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_5__index__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__index__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_4__index__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_4__index__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__index__", __pyx_f[0], 149, 0, __PYX_ERR(0, 149, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.__index__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+150: return self.sid
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_npy_longlong(__pyx_v_self->sid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
151:
+152: def __hash__(self):
/* Python wrapper */ static Py_hash_t __pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_7__hash__(PyObject *__pyx_v_self); /*proto*/ static Py_hash_t __pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_7__hash__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; Py_hash_t __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__hash__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_6__hash__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static Py_hash_t __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_6__hash__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { Py_hash_t __pyx_r; __Pyx_TraceDeclarations __Pyx_TraceCall("__hash__", __pyx_f[0], 152, 0, __PYX_ERR(0, 152, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.__hash__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; if (unlikely(__pyx_r == -1) && !PyErr_Occurred()) __pyx_r = -2; __Pyx_TraceReturn(Py_None, 0); return __pyx_r; }
+153: return self.sid_hash
__pyx_r = __pyx_v_self->sid_hash; goto __pyx_L0;
154:
+155: def __richcmp__(x, y, int op):
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_9__richcmp__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_9__richcmp__(PyObject *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__richcmp__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_x), ((PyObject *)__pyx_v_y), ((int)__pyx_v_op)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__richcmp__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_x, PyObject *__pyx_v_y, int __pyx_v_op) { __pyx_t_5numpy_longlong_t __pyx_v_x_as_int; __pyx_t_5numpy_longlong_t __pyx_v_y_as_int; __pyx_t_5numpy_longlong_t __pyx_v_compared; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__richcmp__", __pyx_f[0], 155, 0, __PYX_ERR(0, 155, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
156: """
157: Cython rich comparison method. This is used in place of various
158: equality checkers in pure python.
159: """
160: cdef longlong_t x_as_int, y_as_int
161:
+162: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L8_try_end:; }
+163: x_as_int = PyNumber_Index(x)
__pyx_t_4 = PyNumber_Index(((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 163, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_As_npy_longlong(__pyx_t_4); if (unlikely((__pyx_t_5 == ((npy_longlong)-1)) && PyErr_Occurred())) __PYX_ERR(0, 163, __pyx_L3_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_x_as_int = __pyx_t_5;
+164: except (TypeError, OverflowError):
__pyx_t_6 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_TypeError, __pyx_builtin_OverflowError); if (__pyx_t_6) { __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(0, 164, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8);
+165: return NotImplemented
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_builtin_NotImplemented); __pyx_r = __pyx_builtin_NotImplemented; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L6_except_return; } goto __pyx_L5_except_error;
166:
+167: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L16_try_end; __pyx_L11_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __pyx_L13_except_error:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_1); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1); goto __pyx_L1_error; __pyx_L14_except_return:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_1); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1); goto __pyx_L0; __pyx_L16_try_end:; }
+168: y_as_int = PyNumber_Index(y)
__pyx_t_8 = PyNumber_Index(__pyx_v_y); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 168, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = __Pyx_PyInt_As_npy_longlong(__pyx_t_8); if (unlikely((__pyx_t_5 == ((npy_longlong)-1)) && PyErr_Occurred())) __PYX_ERR(0, 168, __pyx_L11_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_y_as_int = __pyx_t_5;
+169: except (TypeError, OverflowError):
__pyx_t_6 = __Pyx_PyErr_ExceptionMatches2(__pyx_builtin_TypeError, __pyx_builtin_OverflowError); if (__pyx_t_6) { __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_4) < 0) __PYX_ERR(0, 169, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_4);
+170: return NotImplemented
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_builtin_NotImplemented); __pyx_r = __pyx_builtin_NotImplemented; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L14_except_return; } goto __pyx_L13_except_error;
171:
+172: compared = x_as_int - y_as_int
__pyx_v_compared = (__pyx_v_x_as_int - __pyx_v_y_as_int);
173:
174: # Handle == and != first because they're significantly more common
175: # operations.
+176: if op == Py_EQ:
__pyx_t_9 = (__pyx_v_op == Py_EQ); if (__pyx_t_9) { /* … */ }
+177: return compared == 0
__Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_v_compared == 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 177, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
+178: elif op == Py_NE:
__pyx_t_9 = (__pyx_v_op == Py_NE); if (__pyx_t_9) { /* … */ }
+179: return compared != 0
__Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_v_compared != 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
+180: elif op == Py_LT:
__pyx_t_9 = (__pyx_v_op == Py_LT); if (__pyx_t_9) { /* … */ }
+181: return compared < 0
__Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_v_compared < 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
+182: elif op == Py_LE:
__pyx_t_9 = (__pyx_v_op == Py_LE); if (__pyx_t_9) { /* … */ }
+183: return compared <= 0
__Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_v_compared <= 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
+184: elif op == Py_GT:
__pyx_t_9 = (__pyx_v_op == Py_GT); if (__pyx_t_9) { /* … */ }
+185: return compared > 0
__Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_v_compared > 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
+186: elif op == Py_GE:
__pyx_t_9 = (__pyx_v_op == Py_GE); if (likely(__pyx_t_9)) { /* … */ }
+187: return compared >= 0
__Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_v_compared >= 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
188: else:
+189: raise AssertionError('%d is not an operator' % op)
/*else*/ { __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_op); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = PyUnicode_Format(__pyx_kp_u_d_is_not_an_operator, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AssertionError, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 189, __pyx_L1_error) }
190:
+191: def __str__(self):
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_11__str__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_11__str__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_10__str__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_10__str__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__str__", __pyx_f[0], 191, 0, __PYX_ERR(0, 191, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+192: return '%s(%d [%s, %s, %s, %s])' % (
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = 127; /* … */ __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_1, 12, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
+193: type(self).__name__,
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))), __pyx_n_s_name_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_4), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_3; __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u__12); __pyx_t_2 += 1; __Pyx_GIVEREF(__pyx_kp_u__12); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u__12);
+194: self.sid,
__pyx_t_5 = __Pyx_PyInt_From_npy_longlong(__pyx_v_self->sid); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_PyObject_FormatAndDecref(__Pyx_PyNumber_IntOrLong(__pyx_t_5), __pyx_n_u_d); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3; __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__13); __pyx_t_2 += 2; __Pyx_GIVEREF(__pyx_kp_u__13); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_kp_u__13);
+195: self.root_symbol,
__pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_v_self->root_symbol), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3; __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_2 += 2; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_kp_u__14);
+196: self.offset,
__pyx_t_4 = __Pyx_PyUnicode_From_int(__pyx_v_self->offset, 0, ' ', 'd'); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 6, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_2 += 2; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_1, 7, __pyx_kp_u__14);
+197: self.roll_style,
__pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_v_self->roll_style), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 197, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3; __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 8, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_2 += 2; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_1, 9, __pyx_kp_u__14);
+198: self.adjustment,
__pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_v_self->adjustment), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_3; __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 10, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__15); __pyx_t_2 += 2; __Pyx_GIVEREF(__pyx_kp_u__15); PyTuple_SET_ITEM(__pyx_t_1, 11, __pyx_kp_u__15);
199: )
200:
+201: def __repr__(self):
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_13__repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_13__repr__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_12__repr__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__repr___2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_12__repr__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { struct __pyx_obj_7zipline_6assets_18continuous_futures___pyx_scope_struct____repr__ *__pyx_cur_scope; PyObject *__pyx_v_attrs = NULL; PyObject *__pyx_v_tuples = NULL; PyObject *__pyx_v_strings = NULL; PyObject *__pyx_v_params = NULL; PyObject *__pyx_gb_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__repr___2generator = 0; PyObject *__pyx_gb_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__repr___5generator1 = 0; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __pyx_cur_scope = (struct __pyx_obj_7zipline_6assets_18continuous_futures___pyx_scope_struct____repr__ *)__pyx_tp_new_7zipline_6assets_18continuous_futures___pyx_scope_struct____repr__(__pyx_ptype_7zipline_6assets_18continuous_futures___pyx_scope_struct____repr__, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_7zipline_6assets_18continuous_futures___pyx_scope_struct____repr__ *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 201, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("__repr__", __pyx_f[0], 201, 0, __PYX_ERR(0, 201, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_self = __pyx_v_self; __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_attrs); __Pyx_XDECREF(__pyx_v_tuples); __Pyx_XDECREF(__pyx_v_strings); __Pyx_XDECREF(__pyx_v_params); __Pyx_XDECREF(__pyx_gb_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__repr___2generator); __Pyx_XDECREF(__pyx_gb_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__repr___5generator1); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_obj_7zipline_6assets_18continuous_futures___pyx_scope_struct____repr__ { PyObject_HEAD struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self; };
+202: attrs = ('root_symbol', 'offset', 'roll_style', 'adjustment')
__Pyx_INCREF(__pyx_tuple__17); __pyx_v_attrs = __pyx_tuple__17; /* … */ __pyx_tuple__17 = PyTuple_Pack(4, __pyx_n_u_root_symbol, __pyx_n_u_offset, __pyx_n_u_roll_style, __pyx_n_u_adjustment); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__17); __Pyx_GIVEREF(__pyx_tuple__17);
+203: tuples = ((attr, repr(getattr(self, attr, None)))
static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__repr___genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) { struct __pyx_obj_7zipline_6assets_18continuous_futures___pyx_scope_struct_1_genexpr *__pyx_cur_scope; PyObject *__pyx_r = NULL; __pyx_cur_scope = (struct __pyx_obj_7zipline_6assets_18continuous_futures___pyx_scope_struct_1_genexpr *)__pyx_tp_new_7zipline_6assets_18continuous_futures___pyx_scope_struct_1_genexpr(__pyx_ptype_7zipline_6assets_18continuous_futures___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_7zipline_6assets_18continuous_futures___pyx_scope_struct_1_genexpr *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 203, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_7zipline_6assets_18continuous_futures___pyx_scope_struct____repr__ *) __pyx_self; __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope); __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0); { __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__repr___2generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_repr___locals_genexpr, __pyx_n_s_zipline_assets_continuous_future); if (unlikely(!gen)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.__repr__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__repr___2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("genexpr", 0); __Pyx_TraceDeclarations __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 203, __pyx_L1_error) /* … */ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 203, __pyx_L1_error) } __pyx_t_3 = ((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = __Pyx_GetAttr3(__pyx_t_3, __pyx_cur_scope->__pyx_v_attr, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_Repr(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_attr); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_attr); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_cur_scope->__pyx_v_attr)) __PYX_ERR(0, 203, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3)) __PYX_ERR(0, 203, __pyx_L1_error); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; __Pyx_XGIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_cur_scope->__pyx_t_0 = 0; __Pyx_XGOTREF(__pyx_t_1); __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 203, __pyx_L1_error) /* … */ /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; __Pyx_Generator_Replace_StopIteration(0); __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; #if !CYTHON_USE_EXC_INFO_STACK __Pyx_Coroutine_ResetAndClearException(__pyx_generator); #endif __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__repr___5generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ __pyx_t_1 = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__repr___genexpr(((PyObject*)__pyx_cur_scope), __pyx_v_attrs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_tuples = __pyx_t_1; __pyx_t_1 = 0; /* … */ struct __pyx_obj_7zipline_6assets_18continuous_futures___pyx_scope_struct_1_genexpr { PyObject_HEAD struct __pyx_obj_7zipline_6assets_18continuous_futures___pyx_scope_struct____repr__ *__pyx_outer_scope; PyObject *__pyx_genexpr_arg_0; PyObject *__pyx_v_attr; PyObject *__pyx_t_0; Py_ssize_t __pyx_t_1; };
+204: for attr in attrs)
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 204, __pyx_L1_error) } __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 204, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 204, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_attr); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_attr, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
+205: strings = ('%s=%s' % (t[0], t[1]) for t in tuples)
static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__repr___3genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) { struct __pyx_obj_7zipline_6assets_18continuous_futures___pyx_scope_struct_2_genexpr *__pyx_cur_scope; PyObject *__pyx_r = NULL; __pyx_cur_scope = (struct __pyx_obj_7zipline_6assets_18continuous_futures___pyx_scope_struct_2_genexpr *)__pyx_tp_new_7zipline_6assets_18continuous_futures___pyx_scope_struct_2_genexpr(__pyx_ptype_7zipline_6assets_18continuous_futures___pyx_scope_struct_2_genexpr, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_7zipline_6assets_18continuous_futures___pyx_scope_struct_2_genexpr *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 205, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0); { __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__repr___5generator1, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_repr___locals_genexpr, __pyx_n_s_zipline_assets_continuous_future); if (unlikely(!gen)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.__repr__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__repr___5generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("genexpr", 0); __Pyx_TraceDeclarations __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 205, __pyx_L1_error) if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 205, __pyx_L1_error) } if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) { __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 205, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_3)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 205, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 205, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 205, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 205, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 205, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_t); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_t, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = 0; __pyx_t_6 = 127; __pyx_t_7 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_t, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_7), __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_6; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8); __pyx_t_8 = 0; __Pyx_INCREF(__pyx_kp_u__16); __pyx_t_5 += 1; __Pyx_GIVEREF(__pyx_kp_u__16); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_kp_u__16); __pyx_t_8 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_t, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_8), __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_6; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_4, 3, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_7; __pyx_t_7 = 0; __Pyx_XGIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; __pyx_cur_scope->__pyx_t_2 = __pyx_t_3; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_cur_scope->__pyx_t_0 = 0; __Pyx_XGOTREF(__pyx_t_1); __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; __pyx_t_3 = __pyx_cur_scope->__pyx_t_2; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 205, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; __Pyx_Generator_Replace_StopIteration(0); __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; #if !CYTHON_USE_EXC_INFO_STACK __Pyx_Coroutine_ResetAndClearException(__pyx_generator); #endif __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_1 = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_8__repr___3genexpr(NULL, __pyx_v_tuples); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_strings = __pyx_t_1; __pyx_t_1 = 0; /* … */ struct __pyx_obj_7zipline_6assets_18continuous_futures___pyx_scope_struct_2_genexpr { PyObject_HEAD PyObject *__pyx_genexpr_arg_0; PyObject *__pyx_v_t; PyObject *__pyx_t_0; Py_ssize_t __pyx_t_1; PyObject *(*__pyx_t_2)(PyObject *); };
+206: params = ', '.join(strings)
__pyx_t_1 = PyUnicode_Join(__pyx_kp_u__14, __pyx_v_strings); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_params = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+207: return 'ContinuousFuture(%d, %s)' % (self.sid, params)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = 127; __Pyx_INCREF(__pyx_kp_u_ContinuousFuture); __pyx_t_2 += 17; __Pyx_GIVEREF(__pyx_kp_u_ContinuousFuture); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_ContinuousFuture); __pyx_t_4 = __Pyx_PyInt_From_npy_longlong(__pyx_cur_scope->__pyx_v_self->sid); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_FormatAndDecref(__Pyx_PyNumber_IntOrLong(__pyx_t_4), __pyx_n_u_d); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_3; __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_2 += 2; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__14); __pyx_t_5 = __Pyx_PyUnicode_Unicode(__pyx_v_params); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_3; __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u__7); __pyx_t_2 += 1; __Pyx_GIVEREF(__pyx_kp_u__7); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u__7); __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_1, 5, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
208:
+209: cpdef __reduce__(self):
static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_15__reduce__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_7zipline_6assets_18continuous_futures_16ContinuousFuture___reduce__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__18) __Pyx_TraceCall("__reduce__", __pyx_f[0], 209, 0, __PYX_ERR(0, 209, __pyx_L1_error)); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reduce); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!__Pyx_IsSameCFunction(__pyx_t_1, (void*) __pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_15__reduce__)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_15__reduce__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7zipline_6assets_18continuous_futures_16ContinuousFuture_14__reduce__, "ContinuousFuture.__reduce__(self)\n\n Function used by pickle to determine how to serialize/deserialize this\n class. Should return a tuple whose first element is self.__class__,\n and whose second element is a tuple of all the attributes that should\n be serialized/deserialized during pickling.\n "); static PyMethodDef __pyx_mdef_7zipline_6assets_18continuous_futures_16ContinuousFuture_15__reduce__ = {"__reduce__", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_15__reduce__, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7zipline_6assets_18continuous_futures_16ContinuousFuture_14__reduce__}; static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_15__reduce__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__reduce__", 1, 0, 0, __pyx_nargs); return NULL;} if (unlikely(__pyx_kwds) && __Pyx_NumKwargs_FASTCALL(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__reduce__", 0))) return NULL; __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_14__reduce__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_14__reduce__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__18) __Pyx_TraceCall("__reduce__ (wrapper)", __pyx_f[0], 209, 0, __PYX_ERR(0, 209, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_7zipline_6assets_18continuous_futures_16ContinuousFuture___reduce__(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__46 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__46); __Pyx_GIVEREF(__pyx_tuple__46); /* … */ __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_6assets_18continuous_futures_16ContinuousFuture_15__reduce__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_ContinuousFuture___reduce, NULL, __pyx_n_s_zipline_assets_continuous_future, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture, __pyx_n_s_reduce, __pyx_t_4) < 0) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; PyType_Modified(__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture); __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__46, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline_assets_continuous_fu, __pyx_n_s_reduce, 209, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 209, __pyx_L1_error)
210: """
211: Function used by pickle to determine how to serialize/deserialize this
212: class. Should return a tuple whose first element is self.__class__,
213: and whose second element is a tuple of all the attributes that should
214: be serialized/deserialized during pickling.
215: """
+216: return (self.__class__, (self.sid,
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_npy_longlong(__pyx_v_self->sid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); /* … */ __pyx_t_6 = PyTuple_New(7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error); __Pyx_INCREF(__pyx_v_self->root_symbol); __Pyx_GIVEREF(__pyx_v_self->root_symbol); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_self->root_symbol)) __PYX_ERR(0, 216, __pyx_L1_error); __Pyx_INCREF(__pyx_v_self->start_date); __Pyx_GIVEREF(__pyx_v_self->start_date); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_self->start_date)) __PYX_ERR(0, 216, __pyx_L1_error); __Pyx_INCREF(__pyx_v_self->end_date); __Pyx_GIVEREF(__pyx_v_self->end_date); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_v_self->end_date)) __PYX_ERR(0, 216, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_3)) __PYX_ERR(0, 216, __pyx_L1_error); __Pyx_INCREF(__pyx_v_self->roll_style); __Pyx_GIVEREF(__pyx_v_self->roll_style); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_v_self->roll_style)) __PYX_ERR(0, 216, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 6, __pyx_t_4)) __PYX_ERR(0, 216, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1)) __PYX_ERR(0, 216, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_6); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6)) __PYX_ERR(0, 216, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_6 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
217: self.root_symbol,
218: self.start_date,
219: self.end_date,
+220: self.offset,
__pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->offset); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 220, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3);
221: self.roll_style,
+222: self.exchange))
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exchange); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4);
223:
+224: cpdef to_dict(self):
static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_17to_dict(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_7zipline_6assets_18continuous_futures_16ContinuousFuture_to_dict(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self, int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__19) __Pyx_TraceCall("to_dict", __pyx_f[0], 224, 0, __PYX_ERR(0, 224, __pyx_L1_error)); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_to_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!__Pyx_IsSameCFunction(__pyx_t_1, (void*) __pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_17to_dict)) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.to_dict", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_17to_dict(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7zipline_6assets_18continuous_futures_16ContinuousFuture_16to_dict, "ContinuousFuture.to_dict(self)\n\n Convert to a python dict.\n "); static PyMethodDef __pyx_mdef_7zipline_6assets_18continuous_futures_16ContinuousFuture_17to_dict = {"to_dict", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_17to_dict, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7zipline_6assets_18continuous_futures_16ContinuousFuture_16to_dict}; static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_17to_dict(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_dict (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("to_dict", 1, 0, 0, __pyx_nargs); return NULL;} if (unlikely(__pyx_kwds) && __Pyx_NumKwargs_FASTCALL(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "to_dict", 0))) return NULL; __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_16to_dict(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_16to_dict(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__19) __Pyx_TraceCall("to_dict (wrapper)", __pyx_f[0], 224, 0, __PYX_ERR(0, 224, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_7zipline_6assets_18continuous_futures_16ContinuousFuture_to_dict(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.to_dict", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_6assets_18continuous_futures_16ContinuousFuture_17to_dict, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_ContinuousFuture_to_dict, NULL, __pyx_n_s_zipline_assets_continuous_future, __pyx_d, ((PyObject *)__pyx_codeobj__19)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture, __pyx_n_s_to_dict, __pyx_t_4) < 0) __PYX_ERR(0, 224, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; PyType_Modified(__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture); /* … */ __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__46, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline_assets_continuous_fu, __pyx_n_s_to_dict, 224, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 224, __pyx_L1_error)
225: """
226: Convert to a python dict.
227: """
+228: return {
__Pyx_XDECREF(__pyx_r);
+229: 'sid': self.sid,
__pyx_t_1 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_npy_longlong(__pyx_v_self->sid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_sid, __pyx_t_2) < 0) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+230: 'root_symbol': self.root_symbol,
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_root_symbol, __pyx_v_self->root_symbol) < 0) __PYX_ERR(0, 229, __pyx_L1_error)
+231: 'start_date': self.start_date,
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_start_date, __pyx_v_self->start_date) < 0) __PYX_ERR(0, 229, __pyx_L1_error)
+232: 'end_date': self.end_date,
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_end_date, __pyx_v_self->end_date) < 0) __PYX_ERR(0, 229, __pyx_L1_error)
+233: 'offset': self.offset,
__pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->offset); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 233, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_offset, __pyx_t_2) < 0) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+234: 'roll_style': self.roll_style,
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_roll_style, __pyx_v_self->roll_style) < 0) __PYX_ERR(0, 229, __pyx_L1_error)
+235: 'exchange': self.exchange,
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exchange); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 235, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_exchange, __pyx_t_2) < 0) __PYX_ERR(0, 229, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
236: }
237:
+238: @classmethod
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_19from_dict(PyObject *__pyx_v_cls, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7zipline_6assets_18continuous_futures_16ContinuousFuture_18from_dict, "ContinuousFuture.from_dict(cls, dict_)\n\n Build an ContinuousFuture instance from a dict.\n "); static PyMethodDef __pyx_mdef_7zipline_6assets_18continuous_futures_16ContinuousFuture_19from_dict = {"from_dict", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_19from_dict, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7zipline_6assets_18continuous_futures_16ContinuousFuture_18from_dict}; static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_19from_dict(PyObject *__pyx_v_cls, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_dict_ = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("from_dict (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dict_2,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dict_2)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 238, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "from_dict") < 0)) __PYX_ERR(0, 238, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_dict_ = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("from_dict", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 238, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.from_dict", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_18from_dict(((PyTypeObject*)__pyx_v_cls), __pyx_v_dict_); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_18from_dict(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_dict_) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__20) __Pyx_TraceCall("from_dict", __pyx_f[0], 238, 0, __PYX_ERR(0, 238, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.from_dict", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__47 = PyTuple_Pack(2, __pyx_n_s_cls, __pyx_n_s_dict_2); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__47); __Pyx_GIVEREF(__pyx_tuple__47); /* … */ __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_6assets_18continuous_futures_16ContinuousFuture_19from_dict, __Pyx_CYFUNCTION_CLASSMETHOD | __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_ContinuousFuture_from_dict, NULL, __pyx_n_s_zipline_assets_continuous_future, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture, __pyx_n_s_from_dict, __pyx_t_4) < 0) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; PyType_Modified(__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture); __Pyx_GetNameInClass(__pyx_t_4, (PyObject *)__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture, __pyx_n_s_from_dict); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_Method_ClassMethod(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture, __pyx_n_s_from_dict, __pyx_t_5) < 0) __PYX_ERR(0, 238, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; PyType_Modified(__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture); __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline_assets_continuous_fu, __pyx_n_s_from_dict, 238, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 238, __pyx_L1_error)
239: def from_dict(cls, dict_):
240: """
241: Build an ContinuousFuture instance from a dict.
242: """
+243: return cls(**dict_)
__Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_dict_ == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 243, __pyx_L1_error) } if (likely(PyDict_CheckExact(__pyx_v_dict_))) { __pyx_t_1 = PyDict_Copy(__pyx_v_dict_); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { __pyx_t_1 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_v_dict_); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_v_cls), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
244:
+245: def is_alive_for_session(self, session_label):
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_21is_alive_for_session(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7zipline_6assets_18continuous_futures_16ContinuousFuture_20is_alive_for_session, "ContinuousFuture.is_alive_for_session(self, session_label)\n\n Returns whether the continuous future is alive at the given dt.\n\n Parameters\n ----------\n session_label: pd.Timestamp\n The desired session label to check. (midnight UTC)\n\n Returns\n -------\n boolean: whether the continuous is alive at the given dt.\n "); static PyMethodDef __pyx_mdef_7zipline_6assets_18continuous_futures_16ContinuousFuture_21is_alive_for_session = {"is_alive_for_session", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_21is_alive_for_session, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7zipline_6assets_18continuous_futures_16ContinuousFuture_20is_alive_for_session}; static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_21is_alive_for_session(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_session_label = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_alive_for_session (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_session_label,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_session_label)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 245, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "is_alive_for_session") < 0)) __PYX_ERR(0, 245, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_session_label = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("is_alive_for_session", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 245, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.is_alive_for_session", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_20is_alive_for_session(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self), __pyx_v_session_label); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_20is_alive_for_session(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self, PyObject *__pyx_v_session_label) { __pyx_t_5numpy_int64_t __pyx_v_ref_start; __pyx_t_5numpy_int64_t __pyx_v_ref_end; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__21) __Pyx_TraceCall("is_alive_for_session", __pyx_f[0], 245, 0, __PYX_ERR(0, 245, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.is_alive_for_session", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__48 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_session_label, __pyx_n_s_ref_start, __pyx_n_s_ref_end); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 245, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__48); __Pyx_GIVEREF(__pyx_tuple__48); /* … */ __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_6assets_18continuous_futures_16ContinuousFuture_21is_alive_for_session, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_ContinuousFuture_is_alive_for_se, NULL, __pyx_n_s_zipline_assets_continuous_future, __pyx_d, ((PyObject *)__pyx_codeobj__21)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture, __pyx_n_s_is_alive_for_session, __pyx_t_5) < 0) __PYX_ERR(0, 245, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; PyType_Modified(__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture); __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__48, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline_assets_continuous_fu, __pyx_n_s_is_alive_for_session, 245, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 245, __pyx_L1_error)
246: """
247: Returns whether the continuous future is alive at the given dt.
248:
249: Parameters
250: ----------
251: session_label: pd.Timestamp
252: The desired session label to check. (midnight UTC)
253:
254: Returns
255: -------
256: boolean: whether the continuous is alive at the given dt.
257: """
258: cdef int64_t ref_start
259: cdef int64_t ref_end
260:
+261: ref_start = self.start_date.value
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->start_date, __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_As_npy_int64(__pyx_t_1); if (unlikely((__pyx_t_2 == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_ref_start = __pyx_t_2;
+262: ref_end = self.end_date.value
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->end_date, __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_As_npy_int64(__pyx_t_1); if (unlikely((__pyx_t_2 == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_ref_end = __pyx_t_2;
263:
+264: return ref_start <= session_label.value <= ref_end
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_ref_start); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_session_label, __pyx_n_s_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 264, __pyx_L1_error) if (__Pyx_PyObject_IsTrue(__pyx_t_4)) { __Pyx_DECREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_From_npy_int64(__pyx_v_ref_end); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_t_5, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 264, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
265:
+266: def is_exchange_open(self, dt_minute):
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_23is_exchange_open(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7zipline_6assets_18continuous_futures_16ContinuousFuture_22is_exchange_open, "ContinuousFuture.is_exchange_open(self, dt_minute)\n\n Parameters\n ----------\n dt_minute: pd.Timestamp (UTC, tz-aware)\n The minute to check.\n\n Returns\n -------\n boolean: whether the continuous futures's exchange is open at the\n given minute.\n "); static PyMethodDef __pyx_mdef_7zipline_6assets_18continuous_futures_16ContinuousFuture_23is_exchange_open = {"is_exchange_open", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_23is_exchange_open, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7zipline_6assets_18continuous_futures_16ContinuousFuture_22is_exchange_open}; static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16ContinuousFuture_23is_exchange_open(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_dt_minute = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_exchange_open (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dt_minute,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dt_minute)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 266, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "is_exchange_open") < 0)) __PYX_ERR(0, 266, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_dt_minute = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("is_exchange_open", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 266, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.is_exchange_open", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_22is_exchange_open(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *)__pyx_v_self), __pyx_v_dt_minute); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16ContinuousFuture_22is_exchange_open(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContinuousFuture *__pyx_v_self, PyObject *__pyx_v_dt_minute) { PyObject *__pyx_v_calendar = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__22) __Pyx_TraceCall("is_exchange_open", __pyx_f[0], 266, 0, __PYX_ERR(0, 266, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContinuousFuture.is_exchange_open", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_calendar); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__49 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_dt_minute, __pyx_n_s_calendar); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__49); __Pyx_GIVEREF(__pyx_tuple__49); /* … */ __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_6assets_18continuous_futures_16ContinuousFuture_23is_exchange_open, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_ContinuousFuture_is_exchange_ope, NULL, __pyx_n_s_zipline_assets_continuous_future, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture, __pyx_n_s_is_exchange_open, __pyx_t_5) < 0) __PYX_ERR(0, 266, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; PyType_Modified(__pyx_ptype_7zipline_6assets_18continuous_futures_ContinuousFuture); __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline_assets_continuous_fu, __pyx_n_s_is_exchange_open, 266, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 266, __pyx_L1_error)
267: """
268: Parameters
269: ----------
270: dt_minute: pd.Timestamp (UTC, tz-aware)
271: The minute to check.
272:
273: Returns
274: -------
275: boolean: whether the continuous futures's exchange is open at the
276: given minute.
277: """
+278: calendar = get_calendar(self.exchange)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_get_calendar); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_exchange); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_calendar = __pyx_t_1; __pyx_t_1 = 0;
+279: return calendar.is_open_on_minute(dt_minute)
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_calendar, __pyx_n_s_is_open_on_minute); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_dt_minute}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
280:
281:
+282: cdef class ContractNode(object):
struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode { PyObject_HEAD PyObject *contract; PyObject *prev; PyObject *next; };
283:
+284: cdef readonly object contract
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_8contract_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_8contract_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_8contract___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_8contract___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 284, 0, __PYX_ERR(0, 284, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->contract); __pyx_r = __pyx_v_self->contract; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContractNode.contract.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+285: cdef public object prev
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_4prev_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_4prev_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_4prev___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_4prev___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 285, 0, __PYX_ERR(0, 285, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->prev); __pyx_r = __pyx_v_self->prev; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContractNode.prev.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_4prev_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_4prev_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_4prev_2__set__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_4prev_2__set__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_TraceDeclarations __Pyx_TraceCall("__set__", __pyx_f[0], 285, 0, __PYX_ERR(0, 285, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->prev); __Pyx_DECREF(__pyx_v_self->prev); __pyx_v_self->prev = __pyx_v_value; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContractNode.prev.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_TraceReturn(Py_None, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_4prev_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_4prev_5__del__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_4prev_4__del__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_4prev_4__del__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *__pyx_v_self) { int __pyx_r; __Pyx_TraceDeclarations __Pyx_TraceCall("__del__", __pyx_f[0], 285, 0, __PYX_ERR(0, 285, __pyx_L1_error)); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->prev); __Pyx_DECREF(__pyx_v_self->prev); __pyx_v_self->prev = Py_None; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContractNode.prev.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_TraceReturn(Py_None, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+286: cdef public object next
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_4next_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_4next_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_4next___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_4next___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 286, 0, __PYX_ERR(0, 286, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->next); __pyx_r = __pyx_v_self->next; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContractNode.next.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_4next_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ static int __pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_4next_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_4next_2__set__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *)__pyx_v_self), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_4next_2__set__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_TraceDeclarations __Pyx_TraceCall("__set__", __pyx_f[0], 286, 0, __PYX_ERR(0, 286, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->next); __Pyx_DECREF(__pyx_v_self->next); __pyx_v_self->next = __pyx_v_value; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContractNode.next.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_TraceReturn(Py_None, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_4next_5__del__(PyObject *__pyx_v_self); /*proto*/ static int __pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_4next_5__del__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_4next_4__del__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_4next_4__del__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *__pyx_v_self) { int __pyx_r; __Pyx_TraceDeclarations __Pyx_TraceCall("__del__", __pyx_f[0], 286, 0, __PYX_ERR(0, 286, __pyx_L1_error)); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->next); __Pyx_DECREF(__pyx_v_self->next); __pyx_v_self->next = Py_None; /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContractNode.next.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_TraceReturn(Py_None, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
287:
+288: def __init__(self, contract):
/* Python wrapper */ static int __pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_contract = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_contract,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_contract)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 288, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "__init__") < 0)) __PYX_ERR(0, 288, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); } __pyx_v_contract = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 288, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_AddTraceback("zipline.assets.continuous_futures.ContractNode.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode___init__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *)__pyx_v_self), __pyx_v_contract); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode___init__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *__pyx_v_self, PyObject *__pyx_v_contract) { int __pyx_r; __Pyx_TraceDeclarations __Pyx_TraceCall("__init__", __pyx_f[0], 288, 0, __PYX_ERR(0, 288, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.ContractNode.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_TraceReturn(Py_None, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+289: self.contract = contract
__Pyx_INCREF(__pyx_v_contract); __Pyx_GIVEREF(__pyx_v_contract); __Pyx_GOTREF(__pyx_v_self->contract); __Pyx_DECREF(__pyx_v_self->contract); __pyx_v_self->contract = __pyx_v_contract;
+290: self.prev = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->prev); __Pyx_DECREF(__pyx_v_self->prev); __pyx_v_self->prev = Py_None;
+291: self.next = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->next); __Pyx_DECREF(__pyx_v_self->next); __pyx_v_self->next = Py_None;
292:
+293: def __rshift__(self, offset):
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_3__rshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_offset); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_3__rshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_offset) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__rshift__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_2__rshift__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *)__pyx_v_self), ((PyObject *)__pyx_v_offset)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_2__rshift__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *__pyx_v_self, PyObject *__pyx_v_offset) { PyObject *__pyx_v_i = NULL; PyObject *__pyx_v_curr = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__rshift__", __pyx_f[0], 293, 0, __PYX_ERR(0, 293, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContractNode.__rshift__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_curr); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+294: i = 0
__Pyx_INCREF(__pyx_int_0);
__pyx_v_i = __pyx_int_0;
+295: curr = self
__Pyx_INCREF((PyObject *)__pyx_v_self);
__pyx_v_curr = ((PyObject *)__pyx_v_self);
+296: while i < offset and curr is not None:
while (1) { __pyx_t_2 = PyObject_RichCompare(__pyx_v_i, __pyx_v_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 296, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L5_bool_binop_done; } __pyx_t_3 = (__pyx_v_curr != Py_None); __pyx_t_1 = __pyx_t_3; __pyx_L5_bool_binop_done:; if (!__pyx_t_1) break;
+297: curr = curr.next
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr, __pyx_n_s_next); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_curr, __pyx_t_2); __pyx_t_2 = 0;
+298: i += 1
__pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_i, __pyx_t_2); __pyx_t_2 = 0; }
+299: return curr
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_curr); __pyx_r = __pyx_v_curr; goto __pyx_L0;
300:
+301: def __lshift__(self, offset):
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_5__lshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_offset); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_12ContractNode_5__lshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_offset) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__lshift__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_4__lshift__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *)__pyx_v_self), ((PyObject *)__pyx_v_offset)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_12ContractNode_4__lshift__(struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *__pyx_v_self, PyObject *__pyx_v_offset) { PyObject *__pyx_v_i = NULL; PyObject *__pyx_v_curr = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__lshift__", __pyx_f[0], 301, 0, __PYX_ERR(0, 301, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("zipline.assets.continuous_futures.ContractNode.__lshift__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_curr); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+302: i = 0
__Pyx_INCREF(__pyx_int_0);
__pyx_v_i = __pyx_int_0;
+303: curr = self
__Pyx_INCREF((PyObject *)__pyx_v_self);
__pyx_v_curr = ((PyObject *)__pyx_v_self);
+304: while i < offset and curr is not None:
while (1) { __pyx_t_2 = PyObject_RichCompare(__pyx_v_i, __pyx_v_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 304, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L5_bool_binop_done; } __pyx_t_3 = (__pyx_v_curr != Py_None); __pyx_t_1 = __pyx_t_3; __pyx_L5_bool_binop_done:; if (!__pyx_t_1) break;
+305: curr = curr.prev
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr, __pyx_n_s_prev); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_curr, __pyx_t_2); __pyx_t_2 = 0;
+306: i += 1
__pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_i, __pyx_t_2); __pyx_t_2 = 0; }
+307: return curr
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_curr); __pyx_r = __pyx_v_curr; goto __pyx_L0;
308:
309:
+310: cdef class OrderedContracts(object):
struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts { PyObject_HEAD struct __pyx_vtabstruct_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_vtab; PyObject *root_symbol; PyObject *_head_contract; PyObject *sid_to_contract; __pyx_t_5numpy_int64_t _start_date; __pyx_t_5numpy_int64_t _end_date; PyObject *chain_predicate; }; /* … */ struct __pyx_vtabstruct_7zipline_6assets_18continuous_futures_OrderedContracts { __pyx_t_5numpy_longlong_t (*contract_before_auto_close)(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *, __pyx_t_5numpy_longlong_t, int __pyx_skip_dispatch); PyObject *(*contract_at_offset)(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *, __pyx_t_5numpy_longlong_t, Py_ssize_t, __pyx_t_5numpy_int64_t, int __pyx_skip_dispatch); __Pyx_memviewslice (*active_chain)(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *, __pyx_t_5numpy_longlong_t, __pyx_t_5numpy_longlong_t, int __pyx_skip_dispatch); }; static struct __pyx_vtabstruct_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_vtabptr_7zipline_6assets_18continuous_futures_OrderedContracts;
311: """
312: A container for aligned values of a future contract chain, in sorted order
313: of their occurrence.
314: Used to get answers about contracts in relation to their auto close
315: dates and start dates.
316:
317: Members
318: -------
319: root_symbol : str
320: The root symbol of the future contract chain.
321: contracts : deque
322: The contracts in the chain in order of occurrence.
323: start_dates : long[:]
324: The start dates of the contracts in the chain.
325: Corresponds by index with contract_sids.
326: auto_close_dates : long[:]
327: The auto close dates of the contracts in the chain.
328: Corresponds by index with contract_sids.
329: future_chain_predicates : dict
330: A dict mapping root symbol to a predicate function which accepts a contract
331: as a parameter and returns whether or not the contract should be included in the
332: chain.
333:
334: Instances of this class are used by the simulation engine, but not
335: exposed to the algorithm.
336: """
337:
+338: cdef readonly object root_symbol
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_11root_symbol_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_11root_symbol_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_11root_symbol___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_11root_symbol___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 338, 0, __PYX_ERR(0, 338, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->root_symbol); __pyx_r = __pyx_v_self->root_symbol; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.root_symbol.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+339: cdef readonly object _head_contract
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_14_head_contract_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_14_head_contract_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_14_head_contract___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_14_head_contract___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 339, 0, __PYX_ERR(0, 339, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->_head_contract); __pyx_r = __pyx_v_self->_head_contract; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts._head_contract.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+340: cdef readonly dict sid_to_contract
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_15sid_to_contract_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_15sid_to_contract_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_15sid_to_contract___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_15sid_to_contract___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 340, 0, __PYX_ERR(0, 340, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->sid_to_contract); __pyx_r = __pyx_v_self->sid_to_contract; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.sid_to_contract.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+341: cdef readonly int64_t _start_date
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_11_start_date_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_11_start_date_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_11_start_date___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_11_start_date___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 341, 0, __PYX_ERR(0, 341, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->_start_date); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts._start_date.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+342: cdef readonly int64_t _end_date
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_9_end_date_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_9_end_date_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_9_end_date___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_9_end_date___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 342, 0, __PYX_ERR(0, 342, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->_end_date); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts._end_date.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+343: cdef readonly object chain_predicate
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_15chain_predicate_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_15chain_predicate_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_15chain_predicate___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_15chain_predicate___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 343, 0, __PYX_ERR(0, 343, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_self->chain_predicate); __pyx_r = __pyx_v_self->chain_predicate; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.chain_predicate.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
344:
+345: def __init__(self, object root_symbol, object contracts, object chain_predicate=None):
/* Python wrapper */ static int __pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_root_symbol = 0; PyObject *__pyx_v_contracts = 0; PyObject *__pyx_v_chain_predicate = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_root_symbol,&__pyx_n_s_contracts,&__pyx_n_s_chain_predicate,0}; PyObject* values[3] = {0,0,0}; values[2] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_VARARGS(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_root_symbol)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 345, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_contracts)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 345, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, 1); __PYX_ERR(0, 345, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_chain_predicate); if (value) { values[2] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 345, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "__init__") < 0)) __PYX_ERR(0, 345, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_VARARGS(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_root_symbol = values[0]; __pyx_v_contracts = values[1]; __pyx_v_chain_predicate = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 345, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts___init__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *)__pyx_v_self), __pyx_v_root_symbol, __pyx_v_contracts, __pyx_v_chain_predicate); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static int __pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts___init__(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self, PyObject *__pyx_v_root_symbol, PyObject *__pyx_v_contracts, PyObject *__pyx_v_chain_predicate) { struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *__pyx_v_prev = NULL; PyObject *__pyx_v_contract = NULL; struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *__pyx_v_curr = NULL; int __pyx_r; __Pyx_TraceDeclarations __Pyx_TraceCall("__init__", __pyx_f[0], 345, 0, __PYX_ERR(0, 345, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_chain_predicate); /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_prev); __Pyx_XDECREF(__pyx_v_contract); __Pyx_XDECREF((PyObject *)__pyx_v_curr); __Pyx_XDECREF(__pyx_v_chain_predicate); __Pyx_TraceReturn(Py_None, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
346:
+347: self.root_symbol = root_symbol
__Pyx_INCREF(__pyx_v_root_symbol); __Pyx_GIVEREF(__pyx_v_root_symbol); __Pyx_GOTREF(__pyx_v_self->root_symbol); __Pyx_DECREF(__pyx_v_self->root_symbol); __pyx_v_self->root_symbol = __pyx_v_root_symbol;
348:
+349: self.sid_to_contract = {}
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->sid_to_contract); __Pyx_DECREF(__pyx_v_self->sid_to_contract); __pyx_v_self->sid_to_contract = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
350:
+351: self._start_date = iinfo('int64').max
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_iinfo); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_n_u_int64}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_max); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyInt_As_npy_int64(__pyx_t_2); if (unlikely((__pyx_t_5 == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_self->_start_date = __pyx_t_5;
+352: self._end_date = 0
__pyx_v_self->_end_date = 0;
353:
+354: if chain_predicate is None:
__pyx_t_6 = (__pyx_v_chain_predicate == Py_None); if (__pyx_t_6) { /* … */ }
+355: chain_predicate = lambda x: True
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_8__init___lambda2(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_7zipline_6assets_18continuous_futures_16OrderedContracts_8__init___lambda2 = {"lambda2", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_8__init___lambda2, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_8__init___lambda2(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { CYTHON_UNUSED PyObject *__pyx_v_x = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("lambda2 (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_x)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 355, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda2") < 0)) __PYX_ERR(0, 355, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_x = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("lambda2", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 355, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.__init__.lambda2", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_lambda_funcdef_lambda2(__pyx_self, __pyx_v_x); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_lambda_funcdef_lambda2(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_x) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("lambda2", __pyx_f[0], 355, 0, __PYX_ERR(0, 355, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.__init__.lambda2", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_6assets_18continuous_futures_16OrderedContracts_8__init___lambda2, 0, __pyx_n_s_init___locals_lambda, NULL, __pyx_n_s_zipline_assets_continuous_future, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_chain_predicate, __pyx_t_2); __pyx_t_2 = 0;
356:
+357: self._head_contract = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_head_contract); __Pyx_DECREF(__pyx_v_self->_head_contract); __pyx_v_self->_head_contract = Py_None;
+358: prev = None
__Pyx_INCREF(Py_None);
__pyx_v_prev = ((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *)Py_None);
+359: while contracts:
while (1) { __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_contracts); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 359, __pyx_L1_error) if (!__pyx_t_6) break;
+360: contract = contracts.popleft()
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_contracts, __pyx_n_s_popleft); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 360, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_XDECREF_SET(__pyx_v_contract, __pyx_t_2); __pyx_t_2 = 0;
361:
362: # It is possible that the first contract in our list has a start
363: # date on or after its auto close date. In that case the contract
364: # is not tradable, so do not include it in the chain.
+365: if prev is None and contract.start_date >= contract.auto_close_date:
__pyx_t_7 = (((PyObject *)__pyx_v_prev) == Py_None); if (__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_start_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_auto_close_date); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __pyx_t_7; __pyx_L7_bool_binop_done:; if (__pyx_t_6) { /* … */ }
+366: continue
goto __pyx_L4_continue;
367:
+368: if not chain_predicate(contract):
__Pyx_INCREF(__pyx_v_chain_predicate); __pyx_t_1 = __pyx_v_chain_predicate; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_contract}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 368, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = (!__pyx_t_6); if (__pyx_t_7) { /* … */ }
+369: continue
goto __pyx_L4_continue;
370:
+371: self._start_date = min(contract.start_date.value, self._start_date)
__pyx_t_5 = __pyx_v_self->_start_date; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_start_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 371, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 371, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_7) { __pyx_t_8 = __Pyx_PyInt_From_npy_int64(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __pyx_t_8; __pyx_t_8 = 0; } else { __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyInt_As_npy_int64(__pyx_t_3); if (unlikely((__pyx_t_5 == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 371, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_self->_start_date = __pyx_t_5;
+372: self._end_date = max(contract.end_date.value, self._end_date)
__pyx_t_5 = __pyx_v_self->_end_date; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_end_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyInt_From_npy_int64(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = PyObject_RichCompare(__pyx_t_8, __pyx_t_1, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_7) { __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; } else { __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyInt_As_npy_int64(__pyx_t_3); if (unlikely((__pyx_t_5 == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 372, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_self->_end_date = __pyx_t_5;
373:
+374: curr = ContractNode(contract)
__pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_7zipline_6assets_18continuous_futures_ContractNode), __pyx_v_contract); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 374, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_curr, ((struct __pyx_obj_7zipline_6assets_18continuous_futures_ContractNode *)__pyx_t_3)); __pyx_t_3 = 0;
+375: self.sid_to_contract[contract.sid] = curr
if (unlikely(__pyx_v_self->sid_to_contract == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 375, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_contract, __pyx_n_s_sid); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 375, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely((PyDict_SetItem(__pyx_v_self->sid_to_contract, __pyx_t_3, ((PyObject *)__pyx_v_curr)) < 0))) __PYX_ERR(0, 375, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+376: if self._head_contract is None:
__pyx_t_7 = (__pyx_v_self->_head_contract == Py_None); if (__pyx_t_7) { /* … */ }
+377: self._head_contract = curr
__Pyx_INCREF((PyObject *)__pyx_v_curr); __Pyx_GIVEREF((PyObject *)__pyx_v_curr); __Pyx_GOTREF(__pyx_v_self->_head_contract); __Pyx_DECREF(__pyx_v_self->_head_contract); __pyx_v_self->_head_contract = ((PyObject *)__pyx_v_curr);
+378: prev = curr
__Pyx_INCREF((PyObject *)__pyx_v_curr); __Pyx_DECREF_SET(__pyx_v_prev, __pyx_v_curr);
+379: continue
goto __pyx_L4_continue;
+380: curr.prev = prev
__Pyx_INCREF((PyObject *)__pyx_v_prev); __Pyx_GIVEREF((PyObject *)__pyx_v_prev); __Pyx_GOTREF(__pyx_v_curr->prev); __Pyx_DECREF(__pyx_v_curr->prev); __pyx_v_curr->prev = ((PyObject *)__pyx_v_prev);
+381: prev.next = curr
__Pyx_INCREF((PyObject *)__pyx_v_curr); __Pyx_GIVEREF((PyObject *)__pyx_v_curr); __Pyx_GOTREF(__pyx_v_prev->next); __Pyx_DECREF(__pyx_v_prev->next); __pyx_v_prev->next = ((PyObject *)__pyx_v_curr);
+382: prev = curr
__Pyx_INCREF((PyObject *)__pyx_v_curr); __Pyx_DECREF_SET(__pyx_v_prev, __pyx_v_curr); __pyx_L4_continue:; }
383:
+384: cpdef longlong_t contract_before_auto_close(self, longlong_t dt_value):
static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_3contract_before_auto_close(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static __pyx_t_5numpy_longlong_t __pyx_f_7zipline_6assets_18continuous_futures_16OrderedContracts_contract_before_auto_close(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self, __pyx_t_5numpy_longlong_t __pyx_v_dt_value, int __pyx_skip_dispatch) { PyObject *__pyx_v_curr = NULL; __pyx_t_5numpy_longlong_t __pyx_r; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__25) __Pyx_TraceCall("contract_before_auto_close", __pyx_f[0], 384, 0, __PYX_ERR(0, 384, __pyx_L1_error)); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contract_before_auto_close); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!__Pyx_IsSameCFunction(__pyx_t_1, (void*) __pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_3contract_before_auto_close)) { __pyx_t_3 = __Pyx_PyInt_From_npy_longlong(__pyx_v_dt_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_3}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_7 = __Pyx_PyInt_As_npy_longlong(__pyx_t_2); if (unlikely((__pyx_t_7 == ((npy_longlong)-1)) && PyErr_Occurred())) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_7; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.contract_before_auto_close", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_curr); __Pyx_TraceReturn(Py_None, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_3contract_before_auto_close(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7zipline_6assets_18continuous_futures_16OrderedContracts_2contract_before_auto_close, "OrderedContracts.contract_before_auto_close(self, longlong_t dt_value) -> longlong_t\n\n Get the contract with next upcoming auto close date.\n "); static PyMethodDef __pyx_mdef_7zipline_6assets_18continuous_futures_16OrderedContracts_3contract_before_auto_close = {"contract_before_auto_close", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_3contract_before_auto_close, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7zipline_6assets_18continuous_futures_16OrderedContracts_2contract_before_auto_close}; static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_3contract_before_auto_close(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { __pyx_t_5numpy_longlong_t __pyx_v_dt_value; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("contract_before_auto_close (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dt_value,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dt_value)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 384, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "contract_before_auto_close") < 0)) __PYX_ERR(0, 384, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_dt_value = __Pyx_PyInt_As_npy_longlong(values[0]); if (unlikely((__pyx_v_dt_value == ((npy_longlong)-1)) && PyErr_Occurred())) __PYX_ERR(0, 384, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("contract_before_auto_close", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 384, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.contract_before_auto_close", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_2contract_before_auto_close(((struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *)__pyx_v_self), __pyx_v_dt_value); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_2contract_before_auto_close(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self, __pyx_t_5numpy_longlong_t __pyx_v_dt_value) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__25) __Pyx_TraceCall("contract_before_auto_close (wrapper)", __pyx_f[0], 384, 0, __PYX_ERR(0, 384, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_7zipline_6assets_18continuous_futures_16OrderedContracts_contract_before_auto_close(__pyx_v_self, __pyx_v_dt_value, 1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 384, __pyx_L1_error) __pyx_t_2 = __Pyx_PyInt_From_npy_longlong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.contract_before_auto_close", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__52 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_dt_value); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__52); __Pyx_GIVEREF(__pyx_tuple__52); /* … */ __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_6assets_18continuous_futures_16OrderedContracts_3contract_before_auto_close, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_OrderedContracts_contract_before, NULL, __pyx_n_s_zipline_assets_continuous_future, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_6assets_18continuous_futures_OrderedContracts, __pyx_n_s_contract_before_auto_close, __pyx_t_5) < 0) __PYX_ERR(0, 384, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; PyType_Modified(__pyx_ptype_7zipline_6assets_18continuous_futures_OrderedContracts); __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__52, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline_assets_continuous_fu, __pyx_n_s_contract_before_auto_close, 384, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 384, __pyx_L1_error)
385: """
386: Get the contract with next upcoming auto close date.
387: """
+388: curr = self._head_contract
__pyx_t_1 = __pyx_v_self->_head_contract;
__Pyx_INCREF(__pyx_t_1);
__pyx_v_curr = __pyx_t_1;
__pyx_t_1 = 0;
+389: while curr.next is not None:
while (1) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr, __pyx_n_s_next); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = (__pyx_t_1 != Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_8) break;
+390: if curr.contract.auto_close_date.value > dt_value:
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr, __pyx_n_s_contract); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_auto_close_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyInt_From_npy_longlong(__pyx_v_dt_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_8) { /* … */ }
+391: break
goto __pyx_L4_break;
+392: curr = curr.next
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr, __pyx_n_s_next); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 392, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_curr, __pyx_t_4); __pyx_t_4 = 0; } __pyx_L4_break:;
+393: return curr.contract.sid
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr, __pyx_n_s_contract); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_7 = __Pyx_PyInt_As_npy_longlong(__pyx_t_2); if (unlikely((__pyx_t_7 == ((npy_longlong)-1)) && PyErr_Occurred())) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_7; goto __pyx_L0;
394:
+395: cpdef contract_at_offset(self, longlong_t sid, Py_ssize_t offset, int64_t start_cap):
static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_5contract_at_offset(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_7zipline_6assets_18continuous_futures_16OrderedContracts_contract_at_offset(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self, __pyx_t_5numpy_longlong_t __pyx_v_sid, Py_ssize_t __pyx_v_offset, __pyx_t_5numpy_int64_t __pyx_v_start_cap, int __pyx_skip_dispatch) { Py_ssize_t __pyx_v_i; PyObject *__pyx_v_curr = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__26) __Pyx_TraceCall("contract_at_offset", __pyx_f[0], 395, 0, __PYX_ERR(0, 395, __pyx_L1_error)); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contract_at_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!__Pyx_IsSameCFunction(__pyx_t_1, (void*) __pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_5contract_at_offset)) { __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyInt_From_npy_longlong(__pyx_v_sid); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_offset); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_From_npy_int64(__pyx_v_start_cap); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = __pyx_t_1; __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_7, __pyx_t_3, __pyx_t_4, __pyx_t_5}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 3+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.contract_at_offset", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_curr); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_5contract_at_offset(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7zipline_6assets_18continuous_futures_16OrderedContracts_4contract_at_offset, "OrderedContracts.contract_at_offset(self, longlong_t sid, Py_ssize_t offset, int64_t start_cap)\n\n Get the sid which is the given sid plus the offset distance.\n An offset of 0 should be reflexive.\n "); static PyMethodDef __pyx_mdef_7zipline_6assets_18continuous_futures_16OrderedContracts_5contract_at_offset = {"contract_at_offset", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_5contract_at_offset, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7zipline_6assets_18continuous_futures_16OrderedContracts_4contract_at_offset}; static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_5contract_at_offset(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { __pyx_t_5numpy_longlong_t __pyx_v_sid; Py_ssize_t __pyx_v_offset; __pyx_t_5numpy_int64_t __pyx_v_start_cap; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("contract_at_offset (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sid,&__pyx_n_s_offset,&__pyx_n_s_start_cap,0}; PyObject* values[3] = {0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_sid)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_offset)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("contract_at_offset", 1, 3, 3, 1); __PYX_ERR(0, 395, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_start_cap)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("contract_at_offset", 1, 3, 3, 2); __PYX_ERR(0, 395, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "contract_at_offset") < 0)) __PYX_ERR(0, 395, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); } __pyx_v_sid = __Pyx_PyInt_As_npy_longlong(values[0]); if (unlikely((__pyx_v_sid == ((npy_longlong)-1)) && PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L3_error) __pyx_v_offset = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_offset == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L3_error) __pyx_v_start_cap = __Pyx_PyInt_As_npy_int64(values[2]); if (unlikely((__pyx_v_start_cap == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("contract_at_offset", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 395, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.contract_at_offset", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_4contract_at_offset(((struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *)__pyx_v_self), __pyx_v_sid, __pyx_v_offset, __pyx_v_start_cap); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_4contract_at_offset(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self, __pyx_t_5numpy_longlong_t __pyx_v_sid, Py_ssize_t __pyx_v_offset, __pyx_t_5numpy_int64_t __pyx_v_start_cap) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__26) __Pyx_TraceCall("contract_at_offset (wrapper)", __pyx_f[0], 395, 0, __PYX_ERR(0, 395, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_7zipline_6assets_18continuous_futures_16OrderedContracts_contract_at_offset(__pyx_v_self, __pyx_v_sid, __pyx_v_offset, __pyx_v_start_cap, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.contract_at_offset", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__53 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_sid, __pyx_n_s_offset, __pyx_n_s_start_cap); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__53); __Pyx_GIVEREF(__pyx_tuple__53); /* … */ __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_6assets_18continuous_futures_16OrderedContracts_5contract_at_offset, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_OrderedContracts_contract_at_off, NULL, __pyx_n_s_zipline_assets_continuous_future, __pyx_d, ((PyObject *)__pyx_codeobj__26)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_6assets_18continuous_futures_OrderedContracts, __pyx_n_s_contract_at_offset, __pyx_t_5) < 0) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; PyType_Modified(__pyx_ptype_7zipline_6assets_18continuous_futures_OrderedContracts); __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline_assets_continuous_fu, __pyx_n_s_contract_at_offset, 395, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 395, __pyx_L1_error)
396: """
397: Get the sid which is the given sid plus the offset distance.
398: An offset of 0 should be reflexive.
399: """
400: cdef Py_ssize_t i
+401: curr = self.sid_to_contract[sid]
if (unlikely(__pyx_v_self->sid_to_contract == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 401, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyInt_From_npy_longlong(__pyx_v_sid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->sid_to_contract, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_curr = __pyx_t_2; __pyx_t_2 = 0;
+402: i = 0
__pyx_v_i = 0;
+403: while i < offset:
while (1) { __pyx_t_9 = (__pyx_v_i < __pyx_v_offset); if (!__pyx_t_9) break;
+404: if curr.next is None:
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr, __pyx_n_s_next); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = (__pyx_t_2 == Py_None); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_9) { /* … */ }
+405: return None
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+406: curr = curr.next
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr, __pyx_n_s_next); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_curr, __pyx_t_2); __pyx_t_2 = 0;
+407: i += 1
__pyx_v_i = (__pyx_v_i + 1); }
+408: if curr.contract.start_date.value <= start_cap:
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr, __pyx_n_s_contract); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_start_date); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_start_cap); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_LE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 408, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 408, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_9) { /* … */ }
+409: return curr.contract.sid
__Pyx_XDECREF(__pyx_r); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr, __pyx_n_s_contract); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_sid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
410: else:
+411: return None
/*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; }
412:
+413: cpdef longlong_t[:] active_chain(self, longlong_t starting_sid, longlong_t dt_value):
static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_7active_chain(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static __Pyx_memviewslice __pyx_f_7zipline_6assets_18continuous_futures_16OrderedContracts_active_chain(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self, __pyx_t_5numpy_longlong_t __pyx_v_starting_sid, __pyx_t_5numpy_longlong_t __pyx_v_dt_value, int __pyx_skip_dispatch) { PyObject *__pyx_v_curr = NULL; PyObject *__pyx_v_contracts = 0; __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__27) __Pyx_TraceCall("active_chain", __pyx_f[0], 413, 0, __PYX_ERR(0, 413, __pyx_L1_error)); /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_active_chain); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!__Pyx_IsSameCFunction(__pyx_t_1, (void*) __pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_7active_chain)) { __pyx_t_3 = __Pyx_PyInt_From_npy_longlong(__pyx_v_starting_sid); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_From_npy_longlong(__pyx_v_dt_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = __pyx_t_1; __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_t_3, __pyx_t_4}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_5numpy_longlong_t(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __PYX_XCLEAR_MEMVIEW(&__pyx_t_8, 1); __pyx_r.data = NULL; __pyx_r.memview = NULL; __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.active_chain", __pyx_clineno, __pyx_lineno, __pyx_filename); goto __pyx_L2; __pyx_L0:; if (unlikely(!__pyx_r.memview)) { PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized"); } __pyx_L2:; __Pyx_XDECREF(__pyx_v_curr); __Pyx_XDECREF(__pyx_v_contracts); __Pyx_TraceReturn(Py_None, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_7active_chain(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7zipline_6assets_18continuous_futures_16OrderedContracts_6active_chain, "OrderedContracts.active_chain(self, longlong_t starting_sid, longlong_t dt_value) -> longlong_t[:]"); static PyMethodDef __pyx_mdef_7zipline_6assets_18continuous_futures_16OrderedContracts_7active_chain = {"active_chain", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_7active_chain, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7zipline_6assets_18continuous_futures_16OrderedContracts_6active_chain}; static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_7active_chain(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { __pyx_t_5numpy_longlong_t __pyx_v_starting_sid; __pyx_t_5numpy_longlong_t __pyx_v_dt_value; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("active_chain (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_starting_sid,&__pyx_n_s_dt_value,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_starting_sid)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 413, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dt_value)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 413, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("active_chain", 1, 2, 2, 1); __PYX_ERR(0, 413, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "active_chain") < 0)) __PYX_ERR(0, 413, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_starting_sid = __Pyx_PyInt_As_npy_longlong(values[0]); if (unlikely((__pyx_v_starting_sid == ((npy_longlong)-1)) && PyErr_Occurred())) __PYX_ERR(0, 413, __pyx_L3_error) __pyx_v_dt_value = __Pyx_PyInt_As_npy_longlong(values[1]); if (unlikely((__pyx_v_dt_value == ((npy_longlong)-1)) && PyErr_Occurred())) __PYX_ERR(0, 413, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("active_chain", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 413, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.active_chain", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_6active_chain(((struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *)__pyx_v_self), __pyx_v_starting_sid, __pyx_v_dt_value); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_6active_chain(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self, __pyx_t_5numpy_longlong_t __pyx_v_starting_sid, __pyx_t_5numpy_longlong_t __pyx_v_dt_value) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__27) __Pyx_TraceCall("active_chain (wrapper)", __pyx_f[0], 413, 0, __PYX_ERR(0, 413, __pyx_L1_error)); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_7zipline_6assets_18continuous_futures_16OrderedContracts_active_chain(__pyx_v_self, __pyx_v_starting_sid, __pyx_v_dt_value, 1); if (unlikely(!__pyx_t_1.memview)) __PYX_ERR(0, 413, __pyx_L1_error) __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_t_1, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5numpy_longlong_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5numpy_longlong_t, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __PYX_XCLEAR_MEMVIEW(&__pyx_t_1, 1); __pyx_t_1.memview = NULL; __pyx_t_1.data = NULL; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __PYX_XCLEAR_MEMVIEW(&__pyx_t_1, 1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.active_chain", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__54 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_starting_sid, __pyx_n_s_dt_value); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__54); __Pyx_GIVEREF(__pyx_tuple__54); /* … */ __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_6assets_18continuous_futures_16OrderedContracts_7active_chain, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_OrderedContracts_active_chain, NULL, __pyx_n_s_zipline_assets_continuous_future, __pyx_d, ((PyObject *)__pyx_codeobj__27)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_6assets_18continuous_futures_OrderedContracts, __pyx_n_s_active_chain, __pyx_t_5) < 0) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; PyType_Modified(__pyx_ptype_7zipline_6assets_18continuous_futures_OrderedContracts); __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__54, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline_assets_continuous_fu, __pyx_n_s_active_chain, 413, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 413, __pyx_L1_error)
+414: curr = self.sid_to_contract[starting_sid]
if (unlikely(__pyx_v_self->sid_to_contract == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 414, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyInt_From_npy_longlong(__pyx_v_starting_sid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->sid_to_contract, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 414, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_curr = __pyx_t_2; __pyx_t_2 = 0;
+415: cdef list contracts = []
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_contracts = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
416:
+417: while curr is not None:
while (1) { __pyx_t_9 = (__pyx_v_curr != Py_None); if (!__pyx_t_9) break;
+418: if curr.contract.start_date.value <= dt_value:
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr, __pyx_n_s_contract); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_start_date); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_npy_longlong(__pyx_v_dt_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_LE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_9) { /* … */ }
+419: contracts.append(curr.contract.sid)
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr, __pyx_n_s_contract); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_contracts, __pyx_t_1); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 419, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+420: curr = curr.next
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_curr, __pyx_n_s_next); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_curr, __pyx_t_1); __pyx_t_1 = 0; }
421:
+422: return array(contracts, dtype='int64')
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_contracts); __Pyx_GIVEREF(__pyx_v_contracts); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_contracts)) __PYX_ERR(0, 422, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_n_u_int64) < 0) __PYX_ERR(0, 422, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_nn___pyx_t_5numpy_longlong_t(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL; goto __pyx_L0;
423:
424: property start_date:
+425: def __get__(self):
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_10start_date_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_10start_date_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_10start_date___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_10start_date___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 425, 0, __PYX_ERR(0, 425, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.start_date.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+426: return Timestamp(self._start_date, tz='UTC')
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Timestamp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->_start_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2)) __PYX_ERR(0, 426, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_tz, __pyx_n_u_UTC) < 0) __PYX_ERR(0, 426, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
427:
428: property end_date:
+429: def __get__(self):
/* Python wrapper */ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_8end_date_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7zipline_6assets_18continuous_futures_16OrderedContracts_8end_date_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_8end_date___get__(((struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7zipline_6assets_18continuous_futures_16OrderedContracts_8end_date___get__(struct __pyx_obj_7zipline_6assets_18continuous_futures_OrderedContracts *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("__get__", __pyx_f[0], 429, 0, __PYX_ERR(0, 429, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("zipline.assets.continuous_futures.OrderedContracts.end_date.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+430: return Timestamp(self._end_date, tz='UTC')
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Timestamp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 430, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->_end_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 430, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2)) __PYX_ERR(0, 430, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 430, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_tz, __pyx_n_u_UTC) < 0) __PYX_ERR(0, 430, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 430, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;