mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-05 00:49:38 +08:00
BUG: Fix extra minutely performance period during minute performance.
Prevent an extra performance result with the timestamp of the midnight of the day from being emitted. Fix by setting the `saved_dt` value with the dt of the first event, before entering into the main performance loop, otherwise a performance result with a midnight timestamp and data from just the first event is emitted.
This commit is contained in:
@@ -1075,3 +1075,12 @@ class TestPerformanceTracker(unittest.TestCase):
|
||||
# Check that transactions aren't emitted for previous events.
|
||||
self.assertEquals(0, len(messages[1]['intraday_perf']['transactions']),
|
||||
"The second message should have no transactions.")
|
||||
|
||||
# Ensure that period_close moves through time.
|
||||
# Also, ensure that the period_closes are the expected dts.
|
||||
self.assertEquals(foo_event_1.dt,
|
||||
messages[0]['intraday_perf']['period_close'],
|
||||
messages[0])
|
||||
self.assertEquals(foo_event_2.dt,
|
||||
messages[1]['intraday_perf']['period_close'],
|
||||
messages[1])
|
||||
|
||||
@@ -130,6 +130,7 @@ omitted).
|
||||
|
||||
"""
|
||||
|
||||
import itertools
|
||||
import logbook
|
||||
import math
|
||||
|
||||
@@ -205,7 +206,16 @@ class PerformanceTracker(object):
|
||||
"""
|
||||
Main generator work loop.
|
||||
"""
|
||||
for date, snapshot in stream_in:
|
||||
# Set the simulation date to be the first event we see.
|
||||
peek_date, peek_snapshot = next(stream_in)
|
||||
self.saved_dt = peek_date
|
||||
|
||||
# Stitch back together the generator by placing the peeked
|
||||
# event back in front
|
||||
stream = itertools.chain([(peek_date, peek_snapshot)],
|
||||
stream_in)
|
||||
|
||||
for date, snapshot in stream:
|
||||
new_snapshot = []
|
||||
|
||||
for event in snapshot:
|
||||
|
||||
Reference in New Issue
Block a user