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:
fawce
2013-02-18 10:24:32 -05:00
committed by Eddie Hebert
parent a4a4d38a73
commit d67e5d7a4b
2 changed files with 23 additions and 4 deletions
+11
View File
@@ -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(