Overall Statistics |
Total Trades 8 Average Win 32.62% Average Loss 0% Compounding Annual Return 251.839% Drawdown 15.000% Expectancy 0 Net Profit 201.075% Sharpe Ratio 2.436 Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.988 Beta -0.471 Annual Standard Deviation 0.384 Annual Variance 0.148 Information Ratio 2.108 Tracking Error 0.392 Treynor Ratio -1.987 Total Fees $305.83 |
import numpy as np ### <summary> ### Basic template algorithm simply initializes the date range and cash. This is a skeleton ### framework you can use for designing an algorithm. ### </summary> class BasicTemplateAlgorithm(QCAlgorithm): '''Basic template algorithm simply initializes the date range and cash''' def Initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.SetStartDate(2017,01,01) #Set Start Date self.SetEndDate(2017,11,15) #Set End Date self.SetCash(10000) #Set Strategy Cash self.SetBrokerageModel(BrokerageName.GDAX) self.AddCrypto("BTCUSD", Resolution.Daily) self.rsi_now = self.RSI("BTCUSD", 14, MovingAverageType.Simple, Resolution.Daily) stockPlot = Chart('Trade Plot') # On the Trade Plotter Chart we want 3 series: trades and price: stockPlot.AddSeries(Series('RSI', SeriesType.Line, 0)) self.AddChart(stockPlot) def OnData(self, data): if not self.rsi_now.IsReady or self.rsi_now.Current.Value == 100: return holdings = self.Portfolio.HoldStock #self.Log("Holdings: " + str(holdings)) #self.Log("RSI: " + str(self.rsi_now.Current.Value)) if holdings <= 0: if self.rsi_now.Current.Value < 30: self.SetHoldings("BTCUSD", 1.0) self.Log("IN: " + str(self.Securities["BTCUSD"].Price)) elif self.rsi_now.Current.Value > 80: self.Liquidate("BTCUSD") self.Log("OUT: " + str(self.Securities["BTCUSD"].Price)) # if not self.Portfolio.HoldStock and self.rsi_now.Current.Value < 30: # self.SetHoldings("BTCUSD", 1) # self.Log("IN: " + str(self.Securities["BTCUSD"].Price)) # self.Log("Holdings: " + str(holdings)) # self.Log("RSI: " + str(self.rsi_now.Current.Value)) # elif self.Portfolio.HoldStock and self.rsi_now.Current.Value > 80: # self.Liquidate("BTCUSD") # self.Log("OUT: " + str(self.Securities["BTCUSD"].Price)) # self.Log("Holdings: " + str(holdings)) # self.Log("RSI: " + str(self.rsi_now.Current.Value)) self.Plot("Trade Plot", "RSI", self.rsi_now.Current.Value);