BLD: live mode accepts end parameter, when algo finishes

This commit is contained in:
Victor Grau Serrat
2018-01-16 23:40:18 -07:00
parent 3ed44f72ad
commit 52d4ced37c
3 changed files with 16 additions and 2 deletions
+5
View File
@@ -351,6 +351,7 @@ class ExchangeTradingAlgorithmLive(ExchangeTradingAlgorithmBase):
self.live_graph = kwargs.pop('live_graph', None)
self.stats_output = kwargs.pop('stats_output', None)
self._analyze_live = kwargs.pop('analyze_live', None)
self.end = kwargs.pop('end', None)
self._clock = None
self.frame_stats = list()
@@ -710,6 +711,10 @@ class ExchangeTradingAlgorithmLive(ExchangeTradingAlgorithmBase):
if not self.is_running:
return
if self.end is not None and self.end < data.current_dt:
log.info('Algorithm has reached specified end time. Finishing...')
self.interrupt_algorithm()
# Resetting the frame stats every day to minimize memory footprint
today = data.current_dt.floor('1D')
if self.current_day is not None and today > self.current_day: