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.zipline_warnings import ZiplineDeprecationWarning
  __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_ZiplineDeprecationWarning);
  __Pyx_GIVEREF(__pyx_n_s_ZiplineDeprecationWarning);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_ZiplineDeprecationWarning)) __PYX_ERR(0, 29, __pyx_L1_error);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_zipline_zipline_warnings, __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_ZiplineDeprecationWarning); 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_ZiplineDeprecationWarning, __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: 
+031: 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], 31, 0, __PYX_ERR(0, 31, __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;
}
+032:     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, 32, __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, 32, __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, 32, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) __PYX_ERR(0, 32, __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, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) __PYX_ERR(0, 32, __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;
 033: 
+034: cdef class check_parameters:
struct __pyx_obj_7zipline_9_protocol_check_parameters {
  PyObject_HEAD
  PyObject *keyword_names;
  PyObject *types;
  PyObject *keys_to_types;
};

 035:     """
 036:     Asserts that the keywords passed into the wrapped function are included
 037:     in those passed into this decorator. If not, raise a TypeError with a
 038:     meaningful message, unlike the one Cython returns by default.
 039: 
 040:     Also asserts that the arguments passed into the wrapped function are
 041:     consistent with the types passed into this decorator. If not, raise a
 042:     TypeError with a meaningful message.
 043:     """
 044:     cdef tuple keyword_names
 045:     cdef tuple types
 046:     cdef dict keys_to_types
 047: 
+048:     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, 48, __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, 48, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 48, __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, 48, __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, 48, __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], 48, 0, __PYX_ERR(0, 48, __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;
}
+049:         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, 49, __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;
+050:         self.types = types
  if (!(likely(PyTuple_CheckExact(__pyx_v_types))||((__pyx_v_types) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_v_types))) __PYX_ERR(0, 50, __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;
 051: 
+052:         self.keys_to_types = dict(zip(keyword_names, types))
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __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, 52, __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, 52, __pyx_L1_error);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 52, __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, 52, __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;
 053: 
+054:     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, 54, __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, 54, __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, 54, __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, 54, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __Pyx_TraceCall("__call__", __pyx_f[0], 54, 0, __PYX_ERR(0, 54, __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;
};

+055:         @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], 55, 0, __PYX_ERR(0, 55, __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, 55, __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, 55, __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, 55, __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, 55, __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, 55, __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, 55, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 55, __pyx_L1_error)
 056:         def assert_keywords_and_call(*args, **kwargs):
 057:             cdef short i
 058: 
 059:             # verify all the keyword arguments
+060:             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, 60, __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, 60, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XDECREF_SET(__pyx_v_field, __pyx_t_5);
    __pyx_t_5 = 0;
+061:                 if field not in self.keyword_names:
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 61, __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, 61, __pyx_L1_error)
    if (unlikely(__pyx_t_7)) {
/* … */
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+062:                     raise TypeError("%s() got an unexpected keyword argument"
      __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 62, __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, 62, __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, 62, __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, 62, __pyx_L1_error)
+063:                                     " '%s'" % (func.__name__, field))
      if (unlikely(!__pyx_cur_scope->__pyx_v_func)) { __Pyx_RaiseClosureNameError("func"); __PYX_ERR(0, 63, __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, 63, __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, 63, __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, 63, __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);
 064: 
 065:             # verify type of each argument
+066:             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, 66, __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, 66, __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, 66, __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, 66, __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;
+067:                 expected_type = self.types[i]
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 67, __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, 67, __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, 67, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_expected_type, __pyx_t_1);
    __pyx_t_1 = 0;
 068: 
+069:                 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, 69, __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, 69, __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) {
/* … */
    }
+070:                     if len(arg) == 0:
      __pyx_t_2 = PyObject_Length(__pyx_v_arg); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 70, __pyx_L1_error)
      __pyx_t_7 = (__pyx_t_2 == 0);
      if (__pyx_t_7) {
/* … */
      }
+071:                         continue
        goto __pyx_L6_continue;
+072:                     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, 72, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_1);
      __pyx_t_1 = 0;
 073: 
+074:                 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, 74, __pyx_L1_error)
    __pyx_t_13 = (!__pyx_t_7);
    if (unlikely(__pyx_t_13)) {
/* … */
    }
+075:                     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, 75, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_1 = __pyx_t_11;
        __pyx_t_11 = 0;
      } else {
+076:                         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, 76, __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, 76, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_7 = (!__pyx_t_13);
      if (__pyx_t_7) {
+077:                         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, 77, __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, 77, __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, 77, __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, 77, __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, 77, __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, 77, __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, 77, __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, 77, __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, 77, __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, 77, __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, 77, __pyx_L15_error)
            __Pyx_GOTREF(__pyx_t_15);
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_11, (PyObject*)__pyx_t_15))) __PYX_ERR(0, 77, __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, 77, __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;
 078: 
+079:                     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, 79, __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, 79, __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, 79, __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, 79, __pyx_L1_error)
+080:                                     (self.keyword_names[i],
      if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 80, __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, 80, __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, 80, __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, 80, __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);
+081:                                      '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, 81, __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;
+082:                                      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, 82, __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;
 083:                                     )
 084: 
 085:             # verify type of each kwarg
+086:             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, 86, __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, 86, __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;
+087:                 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, 87, __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, 87, __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, 87, __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, 87, __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) {
/* … */
    }
+088:                     if len(arg) == 0:
      __pyx_t_8 = PyObject_Length(__pyx_v_arg); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 88, __pyx_L1_error)
      __pyx_t_7 = (__pyx_t_8 == 0);
      if (__pyx_t_7) {
/* … */
      }
+089:                         continue
        goto __pyx_L21_continue;
+090:                     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, 90, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_10);
      __pyx_t_10 = 0;
+091:                 if not isinstance(arg, self.keys_to_types[keyword]):
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 91, __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, 91, __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, 91, __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, 91, __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;
+092:                     expected_type = self.keys_to_types[keyword].__name__ \
        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_11 = __Pyx_PyDict_GetItem(__pyx_cur_scope->__pyx_v_self->keys_to_types, __pyx_v_keyword); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 92, __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, 92, __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 {
+093:                         if not _is_iterable(self.keys_to_types[keyword]) \
      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_1 = __Pyx_PyDict_GetItem(__pyx_cur_scope->__pyx_v_self->keys_to_types, __pyx_v_keyword); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __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, 93, __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, 93, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_7 = (!__pyx_t_16);
      if (__pyx_t_7) {
+094:                         else ', '.join([type_.__name__ for type_ in
        { /* enter inner scope */
          __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __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, 94, __pyx_L32_error)
            __Pyx_GOTREF(__pyx_t_11);
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 94, __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, 94, __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;
+095:                                         self.keys_to_types[keyword]])
          if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 95, __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, 95, __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, 95, __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, 95, __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, 95, __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, 95, __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, 95, __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, 95, __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, 95, __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, 95, __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, 95, __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, 95, __pyx_L32_error)
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_11);
            }
            __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_type_, __pyx_t_11);
            __pyx_t_11 = 0;
 096: 
+097:                     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, 97, __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, 97, __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, 97, __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, 97, __pyx_L1_error)
+098:                                     (keyword,
      __pyx_t_15 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_v_keyword), __pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 98, __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);
+099:                                      '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, 99, __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, 99, __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, 99, __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;
 100:                                                                ('assets', 'fields') else '',
+101:                                      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, 101, __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;
 102:                                     )
 103: 
+104:             return func(*args, **kwargs)
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_v_func)) { __Pyx_RaiseClosureNameError("func"); __PYX_ERR(0, 104, __pyx_L1_error) }
  __pyx_t_5 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 104, __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, 104, __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;
 105: 
+106:         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;
 107: 
+108: @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, 108, __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, 108, __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, 108, __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, 108, __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, 108, __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, 108, __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_2, __pyx_n_s_contextmanager); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
/* … */
  __pyx_tuple__32 = PyTuple_Pack(1, __pyx_n_s_bar_data); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);
  __pyx_t_3 = __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_3)) __PYX_ERR(0, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_handle_non_market_minutes, __pyx_t_4) < 0) __PYX_ERR(0, 108, __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, 108, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 108, __pyx_L1_error)
/* … */
struct __pyx_obj_7zipline_9_protocol___pyx_scope_struct_1_handle_non_market_minutes {
  PyObject_HEAD
  PyObject *__pyx_v_bar_data;
};


 109: def handle_non_market_minutes(bar_data):
+110:     try:
  /*try:*/ {
+111:         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, 111, __pyx_L5_error)
+112:         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, 112, __pyx_L5_error)
  }
 113:     finally:
+114:         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, 114, __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, 114, __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);
 115: 
+116: 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;
 117:     """Provides methods for accessing minutely and daily price/volume data from
 118:     Algorithm API functions.
 119: 
 120:     Also provides utility methods to determine if an asset is alive, and if it
 121:     has recent trade data.
 122: 
 123:     An instance of this object is passed as ``data`` to
 124:     :func:`~zipline.api.handle_data` and
 125:     :func:`~zipline.api.before_trading_start`.
 126: 
 127:     Parameters
 128:     ----------
 129:     data_portal : DataPortal
 130:         Provider for bar pricing data.
 131:     simulation_dt_func : callable
 132:         Function which returns the current simulation time.
 133:         This is usually bound to a method of TradingSimulation.
 134:     data_frequency : {'minute', 'daily'}
 135:         The frequency of the bar data; i.e. whether the data is
 136:         daily or minute bars
 137:     restrictions : zipline.finance.asset_restrictions.Restrictions
 138:         Object that combines and returns restricted list information from
 139:         multiple sources
 140:     """
 141:     cdef object data_portal
 142:     cdef object simulation_dt_func
 143:     cdef object data_frequency
 144:     cdef object restrictions
 145:     cdef dict _views
 146:     cdef bool _daily_mode
 147:     cdef object _trading_calendar
 148:     cdef object _is_restricted
 149: 
 150:     cdef bool _adjust_minutes
 151: 
+152:     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, 152, __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, 152, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); __PYX_ERR(0, 152, __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, 152, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); __PYX_ERR(0, 152, __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, 152, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); __PYX_ERR(0, 152, __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, 152, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); __PYX_ERR(0, 152, __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, 152, __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, 152, __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], 152, 0, __PYX_ERR(0, 152, __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;
}
 153:                  trading_calendar, restrictions):
+154:         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;
+155:         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;
+156:         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;
+157:         self._views = {}
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __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;
 158: 
+159:         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, 159, __pyx_L1_error)
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(0, 159, __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;
 160: 
+161:         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);
 162: 
+163:         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;
+164:         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, 164, __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;
 165: 
+166:     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], 166, 0, __PYX_ERR(0, 166, __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;
}
 167:         """Internal utility method to get the current simulation time.
 168: 
 169:         Possible answers are:
 170:         - whatever the algorithm's get_datetime() method returns (this is what
 171:             `self.simulation_dt_func()` points to)
 172:         - sometimes we're knowingly not in a market minute, like if we're in
 173:             before_trading_start.  In that case, `self._adjust_minutes` is
 174:             True, and we get the previous market minute.
 175:         - if we're in daily mode, get the session label for this minute.
 176:         """
+177:         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, 177, __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;
 178: 
+179:         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, 179, __pyx_L1_error)
  if (__pyx_t_5) {
/* … */
  }
+180:             dt = 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, 180, __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, 180, __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, 180, __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;
 181: 
+182:         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, 182, __pyx_L1_error)
  if (__pyx_t_5) {
/* … */
  }
 183:             # if we're in daily mode, take the given dt (which is the last
 184:             # minute of the session) and get the session label for it.
+185:             dt = self.data_portal.trading_calendar.minute_to_session(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, 185, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_minute_to_session); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __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, 185, __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;
 186: 
+187:         return dt
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_dt);
  __pyx_r = __pyx_v_dt;
  goto __pyx_L0;
 188: 
+189:     @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, "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            \"last_traded\", \"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\" produces the last known close price 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 adj""usted 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, 189, __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, 189, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("current", 1, 2, 2, 1); __PYX_ERR(0, 189, __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, 189, __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, 189, __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], 189, 0, __PYX_ERR(0, 189, __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, 189, __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, 189, __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, 189, __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, 189, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 189, __pyx_L1_error)
/* … */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_tuple__34)) __PYX_ERR(0, 189, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_5);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5)) __PYX_ERR(0, 189, __pyx_L1_error);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7zipline_9_protocol_check_parameters), __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GetNameInClass(__pyx_t_3, (PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_current); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 189, __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_5))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_6 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_3};
    __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __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, 189, __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, 189, __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, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);
+190:                       ((Asset, ContinuousFuture, str), (str,)))
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_ContinuousFuture); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __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, 190, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error);
  __Pyx_INCREF((PyObject *)(&PyUnicode_Type));
  __Pyx_GIVEREF((PyObject *)(&PyUnicode_Type));
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)(&PyUnicode_Type)))) __PYX_ERR(0, 190, __pyx_L1_error);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __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, 190, __pyx_L1_error);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_2);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
 191:     def current(self, assets, fields):
 192:         """Returns the "current" value of the given fields for the given assets
 193:         at the current simulation time.
 194: 
 195:         Parameters
 196:         ----------
 197:         assets : zipline.assets.Asset or iterable of zipline.assets.Asset
 198:             The asset(s) for which data is requested.
 199:         fields : str or iterable[str].
 200:             Requested data field(s). Valid field names are: "price",
 201:             "last_traded", "open", "high", "low", "close", and "volume".
 202: 
 203:         Returns
 204:         -------
 205:         current_value : Scalar, pandas Series, or pandas DataFrame.
 206:             See notes below.
 207: 
 208:         Notes
 209:         -----
 210:         The return type of this function depends on the types of its inputs:
 211: 
 212:         - If a single asset and a single field are requested, the returned
 213:           value is a scalar (either a float or a ``pd.Timestamp`` depending on
 214:           the field).
 215: 
 216:         - If a single asset and a list of fields are requested, the returned
 217:           value is a :class:`pd.Series` whose indices are the requested fields.
 218: 
 219:         - If a list of assets and a single field are requested, the returned
 220:           value is a :class:`pd.Series` whose indices are the assets.
 221: 
 222:         - If a list of assets and a list of fields are requested, the returned
 223:           value is a :class:`pd.DataFrame`.  The columns of the returned frame
 224:           will be the requested fields, and the index of the frame will be the
 225:           requested assets.
 226: 
 227:         The values produced for ``fields`` are as follows:
 228: 
 229:         - Requesting "price" produces the last known close price for the asset,
 230:           forward-filled from an earlier minute if there is no trade this
 231:           minute. If there is no last known value (either because the asset
 232:           has never traded, or because it has delisted) NaN is returned. If a
 233:           value is found, and we had to cross an adjustment boundary (split,
 234:           dividend, etc) to get it, the value is adjusted to the current
 235:           simulation time before being returned.
 236: 
 237:         - Requesting "open", "high", "low", or "close" produces the open, high,
 238:           low, or close for the current minute. If no trades occurred this
 239:           minute, ``NaN`` is returned.
 240: 
 241:         - Requesting "volume" produces the trade volume for the current
 242:           minute. If no trades occurred this minute, 0 is returned.
 243: 
 244:         - Requesting "last_traded" produces the datetime of the last minute in
 245:           which the asset traded, even if the asset has stopped trading. If
 246:           there is no last known value, ``pd.NaT`` is returned.
 247: 
 248:         If the current simulation time is not a valid market time for an asset,
 249:         we use the most recent market close instead.
 250:         """
+251:         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, 251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_multiple_assets = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
+252:         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, 252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_multiple_fields = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 253: 
 254:         # There's some overly verbose code in here, particularly around
 255:         # 'do something if self._adjust_minutes is False, otherwise do
 256:         # something else'. This could be less verbose, but the 99% case is that
 257:         # `self._adjust_minutes` is False, so it's important to keep that code
 258:         # path as fast as possible.
 259: 
 260:         # There's probably a way to make this method (and `history`) less
 261:         # verbose, but this is OK for now.
 262: 
+263:         if not multiple_assets:
  __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_multiple_assets)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 263, __pyx_L1_error)
  __pyx_t_3 = (!__pyx_t_2);
  if (__pyx_t_3) {
/* … */
  }
+264:             asset = assets
    __Pyx_INCREF(__pyx_v_assets);
    __pyx_v_asset = __pyx_v_assets;
 265: 
+266:             if not multiple_fields:
    __pyx_t_3 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_multiple_fields)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 266, __pyx_L1_error)
    __pyx_t_2 = (!__pyx_t_3);
    if (__pyx_t_2) {
/* … */
    }
+267:                 field = fields
      __Pyx_INCREF(__pyx_v_fields);
      __pyx_v_field = __pyx_v_fields;
 268: 
 269:                 # return scalar value
+270:                 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, 270, __pyx_L1_error)
      __pyx_t_3 = (!__pyx_t_2);
      if (__pyx_t_3) {
/* … */
      }
+271:                     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, 271, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
 272:                         asset,
 273:                         field,
+274:                         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, 274, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
+275:                         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, 271, __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;
 276:                     )
 277:                 else:
+278:                     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, 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.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, 282, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
+283:                         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, 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;
      }
 284:                     )
 285:             else:
 286:                 # assume fields is iterable
 287:                 # return a Series indexed by field
+288:                 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, 288, __pyx_L1_error)
      __pyx_t_2 = (!__pyx_t_3);
      if (__pyx_t_2) {
/* … */
      }
+289:                     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, 289, __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, 289, __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, 289, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        { /* enter inner scope */
          __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 289, __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, 289, __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;
+290:                         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, 290, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_9);
 291:                             asset,
 292:                             field,
+293:                             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, 293, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_12);
+294:                             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, 290, __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, 290, __pyx_L9_error)
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 295:                         )
+296:                         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, 296, __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, 296, __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, 296, __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, 296, __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, 296, __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, 296, __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, 296, __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, 296, __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, 296, __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, 289, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+297:                     }, index=fields, name=assets.symbol)
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index, __pyx_v_fields) < 0) __PYX_ERR(0, 289, __pyx_L1_error)
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_assets, __pyx_n_s_symbol); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 297, __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, 289, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 298:                 else:
+299:                     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, 299, __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, 299, __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, 299, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        { /* enter inner scope */
          __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 299, __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, 299, __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;
      }
    }
+300:                         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, 300, __pyx_L16_error)
            __Pyx_GOTREF(__pyx_t_9);
 301:                             asset,
 302:                             field,
+303:                             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, 303, __pyx_L16_error)
            __Pyx_GOTREF(__pyx_t_12);
+304:                             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, 304, __pyx_L16_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            }
+305:                             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, 300, __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, 300, __pyx_L16_error)
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 306:                         )
+307:                         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, 307, __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, 307, __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, 307, __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, 307, __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, 307, __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, 307, __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, 307, __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, 307, __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, 307, __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, 299, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+308:                     }, index=fields, name=assets.symbol)
        if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_index, __pyx_v_fields) < 0) __PYX_ERR(0, 299, __pyx_L1_error)
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_assets, __pyx_n_s_symbol); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 308, __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, 299, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 309:         else:
+310:             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, 310, __pyx_L1_error)
    __pyx_t_3 = (!__pyx_t_2);
    if (__pyx_t_3) {
/* … */
    }
+311:                 field = fields
      __Pyx_INCREF(__pyx_v_fields);
      __pyx_v_field = __pyx_v_fields;
 312: 
 313:                 # assume assets is iterable
 314:                 # return a Series indexed by asset
+315:                 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, 315, __pyx_L1_error)
      __pyx_t_2 = (!__pyx_t_3);
      if (__pyx_t_2) {
/* … */
      }
+316:                     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, 316, __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, 316, __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, 316, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        { /* enter inner scope */
          __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __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, 316, __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;
+317:                         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, 317, __pyx_L25_error)
            __Pyx_GOTREF(__pyx_t_9);
 318:                             asset,
 319:                             field,
+320:                             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, 320, __pyx_L25_error)
            __Pyx_GOTREF(__pyx_t_13);
+321:                             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, 317, __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, 317, __pyx_L25_error)
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 322:                         )
+323:                         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, 323, __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, 323, __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, 323, __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, 323, __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, 323, __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, 323, __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, 323, __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, 323, __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, 323, __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, 316, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+324:                     }, index=assets, name=fields)
        if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_index, __pyx_v_assets) < 0) __PYX_ERR(0, 316, __pyx_L1_error)
        if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_name_2, __pyx_v_fields) < 0) __PYX_ERR(0, 316, __pyx_L1_error)
 325:                 else:
+326:                     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, 326, __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, 326, __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, 326, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        { /* enter inner scope */
          __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 326, __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, 326, __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;
      }
+327:                         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, 327, __pyx_L32_error)
            __Pyx_GOTREF(__pyx_t_9);
 328:                             asset,
 329:                             field,
+330:                             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, 330, __pyx_L32_error)
            __Pyx_GOTREF(__pyx_t_13);
+331:                             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, 331, __pyx_L32_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            }
+332:                             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, 327, __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, 327, __pyx_L32_error)
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 333:                         )
+334:                         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, 334, __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, 334, __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, 334, __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, 334, __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, 334, __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, 334, __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, 334, __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, 334, __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, 334, __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, 326, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+335:                     }, index=assets, name=fields)
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index, __pyx_v_assets) < 0) __PYX_ERR(0, 326, __pyx_L1_error)
        if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name_2, __pyx_v_fields) < 0) __PYX_ERR(0, 326, __pyx_L1_error)
 336: 
 337:             else:
 338:                 # both assets and fields are iterable
+339:                 data = {}
    /*else*/ {
      __pyx_t_6 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 339, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_v_data = ((PyObject*)__pyx_t_6);
      __pyx_t_6 = 0;
 340: 
+341:                 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, 341, __pyx_L1_error)
      __pyx_t_3 = (!__pyx_t_2);
      if (__pyx_t_3) {
/* … */
        goto __pyx_L37;
      }
+342:                     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, 342, __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, 342, __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, 342, __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, 342, __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, 342, __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, 342, __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, 342, __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, 342, __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, 342, __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;
+343:                         series = pd.Series(data={
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 343, __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, 343, __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, 343, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          { /* enter inner scope */
            __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 343, __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, 343, __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;
+344:                             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, 344, __pyx_L42_error)
              __Pyx_GOTREF(__pyx_t_12);
 345:                                 asset,
 346:                                 field,
+347:                                 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, 347, __pyx_L42_error)
              __Pyx_GOTREF(__pyx_t_13);
+348:                                 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, 344, __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, 344, __pyx_L42_error)
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 349:                             )
+350:                             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, 350, __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, 350, __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, 350, __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, 350, __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, 350, __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, 350, __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, 350, __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, 350, __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, 350, __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, 343, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+351:                         }, index=assets, name=field)
          if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index, __pyx_v_assets) < 0) __PYX_ERR(0, 343, __pyx_L1_error)
          if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name_2, __pyx_v_field) < 0) __PYX_ERR(0, 343, __pyx_L1_error)
+352:                         data[field] = series
          if (unlikely((PyDict_SetItem(__pyx_v_data, __pyx_v_field, __pyx_v_series) < 0))) __PYX_ERR(0, 352, __pyx_L1_error)
 353:                 else:
+354:                     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, 354, __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, 354, __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, 354, __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, 354, __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, 354, __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, 354, __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, 354, __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, 354, __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, 354, __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:;
+355:                         series = pd.Series(data={
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pd); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 355, __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, 355, __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, 355, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          { /* enter inner scope */
            __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 355, __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, 355, __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;
+356:                             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, 356, __pyx_L52_error)
              __Pyx_GOTREF(__pyx_t_12);
 357:                                 asset,
 358:                                 field,
+359:                                 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, 359, __pyx_L52_error)
              __Pyx_GOTREF(__pyx_t_13);
+360:                                 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, 360, __pyx_L52_error)
                __Pyx_GOTREF(__pyx_t_14);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              }
+361:                                 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, 356, __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, 356, __pyx_L52_error)
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 362:                             )
+363:                             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, 363, __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, 363, __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, 363, __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, 363, __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, 363, __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, 363, __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, 363, __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, 363, __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, 363, __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, 355, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+364:                         }, index=assets, name=field)
          if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_index, __pyx_v_assets) < 0) __PYX_ERR(0, 355, __pyx_L1_error)
          if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_name_2, __pyx_v_field) < 0) __PYX_ERR(0, 355, __pyx_L1_error)
+365:                         data[field] = series
          if (unlikely((PyDict_SetItem(__pyx_v_data, __pyx_v_field, __pyx_v_series) < 0))) __PYX_ERR(0, 365, __pyx_L1_error)
 366: 
+367:                 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, 367, __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, 367, __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, 367, __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;
    }
  }
 368: 
+369:     @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, 369, __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, 369, __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, 369, __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], 369, 0, __PYX_ERR(0, 369, __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, 369, __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, 369, __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, 369, __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, 369, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 369, __pyx_L1_error)
/* … */
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 369, __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, 369, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3)) __PYX_ERR(0, 369, __pyx_L1_error);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7zipline_9_protocol_check_parameters), __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 369, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __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, 369, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = NULL;
  __pyx_t_6 = 0;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(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_6 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_5};
    __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 369, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_current_chain, __pyx_t_4) < 0) __PYX_ERR(0, 369, __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, 369, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);
+370:                       (ContinuousFuture,))
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_ContinuousFuture); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5)) __PYX_ERR(0, 370, __pyx_L1_error);
  __pyx_t_5 = 0;
 371:     def current_chain(self, continuous_future):
+372:         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, 372, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
 373:             continuous_future,
+374:             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, 374, __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, 372, __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;
 375: 
+376:     @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, "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, 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, "can_trade") < 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_assets = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("can_trade", 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.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], 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_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, 376, __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, 376, __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, 376, __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, 376, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(0, 376, __pyx_L1_error)
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 376, __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, 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__38);
  __Pyx_GIVEREF(__pyx_tuple__38);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_tuple__38)) __PYX_ERR(0, 376, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3)) __PYX_ERR(0, 376, __pyx_L1_error);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7zipline_9_protocol_check_parameters), __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __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, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = NULL;
  __pyx_t_6 = 0;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(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_6 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_5};
    __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 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_3); __pyx_t_3 = 0;
  }
  if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_can_trade, __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__38 = PyTuple_Pack(1, __pyx_n_u_assets); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 376, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);
 377:     def can_trade(self, assets):
 378:         """For the given asset or iterable of assets, returns True if all of the
 379:         following are true:
 380: 
 381:         1. The asset is alive for the session of the current simulation time
 382:            (if current simulation time is not a market minute, we use the next
 383:            session).
 384:         2. The asset's exchange is open at the current simulation time or at
 385:            the simulation calendar's next market minute.
 386:         3. There is a known last price for the asset.
 387: 
 388:         Parameters
 389:         ----------
 390:         assets: zipline.assets.Asset or iterable of zipline.assets.Asset
 391:             Asset(s) for which tradability should be determined.
 392: 
 393:         Notes
 394:         -----
 395:         The second condition above warrants some further explanation:
 396: 
 397:         - If the asset's exchange calendar is identical to the simulation
 398:           calendar, then this condition always returns True.
 399:         - If there are market minutes in the simulation calendar outside of
 400:           this asset's exchange's trading hours (for example, if the simulation
 401:           is running on the CMES calendar but the asset is MSFT, which trades
 402:           on the NYSE), during those minutes, this condition will return False
 403:           (for example, 3:15 am Eastern on a weekday, during which the CMES is
 404:           open but the NYSE is closed).
 405: 
 406:         Returns
 407:         -------
 408:         can_trade : bool or pd.Series[bool]
 409:             Bool or series of bools indicating whether the requested asset(s)
 410:             can be traded in the current minute.
 411:         """
+412:         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, 412, __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;
 413: 
+414:         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, 414, __pyx_L1_error)
  if (__pyx_t_5) {
/* … */
    goto __pyx_L3;
  }
+415:             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, 415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_adjusted_dt = __pyx_t_1;
    __pyx_t_1 = 0;
 416:         else:
+417:             adjusted_dt = dt
  /*else*/ {
    __Pyx_INCREF(__pyx_v_dt);
    __pyx_v_adjusted_dt = __pyx_v_dt;
  }
  __pyx_L3:;
 418: 
+419:         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;
 420: 
+421:         if isinstance(assets, Asset):
  __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_assets, __pyx_ptype_7zipline_6assets_7_assets_Asset); 
  if (__pyx_t_5) {
/* … */
  }
+422:             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, 422, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
 423:                 assets, dt, adjusted_dt, data_portal
 424:             )
 425:         else:
+426:             tradeable = [
  /*else*/ {
    { /* enter inner scope */
      __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 426, __pyx_L7_error)
      __Pyx_GOTREF(__pyx_t_1);
+427:                 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, 427, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 426, __pyx_L7_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 428:                     asset, dt, adjusted_dt, data_portal
 429:                 )
+430:                 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, 430, __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, 430, __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, 430, __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, 430, __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, 430, __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, 430, __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, 430, __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, 430, __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, 430, __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;
 431:             ]
+432:             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, 432, __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, 432, __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, 432, __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, 432, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index, __pyx_v_assets) < 0) __PYX_ERR(0, 432, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, ((PyObject *)__pyx_ptype_7cpython_4bool_bool)) < 0) __PYX_ERR(0, 432, __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, 432, __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;
  }
 433: 
+434:     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], 434, 0, __PYX_ERR(0, 434, __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;
}
 435:         cdef object session_label
 436:         cdef object dt_to_use_for_exchange_check,
 437: 
+438:         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, 438, __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, 438, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {
/* … */
  }
+439:             return False
    __Pyx_XDECREF((PyObject *)__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = ((PyBoolObject *)Py_False);
    goto __pyx_L0;
 440: 
+441:         session_label = self._trading_calendar.minute_to_session(dt)
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_trading_calendar, __pyx_n_s_minute_to_session); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 441, __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, 441, __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;
 442: 
+443:         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, 443, __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, 443, __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, 443, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = (!__pyx_t_5);
  if (__pyx_t_6) {
/* … */
  }
 444:             # asset isn't alive
+445:             return False
    __Pyx_XDECREF((PyObject *)__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = ((PyBoolObject *)Py_False);
    goto __pyx_L0;
 446: 
+447:         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, 447, __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, 447, __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, 447, __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, 447, __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, 447, __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) {
/* … */
  }
+448:             return False
    __Pyx_XDECREF((PyObject *)__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = ((PyBoolObject *)Py_False);
    goto __pyx_L0;
 449: 
+450:         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, 450, __pyx_L1_error)
  __pyx_t_5 = (!__pyx_t_6);
  if (__pyx_t_5) {
/* … */
  }
 451:             # Find the next market minute for this calendar, and check if this
 452:             # asset's exchange is open at that minute.
+453:             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, 453, __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, 453, __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, 453, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_5) {
/* … */
      goto __pyx_L9;
    }
+454:                 dt_to_use_for_exchange_check = dt
      __Pyx_INCREF(__pyx_v_dt);
      __pyx_v_dt_to_use_for_exchange_check = __pyx_v_dt;
 455:             else:
+456:                 dt_to_use_for_exchange_check = 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, 456, __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, 456, __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:;
 457: 
+458:             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, 458, __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, 458, __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, 458, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_6 = (!__pyx_t_5);
    if (__pyx_t_6) {
/* … */
    }
+459:                 return False
      __Pyx_XDECREF((PyObject *)__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = ((PyBoolObject *)Py_False);
      goto __pyx_L0;
 460: 
 461:         # is there a last price?
+462:         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, 462, __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, 462, __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, 462, __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, 462, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) __PYX_ERR(0, 462, __pyx_L1_error)
  __pyx_r = ((PyBoolObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;
+463:             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, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
+464:                 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, 463, __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, 462, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
 465:             )
 466:         )
 467: 
+468:     @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, "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, 468, __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, 468, __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, 468, __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], 468, 0, __PYX_ERR(0, 468, __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, 468, __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, 468, __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, 468, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_7zipline_9_protocol_BarData);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 468, __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, 468, __pyx_L1_error);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 468, __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, 468, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3)) __PYX_ERR(0, 468, __pyx_L1_error);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7zipline_9_protocol_check_parameters), __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __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, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = NULL;
  __pyx_t_6 = 0;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(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_6 = 1;
    }
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_5};
    __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 468, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_is_stale, __pyx_t_4) < 0) __PYX_ERR(0, 468, __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, 468, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 468, __pyx_L1_error)
 469:     def is_stale(self, assets):
 470:         """For the given asset or iterable of assets, returns True if the asset
 471:         is alive and there is no trade data for the current simulation time.
 472: 
 473:         If the asset has never traded, returns False.
 474: 
 475:         If the current simulation time is not a valid market time, we use the
 476:         current time to check if the asset is alive, but we use the last
 477:         market minute/day for the trade data check.
 478: 
 479:         Parameters
 480:         ----------
 481:         assets: zipline.assets.Asset or iterable of zipline.assets.Asset
 482:             Asset(s) for which staleness should be determined.
 483: 
 484:         Returns
 485:         -------
 486:         is_stale : bool or pd.Series[bool]
 487:             Bool or series of bools indicating whether the requested asset(s)
 488:             are stale.
 489:         """
+490:         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, 490, __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;
+491:         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, 491, __pyx_L1_error)
  if (__pyx_t_5) {
/* … */
    goto __pyx_L3;
  }
+492:             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, 492, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_adjusted_dt = __pyx_t_1;
    __pyx_t_1 = 0;
 493:         else:
+494:             adjusted_dt = dt
  /*else*/ {
    __Pyx_INCREF(__pyx_v_dt);
    __pyx_v_adjusted_dt = __pyx_v_dt;
  }
  __pyx_L3:;
 495: 
+496:         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;
 497: 
+498:         if isinstance(assets, Asset):
  __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_assets, __pyx_ptype_7zipline_6assets_7_assets_Asset); 
  if (__pyx_t_5) {
/* … */
  }
+499:             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, 499, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
 500:                 assets, dt, adjusted_dt, data_portal
 501:             )
 502:         else:
+503:             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, 503, __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, 503, __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, 503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    { /* enter inner scope */
      __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 503, __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, 503, __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;
  }
+504:                 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, 504, __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, 504, __pyx_L7_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 505:                     asset, dt, adjusted_dt, data_portal
 506:                 )
+507:                 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, 507, __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, 507, __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, 507, __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, 507, __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, 507, __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, 507, __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, 507, __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, 507, __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, 507, __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, 503, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 508:             })
 509: 
+510:     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], 510, 0, __PYX_ERR(0, 510, __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;
}
+511:         session_label = dt.normalize()  # FIXME
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_dt, __pyx_n_s_normalize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 511, __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, 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, 511, __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;
 512: 
+513:         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, 513, __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, 513, __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, 513, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = (!__pyx_t_5);
  if (__pyx_t_6) {
/* … */
  }
+514:             return False
    __Pyx_XDECREF((PyObject *)__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = ((PyBoolObject *)Py_False);
    goto __pyx_L0;
 515: 
+516:         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, 516, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
+517:             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, 516, __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;
 518:         )
 519: 
+520:         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, 520, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 520, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_6) {
/* … */
  }
 521:             # found a current value, so we know this asset is not stale.
+522:             return False
    __Pyx_XDECREF((PyObject *)__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = ((PyBoolObject *)Py_False);
    goto __pyx_L0;
 523:         else:
 524:             # we need to distinguish between if this asset has ever traded
 525:             # (stale = True) or has never traded (stale = False)
+526:             last_traded_dt = \
  /*else*/ {
+527:                 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, 527, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
+528:                                            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, 527, __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;
 529: 
+530:             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, 530, __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, 530, __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, 530, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) __PYX_ERR(0, 530, __pyx_L1_error)
    __pyx_r = ((PyBoolObject *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }
 531: 
+532:     @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, "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 multiple fi""elds are requested, the returned\n          value is a :class:`pd.DataFrame` with a pd.MultiIndex containing\n          pairs of :class:`pd.DatetimeIndex`, and ``assets``, while the columns\n          while contain the field(s). It has shape ``(bar_count * len(assets),\n          len(fields))``. The names of the pd.MultiIndex are\n\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, 532, __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, 532, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("history", 1, 4, 4, 1); __PYX_ERR(0, 532, __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, 532, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("history", 1, 4, 4, 2); __PYX_ERR(0, 532, __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, 532, __pyx_L3_error)
        else {
          __Pyx_RaiseArgtupleInvalid("history", 1, 4, 4, 3); __PYX_ERR(0, 532, __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, 532, __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, 532, __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], 532, 0, __PYX_ERR(0, 532, __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, 532, __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, 532, __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, 532, __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, 532, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(0, 532, __pyx_L1_error)
/* … */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_tuple__41)) __PYX_ERR(0, 532, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_7);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_7)) __PYX_ERR(0, 532, __pyx_L1_error);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7zipline_9_protocol_check_parameters), __pyx_t_2, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GetNameInClass(__pyx_t_2, (PyObject *)__pyx_ptype_7zipline_9_protocol_BarData, __pyx_n_s_history); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 532, __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_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_2};
    __pyx_t_4 = __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_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 532, __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, 532, __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, 532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);
+533:                       ((Asset, ContinuousFuture, str),
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_ContinuousFuture); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 533, __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, 533, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3)) __PYX_ERR(0, 533, __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, 533, __pyx_L1_error);
  __pyx_t_3 = 0;
/* … */
  __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 533, __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, 533, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_3)) __PYX_ERR(0, 533, __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, 533, __pyx_L1_error);
  __Pyx_GIVEREF(__pyx_t_2);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_2)) __PYX_ERR(0, 533, __pyx_L1_error);
  __pyx_t_5 = 0;
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
+534:                        (str,),
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 534, __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, 534, __pyx_L1_error);
 535:                        int,
+536:                        (str,)))
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 536, __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, 536, __pyx_L1_error);
 537:     def history(self, assets, fields, bar_count, frequency):
 538:         """Returns a trailing window of length ``bar_count`` with data for
 539:         the given assets, fields, and frequency, adjusted for splits, dividends,
 540:         and mergers as of the current simulation time.
 541: 
 542:         The semantics for missing data are identical to the ones described in
 543:         the notes for :meth:`current`.
 544: 
 545:         Parameters
 546:         ----------
 547:         assets: zipline.assets.Asset or iterable of zipline.assets.Asset
 548:             The asset(s) for which data is requested.
 549:         fields: string or iterable of string.
 550:             Requested data field(s). Valid field names are: "price",
 551:             "last_traded", "open", "high", "low", "close", and "volume".
 552:         bar_count: int
 553:             Number of data observations requested.
 554:         frequency: str
 555:             String indicating whether to load daily or minutely data
 556:             observations. Pass '1m' for minutely data, '1d' for daily data.
 557: 
 558:         Returns
 559:         -------
 560:         history : pd.Series or pd.DataFrame or pd.Panel
 561:             See notes below.
 562: 
 563:         Notes
 564:         -----
 565:         The return type of this function depends on the types of ``assets`` and
 566:         ``fields``:
 567: 
 568:         - If a single asset and a single field are requested, the returned
 569:           value is a :class:`pd.Series` of length ``bar_count`` whose index is
 570:           :class:`pd.DatetimeIndex`.
 571: 
 572:         - If a single asset and multiple fields are requested, the returned
 573:           value is a :class:`pd.DataFrame` with shape
 574:           ``(bar_count, len(fields))``. The frame's index will be a
 575:           :class:`pd.DatetimeIndex`, and its columns will be ``fields``.
 576: 
 577:         - If multiple assets and a single field are requested, the returned
 578:           value is a :class:`pd.DataFrame` with shape
 579:           ``(bar_count, len(assets))``. The frame's index will be a
 580:           :class:`pd.DatetimeIndex`, and its columns will be ``assets``.
 581: 
 582:         - If multiple assets and multiple fields are requested, the returned
 583:           value is a :class:`pd.DataFrame` with a pd.MultiIndex containing
 584:           pairs of :class:`pd.DatetimeIndex`, and ``assets``, while the columns
 585:           while contain the field(s). It has shape ``(bar_count * len(assets),
 586:           len(fields))``. The names of the pd.MultiIndex are
 587: 
 588:               - ``date`` if frequency == '1d'`` or ``date_time`` if frequency == '1m``, and
 589:               - ``asset``
 590: 
 591:         If the current simulation time is not a valid market time, we use the last market close instead.
 592:         """
 593: 
+594:         single_field = isinstance(fields, str)
  __pyx_t_1 = PyUnicode_Check(__pyx_v_fields); 
  __pyx_v_single_field = __pyx_t_1;
 595: 
+596:         single_asset = isinstance(assets, PricingDataAssociable)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_PricingDataAssociable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 596, __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, 596, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_single_asset = __pyx_t_1;
+597:         if single_asset:
  if (__pyx_v_single_asset) {
/* … */
    goto __pyx_L3;
  }
+598:             asset_list = [assets]
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 598, __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, 598, __pyx_L1_error);
    __pyx_v_asset_list = __pyx_t_2;
    __pyx_t_2 = 0;
 599:         else:
+600:             asset_list = assets
  /*else*/ {
    __Pyx_INCREF(__pyx_v_assets);
    __pyx_v_asset_list = __pyx_v_assets;
  }
  __pyx_L3:;
 601: 
+602:         if single_field:  # for one or more assets:
  if (__pyx_v_single_field) {
/* … */
  }
+603:             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, 603, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
 604:                 asset_list,
+605:                 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, 605, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
 606:                 bar_count,
 607:                 frequency,
 608:                 fields,
+609:                 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, 603, __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;
 610:             )
 611: 
+612:             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, 612, __pyx_L1_error)
    if (__pyx_t_1) {
/* … */
    }
+613:                 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, 613, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
 614:                     asset_list,
 615:                     fields,
+616:                     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, 616, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
+617:                     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, 617, __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, 613, __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;
 618:                 )
 619: 
+620:                 df = df * adjs
      __pyx_t_2 = PyNumber_Multiply(__pyx_v_df, __pyx_v_adjs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 620, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF_SET(__pyx_v_df, __pyx_t_2);
      __pyx_t_2 = 0;
 621: 
+622:             if single_asset:
    if (__pyx_v_single_asset) {
/* … */
    }
 623:                 # single asset, single field: return pd.Series with pd.DateTimeIndex
+624:                 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, 624, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 624, __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, 624, __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, 624, __pyx_L1_error);
      __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 624, __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, 624, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__16);
  __Pyx_GIVEREF(__pyx_slice__16);
 625:             else:
 626:                 # multiple assets, single field: return DataFrame with pd.DateTimeIndex
 627:                 # and assets in columns.
+628:                 return df
    /*else*/ {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_df);
      __pyx_r = __pyx_v_df;
      goto __pyx_L0;
    }
 629:         else:  # multiple fields
 630:             # if single_asset:
 631:             # todo: optimize by querying multiple fields
 632:             # Make multiple history calls, one per field, then combine results
 633: 
+634:             df_dict = {
  /*else*/ {
    { /* enter inner scope */
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 634, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_5);
+635:                 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, 635, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_4);
+636:                                                            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, 636, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_7);
 637:                                                            bar_count,
 638:                                                            frequency,
 639:                                                            field,
+640:                                                            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, 635, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
+641:                                                            ).loc[:, asset_list]
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_loc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 641, __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, 641, __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, 641, __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, 641, __pyx_L9_error);
        __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 641, __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, 635, __pyx_L9_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+642:                 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, 642, __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, 642, __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, 642, __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, 642, __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, 642, __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, 642, __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, 642, __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, 642, __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, 642, __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;
 643:             }
 644: 
+645:             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, 645, __pyx_L1_error)
    if (__pyx_t_1) {
/* … */
    }
+646:                 adjs = {
      { /* enter inner scope */
        __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 646, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_5);
+647:                     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, 647, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
 648:                         assets,
 649:                         field,
+650:                         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, 650, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_4);
+651:                         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, 651, __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, 647, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          }
+652:                     )[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, 652, __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, 652, __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, 652, __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, 652, __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, 652, __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, 652, __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, 652, __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, 652, __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, 652, __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, 652, __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, 647, __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;
 653:                 }
 654: 
+655:                 df_dict = {field: df * adjs[field]
      { /* enter inner scope */
        __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 655, __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, 655, __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, 655, __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, 655, __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;
+656:                            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, 656, __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, 656, __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;
 657: 
+658:             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, 658, __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;
+659:             df = (pd.concat(df_dict,
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pd); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 659, __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, 659, __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, 659, __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, 659, __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, 659, __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;
+660:                             keys=df_dict.keys(),
    __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 660, __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, 660, __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, 660, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+661:                             names=['fields', dt_label])
    __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 661, __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, 661, __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, 661, __pyx_L1_error);
    if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_names, __pyx_t_7) < 0) __PYX_ERR(0, 660, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+662:                   .stack(future_stack=True)  # 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, 662, __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, 662, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_future_stack, Py_True) < 0) __PYX_ERR(0, 662, __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, 662, __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;
+663:                   .unstack(level='fields'))
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_unstack); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 663, __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, 663, __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, 663, __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, 663, __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;
+664:             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, 664, __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, 664, __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, 664, __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, 664, __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, 664, __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, 664, __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;
+665:             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, 665, __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, 665, __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;
  }
 666: 
 667:     property current_dt:
+668:         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], 668, 0, __PYX_ERR(0, 668, __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;
}
+669:             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, 669, __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;
 670: 
+671:     @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], 671, 0, __PYX_ERR(0, 671, __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;
}
 672:     def fetcher_assets(self):
+673:         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, 673, __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, 673, __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, 673, __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;
 674: 
 675:     property _handle_non_market_minutes:
+676:         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], 676, 0, __PYX_ERR(0, 676, __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;
}
+677:             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, 677, __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;
 678: 
 679:     property current_session:
+680:         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], 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_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;
}
+681:             return self._trading_calendar.minute_to_session(
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_trading_calendar, __pyx_n_s_minute_to_session); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
/* … */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 681, __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, 681, __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, 681, __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;
+682:                 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, 682, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
+683:                 direction="next"
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 683, __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, 683, __pyx_L1_error)
 684:             )
 685: 
 686:     property current_session_minutes:
+687:         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], 687, 0, __PYX_ERR(0, 687, __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;
}
+688:             return self._trading_calendar.session_minutes(
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_trading_calendar, __pyx_n_s_session_minutes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
+689:                 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, 689, __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, 688, __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;
 690:             )
 691: 
 692: cdef class InnerPosition:
 693:     """The real values of a position.
 694: 
 695:     This exists to be owned by both a
 696:     :class:`zipline.finance.position.Position` and a
 697:     :class:`zipline.protocol.Position` at the same time without a cycle.
 698:     """
+699:     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;
  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,0};
  PyObject* values[5] = {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) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_TraceCall("__init__", __pyx_f[0], 699, 0, __PYX_ERR(0, 699, __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;
}
 700:                  asset,
 701:                  amount=0,
 702:                  cost_basis=0.0,
 703:                  last_sale_price=0.0,
+704:                  last_sale_date=None):
    values[4] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)Py_None));
    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_asset)) != 0)) {
          (void)__Pyx_Arg_NewRef_VARARGS(values[0]);
          kw_args--;
        }
        else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 699, __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, 699, __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, 699, __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, 699, __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, 699, __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, 699, __pyx_L3_error)
      }
    } else {
      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);
        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];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 5, __pyx_nargs); __PYX_ERR(0, 699, __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);
+705:         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, 705, __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;
+706:         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, 706, __pyx_L1_error)
  __pyx_v_self->amount = __pyx_t_2;
+707:         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, 707, __pyx_L1_error)
  __pyx_v_self->cost_basis = __pyx_t_3;
+708:         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, 708, __pyx_L1_error)
  __pyx_v_self->last_sale_price = __pyx_t_3;
+709:         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;
 710: 
+711:     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], 711, 0, __PYX_ERR(0, 711, __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;
}
+712:         return (
  __Pyx_XDECREF(__pyx_r);
+713:                 '%s(asset=%r, amount=%r, cost_basis=%r,'
  __pyx_t_1 = PyTuple_New(12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = 0;
  __pyx_t_3 = 127;
/* … */
  __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_1, 12, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 713, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 714:                 ' last_sale_price=%r, last_sale_date=%r)' % (
+715:                     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, 715, __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, 715, __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);
+716:                     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, 716, __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);
+717:                     self.amount,
  __pyx_t_5 = __Pyx_PyInt_From_npy_int64(__pyx_v_self->amount); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 717, __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, 717, __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);
+718:                     self.cost_basis,
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->cost_basis); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 718, __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, 718, __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);
+719:                     self.last_sale_price,
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_self->last_sale_price); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 719, __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, 719, __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);
+720:                     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, 720, __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__19);
  __pyx_t_2 += 1;
  __Pyx_GIVEREF(__pyx_kp_u__19);
  PyTuple_SET_ITEM(__pyx_t_1, 11, __pyx_kp_u__19);
 721:                 )
 722:         )