mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-29 07:39:11 +08:00
BUG: Fix tradesimulation index into perf results when emitting minutely.
The indexing into performance results during the simulation loop fails when emitting minutely since 'daily_perf' only exists on daily performance results, not the minutely results. Fix by making the key used to index into performance results depend on the emission rate.
This commit is contained in:
@@ -137,6 +137,11 @@ class TradeSimulationClient(object):
|
||||
|
||||
class AlgorithmSimulator(object):
|
||||
|
||||
EMISSION_TO_PERF_KEY_MAP = {
|
||||
'minute': 'intraday_perf',
|
||||
'daily': 'daily_perf'
|
||||
}
|
||||
|
||||
def __init__(self,
|
||||
order_book,
|
||||
perf_tracker,
|
||||
@@ -152,6 +157,9 @@ class AlgorithmSimulator(object):
|
||||
self.order_book = order_book
|
||||
self.perf_tracker = perf_tracker
|
||||
|
||||
self.perf_key = self.EMISSION_TO_PERF_KEY_MAP[
|
||||
perf_tracker.emission_rate]
|
||||
|
||||
self.algo = algo
|
||||
self.algo_start = algo_start.replace(hour=0, minute=0,
|
||||
second=0,
|
||||
@@ -263,7 +271,7 @@ class AlgorithmSimulator(object):
|
||||
for perf_message in event.perf_messages:
|
||||
# append current values of recorded vars
|
||||
# to emitted message
|
||||
perf_message['daily_perf']['recorded_vars'] =\
|
||||
perf_message[self.perf_key]['recorded_vars'] =\
|
||||
self.algo.recorded_vars
|
||||
yield perf_message
|
||||
del event['perf_messages']
|
||||
@@ -278,7 +286,7 @@ class AlgorithmSimulator(object):
|
||||
self.perf_tracker.handle_simulation_end()
|
||||
|
||||
for message in perf_messages:
|
||||
message['daily_perf']['recorded_vars'] =\
|
||||
message[self.perf_key]['recorded_vars'] =\
|
||||
self.algo.recorded_vars
|
||||
yield message
|
||||
|
||||
|
||||
Reference in New Issue
Block a user