Cython: _adjustments.pyx

Generated by Cython 3.1.8

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

    +001: #

      __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_test, __pyx_t_2) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     002: # Copyright 2015 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: from cpython cimport (

     016:     bool,

     017:     PyDict_Contains,

     018:     PySet_Add,

     019: )

     020:

    +021: from itertools import chain

      __pyx_t_2 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_chain); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_itertools, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 21, __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_mstate_global->__pyx_n_u_chain); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_chain, __pyx_t_2) < (0)) __PYX_ERR(0, 21, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    +022: from numpy import (

      __pyx_t_2 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_numpy, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __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_mstate_global->__pyx_n_u_int64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_int64, __pyx_t_3) < (0)) __PYX_ERR(0, 23, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_uint32); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_uint32, __pyx_t_3) < (0)) __PYX_ERR(0, 24, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_zeros, __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;

    +023:     int64,

      __pyx_t_3 = __Pyx_PyList_Pack(3, __pyx_mstate_global->__pyx_n_u_int64, __pyx_mstate_global->__pyx_n_u_uint32, __pyx_mstate_global->__pyx_n_u_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 23, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);

     024:     uint32,

     025:     zeros,

     026: )

     027: from numpy cimport float64_t, int64_t, ndarray

    +028: from pandas import Timestamp

      __pyx_t_2 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_Timestamp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_pandas, __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_mstate_global->__pyx_n_u_Timestamp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_Timestamp, __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:

    +030: ctypedef object Timestamp_t

    typedef PyObject *__pyx_t_7zipline_4data_12_adjustments_Timestamp_t;

    +031: ctypedef object DatetimeIndex_t

    typedef PyObject *__pyx_t_7zipline_4data_12_adjustments_DatetimeIndex_t;

     032: ctypedef object Int64Index_t

     033:

    +034: from zipline.lib.adjustment import Float64Multiply

      __pyx_t_3 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_Float64Multiply); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 34, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_zipline_lib_adjustment, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __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_mstate_global->__pyx_n_u_Float64Multiply); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 34, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_Float64Multiply, __pyx_t_3) < (0)) __PYX_ERR(0, 34, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    +035: from zipline.assets.asset_writer import (

      __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_zipline_assets_asset_writer, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 35, __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_mstate_global->__pyx_n_u_SQLITE_MAX_VARIABLE_NUMBER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_SQLITE_MAX_IN_STATEMENT, __pyx_t_2) < (0)) __PYX_ERR(0, 36, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    +036:     SQLITE_MAX_VARIABLE_NUMBER as SQLITE_MAX_IN_STATEMENT,

      __pyx_t_2 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_SQLITE_MAX_VARIABLE_NUMBER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);

     037: )

    +038: from zipline.utils.pandas_utils import timedelta_to_integral_seconds

      __pyx_t_3 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_timedelta_to_integral_seconds); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 38, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_zipline_utils_pandas_utils, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __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_mstate_global->__pyx_n_u_timedelta_to_integral_seconds); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 38, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_timedelta_to_integral_seconds, __pyx_t_3) < (0)) __PYX_ERR(0, 38, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     039:

     040:

    +041: _SID_QUERY_TEMPLATE = """

      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_SID_QUERY_TEMPLATE, __pyx_mstate_global->__pyx_kp_u_SELECT_DISTINCT_sid_FROM_0_WHER) < (0)) __PYX_ERR(0, 41, __pyx_L1_error)

     042: SELECT DISTINCT sid FROM {0}

     043: WHERE effective_date >= ? AND effective_date <= ?

     044: """

    +045: cdef dict SID_QUERIES = {

      { /* enter inner scope */
        __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_2);

    +046:     tablename: _SID_QUERY_TEMPLATE.format(tablename)

          __pyx_t_6 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_SID_QUERY_TEMPLATE); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 46, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 46, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_9 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_8))) {
            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
            assert(__pyx_t_6);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
            __pyx_t_9 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_7genexpr__pyx_v_7zipline_4data_12_adjustments_tablename};
            __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          if (unlikely(PyDict_SetItem(__pyx_t_2, (PyObject*)__pyx_7genexpr__pyx_v_7zipline_4data_12_adjustments_tablename, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 46, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    +047:     for tablename in ('splits', 'dividends', 'mergers')

        __pyx_t_3 = __pyx_mstate_global->__pyx_tuple[0]; __Pyx_INCREF(__pyx_t_3);
        __pyx_t_4 = 0;
        for (;;) {
          if (__pyx_t_4 >= 3) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_5 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4));
          #else
          __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_4);
          #endif
          ++__pyx_t_4;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 47, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_XGOTREF(__pyx_7genexpr__pyx_v_7zipline_4data_12_adjustments_tablename);
          __Pyx_DECREF_SET(__pyx_7genexpr__pyx_v_7zipline_4data_12_adjustments_tablename, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_5);
          __pyx_t_5 = 0;
    /* … */
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_7genexpr__pyx_v_7zipline_4data_12_adjustments_tablename);
        __Pyx_DECREF_SET(__pyx_7genexpr__pyx_v_7zipline_4data_12_adjustments_tablename, Py_None);
        goto __pyx_L8_exit_scope;
        __pyx_L4_error:;
        __Pyx_GOTREF(__pyx_7genexpr__pyx_v_7zipline_4data_12_adjustments_tablename);
        __Pyx_DECREF_SET(__pyx_7genexpr__pyx_v_7zipline_4data_12_adjustments_tablename, Py_None);
        goto __pyx_L1_error;
        __pyx_L8_exit_scope:;
      } /* exit inner scope */
      __Pyx_XGOTREF(__pyx_v_7zipline_4data_12_adjustments_SID_QUERIES);
      __Pyx_DECREF_SET(__pyx_v_7zipline_4data_12_adjustments_SID_QUERIES, ((PyObject*)__pyx_t_2));
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;

     048: }

     049:

    +050: ADJ_QUERY_TEMPLATE = """

      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_ADJ_QUERY_TEMPLATE, __pyx_mstate_global->__pyx_kp_u_SELECT_sid_ratio_effective_date) < (0)) __PYX_ERR(0, 50, __pyx_L1_error)

     051: SELECT sid, ratio, effective_date

     052: FROM {0}

     053: WHERE sid IN ({1}) AND effective_date >= {2} AND effective_date <= {3}

     054: """

     055:

    +056: EPOCH = Timestamp(0, tz='UTC')

      __pyx_t_3 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_Timestamp); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 56, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = 1;
      {
        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, __pyx_mstate_global->__pyx_int_0};
        __pyx_t_8 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 56, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_tz, __pyx_mstate_global->__pyx_n_u_UTC, __pyx_t_8, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 56, __pyx_L1_error)
        __pyx_t_2 = __Pyx_Object_Vectorcall_CallFromBuilder(__pyx_t_5, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_8);
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_EPOCH, __pyx_t_2) < (0)) __PYX_ERR(0, 56, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     057:

    +058: cdef set _get_sids_from_table(object db,

    static PyObject *__pyx_f_7zipline_4data_12_adjustments__get_sids_from_table(PyObject *__pyx_v_db, PyObject *__pyx_v_tablename, int __pyx_v_start_date, int __pyx_v_end_date) {
      PyObject *__pyx_v_cursor = 0;
      PyObject *__pyx_v_out = 0;
      PyObject *__pyx_v_result = 0;
      PyObject *__pyx_r = NULL;
      __Pyx_TraceDeclarationsFunc
      __Pyx_TraceFrameInit(((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[39]))
      __Pyx_TraceStartFunc("_get_sids_from_table", __pyx_f[0], 58, 0, 0, 0, __PYX_ERR(0, 58, __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_XDECREF(__pyx_t_6);
      __Pyx_TraceException(__pyx_lineno, 0, 0);
      #if CYTHON_USE_SYS_MONITORING
      __Pyx_TraceExceptionUnwind(0, 0);
      #else
      __Pyx_TraceReturnValue(NULL, 0, 0, __PYX_ERR(0, 58, __pyx_L1_error));
      #endif
      __Pyx_AddTraceback("zipline.data._adjustments._get_sids_from_table", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XDECREF(__pyx_v_cursor);
      __Pyx_XDECREF(__pyx_v_out);
      __Pyx_XDECREF(__pyx_v_result);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_PyMonitoring_ExitScope(0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     059:                               str tablename,

     060:                               int start_date,

     061:                               int end_date):

     062:     """Get the unique sids for all adjustments between start_date and end_date

     063:     from table `tablename`.

     064:

     065:     Parameters

     066:     ----------

     067:     db : sqlite3.connection

     068:     tablename : str

     069:     start_date : int (seconds since epoch)

     070:     end_date : int (seconds since epoch)

     071:

     072:     Returns

     073:     -------

     074:     sids : set

     075:         Set of sets

     076:     """

     077:

    +078:     cdef object cursor = db.execute(

      __pyx_t_2 = __pyx_v_db;
      __Pyx_INCREF(__pyx_t_2);

    +079:         SID_QUERIES[tablename],

      if (unlikely(__pyx_v_7zipline_4data_12_adjustments_SID_QUERIES == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 79, __pyx_L1_error)
      }
      __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_7zipline_4data_12_adjustments_SID_QUERIES, __pyx_v_tablename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 79, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);

    +080:         (start_date, end_date),

      __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_v_start_date); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 80, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyLong_From_int(__pyx_v_end_date); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 80, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 80, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_4);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4) != (0)) __PYX_ERR(0, 80, __pyx_L1_error);
      __Pyx_GIVEREF(__pyx_t_5);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 80, __pyx_L1_error);
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_7 = 0;
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_t_3, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __pyx_v_cursor = __pyx_t_1;
      __pyx_t_1 = 0;

     081:     )

    +082:     cdef set out = set()

      __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_v_out = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

     083:     cdef tuple result

    +084:     for result in cursor.fetchall():

      __pyx_t_6 = __pyx_v_cursor;
      __Pyx_INCREF(__pyx_t_6);
      __pyx_t_7 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
        __pyx_t_1 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_fetchall, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
        __pyx_t_6 = __pyx_t_1; __Pyx_INCREF(__pyx_t_6);
        __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
      } else {
        __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 84, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_9 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 84, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      for (;;) {
        if (likely(!__pyx_t_9)) {
          if (likely(PyList_CheckExact(__pyx_t_6))) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 84, __pyx_L1_error)
              #endif
              if (__pyx_t_8 >= __pyx_temp) break;
            }
            __pyx_t_1 = __Pyx_PyList_GetItemRef(__pyx_t_6, __pyx_t_8);
            ++__pyx_t_8;
          } else {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 84, __pyx_L1_error)
              #endif
              if (__pyx_t_8 >= __pyx_temp) break;
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_1 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8));
            #else
            __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_8);
            #endif
            ++__pyx_t_8;
          }
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
        } else {
          __pyx_t_1 = __pyx_t_9(__pyx_t_6);
          if (unlikely(!__pyx_t_1)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 84, __pyx_L1_error)
              PyErr_Clear();
            }
            break;
          }
        }
        __Pyx_GOTREF(__pyx_t_1);
        if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("tuple", __pyx_t_1))) __PYX_ERR(0, 84, __pyx_L1_error)
        __Pyx_XDECREF_SET(__pyx_v_result, ((PyObject*)__pyx_t_1));
        __pyx_t_1 = 0;
    /* … */
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    +085:         PySet_Add(out, result[0])

        if (unlikely(__pyx_v_result == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 85, __pyx_L1_error)
        }
        __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v_result, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_10 = PySet_Add(__pyx_v_out, __pyx_t_1); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 85, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    +086:     return out

      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_out);
      __pyx_r = __pyx_v_out;
      __Pyx_TraceReturnValue(__pyx_r, 23, 0, __PYX_ERR(0, 86, __pyx_L1_error));
      goto __pyx_L0;

     087:

     088:

    +089: cdef set _get_split_sids(object db, int start_date, int end_date):

    static PyObject *__pyx_f_7zipline_4data_12_adjustments__get_split_sids(PyObject *__pyx_v_db, int __pyx_v_start_date, int __pyx_v_end_date) {
      PyObject *__pyx_r = NULL;
      __Pyx_TraceDeclarationsFunc
      __Pyx_TraceFrameInit(((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[40]))
      __Pyx_TraceStartFunc("_get_split_sids", __pyx_f[0], 89, 0, 0, 0, __PYX_ERR(0, 89, __pyx_L1_error));
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_TraceException(__pyx_lineno, 0, 0);
      #if CYTHON_USE_SYS_MONITORING
      __Pyx_TraceExceptionUnwind(0, 0);
      #else
      __Pyx_TraceReturnValue(NULL, 0, 0, __PYX_ERR(0, 89, __pyx_L1_error));
      #endif
      __Pyx_AddTraceback("zipline.data._adjustments._get_split_sids", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_PyMonitoring_ExitScope(0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    +090:     return _get_sids_from_table(db, 'splits', start_date, end_date)

      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_7zipline_4data_12_adjustments__get_sids_from_table(__pyx_v_db, __pyx_mstate_global->__pyx_n_u_splits, __pyx_v_start_date, __pyx_v_end_date); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;
      __Pyx_TraceReturnValue(__pyx_r, 1, 0, __PYX_ERR(0, 90, __pyx_L1_error));
      goto __pyx_L0;

     091:

     092:

    +093: cdef set _get_merger_sids(object db, int start_date, int end_date):

    static PyObject *__pyx_f_7zipline_4data_12_adjustments__get_merger_sids(PyObject *__pyx_v_db, int __pyx_v_start_date, int __pyx_v_end_date) {
      PyObject *__pyx_r = NULL;
      __Pyx_TraceDeclarationsFunc
      __Pyx_TraceFrameInit(((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[41]))
      __Pyx_TraceStartFunc("_get_merger_sids", __pyx_f[0], 93, 0, 0, 0, __PYX_ERR(0, 93, __pyx_L1_error));
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_TraceException(__pyx_lineno, 0, 0);
      #if CYTHON_USE_SYS_MONITORING
      __Pyx_TraceExceptionUnwind(0, 0);
      #else
      __Pyx_TraceReturnValue(NULL, 0, 0, __PYX_ERR(0, 93, __pyx_L1_error));
      #endif
      __Pyx_AddTraceback("zipline.data._adjustments._get_merger_sids", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_PyMonitoring_ExitScope(0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    +094:     return _get_sids_from_table(db, 'mergers', start_date, end_date)

      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_7zipline_4data_12_adjustments__get_sids_from_table(__pyx_v_db, __pyx_mstate_global->__pyx_n_u_mergers, __pyx_v_start_date, __pyx_v_end_date); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;
      __Pyx_TraceReturnValue(__pyx_r, 1, 0, __PYX_ERR(0, 94, __pyx_L1_error));
      goto __pyx_L0;

     095:

     096:

    +097: cdef set _get_dividend_sids(object db, int start_date, int end_date):

    static PyObject *__pyx_f_7zipline_4data_12_adjustments__get_dividend_sids(PyObject *__pyx_v_db, int __pyx_v_start_date, int __pyx_v_end_date) {
      PyObject *__pyx_r = NULL;
      __Pyx_TraceDeclarationsFunc
      __Pyx_TraceFrameInit(((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[42]))
      __Pyx_TraceStartFunc("_get_dividend_sids", __pyx_f[0], 97, 0, 0, 0, __PYX_ERR(0, 97, __pyx_L1_error));
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_TraceException(__pyx_lineno, 0, 0);
      #if CYTHON_USE_SYS_MONITORING
      __Pyx_TraceExceptionUnwind(0, 0);
      #else
      __Pyx_TraceReturnValue(NULL, 0, 0, __PYX_ERR(0, 97, __pyx_L1_error));
      #endif
      __Pyx_AddTraceback("zipline.data._adjustments._get_dividend_sids", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_PyMonitoring_ExitScope(0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    +098:     return _get_sids_from_table(db, 'dividends', start_date, end_date)

      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_7zipline_4data_12_adjustments__get_sids_from_table(__pyx_v_db, __pyx_mstate_global->__pyx_n_u_dividends, __pyx_v_start_date, __pyx_v_end_date); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;
      __Pyx_TraceReturnValue(__pyx_r, 1, 0, __PYX_ERR(0, 98, __pyx_L1_error));
      goto __pyx_L0;

     099:

     100:

    +101: cdef _adjustments(object adjustments_db,

    static PyObject *__pyx_f_7zipline_4data_12_adjustments__adjustments(PyObject *__pyx_v_adjustments_db, PyObject *__pyx_v_split_sids, PyObject *__pyx_v_merger_sids, PyObject *__pyx_v_dividends_sids, int __pyx_v_start_date, int __pyx_v_end_date, __pyx_t_7zipline_4data_12_adjustments_Int64Index_t __pyx_v_assets) {
      PyObject *__pyx_v_c = NULL;
      PyObject *__pyx_v_splits_to_query = NULL;
      PyObject *__pyx_v_splits_results = NULL;
      PyObject *__pyx_v_query_len = NULL;
      PyObject *__pyx_v_query_assets = NULL;
      PyObject *__pyx_v_t = NULL;
      PyObject *__pyx_v_statement = NULL;
      PyObject *__pyx_v_mergers_to_query = NULL;
      PyObject *__pyx_v_mergers_results = NULL;
      PyObject *__pyx_v_dividends_to_query = NULL;
      PyObject *__pyx_v_dividends_results = NULL;
      PyObject *__pyx_8genexpr1__pyx_v_a = NULL;
      PyObject *__pyx_8genexpr2__pyx_v_a = NULL;
      CYTHON_UNUSED PyObject *__pyx_8genexpr3__pyx_v__ = NULL;
      PyObject *__pyx_8genexpr4__pyx_v_a = NULL;
      PyObject *__pyx_8genexpr5__pyx_v_a = NULL;
      CYTHON_UNUSED PyObject *__pyx_8genexpr6__pyx_v__ = NULL;
      PyObject *__pyx_8genexpr7__pyx_v_a = NULL;
      PyObject *__pyx_8genexpr8__pyx_v_a = NULL;
      CYTHON_UNUSED PyObject *__pyx_8genexpr9__pyx_v__ = NULL;
      PyObject *__pyx_r = NULL;
      __Pyx_TraceDeclarationsFunc
      __Pyx_TraceFrameInit(((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[43]))
      __Pyx_TraceStartFunc("_adjustments", __pyx_f[0], 101, 0, 0, 0, __PYX_ERR(0, 101, __pyx_L1_error));
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_6);
      __Pyx_XDECREF(__pyx_t_8);
      __Pyx_XDECREF(__pyx_t_10);
      __Pyx_XDECREF(__pyx_t_11);
      __Pyx_TraceException(__pyx_lineno, 0, 0);
      #if CYTHON_USE_SYS_MONITORING
      __Pyx_TraceExceptionUnwind(0, 0);
      #else
      __Pyx_TraceReturnValue(NULL, 0, 0, __PYX_ERR(0, 101, __pyx_L1_error));
      #endif
      __Pyx_AddTraceback("zipline.data._adjustments._adjustments", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      __pyx_L0:;
      __Pyx_XDECREF(__pyx_v_c);
      __Pyx_XDECREF(__pyx_v_splits_to_query);
      __Pyx_XDECREF(__pyx_v_splits_results);
      __Pyx_XDECREF(__pyx_v_query_len);
      __Pyx_XDECREF(__pyx_v_query_assets);
      __Pyx_XDECREF(__pyx_v_t);
      __Pyx_XDECREF(__pyx_v_statement);
      __Pyx_XDECREF(__pyx_v_mergers_to_query);
      __Pyx_XDECREF(__pyx_v_mergers_results);
      __Pyx_XDECREF(__pyx_v_dividends_to_query);
      __Pyx_XDECREF(__pyx_v_dividends_results);
      __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_a);
      __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_a);
      __Pyx_XDECREF(__pyx_8genexpr3__pyx_v__);
      __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_a);
      __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_a);
      __Pyx_XDECREF(__pyx_8genexpr6__pyx_v__);
      __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_a);
      __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_a);
      __Pyx_XDECREF(__pyx_8genexpr9__pyx_v__);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_PyMonitoring_ExitScope(0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

     102:                   set split_sids,

     103:                   set merger_sids,

     104:                   set dividends_sids,

     105:                   int start_date,

     106:                   int end_date,

     107:                   Int64Index_t assets):

     108:

    +109:     c = adjustments_db.cursor()

      __pyx_t_2 = __pyx_v_adjustments_db;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_3 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
        __pyx_t_1 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_cursor, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __pyx_v_c = __pyx_t_1;
      __pyx_t_1 = 0;

     110:

    +111:     splits_to_query = [str(a) for a in assets if a in split_sids]

      { /* enter inner scope */
        __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (likely(PyList_CheckExact(((PyObject *)__pyx_v_assets))) || PyTuple_CheckExact(((PyObject *)__pyx_v_assets))) {
          __pyx_t_2 = ((PyObject *)__pyx_v_assets); __Pyx_INCREF(__pyx_t_2);
          __pyx_t_4 = 0;
          __pyx_t_5 = NULL;
        } else {
          __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(((PyObject *)__pyx_v_assets)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_5 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 111, __pyx_L5_error)
        }
        for (;;) {
          if (likely(!__pyx_t_5)) {
            if (likely(PyList_CheckExact(__pyx_t_2))) {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
                #if !CYTHON_ASSUME_SAFE_SIZE
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 111, __pyx_L5_error)
                #endif
                if (__pyx_t_4 >= __pyx_temp) break;
              }
              __pyx_t_6 = __Pyx_PyList_GetItemRef(__pyx_t_2, __pyx_t_4);
              ++__pyx_t_4;
            } else {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2);
                #if !CYTHON_ASSUME_SAFE_SIZE
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 111, __pyx_L5_error)
                #endif
                if (__pyx_t_4 >= __pyx_temp) break;
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_6 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4));
              #else
              __pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_4);
              #endif
              ++__pyx_t_4;
            }
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 111, __pyx_L5_error)
          } else {
            __pyx_t_6 = __pyx_t_5(__pyx_t_2);
            if (unlikely(!__pyx_t_6)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 111, __pyx_L5_error)
                PyErr_Clear();
              }
              break;
            }
          }
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_a, __pyx_t_6);
          __pyx_t_6 = 0;
          if (unlikely(__pyx_v_split_sids == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
            __PYX_ERR(0, 111, __pyx_L5_error)
          }
          __pyx_t_7 = (__Pyx_PySet_ContainsTF(__pyx_8genexpr1__pyx_v_a, __pyx_v_split_sids, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 111, __pyx_L5_error)
          if (__pyx_t_7) {
            __pyx_t_6 = __Pyx_PyObject_Unicode(__pyx_8genexpr1__pyx_v_a); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 111, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_6);
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 111, __pyx_L5_error)
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_a); __pyx_8genexpr1__pyx_v_a = 0;
        goto __pyx_L10_exit_scope;
        __pyx_L5_error:;
        __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_a); __pyx_8genexpr1__pyx_v_a = 0;
        goto __pyx_L1_error;
        __pyx_L10_exit_scope:;
      } /* exit inner scope */
      __pyx_v_splits_to_query = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

    +112:     splits_results = []

      __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_v_splits_results = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

    +113:     while splits_to_query:

      while (1) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_v_splits_to_query);
          if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 113, __pyx_L1_error)
          __pyx_t_7 = (__pyx_temp != 0);
        }

        if (!__pyx_t_7) break;

    +114:         query_len = min(len(splits_to_query), SQLITE_MAX_IN_STATEMENT)

        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_SQLITE_MAX_IN_STATEMENT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_PyList_GET_SIZE(__pyx_v_splits_to_query); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 114, __pyx_L1_error)
        __pyx_t_6 = PyLong_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 114, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_8 = PyObject_RichCompare(__pyx_t_1, __pyx_t_6, Py_LT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 114, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 114, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (__pyx_t_7) {
          __Pyx_INCREF(__pyx_t_1);
          __pyx_t_2 = __pyx_t_1;
        } else {
          __pyx_t_8 = PyLong_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 114, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_2 = __pyx_t_8;
          __pyx_t_8 = 0;
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __pyx_t_2;
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF_SET(__pyx_v_query_len, __pyx_t_1);
        __pyx_t_1 = 0;

    +115:         query_assets = splits_to_query[:query_len]

        __Pyx_INCREF(__pyx_v_query_len);
        __pyx_t_1 = __pyx_v_query_len;
        __pyx_t_7 = (__pyx_t_1 == Py_None);
        if (__pyx_t_7) {
          __pyx_t_4 = PY_SSIZE_T_MAX;
        } else {
          __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 115, __pyx_L1_error)
          __pyx_t_4 = __pyx_t_9;
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_v_splits_to_query, 0, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_XDECREF_SET(__pyx_v_query_assets, ((PyObject*)__pyx_t_1));
        __pyx_t_1 = 0;

    +116:         t = [str(a) for a in query_assets]

        { /* enter inner scope */
          __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L15_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_v_query_assets; __Pyx_INCREF(__pyx_t_2);
          __pyx_t_4 = 0;
          for (;;) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 116, __pyx_L15_error)
              #endif
              if (__pyx_t_4 >= __pyx_temp) break;
            }
            __pyx_t_8 = __Pyx_PyList_GetItemRef(__pyx_t_2, __pyx_t_4);
            ++__pyx_t_4;
            if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 116, __pyx_L15_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_a, __pyx_t_8);
            __pyx_t_8 = 0;
            __pyx_t_8 = __Pyx_PyObject_Unicode(__pyx_8genexpr2__pyx_v_a); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 116, __pyx_L15_error)
            __Pyx_GOTREF(__pyx_t_8);
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 116, __pyx_L15_error)
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_a); __pyx_8genexpr2__pyx_v_a = 0;
          goto __pyx_L19_exit_scope;
          __pyx_L15_error:;
          __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_a); __pyx_8genexpr2__pyx_v_a = 0;
          goto __pyx_L1_error;
          __pyx_L19_exit_scope:;
        } /* exit inner scope */
        __Pyx_XDECREF_SET(__pyx_v_t, ((PyObject*)__pyx_t_1));
        __pyx_t_1 = 0;

    +117:         statement = ADJ_QUERY_TEMPLATE.format(

        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_ADJ_QUERY_TEMPLATE); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 117, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 117, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

     118:             'splits',

    +119:             ",".join(['?' for _ in query_assets]),

        { /* enter inner scope */
          __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 119, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_10 = __pyx_v_query_assets; __Pyx_INCREF(__pyx_t_10);
          __pyx_t_4 = 0;
          for (;;) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_10);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 119, __pyx_L22_error)
              #endif
              if (__pyx_t_4 >= __pyx_temp) break;
            }
            __pyx_t_11 = __Pyx_PyList_GetItemRef(__pyx_t_10, __pyx_t_4);
            ++__pyx_t_4;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 119, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v__, __pyx_t_11);
            __pyx_t_11 = 0;
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_mstate_global->__pyx_kp_u__2))) __PYX_ERR(0, 119, __pyx_L22_error)
          }
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_8genexpr3__pyx_v__); __pyx_8genexpr3__pyx_v__ = 0;
          goto __pyx_L26_exit_scope;
          __pyx_L22_error:;
          __Pyx_XDECREF(__pyx_8genexpr3__pyx_v__); __pyx_8genexpr3__pyx_v__ = 0;
          goto __pyx_L1_error;
          __pyx_L26_exit_scope:;
        } /* exit inner scope */
        __pyx_t_10 = PyUnicode_Join(__pyx_mstate_global->__pyx_kp_u_, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 119, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    +120:             start_date,

        __pyx_t_8 = __Pyx_PyLong_From_int(__pyx_v_start_date); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 120, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);

    +121:             end_date,

        __pyx_t_11 = __Pyx_PyLong_From_int(__pyx_v_end_date); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 121, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_3 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_3 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[5] = {__pyx_t_2, __pyx_mstate_global->__pyx_n_u_splits, __pyx_t_10, __pyx_t_8, __pyx_t_11};
          __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+__pyx_t_3, (5-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_XDECREF_SET(__pyx_v_statement, __pyx_t_1);
        __pyx_t_1 = 0;

     122:         )

    +123:         c.execute(statement, t)

        __pyx_t_6 = __pyx_v_c;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_3 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_v_statement, __pyx_v_t};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    +124:         splits_to_query = splits_to_query[query_len:]

        __Pyx_INCREF(__pyx_v_query_len);
        __pyx_t_1 = __pyx_v_query_len;
        __pyx_t_7 = (__pyx_t_1 == Py_None);
        if (__pyx_t_7) {
          __pyx_t_4 = 0;
        } else {
          __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 124, __pyx_L1_error)
          __pyx_t_4 = __pyx_t_9;
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_v_splits_to_query, __pyx_t_4, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF_SET(__pyx_v_splits_to_query, ((PyObject*)__pyx_t_1));
        __pyx_t_1 = 0;

    +125:         splits_results.extend(c.fetchall())

        __pyx_t_6 = __pyx_v_c;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_3 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_fetchall, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_12 = __Pyx_PyList_Extend(__pyx_v_splits_results, __pyx_t_1); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 125, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }

     126:

    +127:     mergers_to_query = [str(a) for a in assets if a in merger_sids]

      { /* enter inner scope */
        __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L29_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (likely(PyList_CheckExact(((PyObject *)__pyx_v_assets))) || PyTuple_CheckExact(((PyObject *)__pyx_v_assets))) {
          __pyx_t_6 = ((PyObject *)__pyx_v_assets); __Pyx_INCREF(__pyx_t_6);
          __pyx_t_4 = 0;
          __pyx_t_5 = NULL;
        } else {
          __pyx_t_4 = -1; __pyx_t_6 = PyObject_GetIter(((PyObject *)__pyx_v_assets)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 127, __pyx_L29_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_5 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 127, __pyx_L29_error)
        }
        for (;;) {
          if (likely(!__pyx_t_5)) {
            if (likely(PyList_CheckExact(__pyx_t_6))) {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
                #if !CYTHON_ASSUME_SAFE_SIZE
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 127, __pyx_L29_error)
                #endif
                if (__pyx_t_4 >= __pyx_temp) break;
              }
              __pyx_t_11 = __Pyx_PyList_GetItemRef(__pyx_t_6, __pyx_t_4);
              ++__pyx_t_4;
            } else {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
                #if !CYTHON_ASSUME_SAFE_SIZE
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 127, __pyx_L29_error)
                #endif
                if (__pyx_t_4 >= __pyx_temp) break;
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_11 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_4));
              #else
              __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_4);
              #endif
              ++__pyx_t_4;
            }
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 127, __pyx_L29_error)
          } else {
            __pyx_t_11 = __pyx_t_5(__pyx_t_6);
            if (unlikely(!__pyx_t_11)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 127, __pyx_L29_error)
                PyErr_Clear();
              }
              break;
            }
          }
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_a, __pyx_t_11);
          __pyx_t_11 = 0;
          if (unlikely(__pyx_v_merger_sids == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
            __PYX_ERR(0, 127, __pyx_L29_error)
          }
          __pyx_t_7 = (__Pyx_PySet_ContainsTF(__pyx_8genexpr4__pyx_v_a, __pyx_v_merger_sids, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 127, __pyx_L29_error)
          if (__pyx_t_7) {
            __pyx_t_11 = __Pyx_PyObject_Unicode(__pyx_8genexpr4__pyx_v_a); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 127, __pyx_L29_error)
            __Pyx_GOTREF(__pyx_t_11);
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 127, __pyx_L29_error)
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_a); __pyx_8genexpr4__pyx_v_a = 0;
        goto __pyx_L34_exit_scope;
        __pyx_L29_error:;
        __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_a); __pyx_8genexpr4__pyx_v_a = 0;
        goto __pyx_L1_error;
        __pyx_L34_exit_scope:;
      } /* exit inner scope */
      __pyx_v_mergers_to_query = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

    +128:     mergers_results = []

      __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_v_mergers_results = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

    +129:     while mergers_to_query:

      while (1) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_v_mergers_to_query);
          if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 129, __pyx_L1_error)
          __pyx_t_7 = (__pyx_temp != 0);
        }

        if (!__pyx_t_7) break;

    +130:         query_len = min(len(mergers_to_query), SQLITE_MAX_IN_STATEMENT)

        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_SQLITE_MAX_IN_STATEMENT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_PyList_GET_SIZE(__pyx_v_mergers_to_query); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 130, __pyx_L1_error)
        __pyx_t_11 = PyLong_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 130, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_8 = PyObject_RichCompare(__pyx_t_1, __pyx_t_11, Py_LT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 130, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 130, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (__pyx_t_7) {
          __Pyx_INCREF(__pyx_t_1);
          __pyx_t_6 = __pyx_t_1;
        } else {
          __pyx_t_8 = PyLong_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 130, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_6 = __pyx_t_8;
          __pyx_t_8 = 0;
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __pyx_t_6;
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF_SET(__pyx_v_query_len, __pyx_t_1);
        __pyx_t_1 = 0;

    +131:         query_assets = mergers_to_query[:query_len]

        __Pyx_INCREF(__pyx_v_query_len);
        __pyx_t_1 = __pyx_v_query_len;
        __pyx_t_7 = (__pyx_t_1 == Py_None);
        if (__pyx_t_7) {
          __pyx_t_4 = PY_SSIZE_T_MAX;
        } else {
          __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 131, __pyx_L1_error)
          __pyx_t_4 = __pyx_t_9;
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_v_mergers_to_query, 0, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_XDECREF_SET(__pyx_v_query_assets, ((PyObject*)__pyx_t_1));
        __pyx_t_1 = 0;

    +132:         t = [str(a) for a in query_assets]

        { /* enter inner scope */
          __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L39_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_6 = __pyx_v_query_assets; __Pyx_INCREF(__pyx_t_6);
          __pyx_t_4 = 0;
          for (;;) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 132, __pyx_L39_error)
              #endif
              if (__pyx_t_4 >= __pyx_temp) break;
            }
            __pyx_t_8 = __Pyx_PyList_GetItemRef(__pyx_t_6, __pyx_t_4);
            ++__pyx_t_4;
            if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 132, __pyx_L39_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_a, __pyx_t_8);
            __pyx_t_8 = 0;
            __pyx_t_8 = __Pyx_PyObject_Unicode(__pyx_8genexpr5__pyx_v_a); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 132, __pyx_L39_error)
            __Pyx_GOTREF(__pyx_t_8);
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 132, __pyx_L39_error)
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          }
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_a); __pyx_8genexpr5__pyx_v_a = 0;
          goto __pyx_L43_exit_scope;
          __pyx_L39_error:;
          __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_a); __pyx_8genexpr5__pyx_v_a = 0;
          goto __pyx_L1_error;
          __pyx_L43_exit_scope:;
        } /* exit inner scope */
        __Pyx_XDECREF_SET(__pyx_v_t, ((PyObject*)__pyx_t_1));
        __pyx_t_1 = 0;

    +133:         statement = ADJ_QUERY_TEMPLATE.format(

        __pyx_t_6 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_ADJ_QUERY_TEMPLATE); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 133, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_format); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 133, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

     134:             'mergers',

    +135:             ",".join(['?' for _ in query_assets]),

        { /* enter inner scope */
          __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 135, __pyx_L46_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_10 = __pyx_v_query_assets; __Pyx_INCREF(__pyx_t_10);
          __pyx_t_4 = 0;
          for (;;) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_10);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 135, __pyx_L46_error)
              #endif
              if (__pyx_t_4 >= __pyx_temp) break;
            }
            __pyx_t_2 = __Pyx_PyList_GetItemRef(__pyx_t_10, __pyx_t_4);
            ++__pyx_t_4;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L46_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_XDECREF_SET(__pyx_8genexpr6__pyx_v__, __pyx_t_2);
            __pyx_t_2 = 0;
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_mstate_global->__pyx_kp_u__2))) __PYX_ERR(0, 135, __pyx_L46_error)
          }
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_8genexpr6__pyx_v__); __pyx_8genexpr6__pyx_v__ = 0;
          goto __pyx_L50_exit_scope;
          __pyx_L46_error:;
          __Pyx_XDECREF(__pyx_8genexpr6__pyx_v__); __pyx_8genexpr6__pyx_v__ = 0;
          goto __pyx_L1_error;
          __pyx_L50_exit_scope:;
        } /* exit inner scope */
        __pyx_t_10 = PyUnicode_Join(__pyx_mstate_global->__pyx_kp_u_, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 135, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    +136:             start_date,

        __pyx_t_8 = __Pyx_PyLong_From_int(__pyx_v_start_date); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 136, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);

    +137:             end_date,

        __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_end_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_11);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_11, __pyx__function);
          __pyx_t_3 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[5] = {__pyx_t_6, __pyx_mstate_global->__pyx_n_u_mergers, __pyx_t_10, __pyx_t_8, __pyx_t_2};
          __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+__pyx_t_3, (5-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_XDECREF_SET(__pyx_v_statement, __pyx_t_1);
        __pyx_t_1 = 0;

     138:         )

    +139:         c.execute(statement, t)

        __pyx_t_11 = __pyx_v_c;
        __Pyx_INCREF(__pyx_t_11);
        __pyx_t_3 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_v_statement, __pyx_v_t};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    +140:         mergers_to_query = mergers_to_query[query_len:]

        __Pyx_INCREF(__pyx_v_query_len);
        __pyx_t_1 = __pyx_v_query_len;
        __pyx_t_7 = (__pyx_t_1 == Py_None);
        if (__pyx_t_7) {
          __pyx_t_4 = 0;
        } else {
          __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 140, __pyx_L1_error)
          __pyx_t_4 = __pyx_t_9;
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_v_mergers_to_query, __pyx_t_4, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF_SET(__pyx_v_mergers_to_query, ((PyObject*)__pyx_t_1));
        __pyx_t_1 = 0;

    +141:         mergers_results.extend(c.fetchall())

        __pyx_t_11 = __pyx_v_c;
        __Pyx_INCREF(__pyx_t_11);
        __pyx_t_3 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_fetchall, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_12 = __Pyx_PyList_Extend(__pyx_v_mergers_results, __pyx_t_1); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 141, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }

     142:

    +143:     dividends_to_query = [str(a) for a in assets if a in dividends_sids]

      { /* enter inner scope */
        __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L53_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (likely(PyList_CheckExact(((PyObject *)__pyx_v_assets))) || PyTuple_CheckExact(((PyObject *)__pyx_v_assets))) {
          __pyx_t_11 = ((PyObject *)__pyx_v_assets); __Pyx_INCREF(__pyx_t_11);
          __pyx_t_4 = 0;
          __pyx_t_5 = NULL;
        } else {
          __pyx_t_4 = -1; __pyx_t_11 = PyObject_GetIter(((PyObject *)__pyx_v_assets)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 143, __pyx_L53_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_5 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L53_error)
        }
        for (;;) {
          if (likely(!__pyx_t_5)) {
            if (likely(PyList_CheckExact(__pyx_t_11))) {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_11);
                #if !CYTHON_ASSUME_SAFE_SIZE
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 143, __pyx_L53_error)
                #endif
                if (__pyx_t_4 >= __pyx_temp) break;
              }
              __pyx_t_2 = __Pyx_PyList_GetItemRef(__pyx_t_11, __pyx_t_4);
              ++__pyx_t_4;
            } else {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_11);
                #if !CYTHON_ASSUME_SAFE_SIZE
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 143, __pyx_L53_error)
                #endif
                if (__pyx_t_4 >= __pyx_temp) break;
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_2 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_4));
              #else
              __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_11, __pyx_t_4);
              #endif
              ++__pyx_t_4;
            }
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L53_error)
          } else {
            __pyx_t_2 = __pyx_t_5(__pyx_t_11);
            if (unlikely(!__pyx_t_2)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 143, __pyx_L53_error)
                PyErr_Clear();
              }
              break;
            }
          }
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_XDECREF_SET(__pyx_8genexpr7__pyx_v_a, __pyx_t_2);
          __pyx_t_2 = 0;
          if (unlikely(__pyx_v_dividends_sids == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
            __PYX_ERR(0, 143, __pyx_L53_error)
          }
          __pyx_t_7 = (__Pyx_PySet_ContainsTF(__pyx_8genexpr7__pyx_v_a, __pyx_v_dividends_sids, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 143, __pyx_L53_error)
          if (__pyx_t_7) {
            __pyx_t_2 = __Pyx_PyObject_Unicode(__pyx_8genexpr7__pyx_v_a); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L53_error)
            __Pyx_GOTREF(__pyx_t_2);
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 143, __pyx_L53_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_a); __pyx_8genexpr7__pyx_v_a = 0;
        goto __pyx_L58_exit_scope;
        __pyx_L53_error:;
        __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_a); __pyx_8genexpr7__pyx_v_a = 0;
        goto __pyx_L1_error;
        __pyx_L58_exit_scope:;
      } /* exit inner scope */
      __pyx_v_dividends_to_query = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

    +144:     dividends_results = []

      __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_v_dividends_results = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

    +145:     while dividends_to_query:

      while (1) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_v_dividends_to_query);
          if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 145, __pyx_L1_error)
          __pyx_t_7 = (__pyx_temp != 0);
        }

        if (!__pyx_t_7) break;

    +146:         query_len = min(len(dividends_to_query), SQLITE_MAX_IN_STATEMENT)

        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_SQLITE_MAX_IN_STATEMENT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_PyList_GET_SIZE(__pyx_v_dividends_to_query); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 146, __pyx_L1_error)
        __pyx_t_2 = PyLong_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_8 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 146, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 146, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (__pyx_t_7) {
          __Pyx_INCREF(__pyx_t_1);
          __pyx_t_11 = __pyx_t_1;
        } else {
          __pyx_t_8 = PyLong_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 146, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_11 = __pyx_t_8;
          __pyx_t_8 = 0;
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __pyx_t_11;
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF_SET(__pyx_v_query_len, __pyx_t_1);
        __pyx_t_1 = 0;

    +147:         query_assets = dividends_to_query[:query_len]

        __Pyx_INCREF(__pyx_v_query_len);
        __pyx_t_1 = __pyx_v_query_len;
        __pyx_t_7 = (__pyx_t_1 == Py_None);
        if (__pyx_t_7) {
          __pyx_t_4 = PY_SSIZE_T_MAX;
        } else {
          __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 147, __pyx_L1_error)
          __pyx_t_4 = __pyx_t_9;
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_v_dividends_to_query, 0, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_XDECREF_SET(__pyx_v_query_assets, ((PyObject*)__pyx_t_1));
        __pyx_t_1 = 0;

    +148:         t = [str(a) for a in query_assets]

        { /* enter inner scope */
          __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L63_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_11 = __pyx_v_query_assets; __Pyx_INCREF(__pyx_t_11);
          __pyx_t_4 = 0;
          for (;;) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_11);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 148, __pyx_L63_error)
              #endif
              if (__pyx_t_4 >= __pyx_temp) break;
            }
            __pyx_t_8 = __Pyx_PyList_GetItemRef(__pyx_t_11, __pyx_t_4);
            ++__pyx_t_4;
            if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 148, __pyx_L63_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_XDECREF_SET(__pyx_8genexpr8__pyx_v_a, __pyx_t_8);
            __pyx_t_8 = 0;
            __pyx_t_8 = __Pyx_PyObject_Unicode(__pyx_8genexpr8__pyx_v_a); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 148, __pyx_L63_error)
            __Pyx_GOTREF(__pyx_t_8);
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 148, __pyx_L63_error)
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_a); __pyx_8genexpr8__pyx_v_a = 0;
          goto __pyx_L67_exit_scope;
          __pyx_L63_error:;
          __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_a); __pyx_8genexpr8__pyx_v_a = 0;
          goto __pyx_L1_error;
          __pyx_L67_exit_scope:;
        } /* exit inner scope */
        __Pyx_XDECREF_SET(__pyx_v_t, ((PyObject*)__pyx_t_1));
        __pyx_t_1 = 0;

    +149:         statement = ADJ_QUERY_TEMPLATE.format(

        __pyx_t_11 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_ADJ_QUERY_TEMPLATE); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 149, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 149, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

     150:             'dividends',

    +151:             ",".join(['?' for _ in query_assets]),

        { /* enter inner scope */
          __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 151, __pyx_L70_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_10 = __pyx_v_query_assets; __Pyx_INCREF(__pyx_t_10);
          __pyx_t_4 = 0;
          for (;;) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_10);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 151, __pyx_L70_error)
              #endif
              if (__pyx_t_4 >= __pyx_temp) break;
            }
            __pyx_t_6 = __Pyx_PyList_GetItemRef(__pyx_t_10, __pyx_t_4);
            ++__pyx_t_4;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 151, __pyx_L70_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_XDECREF_SET(__pyx_8genexpr9__pyx_v__, __pyx_t_6);
            __pyx_t_6 = 0;
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_mstate_global->__pyx_kp_u__2))) __PYX_ERR(0, 151, __pyx_L70_error)
          }
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_8genexpr9__pyx_v__); __pyx_8genexpr9__pyx_v__ = 0;
          goto __pyx_L74_exit_scope;
          __pyx_L70_error:;
          __Pyx_XDECREF(__pyx_8genexpr9__pyx_v__); __pyx_8genexpr9__pyx_v__ = 0;
          goto __pyx_L1_error;
          __pyx_L74_exit_scope:;
        } /* exit inner scope */
        __pyx_t_10 = PyUnicode_Join(__pyx_mstate_global->__pyx_kp_u_, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 151, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    +152:             start_date,

        __pyx_t_8 = __Pyx_PyLong_From_int(__pyx_v_start_date); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 152, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);

    +153:             end_date,

        __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_end_date); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 153, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_11);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_3 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[5] = {__pyx_t_11, __pyx_mstate_global->__pyx_n_u_dividends, __pyx_t_10, __pyx_t_8, __pyx_t_6};
          __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+__pyx_t_3, (5-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_XDECREF_SET(__pyx_v_statement, __pyx_t_1);
        __pyx_t_1 = 0;

     154:         )

    +155:         c.execute(statement, t)

        __pyx_t_2 = __pyx_v_c;
        __Pyx_INCREF(__pyx_t_2);
        __pyx_t_3 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_v_statement, __pyx_v_t};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    +156:         dividends_to_query = dividends_to_query[query_len:]

        __Pyx_INCREF(__pyx_v_query_len);
        __pyx_t_1 = __pyx_v_query_len;
        __pyx_t_7 = (__pyx_t_1 == Py_None);
        if (__pyx_t_7) {
          __pyx_t_4 = 0;
        } else {
          __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 156, __pyx_L1_error)
          __pyx_t_4 = __pyx_t_9;
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_v_dividends_to_query, __pyx_t_4, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF_SET(__pyx_v_dividends_to_query, ((PyObject*)__pyx_t_1));
        __pyx_t_1 = 0;

    +157:         dividends_results.extend(c.fetchall())

        __pyx_t_2 = __pyx_v_c;
        __Pyx_INCREF(__pyx_t_2);
        __pyx_t_3 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_fetchall, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_12 = __Pyx_PyList_Extend(__pyx_v_dividends_results, __pyx_t_1); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 157, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }

     158:

    +159:     return splits_results, mergers_results, dividends_results

      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_splits_results);
      __Pyx_GIVEREF(__pyx_v_splits_results);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_splits_results) != (0)) __PYX_ERR(0, 159, __pyx_L1_error);
      __Pyx_INCREF(__pyx_v_mergers_results);
      __Pyx_GIVEREF(__pyx_v_mergers_results);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_mergers_results) != (0)) __PYX_ERR(0, 159, __pyx_L1_error);
      __Pyx_INCREF(__pyx_v_dividends_results);
      __Pyx_GIVEREF(__pyx_v_dividends_results);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_dividends_results) != (0)) __PYX_ERR(0, 159, __pyx_L1_error);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      __Pyx_TraceReturnValue(__pyx_r, 197, 0, __PYX_ERR(0, 159, __pyx_L1_error));
      goto __pyx_L0;

     160:

     161:

    +162: cpdef load_adjustments_from_sqlite(object adjustments_db,

    static PyObject *__pyx_pw_7zipline_4data_12_adjustments_1load_adjustments_from_sqlite(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 PyObject *__pyx_f_7zipline_4data_12_adjustments_load_adjustments_from_sqlite(PyObject *__pyx_v_adjustments_db, __pyx_t_7zipline_4data_12_adjustments_DatetimeIndex_t __pyx_v_dates, __pyx_t_7zipline_4data_12_adjustments_Int64Index_t __pyx_v_assets, PyLongObject *__pyx_v_should_include_splits, PyLongObject *__pyx_v_should_include_mergers, PyLongObject *__pyx_v_should_include_dividends, PyObject *__pyx_v_adjustment_type, CYTHON_UNUSED int __pyx_skip_dispatch) {
      PyLongObject *__pyx_v_should_include_price_adjustments = 0;
      PyLongObject *__pyx_v_should_include_volume_adjustments = 0;
      int __pyx_v_start_date;
      int __pyx_v_end_date;
      PyObject *__pyx_v_split_sids = 0;
      PyObject *__pyx_v_merger_sids = 0;
      PyObject *__pyx_v_dividend_sids = 0;
      PyObject *__pyx_v_splits = 0;
      PyObject *__pyx_v_mergers = 0;
      PyObject *__pyx_v_dividends = 0;
      PyObject *__pyx_v_price_adjustments = 0;
      PyObject *__pyx_v_volume_adjustments = 0;
      PyObject *__pyx_v_result = 0;
      PyObject *__pyx_v_asset_ixs = 0;
      PyObject *__pyx_v_date_ixs = 0;
      int __pyx_v_i;
      int __pyx_v_dt;
      __pyx_t_5numpy_int64_t __pyx_v_sid;
      __pyx_t_5numpy_float64_t __pyx_v_ratio;
      int __pyx_v_eff_date;
      int __pyx_v_date_loc;
      Py_ssize_t __pyx_v_asset_ix;
      PyArrayObject *__pyx_v__dates_seconds = 0;
      PyObject *__pyx_v_price_adj = NULL;
      PyObject *__pyx_v_volume_adj = NULL;
      __Pyx_LocalBuf_ND __pyx_pybuffernd__dates_seconds;
      __Pyx_Buffer __pyx_pybuffer__dates_seconds;
      PyObject *__pyx_r = NULL;
      __Pyx_TraceDeclarationsFunc
      __Pyx_TraceFrameInit(((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[44]))
      __Pyx_TraceStartFunc("load_adjustments_from_sqlite", __pyx_f[0], 162, 0, 0, __pyx_skip_dispatch, __PYX_ERR(0, 162, __pyx_L1_error));
      __Pyx_INCREF((PyObject *)__pyx_v_should_include_mergers);
      __Pyx_INCREF((PyObject *)__pyx_v_should_include_dividends);
      __pyx_pybuffer__dates_seconds.pybuffer.buf = NULL;
      __pyx_pybuffer__dates_seconds.refcount = 0;
      __pyx_pybuffernd__dates_seconds.data = NULL;
      __pyx_pybuffernd__dates_seconds.rcbuffer = &__pyx_pybuffer__dates_seconds;
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_6);
      __Pyx_XDECREF(__pyx_t_7);
      __Pyx_XDECREF(__pyx_t_9);
      __Pyx_XDECREF(__pyx_t_18);
      __Pyx_XDECREF(__pyx_t_19);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__dates_seconds.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_TraceException(__pyx_lineno, 0, 0);
      #if CYTHON_USE_SYS_MONITORING
      __Pyx_TraceExceptionUnwind(0, 0);
      #else
      __Pyx_TraceReturnValue(NULL, 0, 0, __PYX_ERR(0, 162, __pyx_L1_error));
      #endif
      __Pyx_AddTraceback("zipline.data._adjustments.load_adjustments_from_sqlite", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = 0;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd__dates_seconds.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_should_include_price_adjustments);
      __Pyx_XDECREF((PyObject *)__pyx_v_should_include_volume_adjustments);
      __Pyx_XDECREF(__pyx_v_split_sids);
      __Pyx_XDECREF(__pyx_v_merger_sids);
      __Pyx_XDECREF(__pyx_v_dividend_sids);
      __Pyx_XDECREF(__pyx_v_splits);
      __Pyx_XDECREF(__pyx_v_mergers);
      __Pyx_XDECREF(__pyx_v_dividends);
      __Pyx_XDECREF(__pyx_v_price_adjustments);
      __Pyx_XDECREF(__pyx_v_volume_adjustments);
      __Pyx_XDECREF(__pyx_v_result);
      __Pyx_XDECREF(__pyx_v_asset_ixs);
      __Pyx_XDECREF(__pyx_v_date_ixs);
      __Pyx_XDECREF((PyObject *)__pyx_v__dates_seconds);
      __Pyx_XDECREF(__pyx_v_price_adj);
      __Pyx_XDECREF(__pyx_v_volume_adj);
      __Pyx_XDECREF((PyObject *)__pyx_v_should_include_mergers);
      __Pyx_XDECREF((PyObject *)__pyx_v_should_include_dividends);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_PyMonitoring_ExitScope(0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    /* Python wrapper */
    static PyObject *__pyx_pw_7zipline_4data_12_adjustments_1load_adjustments_from_sqlite(PyObject *__pyx_self,
    #if CYTHON_METH_FASTCALL
    PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
    #else
    PyObject *__pyx_args, PyObject *__pyx_kwds
    #endif
    ); /*proto*/
    PyDoc_STRVAR(__pyx_doc_7zipline_4data_12_adjustments_load_adjustments_from_sqlite, "Load a dictionary of Adjustment objects from adjustments_db.\n\n    Parameters\n    ----------\n    adjustments_db : sqlite3.Connection\n        Connection to a sqlite3 table in the format written by\n        SQLiteAdjustmentWriter.\n    dates : pd.DatetimeIndex\n        Dates for which adjustments are needed.\n    assets : pd.Int64Index\n        Assets for which adjustments are needed.\n    should_include_splits : bool\n        Whether split adjustments should be included.\n    should_include_mergers : bool\n        Whether merger adjustments should be included.\n    should_include_dividends : bool\n        Whether dividend adjustments should be included.\n    adjustment_type : str\n        Whether price adjustments, volume adjustments, or both, should be\n        included in the output.\n\n    Returns\n    -------\n    adjustments : dict[str -> dict[int -> Adjustment]]\n        A dictionary containing price and/or volume adjustment mappings from\n        index to adjustment objects to apply at that index.\n    ");
    static PyMethodDef __pyx_mdef_7zipline_4data_12_adjustments_1load_adjustments_from_sqlite = {"load_adjustments_from_sqlite", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7zipline_4data_12_adjustments_1load_adjustments_from_sqlite, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7zipline_4data_12_adjustments_load_adjustments_from_sqlite};
    static PyObject *__pyx_pw_7zipline_4data_12_adjustments_1load_adjustments_from_sqlite(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_adjustments_db = 0;
      __pyx_t_7zipline_4data_12_adjustments_DatetimeIndex_t __pyx_v_dates = 0;
      __pyx_t_7zipline_4data_12_adjustments_Int64Index_t __pyx_v_assets = 0;
      PyLongObject *__pyx_v_should_include_splits = 0;
      PyLongObject *__pyx_v_should_include_mergers = 0;
      PyLongObject *__pyx_v_should_include_dividends = 0;
      PyObject *__pyx_v_adjustment_type = 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("load_adjustments_from_sqlite (wrapper)", 0);
      #if !CYTHON_METH_FASTCALL
      #if CYTHON_ASSUME_SAFE_SIZE
      __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 ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_adjustments_db,&__pyx_mstate_global->__pyx_n_u_dates,&__pyx_mstate_global->__pyx_n_u_assets,&__pyx_mstate_global->__pyx_n_u_should_include_splits,&__pyx_mstate_global->__pyx_n_u_should_include_mergers,&__pyx_mstate_global->__pyx_n_u_should_include_dividends,&__pyx_mstate_global->__pyx_n_u_adjustment_type,0};
      PyObject* values[7] = {0,0,0,0,0,0,0};
        const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
        if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 162, __pyx_L3_error)
        if (__pyx_kwds_len > 0) {
          switch (__pyx_nargs) {
            case  7:
            values[6] = __Pyx_ArgRef_FASTCALL(__pyx_args, 6);
            if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[6])) __PYX_ERR(0, 162, __pyx_L3_error)
            CYTHON_FALLTHROUGH;
            case  6:
            values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
            if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 162, __pyx_L3_error)
            CYTHON_FALLTHROUGH;
            case  5:
            values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
            if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 162, __pyx_L3_error)
            CYTHON_FALLTHROUGH;
            case  4:
            values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
            if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 162, __pyx_L3_error)
            CYTHON_FALLTHROUGH;
            case  3:
            values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
            if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 162, __pyx_L3_error)
            CYTHON_FALLTHROUGH;
            case  2:
            values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
            if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 162, __pyx_L3_error)
            CYTHON_FALLTHROUGH;
            case  1:
            values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
            if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 162, __pyx_L3_error)
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          const Py_ssize_t kwd_pos_args = __pyx_nargs;
          if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "load_adjustments_from_sqlite", 0) < (0)) __PYX_ERR(0, 162, __pyx_L3_error)
          for (Py_ssize_t i = __pyx_nargs; i < 7; i++) {
            if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("load_adjustments_from_sqlite", 1, 7, 7, i); __PYX_ERR(0, 162, __pyx_L3_error) }
          }
        } else if (unlikely(__pyx_nargs != 7)) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
          if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 162, __pyx_L3_error)
          values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
          if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 162, __pyx_L3_error)
          values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
          if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 162, __pyx_L3_error)
          values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
          if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 162, __pyx_L3_error)
          values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
          if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 162, __pyx_L3_error)
          values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
          if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 162, __pyx_L3_error)
          values[6] = __Pyx_ArgRef_FASTCALL(__pyx_args, 6);
          if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[6])) __PYX_ERR(0, 162, __pyx_L3_error)
        }
        __pyx_v_adjustments_db = values[0];
        __pyx_v_dates = ((__pyx_t_7zipline_4data_12_adjustments_DatetimeIndex_t)values[1]);
        __pyx_v_assets = ((__pyx_t_7zipline_4data_12_adjustments_Int64Index_t)values[2]);
        __pyx_v_should_include_splits = ((PyLongObject *)values[3]);
        __pyx_v_should_include_mergers = ((PyLongObject *)values[4]);
        __pyx_v_should_include_dividends = ((PyLongObject *)values[5]);
        __pyx_v_adjustment_type = ((PyObject*)values[6]);
      }
      goto __pyx_L6_skip;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("load_adjustments_from_sqlite", 1, 7, 7, __pyx_nargs); __PYX_ERR(0, 162, __pyx_L3_error)
      __pyx_L6_skip:;
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L3_error:;
      for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
        Py_XDECREF(values[__pyx_temp]);
      }
      __Pyx_AddTraceback("zipline.data._adjustments.load_adjustments_from_sqlite", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_should_include_splits), __pyx_mstate_global->__pyx_ptype_7cpython_4bool_bool, 1, "should_include_splits", 0))) __PYX_ERR(0, 165, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_should_include_mergers), __pyx_mstate_global->__pyx_ptype_7cpython_4bool_bool, 1, "should_include_mergers", 0))) __PYX_ERR(0, 166, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_should_include_dividends), __pyx_mstate_global->__pyx_ptype_7cpython_4bool_bool, 1, "should_include_dividends", 0))) __PYX_ERR(0, 167, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_adjustment_type), (&PyUnicode_Type), 1, "adjustment_type", 1))) __PYX_ERR(0, 168, __pyx_L1_error)
      __pyx_r = __pyx_pf_7zipline_4data_12_adjustments_load_adjustments_from_sqlite(__pyx_self, __pyx_v_adjustments_db, __pyx_v_dates, __pyx_v_assets, __pyx_v_should_include_splits, __pyx_v_should_include_mergers, __pyx_v_should_include_dividends, __pyx_v_adjustment_type);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
        Py_XDECREF(values[__pyx_temp]);
      }
      goto __pyx_L7_cleaned_up;
      __pyx_L0:;
      for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
        Py_XDECREF(values[__pyx_temp]);
      }
      __pyx_L7_cleaned_up:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_7zipline_4data_12_adjustments_load_adjustments_from_sqlite(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_adjustments_db, __pyx_t_7zipline_4data_12_adjustments_DatetimeIndex_t __pyx_v_dates, __pyx_t_7zipline_4data_12_adjustments_Int64Index_t __pyx_v_assets, PyLongObject *__pyx_v_should_include_splits, PyLongObject *__pyx_v_should_include_mergers, PyLongObject *__pyx_v_should_include_dividends, PyObject *__pyx_v_adjustment_type) {
      PyObject *__pyx_r = NULL;
      __Pyx_TraceDeclarationsFunc
      __Pyx_TraceFrameInit(((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[44]))
      __Pyx_TraceStartFunc("load_adjustments_from_sqlite (wrapper)", __pyx_f[0], 162, 0, 0, 0, __PYX_ERR(0, 162, __pyx_L1_error));
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __pyx_f_7zipline_4data_12_adjustments_load_adjustments_from_sqlite(__pyx_v_adjustments_db, __pyx_v_dates, __pyx_v_assets, __pyx_v_should_include_splits, __pyx_v_should_include_mergers, __pyx_v_should_include_dividends, __pyx_v_adjustment_type, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;

      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_TraceException(__pyx_lineno, 0, 0);
      #if CYTHON_USE_SYS_MONITORING
      __Pyx_TraceExceptionUnwind(0, 0);
      #else
      __Pyx_TraceReturnValue(NULL, 0, 0, __PYX_ERR(0, 162, __pyx_L1_error));
      #endif
      __Pyx_AddTraceback("zipline.data._adjustments.load_adjustments_from_sqlite", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_PyMonitoring_ExitScope(0);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_7zipline_4data_12_adjustments_1load_adjustments_from_sqlite, 0, __pyx_mstate_global->__pyx_n_u_load_adjustments_from_sqlite, NULL, __pyx_mstate_global->__pyx_n_u_zipline_data__adjustments, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[44])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_load_adjustments_from_sqlite, __pyx_t_2) < (0)) __PYX_ERR(0, 162, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

     163:                                    DatetimeIndex_t dates,

     164:                                    Int64Index_t assets,

     165:                                    bool should_include_splits,

     166:                                    bool should_include_mergers,

     167:                                    bool should_include_dividends,

     168:                                    str adjustment_type):

     169:     """Load a dictionary of Adjustment objects from adjustments_db.

     170:

     171:     Parameters

     172:     ----------

     173:     adjustments_db : sqlite3.Connection

     174:         Connection to a sqlite3 table in the format written by

     175:         SQLiteAdjustmentWriter.

     176:     dates : pd.DatetimeIndex

     177:         Dates for which adjustments are needed.

     178:     assets : pd.Int64Index

     179:         Assets for which adjustments are needed.

     180:     should_include_splits : bool

     181:         Whether split adjustments should be included.

     182:     should_include_mergers : bool

     183:         Whether merger adjustments should be included.

     184:     should_include_dividends : bool

     185:         Whether dividend adjustments should be included.

     186:     adjustment_type : str

     187:         Whether price adjustments, volume adjustments, or both, should be

     188:         included in the output.

     189:

     190:     Returns

     191:     -------

     192:     adjustments : dict[str -> dict[int -> Adjustment]]

     193:         A dictionary containing price and/or volume adjustment mappings from

     194:         index to adjustment objects to apply at that index.

     195:     """

     196:

    +197:     if not (adjustment_type == 'price' or

      __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_adjustment_type, __pyx_mstate_global->__pyx_n_u_price, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 197, __pyx_L1_error)
      if (!__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L4_bool_binop_done;
      }
    /* … */
      __pyx_t_2 = (!__pyx_t_1);
      if (unlikely(__pyx_t_2)) {
    /* … */
      }

    +198:             adjustment_type == 'volume' or

      __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_adjustment_type, __pyx_mstate_global->__pyx_n_u_volume, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 198, __pyx_L1_error)
      if (!__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L4_bool_binop_done;
      }

    +199:             adjustment_type == 'all'):

      __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_adjustment_type, __pyx_mstate_global->__pyx_n_u_all, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 199, __pyx_L1_error)
      __pyx_t_1 = __pyx_t_2;
      __pyx_L4_bool_binop_done:;

    +200:         raise ValueError(

        __pyx_t_4 = NULL;
        __Pyx_INCREF(__pyx_builtin_ValueError);
        __pyx_t_5 = __pyx_builtin_ValueError;

    +201:             "%s is not a valid adjustment type.\n"

        __pyx_t_7 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_is_not_a_valid_adjustment_type); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 201, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_8 = 1;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_7};
          __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __PYX_ERR(0, 200, __pyx_L1_error)

     202:             "Valid adjustment types are 'price', 'volume', and 'all'.\n" % (

    +203:                 adjustment_type,

        __pyx_t_6 = __Pyx_PyUnicode_Unicode(__pyx_v_adjustment_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 203, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);

     204:             )

     205:         )

     206:

     207:     cdef bool should_include_price_adjustments = (

    +208:         adjustment_type == 'all' or adjustment_type == 'price'

      __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_adjustment_type, __pyx_mstate_global->__pyx_n_u_all, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 208, __pyx_L1_error)
      if (!__pyx_t_2) {
      } else {
        __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 208, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (!(likely(__Pyx_TypeTest(__pyx_t_5, __pyx_mstate_global->__pyx_ptype_7cpython_4bool_bool)))) __PYX_ERR(0, 208, __pyx_L1_error)
        __pyx_t_3 = __pyx_t_5;
        __pyx_t_5 = 0;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_adjustment_type, __pyx_mstate_global->__pyx_n_u_price, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 208, __pyx_L1_error)
      __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 208, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (!(likely(__Pyx_TypeTest(__pyx_t_5, __pyx_mstate_global->__pyx_ptype_7cpython_4bool_bool)))) __PYX_ERR(0, 208, __pyx_L1_error)
      __pyx_t_3 = __pyx_t_5;
      __pyx_t_5 = 0;
      __pyx_L7_bool_binop_done:;
      __pyx_v_should_include_price_adjustments = ((PyLongObject *)__pyx_t_3);
      __pyx_t_3 = 0;

     209:     )

     210:     cdef bool should_include_volume_adjustments = (

    +211:         adjustment_type == 'all' or adjustment_type == 'volume'

      __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_adjustment_type, __pyx_mstate_global->__pyx_n_u_all, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 211, __pyx_L1_error)
      if (!__pyx_t_2) {
      } else {
        __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 211, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (!(likely(__Pyx_TypeTest(__pyx_t_5, __pyx_mstate_global->__pyx_ptype_7cpython_4bool_bool)))) __PYX_ERR(0, 211, __pyx_L1_error)
        __pyx_t_3 = __pyx_t_5;
        __pyx_t_5 = 0;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_adjustment_type, __pyx_mstate_global->__pyx_n_u_volume, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 211, __pyx_L1_error)
      __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 211, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (!(likely(__Pyx_TypeTest(__pyx_t_5, __pyx_mstate_global->__pyx_ptype_7cpython_4bool_bool)))) __PYX_ERR(0, 211, __pyx_L1_error)
      __pyx_t_3 = __pyx_t_5;
      __pyx_t_5 = 0;
      __pyx_L9_bool_binop_done:;
      __pyx_v_should_include_volume_adjustments = ((PyLongObject *)__pyx_t_3);
      __pyx_t_3 = 0;

     212:     )

     213:

    +214:     if not should_include_price_adjustments:

      __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_should_include_price_adjustments)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 214, __pyx_L1_error)
      __pyx_t_1 = (!__pyx_t_2);
      if (__pyx_t_1) {
    /* … */
      }

    +215:         should_include_mergers = False

        __Pyx_INCREF(Py_False);
        __Pyx_DECREF_SET(__pyx_v_should_include_mergers, ((PyLongObject *)Py_False));

    +216:         should_include_dividends = False

        __Pyx_INCREF(Py_False);
        __Pyx_DECREF_SET(__pyx_v_should_include_dividends, ((PyLongObject *)Py_False));

     217:

    +218:     cdef int start_date = timedelta_to_integral_seconds(dates[0] - EPOCH)

      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_timedelta_to_integral_seconds); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 218, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_v_dates), 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_EPOCH); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 218, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = PyNumber_Subtract(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 218, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_9};
        __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      }
      __pyx_t_10 = __Pyx_PyLong_As_int(__pyx_t_3); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_start_date = __pyx_t_10;

    +219:     cdef int end_date = timedelta_to_integral_seconds(dates[-1] - EPOCH)

      __pyx_t_7 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_timedelta_to_integral_seconds); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 219, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_5 = __Pyx_GetItemInt(((PyObject *)__pyx_v_dates), -1L, long, 1, __Pyx_PyLong_From_long, 0, 1, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 219, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_EPOCH); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 219, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = PyNumber_Subtract(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 219, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
        assert(__pyx_t_7);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 219, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      }
      __pyx_t_10 = __Pyx_PyLong_As_int(__pyx_t_3); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 219, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_end_date = __pyx_t_10;

     220:     cdef:

     221:         set split_sids

     222:         set merger_sids

     223:         set dividend_sids

     224:

    +225:     if should_include_splits:

      __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_should_include_splits)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 225, __pyx_L1_error)
      if (__pyx_t_1) {
    /* … */
        goto __pyx_L12;
      }

    +226:         split_sids = _get_split_sids(

        __pyx_t_3 = __pyx_f_7zipline_4data_12_adjustments__get_split_sids(__pyx_v_adjustments_db, __pyx_v_start_date, __pyx_v_end_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 226, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_v_split_sids = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;

     227:             adjustments_db,

     228:             start_date,

     229:             end_date,

     230:         )

     231:     else:

    +232:         split_sids = set()

      /*else*/ {
        __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 232, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_v_split_sids = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;
      }
      __pyx_L12:;

     233:

    +234:     if should_include_mergers:

      __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_should_include_mergers)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 234, __pyx_L1_error)
      if (__pyx_t_1) {
    /* … */
        goto __pyx_L13;
      }

    +235:         merger_sids = _get_merger_sids(

        __pyx_t_3 = __pyx_f_7zipline_4data_12_adjustments__get_merger_sids(__pyx_v_adjustments_db, __pyx_v_start_date, __pyx_v_end_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 235, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_v_merger_sids = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;

     236:             adjustments_db,

     237:             start_date,

     238:             end_date,

     239:         )

     240:     else:

    +241:         merger_sids = set()

      /*else*/ {
        __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 241, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_v_merger_sids = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;
      }
      __pyx_L13:;

     242:

    +243:     if should_include_dividends:

      __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_should_include_dividends)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 243, __pyx_L1_error)
      if (__pyx_t_1) {
    /* … */
        goto __pyx_L14;
      }

    +244:         dividend_sids = _get_dividend_sids(

        __pyx_t_3 = __pyx_f_7zipline_4data_12_adjustments__get_dividend_sids(__pyx_v_adjustments_db, __pyx_v_start_date, __pyx_v_end_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 244, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_v_dividend_sids = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;

     245:             adjustments_db,

     246:             start_date,

     247:             end_date,

     248:         )

     249:     else:

    +250:         dividend_sids = set()

      /*else*/ {
        __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_v_dividend_sids = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;
      }
      __pyx_L14:;

     251:

     252:     cdef:

     253:         list splits, mergers, dividends

    +254:     splits, mergers, dividends = _adjustments(

      __pyx_t_3 = __pyx_f_7zipline_4data_12_adjustments__adjustments(__pyx_v_adjustments_db, __pyx_v_split_sids, __pyx_v_merger_sids, __pyx_v_dividend_sids, __pyx_v_start_date, __pyx_v_end_date, __pyx_v_assets); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 254, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 3)) {
          if (size > 3) __Pyx_RaiseTooManyValuesError(3);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 254, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0);
          __Pyx_INCREF(__pyx_t_9);
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
          __Pyx_INCREF(__pyx_t_4);
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2);
          __Pyx_INCREF(__pyx_t_7);
        } else {
          __pyx_t_9 = __Pyx_PyList_GetItemRef(sequence, 0);
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 254, __pyx_L1_error)
          __Pyx_XGOTREF(__pyx_t_9);
          __pyx_t_4 = __Pyx_PyList_GetItemRef(sequence, 1);
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 254, __pyx_L1_error)
          __Pyx_XGOTREF(__pyx_t_4);
          __pyx_t_7 = __Pyx_PyList_GetItemRef(sequence, 2);
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 254, __pyx_L1_error)
          __Pyx_XGOTREF(__pyx_t_7);
        }
        #else
        __pyx_t_9 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 254, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_4 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 254, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = __Pyx_PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 254, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 254, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_11 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6);
        index = 0; __pyx_t_9 = __pyx_t_11(__pyx_t_6); if (unlikely(!__pyx_t_9)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_9);
        index = 1; __pyx_t_4 = __pyx_t_11(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 2; __pyx_t_7 = __pyx_t_11(__pyx_t_6); if (unlikely(!__pyx_t_7)) goto __pyx_L15_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_6), 3) < (0)) __PYX_ERR(0, 254, __pyx_L1_error)
        __pyx_t_11 = NULL;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L16_unpacking_done;
        __pyx_L15_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_11 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 254, __pyx_L1_error)
        __pyx_L16_unpacking_done:;
      }
      if (!(likely(PyList_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_t_9))) __PYX_ERR(0, 254, __pyx_L1_error)
      if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_t_4))) __PYX_ERR(0, 254, __pyx_L1_error)
      if (!(likely(PyList_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_t_7))) __PYX_ERR(0, 254, __pyx_L1_error)
      __pyx_v_splits = ((PyObject*)__pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_v_mergers = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_v_dividends = ((PyObject*)__pyx_t_7);
      __pyx_t_7 = 0;

     255:         adjustments_db,

     256:         split_sids,

     257:         merger_sids,

     258:         dividend_sids,

     259:         start_date,

     260:         end_date,

     261:         assets,

     262:     )

     263:

    +264:     cdef dict price_adjustments = {}

      __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 264, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_price_adjustments = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;

    +265:     cdef dict volume_adjustments = {}

      __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_volume_adjustments = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;

    +266:     cdef dict result = {}

      __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 266, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_result = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;

    +267:     cdef dict asset_ixs = {}  # Cache sid lookups here.

      __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_asset_ixs = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;

    +268:     cdef dict date_ixs = {}

      __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 268, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_v_date_ixs = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;

     269:     cdef:

     270:         int i

     271:         int dt

     272:         int64_t sid

     273:         float64_t ratio

     274:         int eff_date

     275:         int date_loc

     276:         Py_ssize_t asset_ix

     277:         dict col_adjustments

     278:

     279:     cdef ndarray[int64_t, ndim=1] _dates_seconds = \

    +280:         dates.values.astype('datetime64[s]').view(int64)

      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dates), __pyx_mstate_global->__pyx_n_u_values); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = __pyx_t_6;
      __Pyx_INCREF(__pyx_t_9);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_datetime64_s};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_astype, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 280, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_7 = __pyx_t_4;
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_int64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 280, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_6};
        __pyx_t_3 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_view, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      }
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_mstate_global->__pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 280, __pyx_L1_error)
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd__dates_seconds.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_3), &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          __pyx_v__dates_seconds = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd__dates_seconds.rcbuffer->pybuffer.buf = NULL;
          __PYX_ERR(0, 279, __pyx_L1_error)
        } else {__pyx_pybuffernd__dates_seconds.diminfo[0].strides = __pyx_pybuffernd__dates_seconds.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd__dates_seconds.diminfo[0].shape = __pyx_pybuffernd__dates_seconds.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_v__dates_seconds = ((PyArrayObject *)__pyx_t_3);
      __pyx_t_3 = 0;

     281:

     282:     # Pre-populate date index cache.

    +283:     for i, dt in enumerate(_dates_seconds):

      __pyx_t_10 = 0;
      if (likely(PyList_CheckExact(((PyObject *)__pyx_v__dates_seconds))) || PyTuple_CheckExact(((PyObject *)__pyx_v__dates_seconds))) {
        __pyx_t_3 = ((PyObject *)__pyx_v__dates_seconds); __Pyx_INCREF(__pyx_t_3);
        __pyx_t_12 = 0;
        __pyx_t_13 = NULL;
      } else {
        __pyx_t_12 = -1; __pyx_t_3 = PyObject_GetIter(((PyObject *)__pyx_v__dates_seconds)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_13 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 283, __pyx_L1_error)
      }
      for (;;) {
        if (likely(!__pyx_t_13)) {
          if (likely(PyList_CheckExact(__pyx_t_3))) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 283, __pyx_L1_error)
              #endif
              if (__pyx_t_12 >= __pyx_temp) break;
            }
            __pyx_t_4 = __Pyx_PyList_GetItemRef(__pyx_t_3, __pyx_t_12);
            ++__pyx_t_12;
          } else {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 283, __pyx_L1_error)
              #endif
              if (__pyx_t_12 >= __pyx_temp) break;
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_12));
            #else
            __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_12);
            #endif
            ++__pyx_t_12;
          }
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 283, __pyx_L1_error)
        } else {
          __pyx_t_4 = __pyx_t_13(__pyx_t_3);
          if (unlikely(!__pyx_t_4)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 283, __pyx_L1_error)
              PyErr_Clear();
            }
            break;
          }
        }
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_14 = __Pyx_PyLong_As_int(__pyx_t_4); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 283, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_v_dt = __pyx_t_14;
        __pyx_v_i = __pyx_t_10;
        __pyx_t_10 = (__pyx_t_10 + 1);
    /* … */
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    +284:         date_ixs[dt] = i

        __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 284, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_dt); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 284, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (unlikely((PyDict_SetItem(__pyx_v_date_ixs, __pyx_t_6, __pyx_t_4) < 0))) __PYX_ERR(0, 284, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

     285:

     286:     # splits affect prices and volumes, volumes is the inverse

    +287:     for sid, ratio, eff_date in splits:

      if (unlikely(__pyx_v_splits == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        __PYX_ERR(0, 287, __pyx_L1_error)
      }
      __pyx_t_3 = __pyx_v_splits; __Pyx_INCREF(__pyx_t_3);
      __pyx_t_12 = 0;
      for (;;) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 287, __pyx_L1_error)
          #endif
          if (__pyx_t_12 >= __pyx_temp) break;
        }
        __pyx_t_4 = __Pyx_PyList_GetItemRef(__pyx_t_3, __pyx_t_12);
        ++__pyx_t_12;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
          PyObject* sequence = __pyx_t_4;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 3)) {
            if (size > 3) __Pyx_RaiseTooManyValuesError(3);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(0, 287, __pyx_L1_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
            __Pyx_INCREF(__pyx_t_6);
            __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1);
            __Pyx_INCREF(__pyx_t_7);
            __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2);
            __Pyx_INCREF(__pyx_t_9);
          } else {
            __pyx_t_6 = __Pyx_PyList_GetItemRef(sequence, 0);
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
            __Pyx_XGOTREF(__pyx_t_6);
            __pyx_t_7 = __Pyx_PyList_GetItemRef(sequence, 1);
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 287, __pyx_L1_error)
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_9 = __Pyx_PyList_GetItemRef(sequence, 2);
            if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 287, __pyx_L1_error)
            __Pyx_XGOTREF(__pyx_t_9);
          }
          #else
          __pyx_t_6 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 287, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_9 = __Pyx_PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 287, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 287, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_11 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5);
          index = 0; __pyx_t_6 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_6)) goto __pyx_L22_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_6);
          index = 1; __pyx_t_7 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_7)) goto __pyx_L22_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_7);
          index = 2; __pyx_t_9 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_9)) goto __pyx_L22_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_9);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_5), 3) < (0)) __PYX_ERR(0, 287, __pyx_L1_error)
          __pyx_t_11 = NULL;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          goto __pyx_L23_unpacking_done;
          __pyx_L22_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_11 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(0, 287, __pyx_L1_error)
          __pyx_L23_unpacking_done:;
        }
        __pyx_t_15 = __Pyx_PyLong_As_npy_int64(__pyx_t_6); if (unlikely((__pyx_t_15 == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 287, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_16 = __Pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_16 == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 287, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_10 = __Pyx_PyLong_As_int(__pyx_t_9); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 287, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_v_sid = __pyx_t_15;
        __pyx_v_ratio = __pyx_t_16;
        __pyx_v_eff_date = __pyx_t_10;
    /* … */
        __pyx_L20_continue:;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    +288:         if eff_date < start_date:

        __pyx_t_1 = (__pyx_v_eff_date < __pyx_v_start_date);
        if (__pyx_t_1) {
    /* … */
        }

    +289:             continue

          goto __pyx_L20_continue;

     290:

    +291:         date_loc = _lookup_dt(date_ixs, eff_date, _dates_seconds)

        __pyx_t_4 = __pyx_f_7zipline_4data_12_adjustments__lookup_dt(__pyx_v_date_ixs, __pyx_v_eff_date, ((PyArrayObject *)__pyx_v__dates_seconds)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 291, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_10 = __Pyx_PyLong_As_int(__pyx_t_4); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 291, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_v_date_loc = __pyx_t_10;

     292:

    +293:         if not PyDict_Contains(asset_ixs, sid):

        __pyx_t_4 = __Pyx_PyLong_From_npy_int64(__pyx_v_sid); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 293, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_10 = PyDict_Contains(__pyx_v_asset_ixs, __pyx_t_4); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 293, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_1 = (!(__pyx_t_10 != 0));
        if (__pyx_t_1) {
    /* … */
        }

    +294:             asset_ixs[sid] = assets.get_loc(sid)

          __pyx_t_9 = ((PyObject *)__pyx_v_assets);
          __Pyx_INCREF(__pyx_t_9);
          __pyx_t_7 = __Pyx_PyLong_From_npy_int64(__pyx_v_sid); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 294, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_7};
            __pyx_t_4 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_get_loc, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 294, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
          }
          __pyx_t_7 = __Pyx_PyLong_From_npy_int64(__pyx_v_sid); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 294, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (unlikely((PyDict_SetItem(__pyx_v_asset_ixs, __pyx_t_7, __pyx_t_4) < 0))) __PYX_ERR(0, 294, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    +295:         asset_ix = asset_ixs[sid]

        __pyx_t_4 = __Pyx_PyLong_From_npy_int64(__pyx_v_sid); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 295, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_asset_ixs, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 295, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_17 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_17 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 295, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_v_asset_ix = __pyx_t_17;

     296:

    +297:         if should_include_price_adjustments:

        __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_should_include_price_adjustments)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 297, __pyx_L1_error)
        if (__pyx_t_1) {
    /* … */
        }

    +298:             price_adj = Float64Multiply(0, date_loc, asset_ix, asset_ix, ratio)

          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_Float64Multiply); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 298, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_date_loc); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 298, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_5 = PyLong_FromSsize_t(__pyx_v_asset_ix); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 298, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_18 = PyLong_FromSsize_t(__pyx_v_asset_ix); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 298, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_19 = PyFloat_FromDouble(__pyx_v_ratio); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 298, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_9))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[6] = {__pyx_t_4, __pyx_mstate_global->__pyx_int_0, __pyx_t_6, __pyx_t_5, __pyx_t_18, __pyx_t_19};
            __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+__pyx_t_8, (6-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 298, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_7);
          }
          __Pyx_XDECREF_SET(__pyx_v_price_adj, __pyx_t_7);
          __pyx_t_7 = 0;

    +299:             price_adjustments.setdefault(date_loc, []).append(price_adj)

          __pyx_t_7 = __Pyx_PyLong_From_int(__pyx_v_date_loc); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 299, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 299, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_19 = __Pyx_PyDict_SetDefault(__pyx_v_price_adjustments, __pyx_t_7, __pyx_t_9, -1L); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 299, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_20 = __Pyx_PyObject_Append(__pyx_t_19, __pyx_v_price_adj); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 299, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

     300:

    +301:         if should_include_volume_adjustments:

        __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_should_include_volume_adjustments)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 301, __pyx_L1_error)
        if (__pyx_t_1) {
    /* … */
        }

    +302:             volume_adj = Float64Multiply(

          __pyx_t_9 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_Float64Multiply); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 302, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);

    +303:                 0, date_loc, asset_ix, asset_ix, 1.0 / ratio

          __pyx_t_18 = __Pyx_PyLong_From_int(__pyx_v_date_loc); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 303, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_5 = PyLong_FromSsize_t(__pyx_v_asset_ix); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 303, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = PyLong_FromSsize_t(__pyx_v_asset_ix); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 303, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (unlikely(__pyx_v_ratio == 0)) {
            PyErr_SetString(PyExc_ZeroDivisionError, "float division");
            __PYX_ERR(0, 303, __pyx_L1_error)
          }
          __pyx_t_4 = PyFloat_FromDouble((((__pyx_t_5numpy_float64_t)1.0) / __pyx_v_ratio)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 303, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_7))) {
            __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
            assert(__pyx_t_9);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_9);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[6] = {__pyx_t_9, __pyx_mstate_global->__pyx_int_0, __pyx_t_18, __pyx_t_5, __pyx_t_6, __pyx_t_4};
            __pyx_t_19 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+__pyx_t_8, (6-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 302, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_19);
          }
          __Pyx_XDECREF_SET(__pyx_v_volume_adj, __pyx_t_19);
          __pyx_t_19 = 0;

     304:             )

    +305:             volume_adjustments.setdefault(date_loc, []).append(volume_adj)

          __pyx_t_19 = __Pyx_PyLong_From_int(__pyx_v_date_loc); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 305, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 305, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_4 = __Pyx_PyDict_SetDefault(__pyx_v_volume_adjustments, __pyx_t_19, __pyx_t_7, -1L); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 305, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_20 = __Pyx_PyObject_Append(__pyx_t_4, __pyx_v_volume_adj); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 305, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

     306:

     307:     # mergers and dividends affect prices only

    +308:     for sid, ratio, eff_date in chain(mergers, dividends):

      __pyx_t_4 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_chain); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 308, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_4);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_v_mergers, __pyx_v_dividends};
        __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      }
      if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
        __pyx_t_7 = __pyx_t_3; __Pyx_INCREF(__pyx_t_7);
        __pyx_t_12 = 0;
        __pyx_t_13 = NULL;
      } else {
        __pyx_t_12 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 308, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_13 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 308, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      for (;;) {
        if (likely(!__pyx_t_13)) {
          if (likely(PyList_CheckExact(__pyx_t_7))) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 308, __pyx_L1_error)
              #endif
              if (__pyx_t_12 >= __pyx_temp) break;
            }
            __pyx_t_3 = __Pyx_PyList_GetItemRef(__pyx_t_7, __pyx_t_12);
            ++__pyx_t_12;
          } else {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_7);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 308, __pyx_L1_error)
              #endif
              if (__pyx_t_12 >= __pyx_temp) break;
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_3 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_12));
            #else
            __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_12);
            #endif
            ++__pyx_t_12;
          }
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __pyx_L1_error)
        } else {
          __pyx_t_3 = __pyx_t_13(__pyx_t_7);
          if (unlikely(!__pyx_t_3)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 308, __pyx_L1_error)
              PyErr_Clear();
            }
            break;
          }
        }
        __Pyx_GOTREF(__pyx_t_3);
        if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
          PyObject* sequence = __pyx_t_3;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 3)) {
            if (size > 3) __Pyx_RaiseTooManyValuesError(3);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(0, 308, __pyx_L1_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
            __Pyx_INCREF(__pyx_t_4);
            __pyx_t_19 = PyTuple_GET_ITEM(sequence, 1);
            __Pyx_INCREF(__pyx_t_19);
            __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2);
            __Pyx_INCREF(__pyx_t_6);
          } else {
            __pyx_t_4 = __Pyx_PyList_GetItemRef(sequence, 0);
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 308, __pyx_L1_error)
            __Pyx_XGOTREF(__pyx_t_4);
            __pyx_t_19 = __Pyx_PyList_GetItemRef(sequence, 1);
            if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 308, __pyx_L1_error)
            __Pyx_XGOTREF(__pyx_t_19);
            __pyx_t_6 = __Pyx_PyList_GetItemRef(sequence, 2);
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 308, __pyx_L1_error)
            __Pyx_XGOTREF(__pyx_t_6);
          }
          #else
          __pyx_t_4 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 308, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_19 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 308, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_6 = __Pyx_PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 308, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          #endif
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 308, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_11 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5);
          index = 0; __pyx_t_4 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L31_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_4);
          index = 1; __pyx_t_19 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_19)) goto __pyx_L31_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_19);
          index = 2; __pyx_t_6 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_6)) goto __pyx_L31_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_6);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_5), 3) < (0)) __PYX_ERR(0, 308, __pyx_L1_error)
          __pyx_t_11 = NULL;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          goto __pyx_L32_unpacking_done;
          __pyx_L31_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_11 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(0, 308, __pyx_L1_error)
          __pyx_L32_unpacking_done:;
        }
        __pyx_t_15 = __Pyx_PyLong_As_npy_int64(__pyx_t_4); if (unlikely((__pyx_t_15 == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_16 = __Pyx_PyFloat_AsDouble(__pyx_t_19); if (unlikely((__pyx_t_16 == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __pyx_t_10 = __Pyx_PyLong_As_int(__pyx_t_6); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_v_sid = __pyx_t_15;
        __pyx_v_ratio = __pyx_t_16;
        __pyx_v_eff_date = __pyx_t_10;
    /* … */
        __pyx_L29_continue:;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    +309:         if eff_date < start_date:

        __pyx_t_1 = (__pyx_v_eff_date < __pyx_v_start_date);
        if (__pyx_t_1) {
    /* … */
        }

    +310:             continue

          goto __pyx_L29_continue;

     311:

    +312:         date_loc = _lookup_dt(date_ixs, eff_date, _dates_seconds)

        __pyx_t_3 = __pyx_f_7zipline_4data_12_adjustments__lookup_dt(__pyx_v_date_ixs, __pyx_v_eff_date, ((PyArrayObject *)__pyx_v__dates_seconds)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 312, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_10 = __Pyx_PyLong_As_int(__pyx_t_3); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 312, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_v_date_loc = __pyx_t_10;

     313:

    +314:         if not PyDict_Contains(asset_ixs, sid):

        __pyx_t_3 = __Pyx_PyLong_From_npy_int64(__pyx_v_sid); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 314, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_10 = PyDict_Contains(__pyx_v_asset_ixs, __pyx_t_3); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 314, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_1 = (!(__pyx_t_10 != 0));
        if (__pyx_t_1) {
    /* … */
        }

    +315:             asset_ixs[sid] = assets.get_loc(sid)

          __pyx_t_6 = ((PyObject *)__pyx_v_assets);
          __Pyx_INCREF(__pyx_t_6);
          __pyx_t_19 = __Pyx_PyLong_From_npy_int64(__pyx_v_sid); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 315, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_19);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_19};
            __pyx_t_3 = __Pyx_PyObject_FastCallMethod(__pyx_mstate_global->__pyx_n_u_get_loc, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 315, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __pyx_t_19 = __Pyx_PyLong_From_npy_int64(__pyx_v_sid); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 315, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_19);
          if (unlikely((PyDict_SetItem(__pyx_v_asset_ixs, __pyx_t_19, __pyx_t_3) < 0))) __PYX_ERR(0, 315, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    +316:         asset_ix = asset_ixs[sid]

        __pyx_t_3 = __Pyx_PyLong_From_npy_int64(__pyx_v_sid); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_19 = __Pyx_PyDict_GetItem(__pyx_v_asset_ixs, __pyx_t_3); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 316, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_19);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_17 = __Pyx_PyIndex_AsSsize_t(__pyx_t_19); if (unlikely((__pyx_t_17 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 316, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __pyx_v_asset_ix = __pyx_t_17;

     317:

    +318:         price_adj = Float64Multiply(0, date_loc, asset_ix, asset_ix, ratio)

        __pyx_t_3 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_Float64Multiply); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 318, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_4 = __Pyx_PyLong_From_int(__pyx_v_date_loc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 318, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = PyLong_FromSsize_t(__pyx_v_asset_ix); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 318, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_18 = PyLong_FromSsize_t(__pyx_v_asset_ix); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 318, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_9 = PyFloat_FromDouble(__pyx_v_ratio); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 318, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[6] = {__pyx_t_3, __pyx_mstate_global->__pyx_int_0, __pyx_t_4, __pyx_t_5, __pyx_t_18, __pyx_t_9};
          __pyx_t_19 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+__pyx_t_8, (6-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 318, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_19);
        }
        __Pyx_XDECREF_SET(__pyx_v_price_adj, __pyx_t_19);
        __pyx_t_19 = 0;

    +319:         price_adjustments.setdefault(date_loc, []).append(price_adj)

        __pyx_t_19 = __Pyx_PyLong_From_int(__pyx_v_date_loc); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 319, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_19);
        __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 319, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_9 = __Pyx_PyDict_SetDefault(__pyx_v_price_adjustments, __pyx_t_19, __pyx_t_6, -1L); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 319, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_20 = __Pyx_PyObject_Append(__pyx_t_9, __pyx_v_price_adj); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 319, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

     320:

    +321:     if should_include_price_adjustments:

      __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_should_include_price_adjustments)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 321, __pyx_L1_error)
      if (__pyx_t_1) {
    /* … */
      }

    +322:         result['price'] = price_adjustments

        if (unlikely((PyDict_SetItem(__pyx_v_result, __pyx_mstate_global->__pyx_n_u_price, __pyx_v_price_adjustments) < 0))) __PYX_ERR(0, 322, __pyx_L1_error)

    +323:     if should_include_volume_adjustments:

      __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_should_include_volume_adjustments)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 323, __pyx_L1_error)
      if (__pyx_t_1) {
    /* … */
      }

    +324:         result['volume'] = volume_adjustments

        if (unlikely((PyDict_SetItem(__pyx_v_result, __pyx_mstate_global->__pyx_n_u_volume, __pyx_v_volume_adjustments) < 0))) __PYX_ERR(0, 324, __pyx_L1_error)

     325:

    +326:     return result

      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_result);
      __pyx_r = __pyx_v_result;
      __Pyx_TraceReturnValue(__pyx_r, 264, 0, __PYX_ERR(0, 326, __pyx_L1_error));
      goto __pyx_L0;

     327:

     328:

    +329: cdef _lookup_dt(dict dt_cache,

    static PyObject *__pyx_f_7zipline_4data_12_adjustments__lookup_dt(PyObject *__pyx_v_dt_cache, int __pyx_v_dt, PyArrayObject *__pyx_v_fallback) {
      __Pyx_LocalBuf_ND __pyx_pybuffernd_fallback;
      __Pyx_Buffer __pyx_pybuffer_fallback;
      PyObject *__pyx_r = NULL;
      __Pyx_TraceDeclarationsFunc
      __Pyx_TraceFrameInit(((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[45]))
      __Pyx_TraceStartFunc("_lookup_dt", __pyx_f[0], 329, 0, 0, 0, __PYX_ERR(0, 329, __pyx_L1_error));
      __pyx_pybuffer_fallback.pybuffer.buf = NULL;
      __pyx_pybuffer_fallback.refcount = 0;
      __pyx_pybuffernd_fallback.data = NULL;
      __pyx_pybuffernd_fallback.rcbuffer = &__pyx_pybuffer_fallback;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_fallback.rcbuffer->pybuffer, (PyObject*)__pyx_v_fallback, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 329, __pyx_L1_error)
      }
      __pyx_pybuffernd_fallback.diminfo[0].strides = __pyx_pybuffernd_fallback.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_fallback.diminfo[0].shape = __pyx_pybuffernd_fallback.rcbuffer->pybuffer.shape[0];

     330:                 int dt,

     331:                 ndarray[int64_t, ndim=1] fallback):

     332:

    +333:     if not PyDict_Contains(dt_cache, dt):

      __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_dt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyDict_Contains(__pyx_v_dt_cache, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 333, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_3 = (!(__pyx_t_2 != 0));
      if (__pyx_t_3) {
    /* … */
      }

    +334:         dt_cache[dt] = fallback.searchsorted(dt, side='right')

        __pyx_t_4 = ((PyObject *)__pyx_v_fallback);
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyLong_From_int(__pyx_v_dt); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 334, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_t_5};
          __pyx_t_7 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 334, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_side, __pyx_mstate_global->__pyx_n_u_right, __pyx_t_7, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 334, __pyx_L1_error)
          __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder(__pyx_mstate_global->__pyx_n_u_searchsorted, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_7);
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 334, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        if (unlikely(__pyx_v_dt_cache == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 334, __pyx_L1_error)
        }
        __pyx_t_7 = __Pyx_PyLong_From_int(__pyx_v_dt); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 334, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (unlikely((PyDict_SetItem(__pyx_v_dt_cache, __pyx_t_7, __pyx_t_1) < 0))) __PYX_ERR(0, 334, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    +335:     return dt_cache[dt]

      __Pyx_XDECREF(__pyx_r);
      if (unlikely(__pyx_v_dt_cache == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(0, 335, __pyx_L1_error)
      }
      __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_dt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = __Pyx_PyDict_GetItem(__pyx_v_dt_cache, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 335, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_7;
      __pyx_t_7 = 0;
      __Pyx_TraceReturnValue(__pyx_r, 16, 0, __PYX_ERR(0, 335, __pyx_L1_error));
      goto __pyx_L0;