def start_up(self, env, mod_config):
self._env = env
self._mod_config = mod_config
env.event_bus.add_listener(EVENT.POST_BAR, self._output_feeds)
output_path = mod_config.output_path
filename = os.path.join(output_path, "portfolio.csv")
new_file = False
if not os.path.exists(filename):
new_file = True
self.csv_file = open(filename, 'a')
fieldnames = ["datetime", "portfolio_value", "market_value", "total_returns"]
self.csv_writer = csv.DictWriter(self.csv_file, fieldnames)
if new_file:
self.csv_writer.writeheader()
评论列表
文章目录