Skip to content

Instantly share code, notes, and snippets.

@natyrix
Created October 15, 2022 22:30
Show Gist options
  • Save natyrix/d2e732c3cabd5d1e8ee3d6de2c83e15b to your computer and use it in GitHub Desktop.
Save natyrix/d2e732c3cabd5d1e8ee3d6de2c83e15b to your computer and use it in GitHub Desktop.
def return_backtest_result(self):
if self.is_experiment:
mlflow.log_param("stock", self.stock)
mlflow.log_param("init_cash", self.init_cash)
for k,v in self.pf.stats().to_dict().items():
mlflow.log_param(str(k).replace('%','').replace('[','').replace(']',''),str(v))
with open('./backtest_result/vectorbt/fast_and_slow_plot.txt','w') as f:
for key, value in self.pf.stats().to_dict().items():
f.write('%s: %s\n' % (key, value))
# f.write(self.pf.stats().to_dict())
return self.pf.stats().to_dict()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment