Closed tspenov closed 5 years ago
In [1]: import san In [2]: from san import backtest In [3]: asset = "bitcoin" In [4]: data = san.get("ohlcv/"+asset) ...: data["returns"]= data.closePriceUsd.pct_change() ...: data["ma50"] = data.closePriceUsd.rolling(50).mean() ...: data["ma200"] = data.closePriceUsd.rolling(200).mean() ...: data = data.dropna() ...: ...: trades = data["ma50"] > data["ma200"] ...: ...: bt = backtest.Backtest(data.returns.dropna(),trades, percent_invested_per_trade=0.8) ...: bt.summary() Returns in Percent: 34.25 Returns Benchmark in Percent: 50.1 Annualized Returns in Percent: 64.43 Annualized Sharpe Raito: 1.5 Number of Trades: 2