diff --git a/tests/test_continuous_futures.py b/tests/test_continuous_futures.py index c00fef85..e47c7e78 100644 --- a/tests/test_continuous_futures.py +++ b/tests/test_continuous_futures.py @@ -222,7 +222,7 @@ class ContinuousFuturesTestCase(WithCreateBarData, 'Auto close at beginning of session so FOG16 is now ' 'the current contract.') - def test_get_spot_value_contract_daily(self): + def test_get_value_contract_daily(self): cf_primary = self.asset_finder.create_continuous_future( 'FO', 0, 'calendar') @@ -246,6 +246,30 @@ class ContinuousFuturesTestCase(WithCreateBarData, 'Auto close at beginning of session so FOG16 is now ' 'the current contract.') + def test_get_value_close_daily(self): + cf_primary = self.asset_finder.create_continuous_future( + 'FO', 0, 'calendar') + + value = self.data_portal.get_spot_value( + cf_primary, + 'close', + pd.Timestamp('2016-01-26', tz='UTC'), + 'daily', + ) + + self.assertEqual(value, 105011.44) + + value = self.data_portal.get_spot_value( + cf_primary, + 'close', + pd.Timestamp('2016-01-27', tz='UTC'), + 'daily', + ) + + self.assertEqual(value, 115021.44, + 'Auto close at beginning of session so FOG16 is now ' + 'the current contract.') + def test_current_contract_volume_roll(self): cf_primary = self.asset_finder.create_continuous_future( 'FO', 0, 'volume') diff --git a/zipline/data/continuous_future_reader.py b/zipline/data/continuous_future_reader.py index ed84f79c..ff170b6e 100644 --- a/zipline/data/continuous_future_reader.py +++ b/zipline/data/continuous_future_reader.py @@ -135,7 +135,7 @@ class ContinuousFutureSessionBarReader(SessionBarReader): If the given dt is not a valid market minute (in minute mode) or session (in daily mode) according to this reader's tradingcalendar. """ - rf = self._roll_finders[continuous_future.roll] + rf = self._roll_finders[continuous_future.roll_style] sid = (rf.get_contract_center(continuous_future.root_symbol, dt, continuous_future.offset)) diff --git a/zipline/data/resample.py b/zipline/data/resample.py index eae2b9f5..538a0c8e 100644 --- a/zipline/data/resample.py +++ b/zipline/data/resample.py @@ -541,7 +541,7 @@ class MinuteResampleSessionBarReader(SessionBarReader): # This was developed to complete interface, but has not been tuned # for real world use. start, end = self._calendar.open_and_close_for_session(session) - return self._get_resampled([colname], start, end, [sid])[0] + return self._get_resampled([colname], start, end, [sid])[0][0][0] @lazyval def sessions(self):