| Overall Statistics |
|
Total Trades 52 Average Win 1.31% Average Loss -0.57% Compounding Annual Return -50.227% Drawdown 7.300% Expectancy -0.494 Net Profit -7.132% Sharpe Ratio -3.431 Probabilistic Sharpe Ratio 2.584% Loss Rate 85% Win Rate 15% Profit-Loss Ratio 2.29 Alpha -0.45 Beta 0.356 Annual Standard Deviation 0.112 Annual Variance 0.012 Information Ratio -3.535 Tracking Error 0.162 Treynor Ratio -1.076 Total Fees $52.00 Estimated Strategy Capacity $27000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
from AlgorithmImports import *
class SwimmingLightBrownBuffalo(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2022, 11, 1)
self.SetEndDate(2022, 12, 9)
self.SetCash(1000)
self.spy = self.AddEquity("SPY", Resolution.Minute).Symbol
self.macd = self.MACD(self.spy, 55, 90, 15, Resolution.Minute)
closing_prices = self.History(self.spy, 1, Resolution.Minute)["close"]
self.SetWarmUp(1)
for time, price in closing_prices.loc[self.spy].items():
self.macd.Update(time, price)
def OnData(self, Data):
if not self.macd.IsReady:
return
if self.macd.IsReady:
self.fast = self.macd.Fast.Current.Value
self.slow = self.macd.Slow.Current.Value
self.signal = self.macd.Signal.Current.Value
self.histogram = self.macd.Histogram.Current.Value
self.current = self.macd.Current.Value
price = self.Securities[self.spy].Price
if self.fast > self.slow:
if not self.Portfolio[self.spy].IsLong:
self.SetHoldings(self.spy, 1)
elif self.fast < self.slow:
self.Liquidate()
#if not self.Portfolio[self.spy].IsShort:
#self.SetHoldings(self.spy, -1)
else:
pass
if self.macd.IsReady:
self.Plot("Benchmark", "fast", self.fast)
self.Plot("Benchmark", "slow", self.slow)