| 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 -1.038 Tracking Error 0.193 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
from System.Drawing import Color
class SquareFluorescentPinkSardine(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019, 1, 1)
self.SetEndDate(2021, 7, 11)
self.SetCash(100000) # Set Strategy Cash
self.spy = self.AddEquity("SPY", Resolution.Hour).Symbol
self.Schedule.On(self.DateRules.MonthStart("SPY"), self.TimeRules.At(15, 0), Action(self.SMA_signal))
self.SetBenchmark("SPY")
self.fast = self.SMA(self.spy, 20, Resolution.Daily);
self.slow = self.SMA(self.spy, 60, Resolution.Daily);
smaPlot = Chart('SMA Chart')
smaPlot.AddSeries(Series('fast_s 25', SeriesType.Line, '$', Color.Red))
smaPlot.AddSeries(Series('slow_s 100', SeriesType.Line, '$', Color.Red))
smaPlot.AddSeries(Series('benchmark', SeriesType.Line, '$', Color.Red))
def SMA_signal (self):
if not self.fast.IsReady:
print("fast not ready")
return
if not self.slow.IsReady:
print("slow not ready")
return
self.fastValue = self.fast.Current.Value
self.slowValue = self.slow.Current.Value
if self.fastValue < self.slowValue:
self.signal = " sell"
else:
self.signal = " buy"
self.Plot('SMA Chart', 'fast_s', self.fast.Current.Value)
self.Plot('SMA Chart', 'slow_s', self.slow.Current.Value)
self.Plot('SMA Chart', 'benchmark', self.Securities[self.spy].Close)
self.SMA_values = "Fast: " + str(self.fastValue) + ". Slow: " + str(self.slowValue)
self.Log("SMA_signal - " + self.SMA_values + self.signal)
return