Skip to content

Commit

Permalink
Merge pull request quantopian#1418 from quantopian/all-calendars
Browse files Browse the repository at this point in the history
All calendars
  • Loading branch information
richafrank authored Aug 22, 2016
2 parents e5490fe + 7fbdf06 commit 81e3a94
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 40 deletions.
11 changes: 10 additions & 1 deletion tests/calendars/test_trading_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from pandas.tslib import Timedelta
from pandas.util.testing import assert_index_equal
from pytz import timezone
from toolz import concat

from zipline.errors import (
CalendarNameCollision,
Expand All @@ -38,7 +39,8 @@
deregister_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, \
TradingCalendar

Expand Down Expand Up @@ -119,6 +121,13 @@ def test_force_registration(self):
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):
@parameterized.expand([
# NYSE standard day
Expand Down
55 changes: 16 additions & 39 deletions zipline/utils/calendars/exchange_calendar_bmf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
#
# Copyright 2016 Quantopian, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from datetime import time
from pandas.tseries.holiday import(
AbstractHolidayCalendar,
Holiday,
Easter,
Day,
Expand Down Expand Up @@ -132,43 +146,6 @@
)


class BMFHolidayCalendar(AbstractHolidayCalendar):
"""
Non-trading days for the BM&F.
See NYSEExchangeCalendar for full description.
"""
rules = [
ConfUniversal,
AniversarioSaoPaulo,
CarnavalSegunda,
CarnavalTerca,
SextaPaixao,
CorpusChristi,
Tiradentes,
DiaTrabalho,
Constitucionalista,
Independencia,
Aparecida,
Finados,
ProclamacaoRepublica,
ConscienciaNegra,
VesperaNatal,
Natal,
AnoNovo,
AnoNovoSabado,
]


class BMFLateOpenCalendar(AbstractHolidayCalendar):
"""
Regular early close calendar for NYSE
"""
rules = [
QuartaCinzas,
]


class BMFExchangeCalendar(TradingCalendar):
"""
Exchange calendar for BM&F BOVESPA
Expand Down Expand Up @@ -202,7 +179,7 @@ def name(self):

@property
def tz(self):
return timezone("America/Sao_Paolo")
return timezone("America/Sao_Paulo")

@property
def open_time(self):
Expand Down
16 changes: 16 additions & 0 deletions zipline/utils/calendars/exchange_calendar_lse.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
#
# Copyright 2016 Quantopian, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from datetime import time
from pandas.tseries.holiday import(
Holiday,
Expand Down Expand Up @@ -27,6 +42,7 @@
"Early May Bank Holiday",
month=5,
offset=DateOffset(weekday=MO(1)),
day=1,
)
# Spring bank holiday
SpringBank = Holiday(
Expand Down

0 comments on commit 81e3a94

Please sign in to comment.