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: _protocol.c

+001: #
  __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_4) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 002: # Copyright 2016 Quantopian, Inc.
 003: #
 004: # Licensed under the Apache License, Version 2.0 (the "License");
 005: # you may not use this file except in compliance with the License.
 006: # You may obtain a copy of the License at
 007: #
 008: #     http://www.apache.org/licenses/LICENSE-2.0
 009: #
 010: # Unless required by applicable law or agreed to in writing, software
 011: # distributed under the License is distributed on an "AS IS" BASIS,
 012: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 013: # See the License for the specific language governing permissions and
 014: # limitations under the License.
+015: import warnings
  __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_warnings, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_2) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+016: from contextlib import contextmanager
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_contextmanager);
  __Pyx_GIVEREF(__pyx_n_s_contextmanager);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_contextmanager)) __PYX_ERR(0, 16, __pyx_L1_error);
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_contextlib, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_contextmanager); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_contextmanager, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+017: from functools import wraps
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_wraps);
  __Pyx_GIVEREF(__pyx_n_s_wraps);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_wraps)) __PYX_ERR(0, 17, __pyx_L1_error);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_functools, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_wraps); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_wraps, __pyx_t_3) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+018: import pandas as pd
  __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_pandas, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pd, __pyx_t_2) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+019: import numpy as np
  __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_numpy, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) __PYX_ERR(0, 19, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 020: 
 021: from cpython cimport bool
+022: from collections.abc import Iterable
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_Iterable);
  __Pyx_GIVEREF(__pyx_n_s_Iterable);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Iterable)) __PYX_ERR(0, 22, __pyx_L1_error);
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_collections_abc, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Iterable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Iterable, __pyx_t_2) < 0) __PYX_ERR(0, 22, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 023: 
+024: from zipline.assets import (
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_zipline_assets, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_PricingDataAssociable); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 24, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_PricingDataAssociable, __pyx_t_3) < 0) __PYX_ERR(0, 25, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+025:     PricingDataAssociable,
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_PricingDataAssociable);
  __Pyx_GIVEREF(__pyx_n_s_PricingDataAssociable);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_PricingDataAssociable)) __PYX_ERR(0, 25, __pyx_L1_error);
 026: )
 027: from zipline.assets._assets cimport Asset
+028: from zipline.assets.continuous_futures import ContinuousFuture
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_ContinuousFuture);
  __Pyx_GIVEREF(__pyx_n_s_ContinuousFuture);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ContinuousFuture)) __PYX_ERR(0, 28, __pyx_L1_error);
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_zipline_assets_continuous_future, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_ContinuousFuture); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ContinuousFuture, __pyx_t_2) < 0) __PYX_ERR(0, 28, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+029: from zipline.utils.pandas_utils import normalize_date
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_n_s_normalize_date);
  __Pyx_GIVEREF(__pyx_n_s_normalize_date);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_normalize_date)) __PYX_ERR(0, 29, __pyx_L1_error);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_zipline_utils_pandas_utils, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_normalize_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_normalize_date, __pyx_t_3) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+030: from zipline.zipline_warnings import ZiplineDeprecationWarning
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_ZiplineDeprecationWarning);
  __Pyx_GIVEREF(__pyx_n_s_ZiplineDeprecationWarning);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ZiplineDeprecationWarning)) __PYX_ERR(0, 30, __pyx_L1_error);
  __pyx_t_3 = __Pyx_Import(__pyx_n_s_zipline_zipline_warnings, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_ZiplineDeprecationWarning); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ZiplineDeprecationWarning, __pyx_t_2) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 031: 
+032: cdef bool _is_iterable(obj):
static PyBoolObject *__pyx_f_7zipline_9_protocol__is_iterable(PyObject *__pyx_v_obj) {
  PyBoolObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("_is_iterable", __pyx_f[0], 32, 0, __PYX_ERR(0, 32, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("zipline._protocol._is_iterable", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+033:     return isinstance(obj, Iterable) and not isinstance(obj, str)
  __Pyx_XDECREF((PyObject *)__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Iterable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_IsInstance(__pyx_v_obj, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
  } else {
    __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) __PYX_ERR(0, 33, __pyx_L1_error)
    __pyx_t_1 = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_3 = PyUnicode_Check(__pyx_v_obj); 
  __pyx_t_4 = (!__pyx_t_3);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) __PYX_ERR(0, 33, __pyx_L1_error)
  __pyx_t_1 = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_L3_bool_binop_done:;
  __pyx_r = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;
 034: 
+035: cdef class check_parameters(object):
struct __pyx_obj_7zipline_9_protocol_check_parameters {
  PyObject_HEAD
  PyObject *keyword_names;
  PyObject *types;
  PyObject *keys_to_types;
};

 036:     """
 037:     Asserts that the keywords passed into the wrapped function are included
 038:     in those passed into this decorator. If not, raise a TypeError with a
 039:     meaningful message, unlike the one Cython returns by default.
 040: 
 041:     Also asserts that the arguments passed into the wrapped function are
 042:     consistent with the types passed into this decorator. If not, raise a
 043:     TypeError with a meaningful message.
 044:     """
 045:     cdef tuple keyword_names
 046:     cdef tuple types
 047:     cdef dict keys_to_types
 048: 
+049:     def __init__(self, keyword_names, types):
/* Python wrapper */
static int __pyx_pw_7zipline_9_protocol_16check_parameters_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_7zipline_9_protocol_16check_parameters_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_keyword_names = 0;
  PyObject *__pyx_v_types = 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_keyword_names,&__pyx_n_s_types,0};
  PyObject* values[2] = {0,0};
    if (__pyx_kwds) {
      Py_ssize_t kw_args;
      switch (__pyx_nargs) {
        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_keyword_names)) != 0)) {
          (void)__Pyx_Arg_NewRef_VARARGS(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 49, __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_types)) != 0)) {
          (void)__Pyx_Arg_NewRef_VARARGS(values[1]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 49, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 49, __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, 49, __pyx_L3_error)
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0);
      values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1);
    }
    __pyx_v_keyword_names = values[0];
    __pyx_v_types = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 49, __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._protocol.check_parameters.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7zipline_9_protocol_16check_parameters___init__(((struct __pyx_obj_7zipline_9_protocol_check_parameters *)__pyx_v_self), __pyx_v_keyword_names, __pyx_v_types);
  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_9_protocol_16check_parameters___init__(struct __pyx_obj_7zipline_9_protocol_check_parameters *__pyx_v_self, PyObject *__pyx_v_keyword_names, PyObject *__pyx_v_types) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("__init__", __pyx_f[0], 49, 0, __PYX_ERR(0, 49, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("zipline._protocol.check_parameters.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+050:         self.keyword_names = keyword_names
  if (!(likely(PyTuple_CheckExact(__pyx_v_keyword_names))||((__pyx_v_keyword_names) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_v_keyword_names))) __PYX_ERR(0, 50, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_keyword_names;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->keyword_names);
  __Pyx_DECREF(__pyx_v_self->keyword_names);
  __pyx_v_self->keyword_names = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
+051:         self.types = types
  if (!(likely(PyTuple_CheckExact(__pyx_v_types))||((__pyx_v_types) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_v_types))) __PYX_ERR(0, 51, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_types;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->types);
  __Pyx_DECREF(__pyx_v_self->types);
  __pyx_v_self->types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 052: 
+053:         self.keys_to_types = dict(zip(keyword_names, types))
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_keyword_names);
  __Pyx_GIVEREF(__pyx_v_keyword_names);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_keyword_names)) __PYX_ERR(0, 53, __pyx_L1_error);
  __Pyx_INCREF(__pyx_v_types);
  __Pyx_GIVEREF(__pyx_v_types);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_types)) __PYX_ERR(0, 53, __pyx_L1_error);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyDict_Type)), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->keys_to_types);
  __Pyx_DECREF(__pyx_v_self->keys_to_types);
  __pyx_v_self->keys_to_types = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 054: 
+055:     def __call__(self, func):
/* Python wrapper */
static PyObject *__pyx_pw_7zipline_9_protocol_16check_parameters_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_7zipline_9_protocol_16check_parameters_3__call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_func = 0;
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__call__ (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 NULL;
  #endif
  __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  {
    PyObject **__pyx_pyargnames[] = {&__pyx_n_s_func,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_func)) != 0)) {
          (void)__Pyx_Arg_NewRef_VARARGS(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 55, __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, "__call__") < 0)) __PYX_ERR(0, 55, __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_func = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 55, __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._protocol.check_parameters.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7zipline_9_protocol_16check_parameters_2__call__(((struct __pyx_obj_7zipline_9_protocol_check_parameters *)__pyx_v_self), __pyx_v_func);
  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 PyObject *__pyx_pf_7zipline_9_protocol_16check_parameters_2__call__(struct __pyx_obj_7zipline_9_protocol_check_parameters *__pyx_v_self, PyObject *__pyx_v_func) {
  struct __pyx_obj_7zipline_9_protocol___pyx_scope_struct____call__ *__pyx_cur_scope;
  PyObject *__pyx_v_assert_keywords_and_call = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __pyx_cur_scope = (struct __pyx_obj_7zipline_9_protocol___pyx_scope_struct____call__ *)__pyx_tp_new_7zipline_9_protocol___pyx_scope_struct____call__(__pyx_ptype_7zipline_9_protocol___pyx_scope_struct____call__, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_7zipline_9_protocol___pyx_scope_struct____call__ *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 55, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __Pyx_TraceCall("__call__", __pyx_f[0], 55, 0, __PYX_ERR(0, 55, __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);
  __pyx_cur_scope->__pyx_v_func = __pyx_v_func;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_func);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_func);
/* … */
  /* 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._protocol.check_parameters.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_assert_keywords_and_call);
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
struct __pyx_obj_7zipline_9_protocol___pyx_scope_struct____call__ {
  PyObject_HEAD
  PyObject *__pyx_v_func;
  struct __pyx_obj_7zipline_9_protocol_check_parameters *__pyx_v_self;
};

+056:         @wraps(func)
/* Python wrapper */
static PyObject *__pyx_pw_7zipline_9_protocol_16check_parameters_8__call___1assert_keywords_and_call(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_7zipline_9_protocol_16check_parameters_8__call___1assert_keywords_and_call = {"assert_keywords_and_call", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7zipline_9_protocol_16check_parameters_8__call___1assert_keywords_and_call, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_7zipline_9_protocol_16check_parameters_8__call___1assert_keywords_and_call(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwargs = 0;
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("assert_keywords_and_call (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 NULL;
  #endif
  __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "assert_keywords_and_call", 1))) return NULL;
  if (unlikely(__pyx_kwds)) {
    __pyx_v_kwargs = __Pyx_KwargsAsDict_VARARGS(__pyx_kwds, __pyx_kwvalues);
    if (unlikely(!__pyx_v_kwargs)) return NULL;
    __Pyx_GOTREF(__pyx_v_kwargs);
  } else {
    __pyx_v_kwargs = PyDict_New();
    if (unlikely(!__pyx_v_kwargs)) return NULL;
    __Pyx_GOTREF(__pyx_v_kwargs);
  }
  __Pyx_INCREF(__pyx_args);
  __pyx_v_args = __pyx_args;
  __pyx_r = __pyx_pf_7zipline_9_protocol_16check_parameters_8__call___assert_keywords_and_call(__pyx_self, __pyx_v_args, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_DECREF(__pyx_v_args);
  __Pyx_DECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7zipline_9_protocol_16check_parameters_8__call___assert_keywords_and_call(PyObject *__pyx_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
  struct __pyx_obj_7zipline_9_protocol___pyx_scope_struct____call__ *__pyx_cur_scope;
  struct __pyx_obj_7zipline_9_protocol___pyx_scope_struct____call__ *__pyx_outer_scope;
  short __pyx_v_i;
  PyObject *__pyx_v_field = NULL;
  PyObject *__pyx_v_arg = NULL;
  PyObject *__pyx_v_expected_type = NULL;
  PyObject *__pyx_v_expected_type_name = NULL;
  PyObject *__pyx_v_keyword = NULL;
  PyObject *__pyx_7genexpr__pyx_v_type_ = NULL;
  PyObject *__pyx_8genexpr1__pyx_v_type_ = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __pyx_outer_scope = (struct __pyx_obj_7zipline_9_protocol___pyx_scope_struct____call__ *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;
  __Pyx_TraceCall("assert_keywords_and_call", __pyx_f[0], 56, 0, __PYX_ERR(0, 56, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("zipline._protocol.check_parameters.__call__.assert_keywords_and_call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_field);
  __Pyx_XDECREF(__pyx_v_arg);
  __Pyx_XDECREF(__pyx_v_expected_type);
  __Pyx_XDECREF(__pyx_v_expected_type_name);
  __Pyx_XDECREF(__pyx_v_keyword);
  __Pyx_XDECREF(__pyx_7genexpr__pyx_v_type_);
  __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_type_);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_wraps); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 56, __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_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, __pyx_cur_scope->__pyx_v_func};
    __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
/* … */
  __pyx_tuple__6 = PyTuple_Pack(10, __pyx_n_s_args, __pyx_n_s_kwargs, __pyx_n_s_i, __pyx_n_s_field, __pyx_n_s_arg, __pyx_n_s_expected_type, __pyx_n_s_expected_type_name, __pyx_n_s_keyword, __pyx_n_s_type, __pyx_n_s_type); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);
  __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_9_protocol_16check_parameters_8__call___1assert_keywords_and_call, 0, __pyx_n_s_call___locals_assert_keywords, ((PyObject*)__pyx_cur_scope), __pyx_n_s_zipline__protocol, __pyx_d, ((PyObject *)__pyx_codeobj__7)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 56, __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, 56, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_v_assert_keywords_and_call = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline__protocol_pyx, __pyx_n_s_assert_keywords_and_call, 56, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 56, __pyx_L1_error)
 057:         def assert_keywords_and_call(*args, **kwargs):
 058:             cdef short i
 059: 
 060:             # verify all the keyword arguments
+061:             for field in kwargs:
  __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_kwargs, 1, ((PyObject *)NULL), (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_1);
  __pyx_t_1 = __pyx_t_5;
  __pyx_t_5 = 0;
  while (1) {
    __pyx_t_6 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_5, NULL, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_6 == 0)) break;
    if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XDECREF_SET(__pyx_v_field, __pyx_t_5);
    __pyx_t_5 = 0;
+062:                 if field not in self.keyword_names:
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 62, __pyx_L1_error) }
    __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_v_field, __pyx_cur_scope->__pyx_v_self->keyword_names, Py_NE)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 62, __pyx_L1_error)
    if (unlikely(__pyx_t_7)) {
/* … */
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+063:                     raise TypeError("%s() got an unexpected keyword argument"
      __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 63, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = 0;
      __pyx_t_9 = 127;
/* … */
      __pyx_t_11 = __Pyx_PyUnicode_Join(__pyx_t_5, 4, __pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 63, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 63, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __PYX_ERR(0, 63, __pyx_L1_error)
+064:                                     " '%s'" % (func.__name__, field))
      if (unlikely(!__pyx_cur_scope->__pyx_v_func)) { __Pyx_RaiseClosureNameError("func"); __PYX_ERR(0, 64, __pyx_L1_error) }
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_func, __pyx_n_s_name); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 64, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_10), __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 64, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_9;
      __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_11);
      __pyx_t_11 = 0;
      __Pyx_INCREF(__pyx_kp_u_got_an_unexpected_keyword_argum);
      __pyx_t_8 += 39;
      __Pyx_GIVEREF(__pyx_kp_u_got_an_unexpected_keyword_argum);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_kp_u_got_an_unexpected_keyword_argum);
      __pyx_t_11 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_v_field), __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 64, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_9;
      __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_11);
      __pyx_t_11 = 0;
      __Pyx_INCREF(__pyx_kp_u__3);
      __pyx_t_8 += 1;
      __Pyx_GIVEREF(__pyx_kp_u__3);
      PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_kp_u__3);
 065: 
 066:             # verify type of each argument
+067:             for i, arg in enumerate(args[1:]):
  __pyx_t_12 = 0;
  __pyx_t_1 = __Pyx_PyTuple_GetSlice(__pyx_v_args, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __pyx_t_1; __Pyx_INCREF(__pyx_t_5);
  __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    {
      Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5);
      #if !CYTHON_ASSUME_SAFE_MACROS
      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 67, __pyx_L1_error)
      #endif
      if (__pyx_t_3 >= __pyx_temp) break;
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 67, __pyx_L1_error)
    #else
    __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_v_i = __pyx_t_12;
    __pyx_t_12 = (__pyx_t_12 + 1);
/* … */
    __pyx_L6_continue:;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+068:                 expected_type = self.types[i]
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 68, __pyx_L1_error) }
    if (unlikely(__pyx_cur_scope->__pyx_v_self->types == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 68, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_cur_scope->__pyx_v_self->types, __pyx_v_i, short, 1, __Pyx_PyInt_From_short, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_expected_type, __pyx_t_1);
    __pyx_t_1 = 0;
 069: 
+070:                 if (i == 0 or i == 1) and _is_iterable(arg):
    switch (__pyx_v_i) {
      case 0:
      case 1:
      __pyx_t_13 = 1;
      break;
      default:
      __pyx_t_13 = 0;
      break;
    }
    if (__pyx_t_13) {
    } else {
      __pyx_t_7 = __pyx_t_13;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_1 = ((PyObject *)__pyx_f_7zipline_9_protocol__is_iterable(__pyx_v_arg)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 70, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = __pyx_t_13;
    __pyx_L9_bool_binop_done:;
    if (__pyx_t_7) {
/* … */
    }
+071:                     if len(arg) == 0:
      __pyx_t_2 = PyObject_Length(__pyx_v_arg); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 71, __pyx_L1_error)
      __pyx_t_7 = (__pyx_t_2 == 0);
      if (__pyx_t_7) {
/* … */
      }
+072:                         continue
        goto __pyx_L6_continue;
+073:                     arg = arg[0]
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_arg, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_1);
      __pyx_t_1 = 0;
 074: 
+075:                 if not isinstance(arg, expected_type):
    __pyx_t_7 = PyObject_IsInstance(__pyx_v_arg, __pyx_v_expected_type); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 75, __pyx_L1_error)
    __pyx_t_13 = (!__pyx_t_7);
    if (unlikely(__pyx_t_13)) {
/* … */
    }
+076:                     expected_type_name = expected_type.__name__ \
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_expected_type, __pyx_n_s_name); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 76, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_1 = __pyx_t_11;
        __pyx_t_11 = 0;
      } else {
+077:                         if not _is_iterable(expected_type) \
      __pyx_t_11 = ((PyObject *)__pyx_f_7zipline_9_protocol__is_iterable(__pyx_v_expected_type)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 77, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 77, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_7 = (!__pyx_t_13);
      if (__pyx_t_7) {
+078:                         else ', '.join([type_.__name__ for type_ in expected_type])
        { /* enter inner scope */
          __pyx_t_11 = PyList_New(0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 78, __pyx_L15_error)
          __Pyx_GOTREF(__pyx_t_11);
          if (likely(PyList_CheckExact(__pyx_v_expected_type)) || PyTuple_CheckExact(__pyx_v_expected_type)) {
            __pyx_t_10 = __pyx_v_expected_type; __Pyx_INCREF(__pyx_t_10);
            __pyx_t_2 = 0;
            __pyx_t_14 = NULL;
          } else {
            __pyx_t_2 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_v_expected_type); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 78, __pyx_L15_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_14 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_10); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 78, __pyx_L15_error)
          }
          for (;;) {
            if (likely(!__pyx_t_14)) {
              if (likely(PyList_CheckExact(__pyx_t_10))) {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_10);
                  #if !CYTHON_ASSUME_SAFE_MACROS
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 78, __pyx_L15_error)
                  #endif
                  if (__pyx_t_2 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_15 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_2); __Pyx_INCREF(__pyx_t_15); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 78, __pyx_L15_error)
                #else
                __pyx_t_15 = __Pyx_PySequence_ITEM(__pyx_t_10, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 78, __pyx_L15_error)
                __Pyx_GOTREF(__pyx_t_15);
                #endif
              } else {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_10);
                  #if !CYTHON_ASSUME_SAFE_MACROS
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 78, __pyx_L15_error)
                  #endif
                  if (__pyx_t_2 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_15 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_2); __Pyx_INCREF(__pyx_t_15); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 78, __pyx_L15_error)
                #else
                __pyx_t_15 = __Pyx_PySequence_ITEM(__pyx_t_10, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 78, __pyx_L15_error)
                __Pyx_GOTREF(__pyx_t_15);
                #endif
              }
            } else {
              __pyx_t_15 = __pyx_t_14(__pyx_t_10);
              if (unlikely(!__pyx_t_15)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                  else __PYX_ERR(0, 78, __pyx_L15_error)
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_15);
            }
            __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_type_, __pyx_t_15);
            __pyx_t_15 = 0;
            __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_7genexpr__pyx_v_type_, __pyx_n_s_name); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 78, __pyx_L15_error)
            __Pyx_GOTREF(__pyx_t_15);
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_11, (PyObject*)__pyx_t_15))) __PYX_ERR(0, 78, __pyx_L15_error)
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          }
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_7genexpr__pyx_v_type_); __pyx_7genexpr__pyx_v_type_ = 0;
          goto __pyx_L19_exit_scope;
          __pyx_L15_error:;
          __Pyx_XDECREF(__pyx_7genexpr__pyx_v_type_); __pyx_7genexpr__pyx_v_type_ = 0;
          goto __pyx_L1_error;
          __pyx_L19_exit_scope:;
        } /* exit inner scope */
        __pyx_t_10 = PyUnicode_Join(__pyx_kp_u__4, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 78, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_1 = __pyx_t_10;
        __pyx_t_10 = 0;
      }
      __pyx_v_expected_type_name = __pyx_t_1;
      __pyx_t_1 = 0;
 079: 
+080:                     raise TypeError("Expected %s argument to be of type %s%s" %
      __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = 0;
      __pyx_t_9 = 127;
      __Pyx_INCREF(__pyx_kp_u_Expected);
      __pyx_t_2 += 9;
      __Pyx_GIVEREF(__pyx_kp_u_Expected);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Expected);
/* … */
      __pyx_t_10 = __Pyx_PyUnicode_Join(__pyx_t_1, 5, __pyx_t_2, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 80, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(0, 80, __pyx_L1_error)
+081:                                     (self.keyword_names[i],
      if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 81, __pyx_L1_error) }
      if (unlikely(__pyx_cur_scope->__pyx_v_self->keyword_names == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 81, __pyx_L1_error)
      }
      __pyx_t_10 = __Pyx_GetItemInt_Tuple(__pyx_cur_scope->__pyx_v_self->keyword_names, __pyx_v_i, short, 1, __Pyx_PyInt_From_short, 0, 1, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 81, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_t_10), __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 81, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_9;
      __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11);
      __pyx_t_11 = 0;
      __Pyx_INCREF(__pyx_kp_u_argument_to_be_of_type);
      __pyx_t_2 += 24;
      __Pyx_GIVEREF(__pyx_kp_u_argument_to_be_of_type);
      PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_argument_to_be_of_type);
+082:                                      'or iterable of type ' if i in (0, 1) else '',
      switch (__pyx_v_i) {
        case 0:
        case 1:
        __Pyx_INCREF(__pyx_kp_u_or_iterable_of_type);
        __pyx_t_11 = __pyx_kp_u_or_iterable_of_type;
        break;
        default:
        __Pyx_INCREF(__pyx_kp_u__5);
        __pyx_t_11 = __pyx_kp_u__5;
        break;
      }
      __pyx_t_10 = __Pyx_PyUnicode_Unicode(__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 82, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_9;
      __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_10);
      __pyx_t_10 = 0;
+083:                                      expected_type_name)
      __pyx_t_10 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_v_expected_type_name), __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 83, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_9;
      __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_t_10);
      __pyx_t_10 = 0;
 084:                                     )
 085: 
 086:             # verify type of each kwarg
+087:             for keyword, arg in kwargs.items():
  __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_dict_iterator(__pyx_v_kwargs, 1, __pyx_n_s_items, (&__pyx_t_2), (&__pyx_t_4)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __pyx_t_5 = __pyx_t_1;
  __pyx_t_1 = 0;
  while (1) {
    __pyx_t_6 = __Pyx_dict_iter_next(__pyx_t_5, __pyx_t_2, &__pyx_t_3, &__pyx_t_1, &__pyx_t_10, NULL, __pyx_t_4);
    if (unlikely(__pyx_t_6 == 0)) break;
    if (unlikely(__pyx_t_6 == -1)) __PYX_ERR(0, 87, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_XDECREF_SET(__pyx_v_keyword, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_10);
    __pyx_t_10 = 0;
+088:                 if keyword in ('assets', 'fields') and _is_iterable(arg):
    __Pyx_INCREF(__pyx_v_keyword);
    __pyx_t_10 = __pyx_v_keyword;
    __pyx_t_16 = (__Pyx_PyUnicode_Equals(__pyx_t_10, __pyx_n_u_assets, Py_EQ)); if (unlikely((__pyx_t_16 < 0))) __PYX_ERR(0, 88, __pyx_L1_error)
    if (!__pyx_t_16) {
    } else {
      __pyx_t_13 = __pyx_t_16;
      goto __pyx_L26_bool_binop_done;
    }
    __pyx_t_16 = (__Pyx_PyUnicode_Equals(__pyx_t_10, __pyx_n_u_fields, Py_EQ)); if (unlikely((__pyx_t_16 < 0))) __PYX_ERR(0, 88, __pyx_L1_error)
    __pyx_t_13 = __pyx_t_16;
    __pyx_L26_bool_binop_done:;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_16 = __pyx_t_13;
    if (__pyx_t_16) {
    } else {
      __pyx_t_7 = __pyx_t_16;
      goto __pyx_L24_bool_binop_done;
    }
    __pyx_t_10 = ((PyObject *)__pyx_f_7zipline_9_protocol__is_iterable(__pyx_v_arg)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 88, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_16 < 0))) __PYX_ERR(0, 88, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_7 = __pyx_t_16;
    __pyx_L24_bool_binop_done:;
    if (__pyx_t_7) {
/* … */
    }
+089:                     if len(arg) == 0:
      __pyx_t_8 = PyObject_Length(__pyx_v_arg); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 89, __pyx_L1_error)
      __pyx_t_7 = (__pyx_t_8 == 0);
      if (__pyx_t_7) {
/* … */
      }
+090:                         continue
        goto __pyx_L21_continue;
+091:                     arg = arg[0]
      __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_arg, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 91, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_10);
      __pyx_t_10 = 0;
+092:                 if not isinstance(arg, self.keys_to_types[keyword]):
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 92, __pyx_L1_error) }
    if (unlikely(__pyx_cur_scope->__pyx_v_self->keys_to_types == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(0, 92, __pyx_L1_error)
    }
    __pyx_t_10 = __Pyx_PyDict_GetItem(__pyx_cur_scope->__pyx_v_self->keys_to_types, __pyx_v_keyword); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 92, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_7 = PyObject_IsInstance(__pyx_v_arg, __pyx_t_10); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 92, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_16 = (!__pyx_t_7);
    if (unlikely(__pyx_t_16)) {
/* … */
    }
    __pyx_L21_continue:;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+093:                     expected_type = self.keys_to_types[keyword].__name__ \
        if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 93, __pyx_L1_error) }
        if (unlikely(__pyx_cur_scope->__pyx_v_self->keys_to_types == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 93, __pyx_L1_error)
        }
        __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_cur_scope->__pyx_v_self->keys_to_types, __pyx_v_keyword); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 93, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_10 = __pyx_t_1;
        __pyx_t_1 = 0;
      } else {
+094:                         if not _is_iterable(self.keys_to_types[keyword]) \
      if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 94, __pyx_L1_error) }
      if (unlikely(__pyx_cur_scope->__pyx_v_self->keys_to_types == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 94, __pyx_L1_error)
      }
      __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_cur_scope->__pyx_v_self->keys_to_types, __pyx_v_keyword); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = ((PyObject *)__pyx_f_7zipline_9_protocol__is_iterable(__pyx_t_1)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 94, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely((__pyx_t_16 < 0))) __PYX_ERR(0, 94, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_7 = (!__pyx_t_16);
      if (__pyx_t_7) {
+095:                         else ', '.join([type_.__name__ for type_ in
        { /* enter inner scope */
          __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L32_error)
          __Pyx_GOTREF(__pyx_t_1);
/* … */
            __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr1__pyx_v_type_, __pyx_n_s_name); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 95, __pyx_L32_error)
            __Pyx_GOTREF(__pyx_t_11);
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 95, __pyx_L32_error)
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          }
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_type_); __pyx_8genexpr1__pyx_v_type_ = 0;
          goto __pyx_L36_exit_scope;
          __pyx_L32_error:;
          __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_type_); __pyx_8genexpr1__pyx_v_type_ = 0;
          goto __pyx_L1_error;
          __pyx_L36_exit_scope:;
        } /* exit inner scope */
        __pyx_t_15 = PyUnicode_Join(__pyx_kp_u__4, __pyx_t_1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 95, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_10 = __pyx_t_15;
        __pyx_t_15 = 0;
      }
      __Pyx_XDECREF_SET(__pyx_v_expected_type, __pyx_t_10);
      __pyx_t_10 = 0;
+096:                                         self.keys_to_types[keyword]])
          if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 96, __pyx_L32_error) }
          if (unlikely(__pyx_cur_scope->__pyx_v_self->keys_to_types == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 96, __pyx_L32_error)
          }
          __pyx_t_11 = __Pyx_PyDict_GetItem(__pyx_cur_scope->__pyx_v_self->keys_to_types, __pyx_v_keyword); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 96, __pyx_L32_error)
          __Pyx_GOTREF(__pyx_t_11);
          if (likely(PyList_CheckExact(__pyx_t_11)) || PyTuple_CheckExact(__pyx_t_11)) {
            __pyx_t_15 = __pyx_t_11; __Pyx_INCREF(__pyx_t_15);
            __pyx_t_8 = 0;
            __pyx_t_14 = NULL;
          } else {
            __pyx_t_8 = -1; __pyx_t_15 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 96, __pyx_L32_error)
            __Pyx_GOTREF(__pyx_t_15);
            __pyx_t_14 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_15); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 96, __pyx_L32_error)
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          for (;;) {
            if (likely(!__pyx_t_14)) {
              if (likely(PyList_CheckExact(__pyx_t_15))) {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_15);
                  #if !CYTHON_ASSUME_SAFE_MACROS
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 96, __pyx_L32_error)
                  #endif
                  if (__pyx_t_8 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_11 = PyList_GET_ITEM(__pyx_t_15, __pyx_t_8); __Pyx_INCREF(__pyx_t_11); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 96, __pyx_L32_error)
                #else
                __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_15, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 96, __pyx_L32_error)
                __Pyx_GOTREF(__pyx_t_11);
                #endif
              } else {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_15);
                  #if !CYTHON_ASSUME_SAFE_MACROS
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 96, __pyx_L32_error)
                  #endif
                  if (__pyx_t_8 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_15, __pyx_t_8); __Pyx_INCREF(__pyx_t_11); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 96, __pyx_L32_error)
                #else
                __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_15, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 96, __pyx_L32_error)
                __Pyx_GOTREF(__pyx_t_11);
                #endif
              }
            } else {
              __pyx_t_11 = __pyx_t_14(__pyx_t_15);
              if (unlikely(!__pyx_t_11)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                  else __PYX_ERR(0, 96, __pyx_L32_error)
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_11);
            }
            __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_type_, __pyx_t_11);
            __pyx_t_11 = 0;
 097: 
+098:                     raise TypeError("Expected %s argument to be of type %s%s" %
      __pyx_t_10 = PyTuple_New(5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 98, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_8 = 0;
      __pyx_t_9 = 127;
      __Pyx_INCREF(__pyx_kp_u_Expected);
      __pyx_t_8 += 9;
      __Pyx_GIVEREF(__pyx_kp_u_Expected);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_u_Expected);
/* … */
      __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_10, 5, __pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 98, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_10, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __PYX_ERR(0, 98, __pyx_L1_error)
+099:                                     (keyword,
      __pyx_t_15 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_v_keyword), __pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 99, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) : __pyx_t_9;
      __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_15);
      __pyx_t_15 = 0;
      __Pyx_INCREF(__pyx_kp_u_argument_to_be_of_type);
      __pyx_t_8 += 24;
      __Pyx_GIVEREF(__pyx_kp_u_argument_to_be_of_type);
      PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u_argument_to_be_of_type);
+100:                                      'or iterable of type ' if keyword in
      __Pyx_INCREF(__pyx_v_keyword);
      __pyx_t_1 = __pyx_v_keyword;
      __pyx_t_16 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_assets, Py_EQ)); if (unlikely((__pyx_t_16 < 0))) __PYX_ERR(0, 100, __pyx_L1_error)
      if (!__pyx_t_16) {
      } else {
        __pyx_t_7 = __pyx_t_16;
        goto __pyx_L37_bool_binop_done;
      }
      __pyx_t_16 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_fields, Py_EQ)); if (unlikely((__pyx_t_16 < 0))) __PYX_ERR(0, 100, __pyx_L1_error)
      __pyx_t_7 = __pyx_t_16;
      __pyx_L37_bool_binop_done:;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_16 = __pyx_t_7;
      if (__pyx_t_16) {
        __Pyx_INCREF(__pyx_kp_u_or_iterable_of_type);
        __pyx_t_15 = __pyx_kp_u_or_iterable_of_type;
      } else {
        __Pyx_INCREF(__pyx_kp_u__5);
        __pyx_t_15 = __pyx_kp_u__5;
      }
      __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_t_15); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_9;
      __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_1);
      __pyx_t_1 = 0;
 101:                                                                ('assets', 'fields') else '',
+102:                                      expected_type)
      __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_v_expected_type), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_9;
      __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_t_1);
      __pyx_t_1 = 0;
 103:                                     )
 104: 
+105:             return func(*args, **kwargs)
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_v_func)) { __Pyx_RaiseClosureNameError("func"); __PYX_ERR(0, 105, __pyx_L1_error) }
  __pyx_t_5 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_10 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_v_func, __pyx_v_args, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 105, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_r = __pyx_t_10;
  __pyx_t_10 = 0;
  goto __pyx_L0;
 106: 
+107:         return assert_keywords_and_call
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_assert_keywords_and_call);
  __pyx_r = __pyx_v_assert_keywords_and_call;
  goto __pyx_L0;
 108: 
+109: @contextmanager
/* Python wrapper */
static PyObject *__pyx_pw_7zipline_9_protocol_1handle_non_market_minutes(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_9_protocol_1handle_non_market_minutes = {"handle_non_market_minutes", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_9_protocol_1handle_non_market_minutes, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_7zipline_9_protocol_1handle_non_market_minutes(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_bar_data = 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("handle_non_market_minutes (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_bar_data,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_bar_data)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 109, __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, "handle_non_market_minutes") < 0)) __PYX_ERR(0, 109, __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_bar_data = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("handle_non_market_minutes", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 109, __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._protocol.handle_non_market_minutes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7zipline_9_protocol_handle_non_market_minutes(__pyx_self, __pyx_v_bar_data);
  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_9_protocol_handle_non_market_minutes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_bar_data) {
  struct __pyx_obj_7zipline_9_protocol___pyx_scope_struct_1_handle_non_market_minutes *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __pyx_cur_scope = (struct __pyx_obj_7zipline_9_protocol___pyx_scope_struct_1_handle_non_market_minutes *)__pyx_tp_new_7zipline_9_protocol___pyx_scope_struct_1_handle_non_market_minutes(__pyx_ptype_7zipline_9_protocol___pyx_scope_struct_1_handle_non_market_minutes, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_7zipline_9_protocol___pyx_scope_struct_1_handle_non_market_minutes *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 109, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_bar_data = __pyx_v_bar_data;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_bar_data);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_bar_data);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_7zipline_9_protocol_2generator, __pyx_codeobj__10, (PyObject *) __pyx_cur_scope, __pyx_n_s_handle_non_market_minutes, __pyx_n_s_handle_non_market_minutes, __pyx_n_s_zipline__protocol); if (unlikely(!gen)) __PYX_ERR(0, 109, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("zipline._protocol.handle_non_market_minutes", __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_9_protocol_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_non_market_minutes", 0);
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__10)
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 109, __pyx_L1_error)
/* … */
  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_Generator_Replace_StopIteration(0);
  __Pyx_AddTraceback("handle_non_market_minutes", __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_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_contextmanager); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
/* … */
  __pyx_tuple__32 = PyTuple_Pack(1, __pyx_n_s_bar_data); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_9_protocol_1handle_non_market_minutes, 0, __pyx_n_s_handle_non_market_minutes, NULL, __pyx_n_s_zipline__protocol, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 109, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_handle_non_market_minutes, __pyx_t_4) < 0) __PYX_ERR(0, 109, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline__protocol_pyx, __pyx_n_s_handle_non_market_minutes, 109, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 109, __pyx_L1_error)
/* … */
struct __pyx_obj_7zipline_9_protocol___pyx_scope_struct_1_handle_non_market_minutes {
  PyObject_HEAD
  PyObject *__pyx_v_bar_data;
};


 110: def handle_non_market_minutes(bar_data):
+111:     try:
  /*try:*/ {
+112:         bar_data._handle_non_market_minutes = True
    if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_bar_data, __pyx_n_s_handle_non_market_minutes_2, Py_True) < 0) __PYX_ERR(0, 112, __pyx_L5_error)
+113:         yield
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    __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_L7_resume_from_yield:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 113, __pyx_L5_error)
  }
 114:     finally:
+115:         bar_data._handle_non_market_minutes = False
  /*finally:*/ {
    /*normal exit:*/{
      if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_bar_data, __pyx_n_s_handle_non_market_minutes_2, Py_False) < 0) __PYX_ERR(0, 115, __pyx_L1_error)
      goto __pyx_L6;
    }
    __pyx_L5_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_assign
      __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0)) __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __pyx_t_1 = __pyx_lineno; __pyx_t_2 = __pyx_clineno; __pyx_t_3 = __pyx_filename;
      {
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_bar_data, __pyx_n_s_handle_non_market_minutes_2, Py_False) < 0) __PYX_ERR(0, 115, __pyx_L9_error)
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      }
      __Pyx_XGIVEREF(__pyx_t_4);
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_ErrRestore(__pyx_t_4, __pyx_t_5, __pyx_t_6);
      __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0;
      __pyx_lineno = __pyx_t_1; __pyx_clineno = __pyx_t_2; __pyx_filename = __pyx_t_3;
      goto __pyx_L1_error;
      __pyx_L9_error:;
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      }
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L6:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
 116: 
+117: cdef class BarData:
struct __pyx_obj_7zipline_9_protocol_BarData {
  PyObject_HEAD
  struct __pyx_vtabstruct_7zipline_9_protocol_BarData *__pyx_vtab;
  PyObject *data_portal;
  PyObject *simulation_dt_func;
  PyObject *data_frequency;
  PyObject *restrictions;
  PyObject *_views;
  PyBoolObject *_daily_mode;
  PyObject *_trading_calendar;
  PyObject *_is_restricted;
  PyBoolObject *_adjust_minutes;
};
/* … */
struct __pyx_vtabstruct_7zipline_9_protocol_BarData {
  PyObject *(*_get_current_minute)(struct __pyx_obj_7zipline_9_protocol_BarData *);
  PyBoolObject *(*_can_trade_for_asset)(struct __pyx_obj_7zipline_9_protocol_BarData *, PyObject *, PyObject *, PyObject *, PyObject *);
  PyBoolObject *(*_is_stale_for_asset)(struct __pyx_obj_7zipline_9_protocol_BarData *, PyObject *, PyObject *, PyObject *, PyObject *);
};
static struct __pyx_vtabstruct_7zipline_9_protocol_BarData *__pyx_vtabptr_7zipline_9_protocol_BarData;
 118:     """
 119:     Provides methods for accessing minutely and daily price/volume data from
 120:     Algorithm API functions.
 121: 
 122:     Also provides utility methods to determine if an asset is alive, and if it
 123:     has recent trade data.
 124: 
 125:     An instance of this object is passed as ``data`` to
 126:     :func:`~zipline.api.handle_data` and
 127:     :func:`~zipline.api.before_trading_start`.
 128: 
 129:     Parameters
 130:     ----------
 131:     data_portal : DataPortal
 132:         Provider for bar pricing data.
 133:     simulation_dt_func : callable
 134:         Function which returns the current simulation time.
 135:         This is usually bound to a method of TradingSimulation.
 136:     data_frequency : {'minute', 'daily'}
 137:         The frequency of the bar data; i.e. whether the data is
 138:         daily or minute bars
 139:     restrictions : zipline.finance.asset_restrictions.Restrictions
 140:         Object that combines and returns restricted list information from
 141:         multiple sources
 142:     """
 143:     cdef object data_portal
 144:     cdef object simulation_dt_func
 145:     cdef object data_frequency
 146:     cdef object restrictions
 147:     cdef dict _views
 148:     cdef bool _daily_mode
 149:     cdef object _trading_calendar
 150:     cdef object _is_restricted
 151: 
 152:     cdef bool _adjust_minutes
 153: 
+154:     def __init__(self, data_portal, simulation_dt_func, data_frequency,
/* Python wrapper */
static int __pyx_pw_7zipline_9_protocol_7BarData_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_7zipline_9_protocol_7BarData_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_data_portal = 0;
  PyObject *__pyx_v_simulation_dt_func = 0;
  PyObject *__pyx_v_data_frequency = 0;
  PyObject *__pyx_v_trading_calendar = 0;
  PyObject *__pyx_v_restrictions = 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_data_portal,&__pyx_n_s_simulation_dt_func,&__pyx_n_s_data_frequency,&__pyx_n_s_trading_calendar,&__pyx_n_s_restrictions,0};
  PyObject* values[5] = {0,0,0,0,0};
    if (__pyx_kwds) {
      Py_ssize_t kw_args;
      switch (__pyx_nargs) {
        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_data_portal)) != 0)) {
          (void)__Pyx_Arg_NewRef_VARARGS(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 154, __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_simulation_dt_func)) != 0)) {
          (void)__Pyx_Arg_NewRef_VARARGS(values[1]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 154, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); __PYX_ERR(0, 154, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data_frequency)) != 0)) {
          (void)__Pyx_Arg_NewRef_VARARGS(values[2]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 154, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); __PYX_ERR(0, 154, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_trading_calendar)) != 0)) {
          (void)__Pyx_Arg_NewRef_VARARGS(values[3]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 154, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); __PYX_ERR(0, 154, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_restrictions)) != 0)) {
          (void)__Pyx_Arg_NewRef_VARARGS(values[4]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 154, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); __PYX_ERR(0, 154, __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, 154, __pyx_L3_error)
      }
    } else if (unlikely(__pyx_nargs != 5)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0);
      values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1);
      values[2] = __Pyx_Arg_VARARGS(__pyx_args, 2);
      values[3] = __Pyx_Arg_VARARGS(__pyx_args, 3);
      values[4] = __Pyx_Arg_VARARGS(__pyx_args, 4);
    }
    __pyx_v_data_portal = values[0];
    __pyx_v_simulation_dt_func = values[1];
    __pyx_v_data_frequency = values[2];
    __pyx_v_trading_calendar = values[3];
    __pyx_v_restrictions = values[4];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, __pyx_nargs); __PYX_ERR(0, 154, __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._protocol.BarData.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7zipline_9_protocol_7BarData___init__(((struct __pyx_obj_7zipline_9_protocol_BarData *)__pyx_v_self), __pyx_v_data_portal, __pyx_v_simulation_dt_func, __pyx_v_data_frequency, __pyx_v_trading_calendar, __pyx_v_restrictions);
  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_9_protocol_7BarData___init__(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self, PyObject *__pyx_v_data_portal, PyObject *__pyx_v_simulation_dt_func, PyObject *__pyx_v_data_frequency, PyObject *__pyx_v_trading_calendar, PyObject *__pyx_v_restrictions) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("__init__", __pyx_f[0], 154, 0, __PYX_ERR(0, 154, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("zipline._protocol.BarData.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 155:                  trading_calendar, restrictions):
+156:         self.data_portal = data_portal
  __Pyx_INCREF(__pyx_v_data_portal);
  __Pyx_GIVEREF(__pyx_v_data_portal);
  __Pyx_GOTREF(__pyx_v_self->data_portal);
  __Pyx_DECREF(__pyx_v_self->data_portal);
  __pyx_v_self->data_portal = __pyx_v_data_portal;
+157:         self.simulation_dt_func = simulation_dt_func
  __Pyx_INCREF(__pyx_v_simulation_dt_func);
  __Pyx_GIVEREF(__pyx_v_simulation_dt_func);
  __Pyx_GOTREF(__pyx_v_self->simulation_dt_func);
  __Pyx_DECREF(__pyx_v_self->simulation_dt_func);
  __pyx_v_self->simulation_dt_func = __pyx_v_simulation_dt_func;
+158:         self.data_frequency = data_frequency
  __Pyx_INCREF(__pyx_v_data_frequency);
  __Pyx_GIVEREF(__pyx_v_data_frequency);
  __Pyx_GOTREF(__pyx_v_self->data_frequency);
  __Pyx_DECREF(__pyx_v_self->data_frequency);
  __pyx_v_self->data_frequency = __pyx_v_data_frequency;
+159:         self._views = {}
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_views);
  __Pyx_DECREF(__pyx_v_self->_views);
  __pyx_v_self->_views = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 160: 
+161:         self._daily_mode = (self.data_frequency == "daily")
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_self->data_frequency, __pyx_n_u_daily, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error)
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(0, 161, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF((PyObject *)__pyx_v_self->_daily_mode);
  __Pyx_DECREF((PyObject *)__pyx_v_self->_daily_mode);
  __pyx_v_self->_daily_mode = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 162: 
+163:         self._adjust_minutes = False
  __Pyx_INCREF(Py_False);
  __Pyx_GIVEREF(Py_False);
  __Pyx_GOTREF((PyObject *)__pyx_v_self->_adjust_minutes);
  __Pyx_DECREF((PyObject *)__pyx_v_self->_adjust_minutes);
  __pyx_v_self->_adjust_minutes = ((PyBoolObject *)Py_False);
 164: 
+165:         self._trading_calendar = trading_calendar
  __Pyx_INCREF(__pyx_v_trading_calendar);
  __Pyx_GIVEREF(__pyx_v_trading_calendar);
  __Pyx_GOTREF(__pyx_v_self->_trading_calendar);
  __Pyx_DECREF(__pyx_v_self->_trading_calendar);
  __pyx_v_self->_trading_calendar = __pyx_v_trading_calendar;
+166:         self._is_restricted = restrictions.is_restricted
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_restrictions, __pyx_n_s_is_restricted); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_is_restricted);
  __Pyx_DECREF(__pyx_v_self->_is_restricted);
  __pyx_v_self->_is_restricted = __pyx_t_1;
  __pyx_t_1 = 0;
 167: 
+168:     cdef _get_current_minute(self):
static PyObject *__pyx_f_7zipline_9_protocol_7BarData__get_current_minute(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self) {
  PyObject *__pyx_v_dt = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("_get_current_minute", __pyx_f[0], 168, 0, __PYX_ERR(0, 168, __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_AddTraceback("zipline._protocol.BarData._get_current_minute", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dt);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 169:         """
 170:         Internal utility method to get the current simulation time.
 171: 
 172:         Possible answers are:
 173:         - whatever the algorithm's get_datetime() method returns (this is what
 174:             `self.simulation_dt_func()` points to)
 175:         - sometimes we're knowingly not in a market minute, like if we're in
 176:             before_trading_start.  In that case, `self._adjust_minutes` is
 177:             True, and we get the previous market minute.
 178:         - if we're in daily mode, get the session label for this minute.
 179:         """
+180:         dt = self.simulation_dt_func()
  __Pyx_INCREF(__pyx_v_self->simulation_dt_func);
  __pyx_t_2 = __pyx_v_self->simulation_dt_func; __pyx_t_3 = NULL;
  __pyx_t_4 = 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_4 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_v_dt = __pyx_t_1;
  __pyx_t_1 = 0;
 181: 
+182:         if self._adjust_minutes:
  __pyx_t_5 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->_adjust_minutes)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 182, __pyx_L1_error)
  if (__pyx_t_5) {
/* … */
  }
 183:             dt = \
+184:                 self.data_portal.trading_calendar.previous_minute(dt)
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_trading_calendar); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_previous_minute); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    __pyx_t_4 = 0;
    #if CYTHON_UNPACK_METHODS
    if (likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_4 = 1;
      }
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_dt};
      __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF_SET(__pyx_v_dt, __pyx_t_1);
    __pyx_t_1 = 0;
 185: 
+186:         if self._daily_mode:
  __pyx_t_5 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->_daily_mode)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 186, __pyx_L1_error)
  if (__pyx_t_5) {
/* … */
  }
 187:             # if we're in daily mode, take the given dt (which is the last
 188:             # minute of the session) and get the session label for it.
+189:             dt = self.data_portal.trading_calendar.minute_to_session_label(dt)
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_trading_calendar); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 189, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_minute_to_session_label); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    __pyx_t_4 = 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_4 = 1;
      }
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_dt};
      __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, 189, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF_SET(__pyx_v_dt, __pyx_t_1);
    __pyx_t_1 = 0;
 190: 
+191:         return dt
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_dt);
  __pyx_r = __pyx_v_dt;
  goto __pyx_L0;
 192: 
+193:     @check_parameters(('assets', 'fields'),
/* Python wrapper */
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_3current(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_9_protocol_7BarData_2current, "\n        Returns the \"current\" value of the given fields for the given assets\n        at the current simulation time.\n\n        Parameters\n        ----------\n        assets : zipline.assets.Asset or iterable of zipline.assets.Asset\n            The asset(s) for which data is requested.\n        fields : str or iterable[str].\n            Requested data field(s). Valid field names are: \"price\",\n            \"open_price\", \"high_price\", \"low_price\", \"last_traded\",\n            \"open\", \"high\", \"low\", \"close\", and \"volume\".\n\n        Returns\n        -------\n        current_value : Scalar, pandas Series, or pandas DataFrame.\n            See notes below.\n\n        Notes\n        -----\n        The return type of this function depends on the types of its inputs:\n\n        - If a single asset and a single field are requested, the returned\n          value is a scalar (either a float or a ``pd.Timestamp`` depending on\n          the field).\n\n        - If a single asset and a list of fields are requested, the returned\n          value is a :class:`pd.Series` whose indices are the requested fields.\n\n        - If a list of assets and a single field are requested, the returned\n          value is a :class:`pd.Series` whose indices are the assets.\n\n        - If a list of assets and a list of fields are requested, the returned\n          value is a :class:`pd.DataFrame`.  The columns of the returned frame\n          will be the requested fields, and the index of the frame will be the\n          requested assets.\n\n        The values produced for ``fields`` are as follows:\n\n        - Requesting \"price\"/\"open_price\"/\"high_price\"/\"low_price\"\n          produces the last known \"close\"/\"open\"/\"high\"/\"low\" for the asset,\n          forward-filled from an earlier minute if there is no trade this\n          minute. If there is no last known value (either because the asset\n          has never traded, or because it has delisted) NaN ""is returned. If a\n          value is found, and we had to cross an adjustment boundary (split,\n          dividend, etc) to get it, the value is adjusted to the current\n          simulation time before being returned.\n\n        - Requesting \"open\", \"high\", \"low\", or \"close\" produces the open, high,\n          low, or close for the current minute. If no trades occurred this\n          minute, ``NaN`` is returned.\n\n        - Requesting \"volume\" produces the trade volume for the current\n          minute. If no trades occurred this minute, 0 is returned.\n\n        - Requesting \"last_traded\" produces the datetime of the last minute in\n          which the asset traded, even if the asset has stopped trading. If\n          there is no last known value, ``pd.NaT`` is returned.\n\n        If the current simulation time is not a valid market time for an asset,\n        we use the most recent market close instead.\n        ");
static PyMethodDef __pyx_mdef_7zipline_9_protocol_7BarData_3current = {"current", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_9_protocol_7BarData_3current, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7zipline_9_protocol_7BarData_2current};
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_3current(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_assets = 0;
  PyObject *__pyx_v_fields = 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("current (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_assets,&__pyx_n_s_fields,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_assets)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 193, __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_fields)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 193, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("current", 1, 2, 2, 1); __PYX_ERR(0, 193, __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, "current") < 0)) __PYX_ERR(0, 193, __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_assets = values[0];
    __pyx_v_fields = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("current", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 193, __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._protocol.BarData.current", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7zipline_9_protocol_7BarData_2current(((struct __pyx_obj_7zipline_9_protocol_BarData *)__pyx_v_self), __pyx_v_assets, __pyx_v_fields);
  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_9_protocol_7BarData_2current(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self, PyObject *__pyx_v_assets, PyObject *__pyx_v_fields) {
  PyBoolObject *__pyx_v_multiple_assets = NULL;
  PyBoolObject *__pyx_v_multiple_fields = NULL;
  PyObject *__pyx_v_asset = NULL;
  PyObject *__pyx_v_field = NULL;
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_v_series = NULL;
  PyObject *__pyx_8genexpr2__pyx_v_field = NULL;
  PyObject *__pyx_8genexpr3__pyx_v_field = NULL;
  PyObject *__pyx_8genexpr4__pyx_v_asset = NULL;
  PyObject *__pyx_8genexpr5__pyx_v_asset = NULL;
  PyObject *__pyx_8genexpr6__pyx_v_asset = NULL;
  PyObject *__pyx_8genexpr7__pyx_v_asset = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__11)
  __Pyx_TraceCall("current", __pyx_f[0], 193, 0, __PYX_ERR(0, 193, __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_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_AddTraceback("zipline._protocol.BarData.current", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_multiple_assets);
  __Pyx_XDECREF((PyObject *)__pyx_v_multiple_fields);
  __Pyx_XDECREF(__pyx_v_asset);
  __Pyx_XDECREF(__pyx_v_field);
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF(__pyx_v_series);
  __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_field);
  __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_field);
  __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_asset);
  __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_asset);
  __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_asset);
  __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_asset);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__33 = PyTuple_Pack(15, __pyx_n_s_self, __pyx_n_s_assets, __pyx_n_s_fields, __pyx_n_s_multiple_assets, __pyx_n_s_multiple_fields, __pyx_n_s_asset, __pyx_n_s_field, __pyx_n_s_data, __pyx_n_s_series, __pyx_n_s_field, __pyx_n_s_field, __pyx_n_s_asset, __pyx_n_s_asset, __pyx_n_s_asset, __pyx_n_s_asset); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_9_protocol_7BarData_3current, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_BarData_current, NULL, __pyx_n_s_zipline__protocol, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_current, __pyx_t_4) < 0) __PYX_ERR(0, 193, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_7zipline_9_protocol_BarData);
  __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline__protocol_pyx, __pyx_n_s_current, 193, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 193, __pyx_L1_error)
/* … */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_tuple__34)) __PYX_ERR(0, 193, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_5);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5)) __PYX_ERR(0, 193, __pyx_L1_error);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7zipline_9_protocol_check_parameters), __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GetNameInClass(__pyx_t_2, (PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_current); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_6 = 0;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_6 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_2};
    __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 193, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_current, __pyx_t_4) < 0) __PYX_ERR(0, 193, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_7zipline_9_protocol_BarData);
  __pyx_tuple__34 = PyTuple_Pack(2, __pyx_n_u_assets, __pyx_n_u_fields); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);
+194:                       ((Asset, ContinuousFuture, str), (str,)))
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ContinuousFuture); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 194, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF((PyObject *)__pyx_ptype_7zipline_6assets_7_assets_Asset);
  __Pyx_GIVEREF((PyObject *)__pyx_ptype_7zipline_6assets_7_assets_Asset);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_ptype_7zipline_6assets_7_assets_Asset))) __PYX_ERR(0, 194, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_2);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error);
  __Pyx_INCREF((PyObject *)(&PyUnicode_Type));
  __Pyx_GIVEREF((PyObject *)(&PyUnicode_Type));
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)(&PyUnicode_Type)))) __PYX_ERR(0, 194, __pyx_L1_error);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF((PyObject *)(&PyUnicode_Type));
  __Pyx_GIVEREF((PyObject *)(&PyUnicode_Type));
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyUnicode_Type)))) __PYX_ERR(0, 194, __pyx_L1_error);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 194, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3)) __PYX_ERR(0, 194, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_2);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
 195:     def current(self, assets, fields):
 196:         """
 197:         Returns the "current" value of the given fields for the given assets
 198:         at the current simulation time.
 199: 
 200:         Parameters
 201:         ----------
 202:         assets : zipline.assets.Asset or iterable of zipline.assets.Asset
 203:             The asset(s) for which data is requested.
 204:         fields : str or iterable[str].
 205:             Requested data field(s). Valid field names are: "price",
 206:             "open_price", "high_price", "low_price", "last_traded",
 207:             "open", "high", "low", "close", and "volume".
 208: 
 209:         Returns
 210:         -------
 211:         current_value : Scalar, pandas Series, or pandas DataFrame.
 212:             See notes below.
 213: 
 214:         Notes
 215:         -----
 216:         The return type of this function depends on the types of its inputs:
 217: 
 218:         - If a single asset and a single field are requested, the returned
 219:           value is a scalar (either a float or a ``pd.Timestamp`` depending on
 220:           the field).
 221: 
 222:         - If a single asset and a list of fields are requested, the returned
 223:           value is a :class:`pd.Series` whose indices are the requested fields.
 224: 
 225:         - If a list of assets and a single field are requested, the returned
 226:           value is a :class:`pd.Series` whose indices are the assets.
 227: 
 228:         - If a list of assets and a list of fields are requested, the returned
 229:           value is a :class:`pd.DataFrame`.  The columns of the returned frame
 230:           will be the requested fields, and the index of the frame will be the
 231:           requested assets.
 232: 
 233:         The values produced for ``fields`` are as follows:
 234: 
 235:         - Requesting "price"/"open_price"/"high_price"/"low_price"
 236:           produces the last known "close"/"open"/"high"/"low" for the asset,
 237:           forward-filled from an earlier minute if there is no trade this
 238:           minute. If there is no last known value (either because the asset
 239:           has never traded, or because it has delisted) NaN is returned. If a
 240:           value is found, and we had to cross an adjustment boundary (split,
 241:           dividend, etc) to get it, the value is adjusted to the current
 242:           simulation time before being returned.
 243: 
 244:         - Requesting "open", "high", "low", or "close" produces the open, high,
 245:           low, or close for the current minute. If no trades occurred this
 246:           minute, ``NaN`` is returned.
 247: 
 248:         - Requesting "volume" produces the trade volume for the current
 249:           minute. If no trades occurred this minute, 0 is returned.
 250: 
 251:         - Requesting "last_traded" produces the datetime of the last minute in
 252:           which the asset traded, even if the asset has stopped trading. If
 253:           there is no last known value, ``pd.NaT`` is returned.
 254: 
 255:         If the current simulation time is not a valid market time for an asset,
 256:         we use the most recent market close instead.
 257:         """
+258:         multiple_assets = _is_iterable(assets)
  __pyx_t_1 = ((PyObject *)__pyx_f_7zipline_9_protocol__is_iterable(__pyx_v_assets)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 258, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_multiple_assets = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
+259:         multiple_fields = _is_iterable(fields)
  __pyx_t_1 = ((PyObject *)__pyx_f_7zipline_9_protocol__is_iterable(__pyx_v_fields)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 259, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_multiple_fields = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 260: 
 261:         # There's some overly verbose code in here, particularly around
 262:         # 'do something if self._adjust_minutes is False, otherwise do
 263:         # something else'. This could be less verbose, but the 99% case is that
 264:         # `self._adjust_minutes` is False, so it's important to keep that code
 265:         # path as fast as possible.
 266: 
 267:         # There's probably a way to make this method (and `history`) less
 268:         # verbose, but this is OK for now.
 269: 
+270:         if not multiple_assets:
  __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_multiple_assets)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 270, __pyx_L1_error)
  __pyx_t_3 = (!__pyx_t_2);
  if (__pyx_t_3) {
/* … */
  }
+271:             asset = assets
    __Pyx_INCREF(__pyx_v_assets);
    __pyx_v_asset = __pyx_v_assets;
 272: 
+273:             if not multiple_fields:
    __pyx_t_3 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_multiple_fields)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 273, __pyx_L1_error)
    __pyx_t_2 = (!__pyx_t_3);
    if (__pyx_t_2) {
/* … */
    }
+274:                 field = fields
      __Pyx_INCREF(__pyx_v_fields);
      __pyx_v_field = __pyx_v_fields;
 275: 
 276:                 # return scalar value
+277:                 if not self._adjust_minutes:
      __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->_adjust_minutes)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 277, __pyx_L1_error)
      __pyx_t_3 = (!__pyx_t_2);
      if (__pyx_t_3) {
/* … */
      }
+278:                     return self.data_portal.get_spot_value(
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_get_spot_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
 279:                         asset,
 280:                         field,
+281:                         self._get_current_minute(),
        __pyx_t_5 = ((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_get_current_minute(__pyx_v_self); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 281, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
+282:                         self.data_frequency
        __pyx_t_6 = NULL;
        __pyx_t_7 = 0;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_6)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
            __pyx_t_7 = 1;
          }
        }
        #endif
        {
          PyObject *__pyx_callargs[5] = {__pyx_t_6, __pyx_v_asset, __pyx_v_field, __pyx_t_5, __pyx_v_self->data_frequency};
          __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 4+__pyx_t_7);
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
        __pyx_r = __pyx_t_1;
        __pyx_t_1 = 0;
        goto __pyx_L0;
 283:                     )
 284:                 else:
+285:                     return self.data_portal.get_adjusted_value(
      /*else*/ {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_get_adjusted_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 285, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
 286:                         asset,
 287:                         field,
+288:                         self._get_current_minute(),
        __pyx_t_5 = ((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_get_current_minute(__pyx_v_self); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 288, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
+289:                         self.simulation_dt_func(),
        __Pyx_INCREF(__pyx_v_self->simulation_dt_func);
        __pyx_t_8 = __pyx_v_self->simulation_dt_func; __pyx_t_9 = NULL;
        __pyx_t_7 = 0;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_9)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_9);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
            __pyx_t_7 = 1;
          }
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL};
          __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7);
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 289, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
+290:                         self.data_frequency
        __pyx_t_8 = NULL;
        __pyx_t_7 = 0;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
            __pyx_t_7 = 1;
          }
        }
        #endif
        {
          PyObject *__pyx_callargs[6] = {__pyx_t_8, __pyx_v_asset, __pyx_v_field, __pyx_t_5, __pyx_t_6, __pyx_v_self->data_frequency};
          __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 5+__pyx_t_7);
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
        __pyx_r = __pyx_t_1;
        __pyx_t_1 = 0;
        goto __pyx_L0;
      }
 291:                     )
 292:             else:
 293:                 # assume fields is iterable
 294:                 # return a Series indexed by field
+295:                 if not self._adjust_minutes:
    /*else*/ {
      __pyx_t_3 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->_adjust_minutes)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 295, __pyx_L1_error)
      __pyx_t_2 = (!__pyx_t_3);
      if (__pyx_t_2) {
/* … */
      }
+296:                     return pd.Series(data={
        __Pyx_XDECREF(__pyx_r);
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Series); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 296, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        { /* enter inner scope */
          __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 296, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_6);
/* … */
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 296, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_r = __pyx_t_6;
        __pyx_t_6 = 0;
        goto __pyx_L0;
+297:                         field: self.data_portal.get_spot_value(
            __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_get_spot_value); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 297, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_9);
 298:                             asset,
 299:                             field,
+300:                             self._get_current_minute(),
            __pyx_t_12 = ((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_get_current_minute(__pyx_v_self); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 300, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_12);
+301:                             self.data_frequency
            __pyx_t_13 = NULL;
            __pyx_t_7 = 0;
            #if CYTHON_UNPACK_METHODS
            if (likely(PyMethod_Check(__pyx_t_9))) {
              __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_9);
              if (likely(__pyx_t_13)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
                __Pyx_INCREF(__pyx_t_13);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_9, function);
                __pyx_t_7 = 1;
              }
            }
            #endif
            {
              PyObject *__pyx_callargs[5] = {__pyx_t_13, __pyx_v_asset, __pyx_8genexpr2__pyx_v_field, __pyx_t_12, __pyx_v_self->data_frequency};
              __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_7, 4+__pyx_t_7);
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 297, __pyx_L9_error)
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            }
            if (unlikely(PyDict_SetItem(__pyx_t_6, (PyObject*)__pyx_8genexpr2__pyx_v_field, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 297, __pyx_L9_error)
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 302:                         )
+303:                         for field in fields
          if (likely(PyList_CheckExact(__pyx_v_fields)) || PyTuple_CheckExact(__pyx_v_fields)) {
            __pyx_t_5 = __pyx_v_fields; __Pyx_INCREF(__pyx_t_5);
            __pyx_t_10 = 0;
            __pyx_t_11 = NULL;
          } else {
            __pyx_t_10 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_fields); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 303, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 303, __pyx_L9_error)
          }
          for (;;) {
            if (likely(!__pyx_t_11)) {
              if (likely(PyList_CheckExact(__pyx_t_5))) {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5);
                  #if !CYTHON_ASSUME_SAFE_MACROS
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 303, __pyx_L9_error)
                  #endif
                  if (__pyx_t_10 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_8 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 303, __pyx_L9_error)
                #else
                __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 303, __pyx_L9_error)
                __Pyx_GOTREF(__pyx_t_8);
                #endif
              } else {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5);
                  #if !CYTHON_ASSUME_SAFE_MACROS
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 303, __pyx_L9_error)
                  #endif
                  if (__pyx_t_10 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 303, __pyx_L9_error)
                #else
                __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 303, __pyx_L9_error)
                __Pyx_GOTREF(__pyx_t_8);
                #endif
              }
            } else {
              __pyx_t_8 = __pyx_t_11(__pyx_t_5);
              if (unlikely(!__pyx_t_8)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                  else __PYX_ERR(0, 303, __pyx_L9_error)
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_8);
            }
            __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_field, __pyx_t_8);
            __pyx_t_8 = 0;
/* … */
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_field); __pyx_8genexpr2__pyx_v_field = 0;
          goto __pyx_L13_exit_scope;
          __pyx_L9_error:;
          __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_field); __pyx_8genexpr2__pyx_v_field = 0;
          goto __pyx_L1_error;
          __pyx_L13_exit_scope:;
        } /* exit inner scope */
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_data, __pyx_t_6) < 0) __PYX_ERR(0, 296, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+304:                     }, index=fields, name=assets.symbol)
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index, __pyx_v_fields) < 0) __PYX_ERR(0, 296, __pyx_L1_error)
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_assets, __pyx_n_s_symbol); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 304, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name_2, __pyx_t_6) < 0) __PYX_ERR(0, 296, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 305:                 else:
+306:                     return pd.Series(data={
      /*else*/ {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pd); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 306, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_Series); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 306, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        { /* enter inner scope */
          __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 306, __pyx_L16_error)
          __Pyx_GOTREF(__pyx_t_4);
/* … */
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 306, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_r = __pyx_t_4;
        __pyx_t_4 = 0;
        goto __pyx_L0;
      }
    }
+307:                         field: self.data_portal.get_adjusted_value(
            __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_get_adjusted_value); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 307, __pyx_L16_error)
            __Pyx_GOTREF(__pyx_t_9);
 308:                             asset,
 309:                             field,
+310:                             self._get_current_minute(),
            __pyx_t_12 = ((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_get_current_minute(__pyx_v_self); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 310, __pyx_L16_error)
            __Pyx_GOTREF(__pyx_t_12);
+311:                             self.simulation_dt_func(),
            __Pyx_INCREF(__pyx_v_self->simulation_dt_func);
            __pyx_t_14 = __pyx_v_self->simulation_dt_func; __pyx_t_15 = NULL;
            __pyx_t_7 = 0;
            #if CYTHON_UNPACK_METHODS
            if (likely(PyMethod_Check(__pyx_t_14))) {
              __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
              if (likely(__pyx_t_15)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
                __Pyx_INCREF(__pyx_t_15);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_14, function);
                __pyx_t_7 = 1;
              }
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
              __pyx_t_13 = __Pyx_PyObject_FastCall(__pyx_t_14, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7);
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 311, __pyx_L16_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            }
+312:                             self.data_frequency
            __pyx_t_14 = NULL;
            __pyx_t_7 = 0;
            #if CYTHON_UNPACK_METHODS
            if (likely(PyMethod_Check(__pyx_t_9))) {
              __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_9);
              if (likely(__pyx_t_14)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
                __Pyx_INCREF(__pyx_t_14);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_9, function);
                __pyx_t_7 = 1;
              }
            }
            #endif
            {
              PyObject *__pyx_callargs[6] = {__pyx_t_14, __pyx_v_asset, __pyx_8genexpr3__pyx_v_field, __pyx_t_12, __pyx_t_13, __pyx_v_self->data_frequency};
              __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_7, 5+__pyx_t_7);
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 307, __pyx_L16_error)
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            }
            if (unlikely(PyDict_SetItem(__pyx_t_4, (PyObject*)__pyx_8genexpr3__pyx_v_field, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 307, __pyx_L16_error)
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 313:                         )
+314:                         for field in fields
          if (likely(PyList_CheckExact(__pyx_v_fields)) || PyTuple_CheckExact(__pyx_v_fields)) {
            __pyx_t_5 = __pyx_v_fields; __Pyx_INCREF(__pyx_t_5);
            __pyx_t_10 = 0;
            __pyx_t_11 = NULL;
          } else {
            __pyx_t_10 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_fields); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 314, __pyx_L16_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 314, __pyx_L16_error)
          }
          for (;;) {
            if (likely(!__pyx_t_11)) {
              if (likely(PyList_CheckExact(__pyx_t_5))) {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5);
                  #if !CYTHON_ASSUME_SAFE_MACROS
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 314, __pyx_L16_error)
                  #endif
                  if (__pyx_t_10 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_8 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 314, __pyx_L16_error)
                #else
                __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 314, __pyx_L16_error)
                __Pyx_GOTREF(__pyx_t_8);
                #endif
              } else {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5);
                  #if !CYTHON_ASSUME_SAFE_MACROS
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 314, __pyx_L16_error)
                  #endif
                  if (__pyx_t_10 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 314, __pyx_L16_error)
                #else
                __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 314, __pyx_L16_error)
                __Pyx_GOTREF(__pyx_t_8);
                #endif
              }
            } else {
              __pyx_t_8 = __pyx_t_11(__pyx_t_5);
              if (unlikely(!__pyx_t_8)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                  else __PYX_ERR(0, 314, __pyx_L16_error)
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_8);
            }
            __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_field, __pyx_t_8);
            __pyx_t_8 = 0;
/* … */
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_field); __pyx_8genexpr3__pyx_v_field = 0;
          goto __pyx_L20_exit_scope;
          __pyx_L16_error:;
          __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_field); __pyx_8genexpr3__pyx_v_field = 0;
          goto __pyx_L1_error;
          __pyx_L20_exit_scope:;
        } /* exit inner scope */
        if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_data, __pyx_t_4) < 0) __PYX_ERR(0, 306, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+315:                     }, index=fields, name=assets.symbol)
        if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_index, __pyx_v_fields) < 0) __PYX_ERR(0, 306, __pyx_L1_error)
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_assets, __pyx_n_s_symbol); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 315, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_name_2, __pyx_t_4) < 0) __PYX_ERR(0, 306, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 316:         else:
+317:             if not multiple_fields:
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_multiple_fields)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 317, __pyx_L1_error)
    __pyx_t_3 = (!__pyx_t_2);
    if (__pyx_t_3) {
/* … */
    }
+318:                 field = fields
      __Pyx_INCREF(__pyx_v_fields);
      __pyx_v_field = __pyx_v_fields;
 319: 
 320:                 # assume assets is iterable
 321:                 # return a Series indexed by asset
+322:                 if not self._adjust_minutes:
      __pyx_t_3 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->_adjust_minutes)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 322, __pyx_L1_error)
      __pyx_t_2 = (!__pyx_t_3);
      if (__pyx_t_2) {
/* … */
      }
+323:                     return pd.Series(data={
        __Pyx_XDECREF(__pyx_r);
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pd); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 323, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_Series); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 323, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 323, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        { /* enter inner scope */
          __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L25_error)
          __Pyx_GOTREF(__pyx_t_1);
/* … */
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_r = __pyx_t_1;
        __pyx_t_1 = 0;
        goto __pyx_L0;
+324:                         asset: self.data_portal.get_spot_value(
            __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_get_spot_value); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 324, __pyx_L25_error)
            __Pyx_GOTREF(__pyx_t_9);
 325:                             asset,
 326:                             field,
+327:                             self._get_current_minute(),
            __pyx_t_13 = ((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_get_current_minute(__pyx_v_self); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 327, __pyx_L25_error)
            __Pyx_GOTREF(__pyx_t_13);
+328:                             self.data_frequency
            __pyx_t_12 = NULL;
            __pyx_t_7 = 0;
            #if CYTHON_UNPACK_METHODS
            if (likely(PyMethod_Check(__pyx_t_9))) {
              __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_9);
              if (likely(__pyx_t_12)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
                __Pyx_INCREF(__pyx_t_12);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_9, function);
                __pyx_t_7 = 1;
              }
            }
            #endif
            {
              PyObject *__pyx_callargs[5] = {__pyx_t_12, __pyx_8genexpr4__pyx_v_asset, __pyx_v_field, __pyx_t_13, __pyx_v_self->data_frequency};
              __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_7, 4+__pyx_t_7);
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 324, __pyx_L25_error)
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            }
            if (unlikely(PyDict_SetItem(__pyx_t_1, (PyObject*)__pyx_8genexpr4__pyx_v_asset, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 324, __pyx_L25_error)
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 329:                         )
+330:                         for asset in assets
          if (likely(PyList_CheckExact(__pyx_v_assets)) || PyTuple_CheckExact(__pyx_v_assets)) {
            __pyx_t_5 = __pyx_v_assets; __Pyx_INCREF(__pyx_t_5);
            __pyx_t_10 = 0;
            __pyx_t_11 = NULL;
          } else {
            __pyx_t_10 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_assets); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 330, __pyx_L25_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 330, __pyx_L25_error)
          }
          for (;;) {
            if (likely(!__pyx_t_11)) {
              if (likely(PyList_CheckExact(__pyx_t_5))) {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5);
                  #if !CYTHON_ASSUME_SAFE_MACROS
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 330, __pyx_L25_error)
                  #endif
                  if (__pyx_t_10 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_8 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 330, __pyx_L25_error)
                #else
                __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 330, __pyx_L25_error)
                __Pyx_GOTREF(__pyx_t_8);
                #endif
              } else {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5);
                  #if !CYTHON_ASSUME_SAFE_MACROS
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 330, __pyx_L25_error)
                  #endif
                  if (__pyx_t_10 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 330, __pyx_L25_error)
                #else
                __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 330, __pyx_L25_error)
                __Pyx_GOTREF(__pyx_t_8);
                #endif
              }
            } else {
              __pyx_t_8 = __pyx_t_11(__pyx_t_5);
              if (unlikely(!__pyx_t_8)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                  else __PYX_ERR(0, 330, __pyx_L25_error)
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_8);
            }
            __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_asset, __pyx_t_8);
            __pyx_t_8 = 0;
/* … */
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_asset); __pyx_8genexpr4__pyx_v_asset = 0;
          goto __pyx_L29_exit_scope;
          __pyx_L25_error:;
          __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_asset); __pyx_8genexpr4__pyx_v_asset = 0;
          goto __pyx_L1_error;
          __pyx_L29_exit_scope:;
        } /* exit inner scope */
        if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_data, __pyx_t_1) < 0) __PYX_ERR(0, 323, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+331:                     }, index=assets, name=fields)
        if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_index, __pyx_v_assets) < 0) __PYX_ERR(0, 323, __pyx_L1_error)
        if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_name_2, __pyx_v_fields) < 0) __PYX_ERR(0, 323, __pyx_L1_error)
 332:                 else:
+333:                     return pd.Series(data={
      /*else*/ {
        __Pyx_XDECREF(__pyx_r);
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Series); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 333, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        { /* enter inner scope */
          __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 333, __pyx_L32_error)
          __Pyx_GOTREF(__pyx_t_6);
/* … */
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 333, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_r = __pyx_t_6;
        __pyx_t_6 = 0;
        goto __pyx_L0;
      }
+334:                         asset: self.data_portal.get_adjusted_value(
            __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_get_adjusted_value); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 334, __pyx_L32_error)
            __Pyx_GOTREF(__pyx_t_9);
 335:                             asset,
 336:                             field,
+337:                             self._get_current_minute(),
            __pyx_t_13 = ((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_get_current_minute(__pyx_v_self); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 337, __pyx_L32_error)
            __Pyx_GOTREF(__pyx_t_13);
+338:                             self.simulation_dt_func(),
            __Pyx_INCREF(__pyx_v_self->simulation_dt_func);
            __pyx_t_14 = __pyx_v_self->simulation_dt_func; __pyx_t_15 = NULL;
            __pyx_t_7 = 0;
            #if CYTHON_UNPACK_METHODS
            if (likely(PyMethod_Check(__pyx_t_14))) {
              __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_14);
              if (likely(__pyx_t_15)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
                __Pyx_INCREF(__pyx_t_15);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_14, function);
                __pyx_t_7 = 1;
              }
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
              __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_14, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7);
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 338, __pyx_L32_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            }
+339:                             self.data_frequency
            __pyx_t_14 = NULL;
            __pyx_t_7 = 0;
            #if CYTHON_UNPACK_METHODS
            if (likely(PyMethod_Check(__pyx_t_9))) {
              __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_9);
              if (likely(__pyx_t_14)) {
                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
                __Pyx_INCREF(__pyx_t_14);
                __Pyx_INCREF(function);
                __Pyx_DECREF_SET(__pyx_t_9, function);
                __pyx_t_7 = 1;
              }
            }
            #endif
            {
              PyObject *__pyx_callargs[6] = {__pyx_t_14, __pyx_8genexpr5__pyx_v_asset, __pyx_v_field, __pyx_t_13, __pyx_t_12, __pyx_v_self->data_frequency};
              __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_7, 5+__pyx_t_7);
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 334, __pyx_L32_error)
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            }
            if (unlikely(PyDict_SetItem(__pyx_t_6, (PyObject*)__pyx_8genexpr5__pyx_v_asset, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 334, __pyx_L32_error)
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 340:                         )
+341:                         for asset in assets
          if (likely(PyList_CheckExact(__pyx_v_assets)) || PyTuple_CheckExact(__pyx_v_assets)) {
            __pyx_t_5 = __pyx_v_assets; __Pyx_INCREF(__pyx_t_5);
            __pyx_t_10 = 0;
            __pyx_t_11 = NULL;
          } else {
            __pyx_t_10 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_assets); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 341, __pyx_L32_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 341, __pyx_L32_error)
          }
          for (;;) {
            if (likely(!__pyx_t_11)) {
              if (likely(PyList_CheckExact(__pyx_t_5))) {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5);
                  #if !CYTHON_ASSUME_SAFE_MACROS
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 341, __pyx_L32_error)
                  #endif
                  if (__pyx_t_10 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_8 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 341, __pyx_L32_error)
                #else
                __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 341, __pyx_L32_error)
                __Pyx_GOTREF(__pyx_t_8);
                #endif
              } else {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5);
                  #if !CYTHON_ASSUME_SAFE_MACROS
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 341, __pyx_L32_error)
                  #endif
                  if (__pyx_t_10 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 341, __pyx_L32_error)
                #else
                __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 341, __pyx_L32_error)
                __Pyx_GOTREF(__pyx_t_8);
                #endif
              }
            } else {
              __pyx_t_8 = __pyx_t_11(__pyx_t_5);
              if (unlikely(!__pyx_t_8)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                  else __PYX_ERR(0, 341, __pyx_L32_error)
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_8);
            }
            __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_asset, __pyx_t_8);
            __pyx_t_8 = 0;
/* … */
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_asset); __pyx_8genexpr5__pyx_v_asset = 0;
          goto __pyx_L36_exit_scope;
          __pyx_L32_error:;
          __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_asset); __pyx_8genexpr5__pyx_v_asset = 0;
          goto __pyx_L1_error;
          __pyx_L36_exit_scope:;
        } /* exit inner scope */
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_data, __pyx_t_6) < 0) __PYX_ERR(0, 333, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+342:                     }, index=assets, name=fields)
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index, __pyx_v_assets) < 0) __PYX_ERR(0, 333, __pyx_L1_error)
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name_2, __pyx_v_fields) < 0) __PYX_ERR(0, 333, __pyx_L1_error)
 343: 
 344:             else:
 345:                 # both assets and fields are iterable
+346:                 data = {}
    /*else*/ {
      __pyx_t_6 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 346, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_v_data = ((PyObject*)__pyx_t_6);
      __pyx_t_6 = 0;
 347: 
+348:                 if not self._adjust_minutes:
      __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->_adjust_minutes)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 348, __pyx_L1_error)
      __pyx_t_3 = (!__pyx_t_2);
      if (__pyx_t_3) {
/* … */
        goto __pyx_L37;
      }
+349:                     for field in fields:
        if (likely(PyList_CheckExact(__pyx_v_fields)) || PyTuple_CheckExact(__pyx_v_fields)) {
          __pyx_t_6 = __pyx_v_fields; __Pyx_INCREF(__pyx_t_6);
          __pyx_t_10 = 0;
          __pyx_t_11 = NULL;
        } else {
          __pyx_t_10 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_fields); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 349, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 349, __pyx_L1_error)
        }
        for (;;) {
          if (likely(!__pyx_t_11)) {
            if (likely(PyList_CheckExact(__pyx_t_6))) {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
                #if !CYTHON_ASSUME_SAFE_MACROS
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 349, __pyx_L1_error)
                #endif
                if (__pyx_t_10 >= __pyx_temp) break;
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_1 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 349, __pyx_L1_error)
              #else
              __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_1);
              #endif
            } else {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
                #if !CYTHON_ASSUME_SAFE_MACROS
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 349, __pyx_L1_error)
                #endif
                if (__pyx_t_10 >= __pyx_temp) break;
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 349, __pyx_L1_error)
              #else
              __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_1);
              #endif
            }
          } else {
            __pyx_t_1 = __pyx_t_11(__pyx_t_6);
            if (unlikely(!__pyx_t_1)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 349, __pyx_L1_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_1);
          }
          __Pyx_XDECREF_SET(__pyx_v_field, __pyx_t_1);
          __pyx_t_1 = 0;
/* … */
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+350:                         series = pd.Series(data={
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 350, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Series); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 350, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 350, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          { /* enter inner scope */
            __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 350, __pyx_L42_error)
            __Pyx_GOTREF(__pyx_t_5);
/* … */
          __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 350, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF_SET(__pyx_v_series, __pyx_t_5);
          __pyx_t_5 = 0;
+351:                             asset: self.data_portal.get_spot_value(
              __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_get_spot_value); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 351, __pyx_L42_error)
              __Pyx_GOTREF(__pyx_t_12);
 352:                                 asset,
 353:                                 field,
+354:                                 self._get_current_minute(),
              __pyx_t_13 = ((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_get_current_minute(__pyx_v_self); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 354, __pyx_L42_error)
              __Pyx_GOTREF(__pyx_t_13);
+355:                                 self.data_frequency
              __pyx_t_14 = NULL;
              __pyx_t_7 = 0;
              #if CYTHON_UNPACK_METHODS
              if (likely(PyMethod_Check(__pyx_t_12))) {
                __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_12);
                if (likely(__pyx_t_14)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
                  __Pyx_INCREF(__pyx_t_14);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_12, function);
                  __pyx_t_7 = 1;
                }
              }
              #endif
              {
                PyObject *__pyx_callargs[5] = {__pyx_t_14, __pyx_8genexpr6__pyx_v_asset, __pyx_v_field, __pyx_t_13, __pyx_v_self->data_frequency};
                __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_7, 4+__pyx_t_7);
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 351, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_9);
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              }
              if (unlikely(PyDict_SetItem(__pyx_t_5, (PyObject*)__pyx_8genexpr6__pyx_v_asset, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 351, __pyx_L42_error)
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 356:                             )
+357:                             for asset in assets
            if (likely(PyList_CheckExact(__pyx_v_assets)) || PyTuple_CheckExact(__pyx_v_assets)) {
              __pyx_t_8 = __pyx_v_assets; __Pyx_INCREF(__pyx_t_8);
              __pyx_t_16 = 0;
              __pyx_t_17 = NULL;
            } else {
              __pyx_t_16 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_assets); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 357, __pyx_L42_error)
              __Pyx_GOTREF(__pyx_t_8);
              __pyx_t_17 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_8); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 357, __pyx_L42_error)
            }
            for (;;) {
              if (likely(!__pyx_t_17)) {
                if (likely(PyList_CheckExact(__pyx_t_8))) {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_8);
                    #if !CYTHON_ASSUME_SAFE_MACROS
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 357, __pyx_L42_error)
                    #endif
                    if (__pyx_t_16 >= __pyx_temp) break;
                  }
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  __pyx_t_9 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_16); __Pyx_INCREF(__pyx_t_9); __pyx_t_16++; if (unlikely((0 < 0))) __PYX_ERR(0, 357, __pyx_L42_error)
                  #else
                  __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_8, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 357, __pyx_L42_error)
                  __Pyx_GOTREF(__pyx_t_9);
                  #endif
                } else {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_8);
                    #if !CYTHON_ASSUME_SAFE_MACROS
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 357, __pyx_L42_error)
                    #endif
                    if (__pyx_t_16 >= __pyx_temp) break;
                  }
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_16); __Pyx_INCREF(__pyx_t_9); __pyx_t_16++; if (unlikely((0 < 0))) __PYX_ERR(0, 357, __pyx_L42_error)
                  #else
                  __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_8, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 357, __pyx_L42_error)
                  __Pyx_GOTREF(__pyx_t_9);
                  #endif
                }
              } else {
                __pyx_t_9 = __pyx_t_17(__pyx_t_8);
                if (unlikely(!__pyx_t_9)) {
                  PyObject* exc_type = PyErr_Occurred();
                  if (exc_type) {
                    if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                    else __PYX_ERR(0, 357, __pyx_L42_error)
                  }
                  break;
                }
                __Pyx_GOTREF(__pyx_t_9);
              }
              __Pyx_XDECREF_SET(__pyx_8genexpr6__pyx_v_asset, __pyx_t_9);
              __pyx_t_9 = 0;
/* … */
            }
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_asset); __pyx_8genexpr6__pyx_v_asset = 0;
            goto __pyx_L46_exit_scope;
            __pyx_L42_error:;
            __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_asset); __pyx_8genexpr6__pyx_v_asset = 0;
            goto __pyx_L1_error;
            __pyx_L46_exit_scope:;
          } /* exit inner scope */
          if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_data, __pyx_t_5) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+358:                         }, index=assets, name=field)
          if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index, __pyx_v_assets) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
          if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name_2, __pyx_v_field) < 0) __PYX_ERR(0, 350, __pyx_L1_error)
+359:                         data[field] = series
          if (unlikely((PyDict_SetItem(__pyx_v_data, __pyx_v_field, __pyx_v_series) < 0))) __PYX_ERR(0, 359, __pyx_L1_error)
 360:                 else:
+361:                     for field in fields:
      /*else*/ {
        if (likely(PyList_CheckExact(__pyx_v_fields)) || PyTuple_CheckExact(__pyx_v_fields)) {
          __pyx_t_6 = __pyx_v_fields; __Pyx_INCREF(__pyx_t_6);
          __pyx_t_10 = 0;
          __pyx_t_11 = NULL;
        } else {
          __pyx_t_10 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_fields); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 361, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 361, __pyx_L1_error)
        }
        for (;;) {
          if (likely(!__pyx_t_11)) {
            if (likely(PyList_CheckExact(__pyx_t_6))) {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
                #if !CYTHON_ASSUME_SAFE_MACROS
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 361, __pyx_L1_error)
                #endif
                if (__pyx_t_10 >= __pyx_temp) break;
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 361, __pyx_L1_error)
              #else
              __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 361, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_5);
              #endif
            } else {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
                #if !CYTHON_ASSUME_SAFE_MACROS
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 361, __pyx_L1_error)
                #endif
                if (__pyx_t_10 >= __pyx_temp) break;
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 361, __pyx_L1_error)
              #else
              __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 361, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_5);
              #endif
            }
          } else {
            __pyx_t_5 = __pyx_t_11(__pyx_t_6);
            if (unlikely(!__pyx_t_5)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 361, __pyx_L1_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_XDECREF_SET(__pyx_v_field, __pyx_t_5);
          __pyx_t_5 = 0;
/* … */
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __pyx_L37:;
+362:                         series = pd.Series(data={
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pd); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 362, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_Series); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 362, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          { /* enter inner scope */
            __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 362, __pyx_L52_error)
            __Pyx_GOTREF(__pyx_t_4);
/* … */
          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 362, __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_XDECREF_SET(__pyx_v_series, __pyx_t_4);
          __pyx_t_4 = 0;
+363:                             asset: self.data_portal.get_adjusted_value(
              __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_get_adjusted_value); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 363, __pyx_L52_error)
              __Pyx_GOTREF(__pyx_t_12);
 364:                                 asset,
 365:                                 field,
+366:                                 self._get_current_minute(),
              __pyx_t_13 = ((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_get_current_minute(__pyx_v_self); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 366, __pyx_L52_error)
              __Pyx_GOTREF(__pyx_t_13);
+367:                                 self.simulation_dt_func(),
              __Pyx_INCREF(__pyx_v_self->simulation_dt_func);
              __pyx_t_15 = __pyx_v_self->simulation_dt_func; __pyx_t_18 = NULL;
              __pyx_t_7 = 0;
              #if CYTHON_UNPACK_METHODS
              if (likely(PyMethod_Check(__pyx_t_15))) {
                __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_15);
                if (likely(__pyx_t_18)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
                  __Pyx_INCREF(__pyx_t_18);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_15, function);
                  __pyx_t_7 = 1;
                }
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL};
                __pyx_t_14 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7);
                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 367, __pyx_L52_error)
                __Pyx_GOTREF(__pyx_t_14);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              }
+368:                                 self.data_frequency
              __pyx_t_15 = NULL;
              __pyx_t_7 = 0;
              #if CYTHON_UNPACK_METHODS
              if (likely(PyMethod_Check(__pyx_t_12))) {
                __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_12);
                if (likely(__pyx_t_15)) {
                  PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
                  __Pyx_INCREF(__pyx_t_15);
                  __Pyx_INCREF(function);
                  __Pyx_DECREF_SET(__pyx_t_12, function);
                  __pyx_t_7 = 1;
                }
              }
              #endif
              {
                PyObject *__pyx_callargs[6] = {__pyx_t_15, __pyx_8genexpr7__pyx_v_asset, __pyx_v_field, __pyx_t_13, __pyx_t_14, __pyx_v_self->data_frequency};
                __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_7, 5+__pyx_t_7);
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 363, __pyx_L52_error)
                __Pyx_GOTREF(__pyx_t_9);
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              }
              if (unlikely(PyDict_SetItem(__pyx_t_4, (PyObject*)__pyx_8genexpr7__pyx_v_asset, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 363, __pyx_L52_error)
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 369:                             )
+370:                             for asset in assets
            if (likely(PyList_CheckExact(__pyx_v_assets)) || PyTuple_CheckExact(__pyx_v_assets)) {
              __pyx_t_8 = __pyx_v_assets; __Pyx_INCREF(__pyx_t_8);
              __pyx_t_16 = 0;
              __pyx_t_17 = NULL;
            } else {
              __pyx_t_16 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_assets); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 370, __pyx_L52_error)
              __Pyx_GOTREF(__pyx_t_8);
              __pyx_t_17 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_8); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 370, __pyx_L52_error)
            }
            for (;;) {
              if (likely(!__pyx_t_17)) {
                if (likely(PyList_CheckExact(__pyx_t_8))) {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_8);
                    #if !CYTHON_ASSUME_SAFE_MACROS
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 370, __pyx_L52_error)
                    #endif
                    if (__pyx_t_16 >= __pyx_temp) break;
                  }
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  __pyx_t_9 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_16); __Pyx_INCREF(__pyx_t_9); __pyx_t_16++; if (unlikely((0 < 0))) __PYX_ERR(0, 370, __pyx_L52_error)
                  #else
                  __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_8, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 370, __pyx_L52_error)
                  __Pyx_GOTREF(__pyx_t_9);
                  #endif
                } else {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_8);
                    #if !CYTHON_ASSUME_SAFE_MACROS
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 370, __pyx_L52_error)
                    #endif
                    if (__pyx_t_16 >= __pyx_temp) break;
                  }
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_16); __Pyx_INCREF(__pyx_t_9); __pyx_t_16++; if (unlikely((0 < 0))) __PYX_ERR(0, 370, __pyx_L52_error)
                  #else
                  __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_8, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 370, __pyx_L52_error)
                  __Pyx_GOTREF(__pyx_t_9);
                  #endif
                }
              } else {
                __pyx_t_9 = __pyx_t_17(__pyx_t_8);
                if (unlikely(!__pyx_t_9)) {
                  PyObject* exc_type = PyErr_Occurred();
                  if (exc_type) {
                    if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                    else __PYX_ERR(0, 370, __pyx_L52_error)
                  }
                  break;
                }
                __Pyx_GOTREF(__pyx_t_9);
              }
              __Pyx_XDECREF_SET(__pyx_8genexpr7__pyx_v_asset, __pyx_t_9);
              __pyx_t_9 = 0;
/* … */
            }
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_asset); __pyx_8genexpr7__pyx_v_asset = 0;
            goto __pyx_L56_exit_scope;
            __pyx_L52_error:;
            __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_asset); __pyx_8genexpr7__pyx_v_asset = 0;
            goto __pyx_L1_error;
            __pyx_L56_exit_scope:;
          } /* exit inner scope */
          if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_data, __pyx_t_4) < 0) __PYX_ERR(0, 362, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+371:                         }, index=assets, name=field)
          if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_index, __pyx_v_assets) < 0) __PYX_ERR(0, 362, __pyx_L1_error)
          if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_name_2, __pyx_v_field) < 0) __PYX_ERR(0, 362, __pyx_L1_error)
+372:                         data[field] = series
          if (unlikely((PyDict_SetItem(__pyx_v_data, __pyx_v_field, __pyx_v_series) < 0))) __PYX_ERR(0, 372, __pyx_L1_error)
 373: 
+374:                 return pd.DataFrame(data)
      __Pyx_XDECREF(__pyx_r);
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pd); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 374, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 374, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      __pyx_t_7 = 0;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
          __pyx_t_7 = 1;
        }
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_data};
        __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 374, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
      __pyx_r = __pyx_t_6;
      __pyx_t_6 = 0;
      goto __pyx_L0;
    }
  }
 375: 
+376:     @check_parameters(('continuous_future',),
/* Python wrapper */
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_5current_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 PyMethodDef __pyx_mdef_7zipline_9_protocol_7BarData_5current_chain = {"current_chain", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_9_protocol_7BarData_5current_chain, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_5current_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
) {
  PyObject *__pyx_v_continuous_future = 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("current_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_continuous_future,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_continuous_future)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 376, __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, "current_chain") < 0)) __PYX_ERR(0, 376, __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_continuous_future = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("current_chain", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 376, __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._protocol.BarData.current_chain", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7zipline_9_protocol_7BarData_4current_chain(((struct __pyx_obj_7zipline_9_protocol_BarData *)__pyx_v_self), __pyx_v_continuous_future);
  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_9_protocol_7BarData_4current_chain(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self, PyObject *__pyx_v_continuous_future) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__12)
  __Pyx_TraceCall("current_chain", __pyx_f[0], 376, 0, __PYX_ERR(0, 376, __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_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("zipline._protocol.BarData.current_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__35 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_continuous_future); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_9_protocol_7BarData_5current_chain, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_BarData_current_chain, NULL, __pyx_n_s_zipline__protocol, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_current_chain, __pyx_t_4) < 0) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_7zipline_9_protocol_BarData);
  __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline__protocol_pyx, __pyx_n_s_current_chain, 376, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 376, __pyx_L1_error)
/* … */
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_tuple__36)) __PYX_ERR(0, 376, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_2);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2)) __PYX_ERR(0, 376, __pyx_L1_error);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7zipline_9_protocol_check_parameters), __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_GetNameInClass(__pyx_t_5, (PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_current_chain); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = NULL;
  __pyx_t_6 = 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_6 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_5};
    __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 376, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_current_chain, __pyx_t_4) < 0) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_7zipline_9_protocol_BarData);
  __pyx_tuple__36 = PyTuple_Pack(1, __pyx_n_u_continuous_future); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);
+377:                       (ContinuousFuture,))
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_ContinuousFuture); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_5);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5)) __PYX_ERR(0, 377, __pyx_L1_error);
  __pyx_t_5 = 0;
 378:     def current_chain(self, continuous_future):
+379:         return self.data_portal.get_current_future_chain(
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_get_current_future_chain); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 379, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
 380:             continuous_future,
+381:             self.simulation_dt_func())
  __Pyx_INCREF(__pyx_v_self->simulation_dt_func);
  __pyx_t_4 = __pyx_v_self->simulation_dt_func; __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  #if CYTHON_UNPACK_METHODS
  if (likely(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, NULL};
    __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 381, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  #if CYTHON_UNPACK_METHODS
  if (likely(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_6 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_v_continuous_future, __pyx_t_3};
    __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6);
    __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, 379, __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;
 382: 
+383:     @check_parameters(('assets',), (Asset,))
/* Python wrapper */
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_7can_trade(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_9_protocol_7BarData_6can_trade, "\n        For the given asset or iterable of assets, returns True if all of the\n        following are true:\n\n        1. The asset is alive for the session of the current simulation time\n           (if current simulation time is not a market minute, we use the next\n           session).\n        2. The asset's exchange is open at the current simulation time or at\n           the simulation calendar's next market minute.\n        3. There is a known last price for the asset.\n\n        Parameters\n        ----------\n        assets: zipline.assets.Asset or iterable of zipline.assets.Asset\n            Asset(s) for which tradability should be determined.\n\n        Notes\n        -----\n        The second condition above warrants some further explanation:\n\n        - If the asset's exchange calendar is identical to the simulation\n          calendar, then this condition always returns True.\n        - If there are market minutes in the simulation calendar outside of\n          this asset's exchange's trading hours (for example, if the simulation\n          is running on the CMES calendar but the asset is MSFT, which trades\n          on the NYSE), during those minutes, this condition will return False\n          (for example, 3:15 am Eastern on a weekday, during which the CMES is\n          open but the NYSE is closed).\n\n        Returns\n        -------\n        can_trade : bool or pd.Series[bool]\n            Bool or series of bools indicating whether the requested asset(s)\n            can be traded in the current minute.\n        ");
static PyMethodDef __pyx_mdef_7zipline_9_protocol_7BarData_7can_trade = {"can_trade", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_9_protocol_7BarData_7can_trade, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7zipline_9_protocol_7BarData_6can_trade};
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_7can_trade(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_assets = 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("can_trade (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_assets,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_assets)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 383, __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, "can_trade") < 0)) __PYX_ERR(0, 383, __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_assets = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("can_trade", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 383, __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._protocol.BarData.can_trade", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7zipline_9_protocol_7BarData_6can_trade(((struct __pyx_obj_7zipline_9_protocol_BarData *)__pyx_v_self), __pyx_v_assets);
  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_9_protocol_7BarData_6can_trade(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self, PyObject *__pyx_v_assets) {
  PyObject *__pyx_v_dt = NULL;
  PyObject *__pyx_v_adjusted_dt = NULL;
  PyObject *__pyx_v_data_portal = NULL;
  PyObject *__pyx_v_tradeable = NULL;
  PyObject *__pyx_8genexpr8__pyx_v_asset = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__13)
  __Pyx_TraceCall("can_trade", __pyx_f[0], 383, 0, __PYX_ERR(0, 383, __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_AddTraceback("zipline._protocol.BarData.can_trade", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dt);
  __Pyx_XDECREF(__pyx_v_adjusted_dt);
  __Pyx_XDECREF(__pyx_v_data_portal);
  __Pyx_XDECREF(__pyx_v_tradeable);
  __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_asset);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__37 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_assets, __pyx_n_s_dt, __pyx_n_s_adjusted_dt, __pyx_n_s_data_portal, __pyx_n_s_tradeable, __pyx_n_s_asset); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_9_protocol_7BarData_7can_trade, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_BarData_can_trade, NULL, __pyx_n_s_zipline__protocol, __pyx_d, ((PyObject *)__pyx_codeobj__13)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_can_trade, __pyx_t_4) < 0) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_7zipline_9_protocol_BarData);
  __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline__protocol_pyx, __pyx_n_s_can_trade, 383, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 383, __pyx_L1_error)
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF((PyObject *)__pyx_ptype_7zipline_6assets_7_assets_Asset);
  __Pyx_GIVEREF((PyObject *)__pyx_ptype_7zipline_6assets_7_assets_Asset);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_ptype_7zipline_6assets_7_assets_Asset))) __PYX_ERR(0, 383, __pyx_L1_error);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_tuple__38)) __PYX_ERR(0, 383, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_2);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7zipline_9_protocol_check_parameters), __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_GetNameInClass(__pyx_t_5, (PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_can_trade); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = NULL;
  __pyx_t_6 = 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_6 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_5};
    __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_can_trade, __pyx_t_4) < 0) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_7zipline_9_protocol_BarData);
  __pyx_tuple__38 = PyTuple_Pack(1, __pyx_n_u_assets); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);
 384:     def can_trade(self, assets):
 385:         """
 386:         For the given asset or iterable of assets, returns True if all of the
 387:         following are true:
 388: 
 389:         1. The asset is alive for the session of the current simulation time
 390:            (if current simulation time is not a market minute, we use the next
 391:            session).
 392:         2. The asset's exchange is open at the current simulation time or at
 393:            the simulation calendar's next market minute.
 394:         3. There is a known last price for the asset.
 395: 
 396:         Parameters
 397:         ----------
 398:         assets: zipline.assets.Asset or iterable of zipline.assets.Asset
 399:             Asset(s) for which tradability should be determined.
 400: 
 401:         Notes
 402:         -----
 403:         The second condition above warrants some further explanation:
 404: 
 405:         - If the asset's exchange calendar is identical to the simulation
 406:           calendar, then this condition always returns True.
 407:         - If there are market minutes in the simulation calendar outside of
 408:           this asset's exchange's trading hours (for example, if the simulation
 409:           is running on the CMES calendar but the asset is MSFT, which trades
 410:           on the NYSE), during those minutes, this condition will return False
 411:           (for example, 3:15 am Eastern on a weekday, during which the CMES is
 412:           open but the NYSE is closed).
 413: 
 414:         Returns
 415:         -------
 416:         can_trade : bool or pd.Series[bool]
 417:             Bool or series of bools indicating whether the requested asset(s)
 418:             can be traded in the current minute.
 419:         """
+420:         dt = self.simulation_dt_func()
  __Pyx_INCREF(__pyx_v_self->simulation_dt_func);
  __pyx_t_2 = __pyx_v_self->simulation_dt_func; __pyx_t_3 = NULL;
  __pyx_t_4 = 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_4 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_v_dt = __pyx_t_1;
  __pyx_t_1 = 0;
 421: 
+422:         if self._adjust_minutes:
  __pyx_t_5 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->_adjust_minutes)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 422, __pyx_L1_error)
  if (__pyx_t_5) {
/* … */
    goto __pyx_L3;
  }
+423:             adjusted_dt = self._get_current_minute()
    __pyx_t_1 = ((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_get_current_minute(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_adjusted_dt = __pyx_t_1;
    __pyx_t_1 = 0;
 424:         else:
+425:             adjusted_dt = dt
  /*else*/ {
    __Pyx_INCREF(__pyx_v_dt);
    __pyx_v_adjusted_dt = __pyx_v_dt;
  }
  __pyx_L3:;
 426: 
+427:         data_portal = self.data_portal
  __pyx_t_1 = __pyx_v_self->data_portal;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_data_portal = __pyx_t_1;
  __pyx_t_1 = 0;
 428: 
+429:         if isinstance(assets, Asset):
  __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_assets, __pyx_ptype_7zipline_6assets_7_assets_Asset); 
  if (__pyx_t_5) {
/* … */
  }
+430:             return self._can_trade_for_asset(
    __Pyx_XDECREF(__pyx_r);
/* … */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_can_trade_for_asset(__pyx_v_self, __pyx_v_assets, __pyx_v_dt, __pyx_v_adjusted_dt, __pyx_v_data_portal)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 430, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
 431:                 assets, dt, adjusted_dt, data_portal
 432:             )
 433:         else:
+434:             tradeable = [
  /*else*/ {
    { /* enter inner scope */
      __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 434, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_1);
+435:                 self._can_trade_for_asset(
        __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_can_trade_for_asset(__pyx_v_self, __pyx_8genexpr8__pyx_v_asset, __pyx_v_dt, __pyx_v_adjusted_dt, __pyx_v_data_portal)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 435, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 434, __pyx_L7_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 436:                     asset, dt, adjusted_dt, data_portal
 437:                 )
+438:                 for asset in assets
      if (likely(PyList_CheckExact(__pyx_v_assets)) || PyTuple_CheckExact(__pyx_v_assets)) {
        __pyx_t_2 = __pyx_v_assets; __Pyx_INCREF(__pyx_t_2);
        __pyx_t_6 = 0;
        __pyx_t_7 = NULL;
      } else {
        __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_assets); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 438, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 438, __pyx_L7_error)
      }
      for (;;) {
        if (likely(!__pyx_t_7)) {
          if (likely(PyList_CheckExact(__pyx_t_2))) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
              #if !CYTHON_ASSUME_SAFE_MACROS
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 438, __pyx_L7_error)
              #endif
              if (__pyx_t_6 >= __pyx_temp) break;
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 438, __pyx_L7_error)
            #else
            __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 438, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_3);
            #endif
          } else {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2);
              #if !CYTHON_ASSUME_SAFE_MACROS
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 438, __pyx_L7_error)
              #endif
              if (__pyx_t_6 >= __pyx_temp) break;
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 438, __pyx_L7_error)
            #else
            __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 438, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_3);
            #endif
          }
        } else {
          __pyx_t_3 = __pyx_t_7(__pyx_t_2);
          if (unlikely(!__pyx_t_3)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 438, __pyx_L7_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_XDECREF_SET(__pyx_8genexpr8__pyx_v_asset, __pyx_t_3);
        __pyx_t_3 = 0;
/* … */
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_asset); __pyx_8genexpr8__pyx_v_asset = 0;
      goto __pyx_L11_exit_scope;
      __pyx_L7_error:;
      __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_asset); __pyx_8genexpr8__pyx_v_asset = 0;
      goto __pyx_L1_error;
      __pyx_L11_exit_scope:;
    } /* exit inner scope */
    __pyx_v_tradeable = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
 439:             ]
+440:             return pd.Series(data=tradeable, index=assets, dtype=bool)
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 440, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Series); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 440, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 440, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_data, __pyx_v_tradeable) < 0) __PYX_ERR(0, 440, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index, __pyx_v_assets) < 0) __PYX_ERR(0, 440, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, ((PyObject *)__pyx_ptype_7cpython_4bool_bool)) < 0) __PYX_ERR(0, 440, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 440, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }
 441: 
+442:     cdef bool _can_trade_for_asset(self, asset, dt, adjusted_dt, data_portal):
static PyBoolObject *__pyx_f_7zipline_9_protocol_7BarData__can_trade_for_asset(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self, PyObject *__pyx_v_asset, PyObject *__pyx_v_dt, PyObject *__pyx_v_adjusted_dt, PyObject *__pyx_v_data_portal) {
  PyObject *__pyx_v_session_label = 0;
  PyObject *__pyx_v_dt_to_use_for_exchange_check = 0;
  PyBoolObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("_can_trade_for_asset", __pyx_f[0], 442, 0, __PYX_ERR(0, 442, __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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("zipline._protocol.BarData._can_trade_for_asset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_session_label);
  __Pyx_XDECREF(__pyx_v_dt_to_use_for_exchange_check);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 443:         cdef object session_label
 444:         cdef object dt_to_use_for_exchange_check,
 445: 
+446:         if self._is_restricted(asset, adjusted_dt):
  __Pyx_INCREF(__pyx_v_self->_is_restricted);
  __pyx_t_2 = __pyx_v_self->_is_restricted; __pyx_t_3 = NULL;
  __pyx_t_4 = 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_4 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_asset, __pyx_v_adjusted_dt};
    __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 446, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {
/* … */
  }
+447:             return False
    __Pyx_XDECREF((PyObject *)__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = ((PyBoolObject *)Py_False);
    goto __pyx_L0;
 448: 
+449:         session_label = self._trading_calendar.minute_to_session_label(dt)
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_trading_calendar, __pyx_n_s_minute_to_session_label); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 449, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 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_4 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_dt};
    __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, 449, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_v_session_label = __pyx_t_1;
  __pyx_t_1 = 0;
 450: 
+451:         if not asset.is_alive_for_session(session_label):
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_asset, __pyx_n_s_is_alive_for_session); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 451, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 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_4 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_session_label};
    __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, 451, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 451, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = (!__pyx_t_5);
  if (__pyx_t_6) {
/* … */
  }
 452:             # asset isn't alive
+453:             return False
    __Pyx_XDECREF((PyObject *)__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = ((PyBoolObject *)Py_False);
    goto __pyx_L0;
 454: 
+455:         if asset.auto_close_date and session_label > asset.auto_close_date:
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_asset, __pyx_n_s_auto_close_date); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 455, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {
  } else {
    __pyx_t_6 = __pyx_t_5;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_asset, __pyx_n_s_auto_close_date); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_session_label, __pyx_t_1, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 455, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 455, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = __pyx_t_5;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_6) {
/* … */
  }
+456:             return False
    __Pyx_XDECREF((PyObject *)__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = ((PyBoolObject *)Py_False);
    goto __pyx_L0;
 457: 
+458:         if not self._daily_mode:
  __pyx_t_6 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->_daily_mode)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 458, __pyx_L1_error)
  __pyx_t_5 = (!__pyx_t_6);
  if (__pyx_t_5) {
/* … */
  }
 459:             # Find the next market minute for this calendar, and check if this
 460:             # asset's exchange is open at that minute.
+461:             if self._trading_calendar.is_open_on_minute(dt):
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_trading_calendar, __pyx_n_s_is_open_on_minute); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 461, __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, __pyx_v_dt};
      __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 461, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 461, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_5) {
/* … */
      goto __pyx_L9;
    }
+462:                 dt_to_use_for_exchange_check = dt
      __Pyx_INCREF(__pyx_v_dt);
      __pyx_v_dt_to_use_for_exchange_check = __pyx_v_dt;
 463:             else:
 464:                 dt_to_use_for_exchange_check = \
+465:                     self._trading_calendar.next_open(dt)
    /*else*/ {
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_trading_calendar, __pyx_n_s_next_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 465, __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, __pyx_v_dt};
        __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4);
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 465, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __pyx_v_dt_to_use_for_exchange_check = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    __pyx_L9:;
 466: 
+467:             if not asset.is_exchange_open(dt_to_use_for_exchange_check):
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_asset, __pyx_n_s_is_exchange_open); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 467, __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, __pyx_v_dt_to_use_for_exchange_check};
      __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 467, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 467, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_6 = (!__pyx_t_5);
    if (__pyx_t_6) {
/* … */
    }
+468:                 return False
      __Pyx_XDECREF((PyObject *)__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = ((PyBoolObject *)Py_False);
      goto __pyx_L0;
 469: 
 470:         # is there a last price?
+471:         return not np.isnan(
  __Pyx_XDECREF((PyObject *)__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_isnan); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 471, __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_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 471, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyBool_FromLong((!__pyx_t_6)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) __PYX_ERR(0, 471, __pyx_L1_error)
  __pyx_r = ((PyBoolObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;
+472:             data_portal.get_spot_value(
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_data_portal, __pyx_n_s_get_spot_value); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 472, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
+473:                 asset, "price", adjusted_dt, self.data_frequency
  __pyx_t_8 = NULL;
  __pyx_t_4 = 0;
  #if CYTHON_UNPACK_METHODS
  if (likely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
      __pyx_t_4 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[5] = {__pyx_t_8, __pyx_v_asset, __pyx_n_u_price, __pyx_v_adjusted_dt, __pyx_v_self->data_frequency};
    __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_4, 4+__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 472, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __pyx_t_7 = NULL;
  __pyx_t_4 = 0;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_4 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_1};
    __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 471, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
 474:             )
 475:         )
 476: 
+477:     @check_parameters(('assets',), (Asset,))
/* Python wrapper */
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_9is_stale(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_9_protocol_7BarData_8is_stale, "\n        For the given asset or iterable of assets, returns True if the asset\n        is alive and there is no trade data for the current simulation time.\n\n        If the asset has never traded, returns False.\n\n        If the current simulation time is not a valid market time, we use the\n        current time to check if the asset is alive, but we use the last\n        market minute/day for the trade data check.\n\n        Parameters\n        ----------\n        assets: zipline.assets.Asset or iterable of zipline.assets.Asset\n            Asset(s) for which staleness should be determined.\n\n        Returns\n        -------\n        is_stale : bool or pd.Series[bool]\n            Bool or series of bools indicating whether the requested asset(s)\n            are stale.\n        ");
static PyMethodDef __pyx_mdef_7zipline_9_protocol_7BarData_9is_stale = {"is_stale", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_9_protocol_7BarData_9is_stale, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7zipline_9_protocol_7BarData_8is_stale};
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_9is_stale(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_assets = 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_stale (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_assets,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_assets)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 477, __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_stale") < 0)) __PYX_ERR(0, 477, __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_assets = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("is_stale", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 477, __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._protocol.BarData.is_stale", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7zipline_9_protocol_7BarData_8is_stale(((struct __pyx_obj_7zipline_9_protocol_BarData *)__pyx_v_self), __pyx_v_assets);
  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_9_protocol_7BarData_8is_stale(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self, PyObject *__pyx_v_assets) {
  PyObject *__pyx_v_dt = NULL;
  PyObject *__pyx_v_adjusted_dt = NULL;
  PyObject *__pyx_v_data_portal = NULL;
  PyObject *__pyx_8genexpr9__pyx_v_asset = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__14)
  __Pyx_TraceCall("is_stale", __pyx_f[0], 477, 0, __PYX_ERR(0, 477, __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_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("zipline._protocol.BarData.is_stale", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dt);
  __Pyx_XDECREF(__pyx_v_adjusted_dt);
  __Pyx_XDECREF(__pyx_v_data_portal);
  __Pyx_XDECREF(__pyx_8genexpr9__pyx_v_asset);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__39 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_assets, __pyx_n_s_dt, __pyx_n_s_adjusted_dt, __pyx_n_s_data_portal, __pyx_n_s_asset); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_9_protocol_7BarData_9is_stale, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_BarData_is_stale, NULL, __pyx_n_s_zipline__protocol, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_is_stale, __pyx_t_4) < 0) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_7zipline_9_protocol_BarData);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF((PyObject *)__pyx_ptype_7zipline_6assets_7_assets_Asset);
  __Pyx_GIVEREF((PyObject *)__pyx_ptype_7zipline_6assets_7_assets_Asset);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_ptype_7zipline_6assets_7_assets_Asset))) __PYX_ERR(0, 477, __pyx_L1_error);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_tuple__38)) __PYX_ERR(0, 477, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_2);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2)) __PYX_ERR(0, 477, __pyx_L1_error);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7zipline_9_protocol_check_parameters), __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_GetNameInClass(__pyx_t_5, (PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_is_stale); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = NULL;
  __pyx_t_6 = 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_6 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_5};
    __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_is_stale, __pyx_t_4) < 0) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_7zipline_9_protocol_BarData);
  __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__39, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline__protocol_pyx, __pyx_n_s_is_stale, 477, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 477, __pyx_L1_error)
 478:     def is_stale(self, assets):
 479:         """
 480:         For the given asset or iterable of assets, returns True if the asset
 481:         is alive and there is no trade data for the current simulation time.
 482: 
 483:         If the asset has never traded, returns False.
 484: 
 485:         If the current simulation time is not a valid market time, we use the
 486:         current time to check if the asset is alive, but we use the last
 487:         market minute/day for the trade data check.
 488: 
 489:         Parameters
 490:         ----------
 491:         assets: zipline.assets.Asset or iterable of zipline.assets.Asset
 492:             Asset(s) for which staleness should be determined.
 493: 
 494:         Returns
 495:         -------
 496:         is_stale : bool or pd.Series[bool]
 497:             Bool or series of bools indicating whether the requested asset(s)
 498:             are stale.
 499:         """
+500:         dt = self.simulation_dt_func()
  __Pyx_INCREF(__pyx_v_self->simulation_dt_func);
  __pyx_t_2 = __pyx_v_self->simulation_dt_func; __pyx_t_3 = NULL;
  __pyx_t_4 = 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_4 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 500, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_v_dt = __pyx_t_1;
  __pyx_t_1 = 0;
+501:         if self._adjust_minutes:
  __pyx_t_5 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->_adjust_minutes)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 501, __pyx_L1_error)
  if (__pyx_t_5) {
/* … */
    goto __pyx_L3;
  }
+502:             adjusted_dt = self._get_current_minute()
    __pyx_t_1 = ((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_get_current_minute(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 502, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_adjusted_dt = __pyx_t_1;
    __pyx_t_1 = 0;
 503:         else:
+504:             adjusted_dt = dt
  /*else*/ {
    __Pyx_INCREF(__pyx_v_dt);
    __pyx_v_adjusted_dt = __pyx_v_dt;
  }
  __pyx_L3:;
 505: 
+506:         data_portal = self.data_portal
  __pyx_t_1 = __pyx_v_self->data_portal;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_data_portal = __pyx_t_1;
  __pyx_t_1 = 0;
 507: 
+508:         if isinstance(assets, Asset):
  __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_assets, __pyx_ptype_7zipline_6assets_7_assets_Asset); 
  if (__pyx_t_5) {
/* … */
  }
+509:             return self._is_stale_for_asset(
    __Pyx_XDECREF(__pyx_r);
/* … */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_is_stale_for_asset(__pyx_v_self, __pyx_v_assets, __pyx_v_dt, __pyx_v_adjusted_dt, __pyx_v_data_portal)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 509, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
 510:                 assets, dt, adjusted_dt, data_portal
 511:             )
 512:         else:
+513:             return pd.Series(data={
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Series); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    { /* enter inner scope */
      __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 513, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_3);
/* … */
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }
+514:                 asset: self._is_stale_for_asset(
        __pyx_t_9 = ((PyObject *)((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_is_stale_for_asset(__pyx_v_self, __pyx_8genexpr9__pyx_v_asset, __pyx_v_dt, __pyx_v_adjusted_dt, __pyx_v_data_portal)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 514, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_8genexpr9__pyx_v_asset, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 514, __pyx_L7_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 515:                     asset, dt, adjusted_dt, data_portal
 516:                 )
+517:                 for asset in assets
      if (likely(PyList_CheckExact(__pyx_v_assets)) || PyTuple_CheckExact(__pyx_v_assets)) {
        __pyx_t_6 = __pyx_v_assets; __Pyx_INCREF(__pyx_t_6);
        __pyx_t_7 = 0;
        __pyx_t_8 = NULL;
      } else {
        __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_assets); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 517, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 517, __pyx_L7_error)
      }
      for (;;) {
        if (likely(!__pyx_t_8)) {
          if (likely(PyList_CheckExact(__pyx_t_6))) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
              #if !CYTHON_ASSUME_SAFE_MACROS
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 517, __pyx_L7_error)
              #endif
              if (__pyx_t_7 >= __pyx_temp) break;
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_9 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 517, __pyx_L7_error)
            #else
            __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 517, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_9);
            #endif
          } else {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
              #if !CYTHON_ASSUME_SAFE_MACROS
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 517, __pyx_L7_error)
              #endif
              if (__pyx_t_7 >= __pyx_temp) break;
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 517, __pyx_L7_error)
            #else
            __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 517, __pyx_L7_error)
            __Pyx_GOTREF(__pyx_t_9);
            #endif
          }
        } else {
          __pyx_t_9 = __pyx_t_8(__pyx_t_6);
          if (unlikely(!__pyx_t_9)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 517, __pyx_L7_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_9);
        }
        __Pyx_XDECREF_SET(__pyx_8genexpr9__pyx_v_asset, __pyx_t_9);
        __pyx_t_9 = 0;
/* … */
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_8genexpr9__pyx_v_asset); __pyx_8genexpr9__pyx_v_asset = 0;
      goto __pyx_L11_exit_scope;
      __pyx_L7_error:;
      __Pyx_XDECREF(__pyx_8genexpr9__pyx_v_asset); __pyx_8genexpr9__pyx_v_asset = 0;
      goto __pyx_L1_error;
      __pyx_L11_exit_scope:;
    } /* exit inner scope */
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_data, __pyx_t_3) < 0) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 518:             })
 519: 
+520:     cdef bool _is_stale_for_asset(self, asset, dt, adjusted_dt, data_portal):
static PyBoolObject *__pyx_f_7zipline_9_protocol_7BarData__is_stale_for_asset(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self, PyObject *__pyx_v_asset, PyObject *__pyx_v_dt, PyObject *__pyx_v_adjusted_dt, PyObject *__pyx_v_data_portal) {
  PyObject *__pyx_v_session_label = NULL;
  PyObject *__pyx_v_current_volume = NULL;
  PyObject *__pyx_v_last_traded_dt = NULL;
  PyBoolObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("_is_stale_for_asset", __pyx_f[0], 520, 0, __PYX_ERR(0, 520, __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_AddTraceback("zipline._protocol.BarData._is_stale_for_asset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_session_label);
  __Pyx_XDECREF(__pyx_v_current_volume);
  __Pyx_XDECREF(__pyx_v_last_traded_dt);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+521:         session_label = normalize_date(dt)  # FIXME
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_normalize_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 521, __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_v_dt};
    __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, 521, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_v_session_label = __pyx_t_1;
  __pyx_t_1 = 0;
 522: 
+523:         if not asset.is_alive_for_session(session_label):
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_asset, __pyx_n_s_is_alive_for_session); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 523, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 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_4 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_session_label};
    __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, 523, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 523, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = (!__pyx_t_5);
  if (__pyx_t_6) {
/* … */
  }
+524:             return False
    __Pyx_XDECREF((PyObject *)__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = ((PyBoolObject *)Py_False);
    goto __pyx_L0;
 525: 
+526:         current_volume = data_portal.get_spot_value(
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_data_portal, __pyx_n_s_get_spot_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
+527:             asset, "volume", adjusted_dt, self.data_frequency
  __pyx_t_3 = NULL;
  __pyx_t_4 = 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_4 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[5] = {__pyx_t_3, __pyx_v_asset, __pyx_n_u_volume, __pyx_v_adjusted_dt, __pyx_v_self->data_frequency};
    __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 4+__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_v_current_volume = __pyx_t_1;
  __pyx_t_1 = 0;
 528:         )
 529: 
+530:         if current_volume > 0:
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_current_volume, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 530, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 530, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_6) {
/* … */
  }
 531:             # found a current value, so we know this asset is not stale.
+532:             return False
    __Pyx_XDECREF((PyObject *)__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = ((PyBoolObject *)Py_False);
    goto __pyx_L0;
 533:         else:
 534:             # we need to distinguish between if this asset has ever traded
 535:             # (stale = True) or has never traded (stale = False)
+536:             last_traded_dt = \
  /*else*/ {
+537:                 data_portal.get_spot_value(asset, "last_traded", adjusted_dt,
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_data_portal, __pyx_n_s_get_spot_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 537, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
+538:                                            self.data_frequency)
    __pyx_t_3 = NULL;
    __pyx_t_4 = 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_4 = 1;
      }
    }
    #endif
    {
      PyObject *__pyx_callargs[5] = {__pyx_t_3, __pyx_v_asset, __pyx_n_u_last_traded, __pyx_v_adjusted_dt, __pyx_v_self->data_frequency};
      __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 4+__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 537, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __pyx_v_last_traded_dt = __pyx_t_1;
    __pyx_t_1 = 0;
 539: 
+540:             return not (last_traded_dt is pd.NaT)
    __Pyx_XDECREF((PyObject *)__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 540, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_NaT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 540, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = (__pyx_v_last_traded_dt != __pyx_t_2);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 540, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) __PYX_ERR(0, 540, __pyx_L1_error)
    __pyx_r = ((PyBoolObject *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }
 541: 
+542:     @check_parameters(('assets', 'fields', 'bar_count', 'frequency'),
/* Python wrapper */
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_11history(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_9_protocol_7BarData_10history, "\n        Returns a trailing window of length ``bar_count`` with data for\n        the given assets, fields, and frequency, adjusted for splits, dividends,\n        and mergers as of the current simulation time.\n\n        The semantics for missing data are identical to the ones described in\n        the notes for :meth:`current`.\n\n        Parameters\n        ----------\n        assets: zipline.assets.Asset or iterable of zipline.assets.Asset\n            The asset(s) for which data is requested.\n        fields: string or iterable of string.\n            Requested data field(s). Valid field names are: \"price\",\n            \"last_traded\", \"open\", \"high\", \"low\", \"close\", and \"volume\".\n        bar_count: int\n            Number of data observations requested.\n        frequency: str\n            String indicating whether to load daily or minutely data\n            observations. Pass '1m' for minutely data, '1d' for daily data.\n\n        Returns\n        -------\n        history : pd.Series or pd.DataFrame or pd.Panel\n            See notes below.\n\n        Notes\n        -----\n        The return type of this function depends on the types of ``assets`` and\n        ``fields``:\n\n        - If a single asset and a single field are requested, the returned\n          value is a :class:`pd.Series` of length ``bar_count`` whose index is\n          :class:`pd.DatetimeIndex`.\n\n        - If a single asset and multiple fields are requested, the returned\n          value is a :class:`pd.DataFrame` with shape\n          ``(bar_count, len(fields))``. The frame's index will be a\n          :class:`pd.DatetimeIndex`, and its columns will be ``fields``.\n\n        - If multiple assets and a single field are requested, the returned\n          value is a :class:`pd.DataFrame` with shape\n          ``(bar_count, len(assets))``. The frame's index will be a\n          :class:`pd.DatetimeIndex`, and its columns will be ``assets``.\n\n        - If multiple assets and m""ultiple fields are requested, the returned\n          value is a :class:`pd.DataFrame` with a pd.MultiIndex containing pairs of\n           :class:`pd.DatetimeIndex`, and ``assets``, while the columns while contain the field(s).\n           It has shape``(bar_count * len(assets), len(fields))``. The names of the pd.MultiIndex are\n            - ``date`` if frequency == '1d'`` or ``date_time`` if frequency == '1m``, and\n            - ``asset``\n\n        If the current simulation time is not a valid market time, we use the last market close instead.\n        ");
static PyMethodDef __pyx_mdef_7zipline_9_protocol_7BarData_11history = {"history", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_9_protocol_7BarData_11history, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7zipline_9_protocol_7BarData_10history};
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_11history(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_assets = 0;
  PyObject *__pyx_v_fields = 0;
  PyObject *__pyx_v_bar_count = 0;
  PyObject *__pyx_v_frequency = 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("history (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_assets,&__pyx_n_s_fields,&__pyx_n_s_bar_count,&__pyx_n_s_frequency,0};
  PyObject* values[4] = {0,0,0,0};
    if (__pyx_kwds) {
      Py_ssize_t kw_args;
      switch (__pyx_nargs) {
        case  4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        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_assets)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 542, __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_fields)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 542, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("history", 1, 4, 4, 1); __PYX_ERR(0, 542, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_bar_count)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[2]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 542, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("history", 1, 4, 4, 2); __PYX_ERR(0, 542, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_frequency)) != 0)) {
          (void)__Pyx_Arg_NewRef_FASTCALL(values[3]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 542, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("history", 1, 4, 4, 3); __PYX_ERR(0, 542, __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, "history") < 0)) __PYX_ERR(0, 542, __pyx_L3_error)
      }
    } else if (unlikely(__pyx_nargs != 4)) {
      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);
      values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
    }
    __pyx_v_assets = values[0];
    __pyx_v_fields = values[1];
    __pyx_v_bar_count = values[2];
    __pyx_v_frequency = values[3];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("history", 1, 4, 4, __pyx_nargs); __PYX_ERR(0, 542, __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._protocol.BarData.history", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7zipline_9_protocol_7BarData_10history(((struct __pyx_obj_7zipline_9_protocol_BarData *)__pyx_v_self), __pyx_v_assets, __pyx_v_fields, __pyx_v_bar_count, __pyx_v_frequency);
  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_9_protocol_7BarData_10history(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self, PyObject *__pyx_v_assets, PyObject *__pyx_v_fields, PyObject *__pyx_v_bar_count, PyObject *__pyx_v_frequency) {
  int __pyx_v_single_field;
  int __pyx_v_single_asset;
  PyObject *__pyx_v_asset_list = NULL;
  PyObject *__pyx_v_df = NULL;
  PyObject *__pyx_v_adjs = NULL;
  PyObject *__pyx_v_df_dict = NULL;
  PyObject *__pyx_v_dt_label = NULL;
  PyObject *__pyx_9genexpr10__pyx_v_field = NULL;
  PyObject *__pyx_9genexpr11__pyx_v_field = NULL;
  PyObject *__pyx_9genexpr12__pyx_v_field = NULL;
  PyObject *__pyx_9genexpr12__pyx_v_df = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceFrameInit(__pyx_codeobj__15)
  __Pyx_TraceCall("history", __pyx_f[0], 542, 0, __PYX_ERR(0, 542, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("zipline._protocol.BarData.history", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_asset_list);
  __Pyx_XDECREF(__pyx_v_df);
  __Pyx_XDECREF(__pyx_v_adjs);
  __Pyx_XDECREF(__pyx_v_df_dict);
  __Pyx_XDECREF(__pyx_v_dt_label);
  __Pyx_XDECREF(__pyx_9genexpr10__pyx_v_field);
  __Pyx_XDECREF(__pyx_9genexpr11__pyx_v_field);
  __Pyx_XDECREF(__pyx_9genexpr12__pyx_v_field);
  __Pyx_XDECREF(__pyx_9genexpr12__pyx_v_df);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__40 = PyTuple_Pack(16, __pyx_n_s_self, __pyx_n_s_assets, __pyx_n_s_fields, __pyx_n_s_bar_count, __pyx_n_s_frequency, __pyx_n_s_single_field, __pyx_n_s_single_asset, __pyx_n_s_asset_list, __pyx_n_s_df, __pyx_n_s_adjs, __pyx_n_s_df_dict, __pyx_n_s_dt_label, __pyx_n_s_field, __pyx_n_s_field, __pyx_n_s_field, __pyx_n_s_df); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);
/* … */
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_9_protocol_7BarData_11history, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_BarData_history, NULL, __pyx_n_s_zipline__protocol, __pyx_d, ((PyObject *)__pyx_codeobj__15)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_history, __pyx_t_4) < 0) __PYX_ERR(0, 542, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_7zipline_9_protocol_BarData);
  __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 16, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_zipline__protocol_pyx, __pyx_n_s_history, 542, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 542, __pyx_L1_error)
/* … */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_tuple__41)) __PYX_ERR(0, 542, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_7);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_7)) __PYX_ERR(0, 542, __pyx_L1_error);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7zipline_9_protocol_check_parameters), __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GetNameInClass(__pyx_t_3, (PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_history); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  __pyx_t_6 = 0;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
      __pyx_t_6 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3};
    __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 542, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_history, __pyx_t_4) < 0) __PYX_ERR(0, 542, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_7zipline_9_protocol_BarData);
  __pyx_tuple__41 = PyTuple_Pack(4, __pyx_n_u_assets, __pyx_n_u_fields, __pyx_n_u_bar_count, __pyx_n_u_frequency); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);
+543:                       ((Asset, ContinuousFuture, str),
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ContinuousFuture); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF((PyObject *)__pyx_ptype_7zipline_6assets_7_assets_Asset);
  __Pyx_GIVEREF((PyObject *)__pyx_ptype_7zipline_6assets_7_assets_Asset);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_ptype_7zipline_6assets_7_assets_Asset))) __PYX_ERR(0, 543, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_2);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2)) __PYX_ERR(0, 543, __pyx_L1_error);
  __Pyx_INCREF((PyObject *)(&PyUnicode_Type));
  __Pyx_GIVEREF((PyObject *)(&PyUnicode_Type));
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)(&PyUnicode_Type)))) __PYX_ERR(0, 543, __pyx_L1_error);
  __pyx_t_2 = 0;
/* … */
  __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_5);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5)) __PYX_ERR(0, 543, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_2);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2)) __PYX_ERR(0, 543, __pyx_L1_error);
  __Pyx_INCREF((PyObject *)(&PyInt_Type));
  __Pyx_GIVEREF((PyObject *)(&PyInt_Type));
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, ((PyObject *)(&PyInt_Type)))) __PYX_ERR(0, 543, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_3)) __PYX_ERR(0, 543, __pyx_L1_error);
  __pyx_t_5 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
+544:                        (str,),
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF((PyObject *)(&PyUnicode_Type));
  __Pyx_GIVEREF((PyObject *)(&PyUnicode_Type));
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyUnicode_Type)))) __PYX_ERR(0, 544, __pyx_L1_error);
 545:                        int,
+546:                        (str,)))
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF((PyObject *)(&PyUnicode_Type));
  __Pyx_GIVEREF((PyObject *)(&PyUnicode_Type));
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)(&PyUnicode_Type)))) __PYX_ERR(0, 546, __pyx_L1_error);
 547:     def history(self, assets, fields, bar_count, frequency):
 548:         """
 549:         Returns a trailing window of length ``bar_count`` with data for
 550:         the given assets, fields, and frequency, adjusted for splits, dividends,
 551:         and mergers as of the current simulation time.
 552: 
 553:         The semantics for missing data are identical to the ones described in
 554:         the notes for :meth:`current`.
 555: 
 556:         Parameters
 557:         ----------
 558:         assets: zipline.assets.Asset or iterable of zipline.assets.Asset
 559:             The asset(s) for which data is requested.
 560:         fields: string or iterable of string.
 561:             Requested data field(s). Valid field names are: "price",
 562:             "last_traded", "open", "high", "low", "close", and "volume".
 563:         bar_count: int
 564:             Number of data observations requested.
 565:         frequency: str
 566:             String indicating whether to load daily or minutely data
 567:             observations. Pass '1m' for minutely data, '1d' for daily data.
 568: 
 569:         Returns
 570:         -------
 571:         history : pd.Series or pd.DataFrame or pd.Panel
 572:             See notes below.
 573: 
 574:         Notes
 575:         -----
 576:         The return type of this function depends on the types of ``assets`` and
 577:         ``fields``:
 578: 
 579:         - If a single asset and a single field are requested, the returned
 580:           value is a :class:`pd.Series` of length ``bar_count`` whose index is
 581:           :class:`pd.DatetimeIndex`.
 582: 
 583:         - If a single asset and multiple fields are requested, the returned
 584:           value is a :class:`pd.DataFrame` with shape
 585:           ``(bar_count, len(fields))``. The frame's index will be a
 586:           :class:`pd.DatetimeIndex`, and its columns will be ``fields``.
 587: 
 588:         - If multiple assets and a single field are requested, the returned
 589:           value is a :class:`pd.DataFrame` with shape
 590:           ``(bar_count, len(assets))``. The frame's index will be a
 591:           :class:`pd.DatetimeIndex`, and its columns will be ``assets``.
 592: 
 593:         - If multiple assets and multiple fields are requested, the returned
 594:           value is a :class:`pd.DataFrame` with a pd.MultiIndex containing pairs of
 595:            :class:`pd.DatetimeIndex`, and ``assets``, while the columns while contain the field(s).
 596:            It has shape``(bar_count * len(assets), len(fields))``. The names of the pd.MultiIndex are
 597:             - ``date`` if frequency == '1d'`` or ``date_time`` if frequency == '1m``, and
 598:             - ``asset``
 599: 
 600:         If the current simulation time is not a valid market time, we use the last market close instead.
 601:         """
 602: 
+603:         single_field = isinstance(fields, str)
  __pyx_t_1 = PyUnicode_Check(__pyx_v_fields); 
  __pyx_v_single_field = __pyx_t_1;
 604: 
+605:         single_asset = isinstance(assets, PricingDataAssociable)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_PricingDataAssociable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 605, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_IsInstance(__pyx_v_assets, __pyx_t_2); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 605, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_single_asset = __pyx_t_1;
+606:         if single_asset:
  if (__pyx_v_single_asset) {
/* … */
    goto __pyx_L3;
  }
+607:             asset_list = [assets]
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 607, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_assets);
    __Pyx_GIVEREF(__pyx_v_assets);
    if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_assets)) __PYX_ERR(0, 607, __pyx_L1_error);
    __pyx_v_asset_list = __pyx_t_2;
    __pyx_t_2 = 0;
 608:         else:
+609:             asset_list = assets
  /*else*/ {
    __Pyx_INCREF(__pyx_v_assets);
    __pyx_v_asset_list = __pyx_v_assets;
  }
  __pyx_L3:;
 610: 
+611:         if single_field:  # for one or more assets:
  if (__pyx_v_single_field) {
/* … */
  }
+612:             df = self.data_portal.get_history_window(
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_get_history_window); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 612, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
 613:                 asset_list,
+614:                 self._get_current_minute(),
    __pyx_t_4 = ((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_get_current_minute(__pyx_v_self); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 614, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
 615:                 bar_count,
 616:                 frequency,
 617:                 fields,
+618:                 self.data_frequency,
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    #if CYTHON_UNPACK_METHODS
    if (likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_6 = 1;
      }
    }
    #endif
    {
      PyObject *__pyx_callargs[7] = {__pyx_t_5, __pyx_v_asset_list, __pyx_t_4, __pyx_v_bar_count, __pyx_v_frequency, __pyx_v_fields, __pyx_v_self->data_frequency};
      __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 6+__pyx_t_6);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 612, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __pyx_v_df = __pyx_t_2;
    __pyx_t_2 = 0;
 619:             )
 620: 
+621:             if self._adjust_minutes:
    __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->_adjust_minutes)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 621, __pyx_L1_error)
    if (__pyx_t_1) {
/* … */
    }
+622:                 adjs = self.data_portal.get_adjustments(
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_get_adjustments); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 622, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
 623:                     asset_list,
 624:                     fields,
+625:                     self._get_current_minute(),
      __pyx_t_4 = ((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_get_current_minute(__pyx_v_self); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 625, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
+626:                     self.simulation_dt_func()
      __Pyx_INCREF(__pyx_v_self->simulation_dt_func);
      __pyx_t_7 = __pyx_v_self->simulation_dt_func; __pyx_t_8 = NULL;
      __pyx_t_6 = 0;
      #if CYTHON_UNPACK_METHODS
      if (likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_6 = 1;
        }
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
        __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6);
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 626, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __pyx_t_7 = NULL;
      __pyx_t_6 = 0;
      #if CYTHON_UNPACK_METHODS
      if (likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_6 = 1;
        }
      }
      #endif
      {
        PyObject *__pyx_callargs[5] = {__pyx_t_7, __pyx_v_asset_list, __pyx_v_fields, __pyx_t_4, __pyx_t_5};
        __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 4+__pyx_t_6);
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 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, 622, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __pyx_v_adjs = __pyx_t_2;
      __pyx_t_2 = 0;
 627:                 )
 628: 
+629:                 df = df * adjs
      __pyx_t_2 = PyNumber_Multiply(__pyx_v_df, __pyx_v_adjs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 629, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF_SET(__pyx_v_df, __pyx_t_2);
      __pyx_t_2 = 0;
 630: 
+631:             if single_asset:
    if (__pyx_v_single_asset) {
/* … */
    }
 632:                 # single asset, single field: return pd.Series with pd.DateTimeIndex
+633:                 return df.loc[:, assets]
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_loc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 633, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_slice__16);
      __Pyx_GIVEREF(__pyx_slice__16);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_slice__16)) __PYX_ERR(0, 633, __pyx_L1_error);
      __Pyx_INCREF(__pyx_v_assets);
      __Pyx_GIVEREF(__pyx_v_assets);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_assets)) __PYX_ERR(0, 633, __pyx_L1_error);
      __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 633, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_5;
      __pyx_t_5 = 0;
      goto __pyx_L0;
/* … */
  __pyx_slice__16 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__16)) __PYX_ERR(0, 633, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__16);
  __Pyx_GIVEREF(__pyx_slice__16);
 634:             else:
 635:                 # multiple assets, single field: return DataFrame with pd.DateTimeIndex
 636:                 # and assets in columns.
+637:                 return df
    /*else*/ {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_df);
      __pyx_r = __pyx_v_df;
      goto __pyx_L0;
    }
 638:         else:  # multiple fields
 639:             # if single_asset:
 640:             # todo: optimize by querying multiple fields
 641:             # Make multiple history calls, one per field, then combine results
 642: 
+643:             df_dict = {
  /*else*/ {
    { /* enter inner scope */
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 643, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_5);
+644:                 field: self.data_portal.get_history_window(asset_list,
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_get_history_window); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 644, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_4);
+645:                                                            self._get_current_minute(),
        __pyx_t_7 = ((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_get_current_minute(__pyx_v_self); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 645, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_7);
 646:                                                            bar_count,
 647:                                                            frequency,
 648:                                                            field,
+649:                                                            self.data_frequency,
        __pyx_t_8 = NULL;
        __pyx_t_6 = 0;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_8)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
            __pyx_t_6 = 1;
          }
        }
        #endif
        {
          PyObject *__pyx_callargs[7] = {__pyx_t_8, __pyx_v_asset_list, __pyx_t_7, __pyx_v_bar_count, __pyx_v_frequency, __pyx_9genexpr10__pyx_v_field, __pyx_v_self->data_frequency};
          __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 6+__pyx_t_6);
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 644, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
+650:                                                            ).loc[:, asset_list]
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_loc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 650, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 650, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_slice__16);
        __Pyx_GIVEREF(__pyx_slice__16);
        if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_slice__16)) __PYX_ERR(0, 650, __pyx_L9_error);
        __Pyx_INCREF(__pyx_v_asset_list);
        __Pyx_GIVEREF(__pyx_v_asset_list);
        if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_asset_list)) __PYX_ERR(0, 650, __pyx_L9_error);
        __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 650, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(PyDict_SetItem(__pyx_t_5, (PyObject*)__pyx_9genexpr10__pyx_v_field, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 644, __pyx_L9_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+651:                 for field in fields
      if (likely(PyList_CheckExact(__pyx_v_fields)) || PyTuple_CheckExact(__pyx_v_fields)) {
        __pyx_t_3 = __pyx_v_fields; __Pyx_INCREF(__pyx_t_3);
        __pyx_t_9 = 0;
        __pyx_t_10 = NULL;
      } else {
        __pyx_t_9 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_fields); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 651, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 651, __pyx_L9_error)
      }
      for (;;) {
        if (likely(!__pyx_t_10)) {
          if (likely(PyList_CheckExact(__pyx_t_3))) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3);
              #if !CYTHON_ASSUME_SAFE_MACROS
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 651, __pyx_L9_error)
              #endif
              if (__pyx_t_9 >= __pyx_temp) break;
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 651, __pyx_L9_error)
            #else
            __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 651, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_2);
            #endif
          } else {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3);
              #if !CYTHON_ASSUME_SAFE_MACROS
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 651, __pyx_L9_error)
              #endif
              if (__pyx_t_9 >= __pyx_temp) break;
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 651, __pyx_L9_error)
            #else
            __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 651, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_2);
            #endif
          }
        } else {
          __pyx_t_2 = __pyx_t_10(__pyx_t_3);
          if (unlikely(!__pyx_t_2)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(0, 651, __pyx_L9_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_XDECREF_SET(__pyx_9genexpr10__pyx_v_field, __pyx_t_2);
        __pyx_t_2 = 0;
/* … */
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_9genexpr10__pyx_v_field); __pyx_9genexpr10__pyx_v_field = 0;
      goto __pyx_L13_exit_scope;
      __pyx_L9_error:;
      __Pyx_XDECREF(__pyx_9genexpr10__pyx_v_field); __pyx_9genexpr10__pyx_v_field = 0;
      goto __pyx_L1_error;
      __pyx_L13_exit_scope:;
    } /* exit inner scope */
    __pyx_v_df_dict = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;
 652:             }
 653: 
+654:             if self._adjust_minutes:
    __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->_adjust_minutes)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 654, __pyx_L1_error)
    if (__pyx_t_1) {
/* … */
    }
+655:                 adjs = {
      { /* enter inner scope */
        __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 655, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_5);
+656:                     field: self.data_portal.get_adjustments(
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_get_adjustments); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 656, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
 657:                         assets,
 658:                         field,
+659:                         self._get_current_minute(),
          __pyx_t_4 = ((struct __pyx_vtabstruct_7zipline_9_protocol_BarData *)__pyx_v_self->__pyx_vtab)->_get_current_minute(__pyx_v_self); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 659, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_4);
+660:                         self.simulation_dt_func()
          __Pyx_INCREF(__pyx_v_self->simulation_dt_func);
          __pyx_t_11 = __pyx_v_self->simulation_dt_func; __pyx_t_12 = NULL;
          __pyx_t_6 = 0;
          #if CYTHON_UNPACK_METHODS
          if (likely(PyMethod_Check(__pyx_t_11))) {
            __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
            if (likely(__pyx_t_12)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
              __Pyx_INCREF(__pyx_t_12);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_11, function);
              __pyx_t_6 = 1;
            }
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL};
            __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6);
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 660, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          }
          __pyx_t_11 = NULL;
          __pyx_t_6 = 0;
          #if CYTHON_UNPACK_METHODS
          if (likely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_2);
            if (likely(__pyx_t_11)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_11);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_2, function);
              __pyx_t_6 = 1;
            }
          }
          #endif
          {
            PyObject *__pyx_callargs[5] = {__pyx_t_11, __pyx_v_assets, __pyx_9genexpr11__pyx_v_field, __pyx_t_4, __pyx_t_8};
            __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 4+__pyx_t_6);
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 656, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          }
+661:                     )[0] for field in fields
        if (likely(PyList_CheckExact(__pyx_v_fields)) || PyTuple_CheckExact(__pyx_v_fields)) {
          __pyx_t_3 = __pyx_v_fields; __Pyx_INCREF(__pyx_t_3);
          __pyx_t_9 = 0;
          __pyx_t_10 = NULL;
        } else {
          __pyx_t_9 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_fields); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 661, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 661, __pyx_L17_error)
        }
        for (;;) {
          if (likely(!__pyx_t_10)) {
            if (likely(PyList_CheckExact(__pyx_t_3))) {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3);
                #if !CYTHON_ASSUME_SAFE_MACROS
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 661, __pyx_L17_error)
                #endif
                if (__pyx_t_9 >= __pyx_temp) break;
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_7 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_7); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 661, __pyx_L17_error)
              #else
              __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 661, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_7);
              #endif
            } else {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3);
                #if !CYTHON_ASSUME_SAFE_MACROS
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 661, __pyx_L17_error)
                #endif
                if (__pyx_t_9 >= __pyx_temp) break;
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_7); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 661, __pyx_L17_error)
              #else
              __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 661, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_7);
              #endif
            }
          } else {
            __pyx_t_7 = __pyx_t_10(__pyx_t_3);
            if (unlikely(!__pyx_t_7)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 661, __pyx_L17_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_7);
          }
          __Pyx_XDECREF_SET(__pyx_9genexpr11__pyx_v_field, __pyx_t_7);
          __pyx_t_7 = 0;
/* … */
          __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_7, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 661, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(PyDict_SetItem(__pyx_t_5, (PyObject*)__pyx_9genexpr11__pyx_v_field, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 656, __pyx_L17_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_9genexpr11__pyx_v_field); __pyx_9genexpr11__pyx_v_field = 0;
        goto __pyx_L21_exit_scope;
        __pyx_L17_error:;
        __Pyx_XDECREF(__pyx_9genexpr11__pyx_v_field); __pyx_9genexpr11__pyx_v_field = 0;
        goto __pyx_L1_error;
        __pyx_L21_exit_scope:;
      } /* exit inner scope */
      __pyx_v_adjs = __pyx_t_5;
      __pyx_t_5 = 0;
 662:                 }
 663: 
+664:                 df_dict = {field: df * adjs[field]
      { /* enter inner scope */
        __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 664, __pyx_L24_error)
        __Pyx_GOTREF(__pyx_t_5);
/* … */
          __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_v_adjs, __pyx_9genexpr12__pyx_v_field); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 664, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_2 = PyNumber_Multiply(__pyx_9genexpr12__pyx_v_df, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 664, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(PyDict_SetItem(__pyx_t_5, (PyObject*)__pyx_9genexpr12__pyx_v_field, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 664, __pyx_L24_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_9genexpr12__pyx_v_df); __pyx_9genexpr12__pyx_v_df = 0;
        __Pyx_XDECREF(__pyx_9genexpr12__pyx_v_field); __pyx_9genexpr12__pyx_v_field = 0;
        goto __pyx_L27_exit_scope;
        __pyx_L24_error:;
        __Pyx_XDECREF(__pyx_9genexpr12__pyx_v_df); __pyx_9genexpr12__pyx_v_df = 0;
        __Pyx_XDECREF(__pyx_9genexpr12__pyx_v_field); __pyx_9genexpr12__pyx_v_field = 0;
        goto __pyx_L1_error;
        __pyx_L27_exit_scope:;
      } /* exit inner scope */
      __Pyx_DECREF_SET(__pyx_v_df_dict, ((PyObject*)__pyx_t_5));
      __pyx_t_5 = 0;
+665:                            for field, df in df_dict.items()}
        __pyx_t_9 = 0;
        __pyx_t_2 = __Pyx_dict_iterator(__pyx_v_df_dict, 1, __pyx_n_s_items, (&__pyx_t_13), (&__pyx_t_14)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 665, __pyx_L24_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_XDECREF(__pyx_t_3);
        __pyx_t_3 = __pyx_t_2;
        __pyx_t_2 = 0;
        while (1) {
          __pyx_t_15 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_13, &__pyx_t_9, &__pyx_t_2, &__pyx_t_7, NULL, __pyx_t_14);
          if (unlikely(__pyx_t_15 == 0)) break;
          if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 665, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_XDECREF_SET(__pyx_9genexpr12__pyx_v_field, __pyx_t_2);
          __pyx_t_2 = 0;
          __Pyx_XDECREF_SET(__pyx_9genexpr12__pyx_v_df, __pyx_t_7);
          __pyx_t_7 = 0;
 666: 
+667:             dt_label = 'date' if frequency == '1d' else 'date_time'
    __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_frequency, __pyx_kp_u_1d, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 667, __pyx_L1_error)
    if (__pyx_t_1) {
      __Pyx_INCREF(__pyx_n_u_date);
      __pyx_t_5 = __pyx_n_u_date;
    } else {
      __Pyx_INCREF(__pyx_n_u_date_time);
      __pyx_t_5 = __pyx_n_u_date_time;
    }
    __pyx_v_dt_label = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;
+668:             df = (pd.concat(df_dict,
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pd); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 668, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_concat); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 668, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 668, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_df_dict);
    __Pyx_GIVEREF(__pyx_v_df_dict);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_df_dict)) __PYX_ERR(0, 668, __pyx_L1_error);
/* … */
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 668, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+669:                             keys=df_dict.keys(),
    __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 669, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyDict_Keys(__pyx_v_df_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 669, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keys, __pyx_t_7) < 0) __PYX_ERR(0, 669, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+670:                             names=['fields', dt_label])
    __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 670, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_n_u_fields);
    __Pyx_GIVEREF(__pyx_n_u_fields);
    if (__Pyx_PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_u_fields)) __PYX_ERR(0, 670, __pyx_L1_error);
    __Pyx_INCREF(__pyx_v_dt_label);
    __Pyx_GIVEREF(__pyx_v_dt_label);
    if (__Pyx_PyList_SET_ITEM(__pyx_t_7, 1, __pyx_v_dt_label)) __PYX_ERR(0, 670, __pyx_L1_error);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_names, __pyx_t_7) < 0) __PYX_ERR(0, 669, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+671:                   .stack(dropna=False)  # ensure we return all fields/assets/dates despite missing values
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_stack); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 671, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 671, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dropna, Py_False) < 0) __PYX_ERR(0, 671, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 671, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+672:                   .unstack(level='fields'))
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_unstack); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 672, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 672, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_level, __pyx_n_u_fields) < 0) __PYX_ERR(0, 672, __pyx_L1_error)
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 672, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_df = __pyx_t_2;
    __pyx_t_2 = 0;
+673:             df.index.set_names([dt_label, 'asset'])
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_index); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 673, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_set_names); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 673, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 673, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_dt_label);
    __Pyx_GIVEREF(__pyx_v_dt_label);
    if (__Pyx_PyList_SET_ITEM(__pyx_t_5, 0, __pyx_v_dt_label)) __PYX_ERR(0, 673, __pyx_L1_error);
    __Pyx_INCREF(__pyx_n_u_asset);
    __Pyx_GIVEREF(__pyx_n_u_asset);
    if (__Pyx_PyList_SET_ITEM(__pyx_t_5, 1, __pyx_n_u_asset)) __PYX_ERR(0, 673, __pyx_L1_error);
    __pyx_t_3 = NULL;
    __pyx_t_6 = 0;
    #if CYTHON_UNPACK_METHODS
    if (likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_6 = 1;
      }
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_5};
      __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 673, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+674:             return df.sort_index()
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_sort_index); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 674, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    #if CYTHON_UNPACK_METHODS
    if (likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_6 = 1;
      }
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
      __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 674, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }
 675: 
 676:     property current_dt:
+677:         def __get__(self):
/* Python wrapper */
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_10current_dt_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_10current_dt_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_9_protocol_7BarData_10current_dt___get__(((struct __pyx_obj_7zipline_9_protocol_BarData *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7zipline_9_protocol_7BarData_10current_dt___get__(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("__get__", __pyx_f[0], 677, 0, __PYX_ERR(0, 677, __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_AddTraceback("zipline._protocol.BarData.current_dt.__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;
}
+678:             return self.simulation_dt_func()
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->simulation_dt_func);
  __pyx_t_2 = __pyx_v_self->simulation_dt_func; __pyx_t_3 = NULL;
  __pyx_t_4 = 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_4 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 678, __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;
 679: 
+680:     @property
/* Python wrapper */
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_14fetcher_assets_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_14fetcher_assets_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_9_protocol_7BarData_14fetcher_assets___get__(((struct __pyx_obj_7zipline_9_protocol_BarData *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7zipline_9_protocol_7BarData_14fetcher_assets___get__(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("__get__", __pyx_f[0], 680, 0, __PYX_ERR(0, 680, __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_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("zipline._protocol.BarData.fetcher_assets.__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;
}
 681:     def fetcher_assets(self):
+682:         return self.data_portal.get_fetcher_assets(self.simulation_dt_func())
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->data_portal, __pyx_n_s_get_fetcher_assets); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->simulation_dt_func);
  __pyx_t_4 = __pyx_v_self->simulation_dt_func; __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  #if CYTHON_UNPACK_METHODS
  if (likely(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, NULL};
    __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_t_4 = NULL;
  __pyx_t_6 = 0;
  #if CYTHON_UNPACK_METHODS
  if (likely(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_6 = 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_6, 1+__pyx_t_6);
    __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, 682, __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;
 683: 
 684:     property _handle_non_market_minutes:
+685:         def __set__(self, val):
/* Python wrapper */
static int __pyx_pw_7zipline_9_protocol_7BarData_26_handle_non_market_minutes_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
static int __pyx_pw_7zipline_9_protocol_7BarData_26_handle_non_market_minutes_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
  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_9_protocol_7BarData_26_handle_non_market_minutes___set__(((struct __pyx_obj_7zipline_9_protocol_BarData *)__pyx_v_self), ((PyObject *)__pyx_v_val));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_7zipline_9_protocol_7BarData_26_handle_non_market_minutes___set__(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self, PyObject *__pyx_v_val) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("__set__", __pyx_f[0], 685, 0, __PYX_ERR(0, 685, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("zipline._protocol.BarData._handle_non_market_minutes.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
+686:             self._adjust_minutes = val
  if (!(likely(((__pyx_v_val) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_val, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(0, 686, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_val;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF((PyObject *)__pyx_v_self->_adjust_minutes);
  __Pyx_DECREF((PyObject *)__pyx_v_self->_adjust_minutes);
  __pyx_v_self->_adjust_minutes = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 687: 
 688:     property current_session:
+689:         def __get__(self):
/* Python wrapper */
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_15current_session_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_15current_session_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_9_protocol_7BarData_15current_session___get__(((struct __pyx_obj_7zipline_9_protocol_BarData *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7zipline_9_protocol_7BarData_15current_session___get__(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("__get__", __pyx_f[0], 689, 0, __PYX_ERR(0, 689, __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._protocol.BarData.current_session.__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;
}
+690:             return self._trading_calendar.minute_to_session_label(
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_trading_calendar, __pyx_n_s_minute_to_session_label); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 690, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
/* … */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 690, __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, 690, __pyx_L1_error);
  __pyx_t_2 = 0;
/* … */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 690, __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;
+691:                 self.simulation_dt_func(),
  __Pyx_INCREF(__pyx_v_self->simulation_dt_func);
  __pyx_t_3 = __pyx_v_self->simulation_dt_func; __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  #if CYTHON_UNPACK_METHODS
  if (likely(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, 691, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
+692:                 direction="next"
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 692, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_direction, __pyx_n_u_next) < 0) __PYX_ERR(0, 692, __pyx_L1_error)
 693:             )
 694: 
 695:     property current_session_minutes:
+696:         def __get__(self):
/* Python wrapper */
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_23current_session_minutes_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_23current_session_minutes_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_9_protocol_7BarData_23current_session_minutes___get__(((struct __pyx_obj_7zipline_9_protocol_BarData *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7zipline_9_protocol_7BarData_23current_session_minutes___get__(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("__get__", __pyx_f[0], 696, 0, __PYX_ERR(0, 696, __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._protocol.BarData.current_session_minutes.__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;
}
+697:             return self._trading_calendar.minutes_for_session(
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_trading_calendar, __pyx_n_s_minutes_for_session); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 697, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
+698:                 self.current_session
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_current_session); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 698, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  #if CYTHON_UNPACK_METHODS
  if (likely(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, 697, __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;
 699:             )
+700:     @property
/* Python wrapper */
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_12_data_portal_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7zipline_9_protocol_7BarData_12_data_portal_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_9_protocol_7BarData_12_data_portal___get__(((struct __pyx_obj_7zipline_9_protocol_BarData *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7zipline_9_protocol_7BarData_12_data_portal___get__(struct __pyx_obj_7zipline_9_protocol_BarData *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("__get__", __pyx_f[0], 700, 0, __PYX_ERR(0, 700, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("zipline._protocol.BarData._data_portal.__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;
}
 701:     def _data_portal(self, ):
+702:         return self.data_portal
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->data_portal);
  __pyx_r = __pyx_v_self->data_portal;
  goto __pyx_L0;
 703: 
 704: cdef class InnerPosition:
 705:     """The real values of a position.
 706: 
 707:     This exists to be owned by both a
 708:     :class:`zipline.finance.position.Position` and a
 709:     :class:`zipline.protocol.Position` at the same time without a cycle.
 710:     """
+711:     def __init__(self,
/* Python wrapper */
static int __pyx_pw_7zipline_9_protocol_13InnerPosition_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_7zipline_9_protocol_13InnerPosition_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_asset = 0;
  PyObject *__pyx_v_amount = 0;
  PyObject *__pyx_v_cost_basis = 0;
  PyObject *__pyx_v_last_sale_price = 0;
  PyObject *__pyx_v_last_sale_date = 0;
  PyObject *__pyx_v_last_open_price = 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_asset,&__pyx_n_s_amount,&__pyx_n_s_cost_basis,&__pyx_n_s_last_sale_price,&__pyx_n_s_last_sale_date,&__pyx_n_s_last_open_price,0};
  PyObject* values[6] = {0,0,0,0,0,0};
    values[1] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)__pyx_int_0));
    values[2] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)__pyx_float_0_0));
    values[3] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)__pyx_float_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_9_protocol_13InnerPosition___init__(struct __pyx_obj_7zipline_9_protocol_InnerPosition *__pyx_v_self, PyObject *__pyx_v_asset, PyObject *__pyx_v_amount, PyObject *__pyx_v_cost_basis, PyObject *__pyx_v_last_sale_price, PyObject *__pyx_v_last_sale_date, PyObject *__pyx_v_last_open_price) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("__init__", __pyx_f[0], 711, 0, __PYX_ERR(0, 711, __pyx_L1_error));
/* … */
  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("zipline._protocol.InnerPosition.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 712:                  asset,
 713:                  amount=0,
 714:                  cost_basis=0.0,
 715:                  last_sale_price=0.0,
+716:                  last_sale_date=None,
    values[4] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)Py_None));
    values[5] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)__pyx_float_0_0));
    if (__pyx_kwds) {
      Py_ssize_t kw_args;
      switch (__pyx_nargs) {
        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_asset)) != 0)) {
          (void)__Pyx_Arg_NewRef_VARARGS(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 711, __pyx_L3_error)
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_amount);
          if (value) { values[1] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; }
          else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 711, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_cost_basis);
          if (value) { values[2] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; }
          else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 711, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_last_sale_price);
          if (value) { values[3] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; }
          else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 711, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_last_sale_date);
          if (value) { values[4] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; }
          else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 711, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_last_open_price);
          if (value) { values[5] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; }
          else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 711, __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, 711, __pyx_L3_error)
      }
    } else {
      switch (__pyx_nargs) {
        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);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_asset = values[0];
    __pyx_v_amount = values[1];
    __pyx_v_cost_basis = values[2];
    __pyx_v_last_sale_price = values[3];
    __pyx_v_last_sale_date = values[4];
    __pyx_v_last_open_price = values[5];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 6, __pyx_nargs); __PYX_ERR(0, 711, __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._protocol.InnerPosition.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_7zipline_9_protocol_13InnerPosition___init__(((struct __pyx_obj_7zipline_9_protocol_InnerPosition *)__pyx_v_self), __pyx_v_asset, __pyx_v_amount, __pyx_v_cost_basis, __pyx_v_last_sale_price, __pyx_v_last_sale_date, __pyx_v_last_open_price);
 717:                  last_open_price=0.0
 718:                  ):
+719:         self.asset = asset
  if (!(likely(((__pyx_v_asset) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_asset, __pyx_ptype_7zipline_6assets_7_assets_Asset))))) __PYX_ERR(0, 719, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_asset;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF((PyObject *)__pyx_v_self->asset);
  __Pyx_DECREF((PyObject *)__pyx_v_self->asset);
  __pyx_v_self->asset = ((struct __pyx_obj_7zipline_6assets_7_assets_Asset *)__pyx_t_1);
  __pyx_t_1 = 0;
+720:         self.amount = amount
  __pyx_t_2 = __Pyx_PyInt_As_npy_int64(__pyx_v_amount); if (unlikely((__pyx_t_2 == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 720, __pyx_L1_error)
  __pyx_v_self->amount = __pyx_t_2;
+721:         self.cost_basis = cost_basis  # per share
  __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_v_cost_basis); if (unlikely((__pyx_t_3 == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 721, __pyx_L1_error)
  __pyx_v_self->cost_basis = __pyx_t_3;
+722:         self.last_sale_price = last_sale_price
  __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_v_last_sale_price); if (unlikely((__pyx_t_3 == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 722, __pyx_L1_error)
  __pyx_v_self->last_sale_price = __pyx_t_3;
+723:         self.last_sale_date = last_sale_date
  __Pyx_INCREF(__pyx_v_last_sale_date);
  __Pyx_GIVEREF(__pyx_v_last_sale_date);
  __Pyx_GOTREF(__pyx_v_self->last_sale_date);
  __Pyx_DECREF(__pyx_v_self->last_sale_date);
  __pyx_v_self->last_sale_date = __pyx_v_last_sale_date;
 724: 
 725:         # !346 #113 for current bar backtesting
 726:         # In order to calculate the initial value of stock.(`portfolio.start_portfolio_value`)
+727:         self.last_open_price = last_open_price
  __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_v_last_open_price); if (unlikely((__pyx_t_3 == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 727, __pyx_L1_error)
  __pyx_v_self->last_open_price = __pyx_t_3;
 728: 
 729: 
+730:     def __repr__(self):
/* Python wrapper */
static PyObject *__pyx_pw_7zipline_9_protocol_13InnerPosition_3__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_7zipline_9_protocol_13InnerPosition_3__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_9_protocol_13InnerPosition_2__repr__(((struct __pyx_obj_7zipline_9_protocol_InnerPosition *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_7zipline_9_protocol_13InnerPosition_2__repr__(struct __pyx_obj_7zipline_9_protocol_InnerPosition *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("__repr__", __pyx_f[0], 730, 0, __PYX_ERR(0, 730, __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._protocol.InnerPosition.__repr__", __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;
}
+731:         return (
  __Pyx_XDECREF(__pyx_r);
+732:                 '%s(asset=%r, amount=%r, cost_basis=%r,'
  __pyx_t_1 = PyTuple_New(14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 732, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = 0;
  __pyx_t_3 = 127;
/* … */
  __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_1, 14, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 732, __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;
 733:                 ' last_sale_price=%r, last_sale_date=%r, last_open_price=%r)' % (
+734:                     type(self).__name__,
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))), __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 734, __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, 734, __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_asset_2);
  __pyx_t_2 += 7;
  __Pyx_GIVEREF(__pyx_kp_u_asset_2);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u_asset_2);
+735:                     self.asset,
  __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(((PyObject *)__pyx_v_self->asset)), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 735, __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, 2, __pyx_t_5);
  __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_kp_u_amount_2);
  __pyx_t_2 += 9;
  __Pyx_GIVEREF(__pyx_kp_u_amount_2);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_kp_u_amount_2);
+736:                     self.amount,
  __pyx_t_5 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->amount); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 736, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_5), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 736, __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, 4, __pyx_t_4);
  __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_kp_u_cost_basis_2);
  __pyx_t_2 += 13;
  __Pyx_GIVEREF(__pyx_kp_u_cost_basis_2);
  PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_kp_u_cost_basis_2);
+737:                     self.cost_basis,
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->cost_basis); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 737, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_4), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 737, __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, 6, __pyx_t_5);
  __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_kp_u_last_sale_price_2);
  __pyx_t_2 += 18;
  __Pyx_GIVEREF(__pyx_kp_u_last_sale_price_2);
  PyTuple_SET_ITEM(__pyx_t_1, 7, __pyx_kp_u_last_sale_price_2);
+738:                     self.last_sale_price,
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_self->last_sale_price); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 738, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_5), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 738, __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, 8, __pyx_t_4);
  __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_kp_u_last_sale_date_2);
  __pyx_t_2 += 17;
  __Pyx_GIVEREF(__pyx_kp_u_last_sale_date_2);
  PyTuple_SET_ITEM(__pyx_t_1, 9, __pyx_kp_u_last_sale_date_2);
+739:                     self.last_sale_date,
  __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_self->last_sale_date), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 739, __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_last_open_price_2);
  __pyx_t_2 += 18;
  __Pyx_GIVEREF(__pyx_kp_u_last_open_price_2);
  PyTuple_SET_ITEM(__pyx_t_1, 11, __pyx_kp_u_last_open_price_2);
+740:                     self.last_open_price,
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->last_open_price); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 740, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_4), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 740, __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, 12, __pyx_t_5);
  __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_kp_u__19);
  __pyx_t_2 += 1;
  __Pyx_GIVEREF(__pyx_kp_u__19);
  PyTuple_SET_ITEM(__pyx_t_1, 13, __pyx_kp_u__19);
 741:                 )
 742:         )