| Overall Statistics |
|
Total Trades 36 Average Win 0.01% Average Loss -0.02% Compounding Annual Return 0.006% Drawdown 0.100% Expectancy 0.347 Net Profit 0.112% Sharpe Ratio 0.209 Probabilistic Sharpe Ratio 0.007% Loss Rate 11% Win Rate 89% Profit-Loss Ratio 0.52 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -0.382 Tracking Error 0.178 Treynor Ratio -0.312 Total Fees $36.00 |
class ConsolodatorTest2(QCAlgorithm):
def Initialize(self):
self.Log("inittestlog")
self.SetStartDate(2000, 12, 11) # Set Start Dateself.Notify.Email
self.SetCash(100000) # Set Strategy Cash
self.AddEquity("SPY", Resolution.Daily)
thirtyMinuteConsolidator = TradeBarConsolidator(timedelta(minutes=10))
thirtyMinuteConsolidator.DataConsolidated += self.ThirtyMinuteBarHandler
self.SubscriptionManager.AddConsolidator("SPY", thirtyMinuteConsolidator)
self.rsi = self.RSI("SPY", 14)
def ThirtyMinuteBarHandler(self, sender, bar):
self.Debug(str(self.Time) + " " + str(bar))
def OnData(self, data):
'''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
'''
#if not self.Portfolio.Invested:
# self.SetHoldings("IBM", .01)
if not self.rsi.IsReady:
return
if self.rsi.Current.Value < 30 and self.Portfolio["SPY"].Invested <= 0:
self.Debug("RSI is less then 30")
a = self.MarketOrder("SPY", 1)
b = a.AverageFillPrice
self.Debug("Market Order Fill Price: {0}".format(a.AverageFillPrice))
self.Debug(a)
self.Log("testlog")
self.Debug("Market order was placed")
if self.rsi.Current.Value > 70:
self.Debug("RSI is greater then 70")
self.Liquidate()
def OnEndOfDay(self):
self.Plot("Indicators","RSI", self.rsi.Current.Value)