Skip to content

Instantly share code, notes, and snippets.

@dkav6
Last active November 5, 2021 09:15
Show Gist options
  • Save dkav6/8ca8be19e3e1c81feb835c5e0e00f14d to your computer and use it in GitHub Desktop.
Save dkav6/8ca8be19e3e1c81feb835c5e0e00f14d to your computer and use it in GitHub Desktop.
df = get_data('ETH-USD')
df = df/1000
strategies = [SmaCross, EmaCross, WmaCross]
all_runs = []
for strategy in strategies:
bt = Backtest(df, strategy, cash=100, commission=.002)
stats = bt.optimize(n1=range(5, 90, 5),
n2=range(10, 120, 5),
maximize='Return (Ann.) [%]',
constraint=lambda param: param.n1 < param.n2)
all_runs.append(stats)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment