Overall Statistics |
Total Trades 10001 Average Win 0.01% Average Loss -0.01% Compounding Annual Return -4.872% Drawdown 8.200% Expectancy -0.141 Net Profit -8.191% Sharpe Ratio -1.372 Loss Rate 58% Win Rate 42% Profit-Loss Ratio 1.06 Alpha -0.049 Beta 0.109 Annual Standard Deviation 0.031 Annual Variance 0.001 Information Ratio -0.935 Tracking Error 0.112 Treynor Ratio -0.387 Total Fees $10001.00 |
from QuantConnect.Data.Custom.TradingEconomics import * class VerticalResistanceShield(QCAlgorithm): def Initialize(self): self.SetStartDate(2014, 1, 1) # Set Start Date self.SetEndDate(2019, 8, 22) self.SetCash(100000) # Set Strategy Cash self.interestRateSymbol = self.AddData(TradingEconomicsCalendar, TradingEconomics.Calendar.UnitedStates.InterestRate, Resolution.Daily, TimeZones.Utc).Symbol self.UniverseSettings.Resolution = Resolution.Daily; self.AddUniverseSelection(FineFundamentalUniverseSelectionModel(self.CoarseSelector, self.FineSelector)) self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel()) self.SetExecution(ImmediateExecutionModel()) self.SetRiskManagement(MaximumSectorExposureRiskManagementModel()) def CoarseSelector(self, coarse): return [i.Symbol for i in coarse if i.DollarVolume > 100000000 and i.DollarVolume < 1000000000] def FineSelector(self, fine): return [i.Symbol for i in fine] def OnData(self, data): insights = [] if not data.ContainsKey(self.interestRateSymbol): return announcement = data[self.interestRateSymbol] if announcement.Event != "Fed Interest Rate Decision": self.Debug(f"Event is: {announcement.Event}") return interestRateActual = self.ParseTEData(announcement.Actual) interestRatePrevious = self.ParseTEData(announcement.Previous) interestRateDecreased = interestRateActual <= interestRatePrevious # Interest rate increases are generally seen as a sign of slowing economic growth after QE insightDirection = InsightDirection.Up if interestRateDecreased else InsightDirection.Down for kvp in self.ActiveSecurities: symbol = kvp.Key insights.append(Insight(symbol, timedelta(days=10), InsightType.Price, insightDirection)) self.EmitInsights(insights) def ParseTEData(self, dataStr): inBillions = "B" in dataStr if inBillions: data = float(dataStr.replace("%", "").replace("B", "").replace("$", "")) data = forecast * 1000000000 elif "M" in dataStr: data = float(dataStr.replace("%", "").replace("M", "").replace("$", "")) data = forecast * 1000000 else: data = float(dataStr.replace("%", "").replace("$", "")) return data