mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-09 11:50:09 +08:00
BUG: Fix and test getting all default calendars
This commit is contained in:
@@ -27,6 +27,7 @@ from pandas import read_csv
|
|||||||
from pandas.tslib import Timedelta
|
from pandas.tslib import Timedelta
|
||||||
from pandas.util.testing import assert_index_equal
|
from pandas.util.testing import assert_index_equal
|
||||||
from pytz import timezone
|
from pytz import timezone
|
||||||
|
from toolz import concat
|
||||||
|
|
||||||
from zipline.errors import (
|
from zipline.errors import (
|
||||||
CalendarNameCollision,
|
CalendarNameCollision,
|
||||||
@@ -38,7 +39,8 @@ from zipline.utils.calendars import(
|
|||||||
deregister_calendar,
|
deregister_calendar,
|
||||||
get_calendar,
|
get_calendar,
|
||||||
)
|
)
|
||||||
from zipline.utils.calendars.calendar_utils import register_calendar_type
|
from zipline.utils.calendars.calendar_utils import register_calendar_type, \
|
||||||
|
_default_calendar_factories
|
||||||
from zipline.utils.calendars.trading_calendar import days_at_time, \
|
from zipline.utils.calendars.trading_calendar import days_at_time, \
|
||||||
TradingCalendar
|
TradingCalendar
|
||||||
|
|
||||||
@@ -119,6 +121,13 @@ class CalendarRegistrationTestCase(TestCase):
|
|||||||
self.assertNotEqual(first_dummy, second_dummy)
|
self.assertNotEqual(first_dummy, second_dummy)
|
||||||
|
|
||||||
|
|
||||||
|
class DefaultsTestCase(TestCase):
|
||||||
|
def test_default_calendars(self):
|
||||||
|
for name in concat(_default_calendar_factories):
|
||||||
|
self.assertIsNotNone(get_calendar(name),
|
||||||
|
"get_calendar(%r) returned None" % name)
|
||||||
|
|
||||||
|
|
||||||
class DaysAtTimeTestCase(TestCase):
|
class DaysAtTimeTestCase(TestCase):
|
||||||
@parameterized.expand([
|
@parameterized.expand([
|
||||||
# NYSE standard day
|
# NYSE standard day
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ class BMFExchangeCalendar(TradingCalendar):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def tz(self):
|
def tz(self):
|
||||||
return timezone("America/Sao_Paolo")
|
return timezone("America/Sao_Paulo")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def open_time(self):
|
def open_time(self):
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ MayBank = Holiday(
|
|||||||
"Early May Bank Holiday",
|
"Early May Bank Holiday",
|
||||||
month=5,
|
month=5,
|
||||||
offset=DateOffset(weekday=MO(1)),
|
offset=DateOffset(weekday=MO(1)),
|
||||||
|
day=1,
|
||||||
)
|
)
|
||||||
# Spring bank holiday
|
# Spring bank holiday
|
||||||
SpringBank = Holiday(
|
SpringBank = Holiday(
|
||||||
|
|||||||
Reference in New Issue
Block a user