mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-03 13:26:01 +08:00
@@ -27,6 +27,7 @@ from pandas import read_csv
|
||||
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,
|
||||
@@ -38,7 +39,8 @@ from zipline.utils.calendars import(
|
||||
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
|
||||
|
||||
@@ -119,6 +121,13 @@ class CalendarRegistrationTestCase(TestCase):
|
||||
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
|
||||
|
||||
@@ -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,
|
||||
@@ -132,43 +146,6 @@ AnoNovoSabado = Holiday(
|
||||
)
|
||||
|
||||
|
||||
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
|
||||
@@ -202,7 +179,7 @@ class BMFExchangeCalendar(TradingCalendar):
|
||||
|
||||
@property
|
||||
def tz(self):
|
||||
return timezone("America/Sao_Paolo")
|
||||
return timezone("America/Sao_Paulo")
|
||||
|
||||
@property
|
||||
def open_time(self):
|
||||
|
||||
@@ -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,
|
||||
@@ -27,6 +42,7 @@ MayBank = Holiday(
|
||||
"Early May Bank Holiday",
|
||||
month=5,
|
||||
offset=DateOffset(weekday=MO(1)),
|
||||
day=1,
|
||||
)
|
||||
# Spring bank holiday
|
||||
SpringBank = Holiday(
|
||||
|
||||
Reference in New Issue
Block a user