Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -0.26 Tracking Error 0.711 Treynor Ratio 0 Total Fees $0.00 |
from clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Indicators") AddReference("QuantConnect.Common") from System import * from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Indicators import * from QuantConnect.Python import PythonQuandl from QuantConnect.Securities.Equity import EquityExchange from datetime import datetime, timedelta import math class Testing(QCAlgorithm): spy_month_high = 0 def Initialize(self): self.SetStartDate(2020, 3, 1) # Set Start Date self.SetEndDate(2020, 4, 30) # Set Start Date self.SetCash(10000) # Set Strategy Cash self.SetWarmup(timedelta(31)) self.AddEquity("SPY", Resolution.Minute) #self.spy = self.Symbol("SPY") #self.df = self.History(self.Symbol("SPY"), 62, Resolution.Daily) self.spy = self.Consolidate("SPY", CalendarType.Monthly, self.CalendarTradeBarHandler); self.Securities["SPY"].SetDataNormalizationMode(DataNormalizationMode.Raw) #spy_month_bar = self.spy def CalendarTradeBarHandler(self, tradeBar): self.Log(f'{self.Time} :: {tradeBar.Time} {tradeBar.Close} {tradeBar.High} {tradeBar.Low}') #self.spy_month_high = self.spy_last_bar.High #self.Log(self.spy_month_high) #example of above output #2020-04-01 00:00:00 : 2020-04-01 00:00:00 :: 2020-03-01 00:00:00 257.7 #close = tradeBar.Close def startOfMonth(self): spy_month_bar = self.History(self.spy, 1, self.CalendarTradeBarHandler) #spy_month_bar = self.History(self.spy, 1, self.CalendarTradeBarHandler) self.spy_month_high = spy_month_bar.High #self.Debug(str(self.spy_month_high)) def OnData(self, slice): '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. Arguments: data: Slice object keyed by symbol containing the stock data ''' #spy_month_high = slice[self.spy].High #spy_month_bar = self.History(self.spy,1, tradeBar) # if not self.Portfolio.Invested: # self.SetHoldings("SPY", 1) #spy_month_high = self.spy_month_high #self.Log(self.spy_month_high) #if close < 300: #self.MarketOrder("SPY",6)