mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-16 11:18:11 +08:00
ENH: allows users to specify the cutoff time for data query in blaze
loaders This allows people to set their cutoff time to the time they will actually execute 'before_trading_start'. Currently this is just passed to the constructor of the loader; however, I would like to make this managed by the algorithm simulation runner. This would help keep all of the loaders in sync and lock 'before_trading_start's execution to the time the data is queried for.
This commit is contained in:
@@ -7,10 +7,12 @@ from unittest import TestCase
|
||||
|
||||
from nose_parameterized import parameterized
|
||||
from numpy import arange, dtype
|
||||
import pytz
|
||||
from six import PY3
|
||||
|
||||
from zipline.utils.preprocess import call, preprocess
|
||||
from zipline.utils.input_validation import (
|
||||
ensure_timezone,
|
||||
expect_element,
|
||||
expect_dtypes,
|
||||
expect_types,
|
||||
@@ -317,3 +319,31 @@ class PreprocessTestCase(TestCase):
|
||||
"or 'float64' for argument 'a', but got 'uint32' instead."
|
||||
).format(qualname=qualname(foo))
|
||||
self.assertEqual(e.exception.args[0], expected_message)
|
||||
|
||||
def test_ensure_timezone(self):
|
||||
@preprocess(tz=ensure_timezone)
|
||||
def f(tz):
|
||||
return tz
|
||||
|
||||
valid = {
|
||||
'utc',
|
||||
'EST',
|
||||
'US/Eastern',
|
||||
}
|
||||
invalid = {
|
||||
# unfortunatly, these are not actually timezones (yet)
|
||||
'ayy',
|
||||
'lmao',
|
||||
}
|
||||
|
||||
# test coercing from string
|
||||
for tz in valid:
|
||||
self.assertEqual(f(tz), pytz.timezone(tz))
|
||||
|
||||
# test pass through of tzinfo objects
|
||||
for tz in map(pytz.timezone, valid):
|
||||
self.assertEqual(f(tz), tz)
|
||||
|
||||
# test invalid timezone strings
|
||||
for tz in invalid:
|
||||
self.assertRaises(pytz.UnknownTimeZoneError, f, tz)
|
||||
|
||||
Reference in New Issue
Block a user