Created
October 15, 2022 22:36
-
-
Save natyrix/40c62bea3e6a6ca526231f8e3d394f35 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_fast_and_slow(self): | |
fig = self.price.vbt.plot(trace_kwargs=dict(name='Close')) | |
self.calc_fast_ma.ma.vbt.plot(trace_kwargs=dict(name='Fast MA'), fig=fig) | |
self.calc_slow_ma.ma.vbt.plot(trace_kwargs=dict(name='Slow MA'), fig=fig) | |
self.pf.positions.plot(close_trace_kwargs=dict(visible=False), fig=fig) | |
# vbt.save('fig.png', fig) | |
with open('./images/vectorbt/fast_and_slow_plot.png','wb') as f: | |
f.write(fig.to_image(format='png')) | |
with open('./images/vectorbt/fast_and_slow_plot.png','rb') as f: | |
if self.is_experiment: | |
mlflow.log_artifact("./images/vectorbt/fast_and_slow_plot.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment