mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-20 12:10:30 +08:00
factory had a bug in the creation of trade history that traversed daylight savings time changes. added a fix and a test.
This commit is contained in:
@@ -28,6 +28,7 @@ from zipline.utils.protocol_utils import ndict
|
||||
|
||||
from zipline.gens.composites import date_sorted_sources
|
||||
from zipline.finance.trading import SimulationParameters
|
||||
import zipline.finance.trading as trading
|
||||
from zipline.utils.factory import create_random_simulation_parameters
|
||||
|
||||
onesec = datetime.timedelta(seconds=1)
|
||||
@@ -44,6 +45,16 @@ class TestDividendPerformance(unittest.TestCase):
|
||||
|
||||
self.sim_params.capital_base = 10e3
|
||||
|
||||
def test_market_hours_calculations(self):
|
||||
with trading.TradingEnvironment():
|
||||
# DST in US/Eastern began on Sunday March 14, 2010
|
||||
before = datetime.datetime(2010, 3, 12, 14, 30, tzinfo=pytz.utc)
|
||||
after = factory.get_next_trading_dt(
|
||||
before,
|
||||
datetime.timedelta(days=1)
|
||||
)
|
||||
self.assertEqual(after.hour, 13)
|
||||
|
||||
def test_long_position_receives_dividend(self):
|
||||
#post some trades in the market
|
||||
events = factory.create_trade_history(
|
||||
|
||||
Reference in New Issue
Block a user