Overall Statistics |
Total Trades 2 Average Win 0% Average Loss -2.83% Compounding Annual Return -0.954% Drawdown 4.700% Expectancy -1 Net Profit -2.832% Sharpe Ratio -0.522 Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.019 Beta 0.7 Annual Standard Deviation 0.015 Annual Variance 0 Information Ratio -1.628 Tracking Error 0.015 Treynor Ratio -0.011 Total Fees $0.00 |
import numpy as np class RSIAlgorithm(QCAlgorithm): def Initialize(self): # Set our main strategy parameters self.SetStartDate(2015,1, 1) # Set Start Date self.SetEndDate(2018,1,1) # Set End Date self.SetCash(100000) # Set Strategy Cash self.IsLong = False self.IsShort = False RSI_Period = 14 # RSI Look back period self.RSI_OB = 80 # RSI Overbought level self.RSI_OS = 20 # RSI Oversold level self.Allocate = 0.5 # Percentage of capital to allocate self.AddForex("EURUSD", Resolution.Daily) self.RSI_Ind = self.RSI("EURUSD", RSI_Period) def OnData(self, data): if not self.RSI_Ind.IsReady: return if not self.Portfolio.Invested: self.Log("inside "+str(self.RSI_Ind.Current.Value)) # If not, we check the RSI Indicator if self.RSI_Ind.Current.Value < self.RSI_OS: self.SetHoldings("EURUSD", self.Allocate) self.IsLong = True #stopPrice = close * decimal.Decimal(.9975) #newTicket = self.StopMarketOrder("EURUSD", -100, stopPrice) elif self.RSI_Ind.Current.Value > self.RSI_OB: self.SetHoldings("EURUSD", self.Allocate*-1) self.IsShort = True #stopPrice = close * decimal.Decimal(1.0025) #newTicket = self.StopMarketOrder("EURUSD", 100, stopPrice) else: if self.IsLong: if self.RSI_Ind.Current.Value >= 50: self.Liquidate() elif self.IsShort: if self.RSI_Ind.Current.Value <= 50: self.Liquidate()