Overall Statistics |
Total Trades 582 Average Win 1.16% Average Loss -0.98% Compounding Annual Return 2.042% Drawdown 18.700% Expectancy 0.098 Net Profit 27.943% Sharpe Ratio 0.365 Probabilistic Sharpe Ratio 0.531% Loss Rate 50% Win Rate 50% Profit-Loss Ratio 1.18 Alpha 0 Beta 0 Annual Standard Deviation 0.041 Annual Variance 0.002 Information Ratio 0.365 Tracking Error 0.041 Treynor Ratio 0 Total Fees $6337.59 Estimated Strategy Capacity $83000.00 Lowest Capacity Asset VIXM UT076X30D0MD |
#region imports from AlgorithmImports import * #endregion # https://quantpedia.com/Screener/Details/4 # buy SPY ETF at its closing price and sell it at the opening each day. import numpy as np class OvernightTradeAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2011, 1, 1) #Set Start Date self.SetEndDate(2025, 3, 1) #Set End Date self.SetCash(1000000) #Set Strategy Cash self.position1 = self.AddEquity("VIXY", Resolution.Minute).Symbol self.position2 = self.AddEquity("VIXM", Resolution.Minute).Symbol self.spy = self.AddEquity("SPY", Resolution.Minute).Symbol self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage) #monthly # self.Schedule.On(self.DateRules.MonthEnd("SPY", 1), self.Schedule.On(self.DateRules.MonthEnd("SPY",1), self.TimeRules.AfterMarketOpen("SPY", 5), self.enter) self.Schedule.On(self.DateRules.MonthEnd("SPY", 1), self.TimeRules.AfterMarketOpen("SPY", 4), self.exit) # self.Schedule.On(self.DateRules.EveryDay(self.spy), self.TimeRules.BeforeMarketClose("SPY", 15), self.enter) # self.Schedule.On(self.DateRules.EveryDay(self.spy), self.TimeRules.AfterMarketOpen("SPY", 0), self.exit) def enter(self): if not self.Portfolio.Invested: # self.SetHoldings(self.spy, 1) self.SetHoldings(self.position1, -.1) self.SetHoldings(self.position2, .1) def exit(self): if self.Portfolio.Invested: self.Liquidate() def OnData(self, data): pass