mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-07 08:14:03 +08:00
Merge pull request #1586 from quantopian/fix-continuous-future-daily-get-value
BUG: Fix bad attribute lookup on session continuous future reader.
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user