Overall Statistics |
Total Trades 273 Average Win 2.99% Average Loss -5.35% Compounding Annual Return 0% Drawdown 100.000% Expectancy -0.477 Net Profit -100.044% Sharpe Ratio -0.359 Probabilistic Sharpe Ratio 5.686% Loss Rate 66% Win Rate 34% Profit-Loss Ratio 0.56 Alpha -1.343 Beta 3.128 Annual Standard Deviation 3.52 Annual Variance 12.387 Information Ratio -0.368 Tracking Error 3.503 Treynor Ratio -0.404 Total Fees $0.00 |
import numpy as np from decimal import * from datetime import timedelta, datetime class RegressionChannelAlgorithm(QCAlgorithm): def Initialize(self): self.SetCash(1000000) self.SetStartDate(2015,3,6) self.symbols = ["EURGBP", "GBPUSD", "USDCHF", "CADJPY", "EURUSD"] slowperiod = 4000 self.SetWarmUp(slowperiod) for symbol in self.symbols: equity = self.AddForex(symbol, Resolution.Hour, Market.Oanda) self.Consolidate(symbol, timedelta(hours=5), self.twoforty) self.Consolidate(symbol, timedelta(hours=23), self.days) #240MIN SETTINGS self.lsma4 = self.LSMA("EURUSD", 850, Resolution.Hour) #lsma 1700, atr kama 1day, 1700, 1700, 300LinearWeightedMovingAverage self.ladx4 = self.ADXR("EURUSD", 850, Resolution.Hour) #ADXR self.sadx4 = self.ADXR("EURUSD", 150, Resolution.Hour) #1day settings self.sma4 = self.LSMA("EURUSD", 1707, Resolution.Hour) #lsma 1700, atr kama 1day, 1700, 1700, 300 self.latr4 = self.ADXR("EURUSD", 1707, Resolution.Hour) #ADXR self.satr4 = self.ADXR("EURUSD", 307, Resolution.Hour) def OnData(self, data): if (not data.ContainsKey(self.symbols[0])): return #(not data.ContainsKey(self.symbols[1])) or if (not data.ContainsKey(self.symbols[1])) or (not data.ContainsKey(self.symbols[2])): return if (not data.ContainsKey(self.symbols[3])) or (not data.ContainsKey(self.symbols[4])): return def twoforty(self, consolidated): if self.IsWarmingUp: return #if (not self.satr4.IsReady): return #if (not self.latr4.IsReady): return value1 = self.Securities[self.symbols[1]].Price value4 = self.Securities[self.symbols[4]].Price #holdings = self.Portfolio["EURUSD"].TotalHoldingsValue #amount240 = decimal.Decimal(0.013) quantity = self.CalculateOrderQuantity("EURUSD",1) holdings = False if holdings == False: if self.sadx4.Current.Value > self.ladx4.Current.Value and value4 < self.lsma4.Current.Value: self.MarketOrder(self.symbols[4], -quantity) self.MarketOrder(self.symbols[0], -quantity) self.MarketOrder(self.symbols[1], -quantity) self.MarketOrder(self.symbols[2], -quantity) holdings == True self.Debug("just went short, holdings is: " + str(holdings)) elif self.sadx4.Current.Value > self.ladx4.Current.Value and value4 > self.lsma4.Current.Value: self.SetHoldings(self.symbols[4], quantity) self.SetHoldings(self.symbols[0], quantity) self.SetHoldings(self.symbols[1], quantity) self.SetHoldings(self.symbols[2], quantity) holdings == True self.Debug("just went long, holdings is: " + str(holdings)) if holdings == True: if self.Portfolio[self.symbols[4]].IsShort: if value4 > self.lsma4.Current.Value and self.sadx4.Current.Value < self.ladx4.Current.Value: self.Liquidate(self.symbols[4]) self.Liquidate(self.symbols[0]) self.Liquidate(self.symbols[1]) self.Liquidate(self.symbols[2]) holdings == False elif self.Portfolio[self.symbols[4]].IsLong: if value4 < self.lsma4.Current.Value and self.sadx4.Current.Value < self.ladx4.Current.Value: self.Liquidate(self.symbols[4]) self.Liquidate(self.symbols[0]) self.Liquidate(self.symbols[1]) self.Liquidate(self.symbols[2]) holdings == False def days(self, consolidated): ''' value1 = self.Securities[self.symbols[1]].Price value4 = self.Securities[self.symbols[4]].Price if not self.Securities["EURUSD"].Invested: if self.satr4.Current.Value > self.latr4.Current.Value and value4 < self.sma4.Current.Value: self.SetHoldings(self.symbols[4], -1) self.SetHoldings(self.symbols[0], -1) self.SetHoldings(self.symbols[1], -1) self.SetHoldings(self.symbols[2], -1) elif self.satr4.Current.Value > self.latr4.Current.Value and value4 > self.sma4.Current.Value: self.SetHoldings(self.symbols[4], 1) self.SetHoldings(self.symbols[0], 1) self.SetHoldings(self.symbols[1], 1) self.SetHoldings(self.symbols[2], 1) if self.Securities["EURUSD"].Invested: if self.Portfolio[self.symbols[4]].IsShort: if value4 > self.sma4.Current.Value and self.satr4.Current.Value < self.latr4.Current.Value: self.Liquidate(self.symbols[4]) self.Liquidate(self.symbols[0]) self.Liquidate(self.symbols[1]) self.Liquidate(self.symbols[2]) elif self.Portfolio[self.symbols[4]].IsLong: if value4 < self.sma4.Current.Value and self.satr4.Current.Value < self.latr4.Current.Value: self.Liquidate(self.symbols[4]) self.Liquidate(self.symbols[0]) self.Liquidate(self.symbols[1]) self.Liquidate(self.symbols[2]) ''' pass