Overall Statistics |
Total Trades 235 Average Win 0.68% Average Loss -0.44% Compounding Annual Return 20.997% Drawdown 6.900% Expectancy 0.402 Net Profit 50.432% Sharpe Ratio 1.717 Loss Rate 45% Win Rate 55% Profit-Loss Ratio 1.56 Alpha 0.138 Beta -0.036 Annual Standard Deviation 0.079 Annual Variance 0.006 Information Ratio 0.547 Tracking Error 0.14 Treynor Ratio -3.826 Total Fees $0.00 |
# # QuantConnect Basic Template: # Fundamentals to using a QuantConnect algorithm. # # You can view the QCAlgorithm base class on Github: # https://github.com/QuantConnect/Lean/tree/master/Algorithm # import numpy as np import statsmodels.api as sm import pandas as pd import math class ForexLive(QCAlgorithm): def Initialize(self): # Set the cash we'd like to use for our backtest # This is ignored in live trading self.SetCash(100000) # Start and end dates for the backtest. # These are ignored in live trading. self.SetStartDate(2015,7,1) self.SetEndDate(2017,8,20) forex = "EURUSD" resolution = Resolution.Hour # Add assets you'd like to see self.forex = self.AddForex(forex, resolution).Symbol self.bb = self.BB(forex, 30, 2, MovingAverageType.Exponential, resolution) self.rsi = self.RSI(forex,14, MovingAverageType.Exponential, resolution) self.ao = self.AROON(forex,14,14,resolution) self.bbupCount = 0 self.bblowCount = 0 self.rsi70Count = 0 self.rsi30Count = 0 self.aoupCount = 0 self.aolowCount = 0 def OnData(self, slice): if not self.bb.IsReady: return if not self.rsi.IsReady: return if not self.ao.IsReady: return close = slice[self.forex].Close bbup = self.bb.UpperBand.Current.Value < close bblow = self.bb.LowerBand.Current.Value > close rsi70 = self.rsi.Current.Value > 70 #70 rsi30 = self.rsi.Current.Value < 30 #30 aoup = self.ao.Current.Value > 50 #50 aolow = self.ao.Current.Value < -50 #-50 self.bbupCount += bbup self.bblowCount += bblow self.rsi70Count += rsi70 self.rsi30Count += rsi30 self.aoupCount += aoup self.aolowCount += aolow if (bbup and self.bbupCount>1) and ((rsi70 and self.rsi70Count>0) or (aoup and self.aoupCount > 2)) : # 1, 0, 2 self.SetHoldings(self.forex,-1) self.bbupCount = self.bblowCount = self.rsi70Count = self.rsi30Count = self.aoupCount = self.aolowCount = 0 elif (bblow and self.bblowCount>1) or (rsi30 and self.rsi30Count>0 and aolow and self.aolowCount > 2): # 1, 0, 2 self.SetHoldings(self.forex,1) self.bbupCount = self.bblowCount = self.rsi70Count = self.rsi30Count = self.aoupCount = self.aolowCount = 0