Overall Statistics |
Total Trades 1023 Average Win 0.65% Average Loss -0.63% Compounding Annual Return 5.574% Drawdown 16.100% Expectancy 0.105 Net Profit 86.052% Sharpe Ratio 0.493 Loss Rate 46% Win Rate 54% Profit-Loss Ratio 1.03 Alpha 0.044 Beta -0.049 Annual Standard Deviation 0.084 Annual Variance 0.007 Information Ratio -0.066 Tracking Error 0.189 Treynor Ratio -0.839 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(2006,1,1) self.SetEndDate(2017,6,10) # Add assets you'd like to see self.aud = self.AddForex("EURUSD", Resolution.Hour).Symbol self.bb = self.BB("EURUSD", 30, 2, MovingAverageType.Exponential, Resolution.Hour) self.rsi = self.RSI("EURUSD",14, MovingAverageType.Exponential, Resolution.Hour) self.bbupCount = 0 self.bblowCount = 0 self.rsi70Count = 0 self.rsi30Count = 0 def OnData(self, slice): if not self.bb.IsReady: return if not self.rsi.IsReady: return close = slice[self.aud].Close bbup = self.bb.UpperBand.Current.Value < close bblow = self.bb.LowerBand.Current.Value > close rsi70 = self.rsi.Current.Value > 70 rsi30 = self.rsi.Current.Value < 30 self.bbupCount += bbup self.bblowCount += bblow self.rsi70Count += rsi70 self.rsi30Count += rsi30 if (bbup and self.bbupCount>1) and (rsi70 and self.rsi70Count>1): self.SetHoldings(self.aud,-1) self.bbupCount = self.bblowCount = self.rsi70Count = self.rsi30Count = 0 elif (bblow and self.bblowCount>1) or (rsi30 and self.rsi30Count>1): self.SetHoldings(self.aud,1) self.bbupCount = self.bblowCount = self.rsi70Count = self.rsi30Count = 0