| Overall Statistics |
|
Total Trades 4 Average Win 0% Average Loss 0% Compounding Annual Return 5877.111% Drawdown 0.300% Expectancy 0 Net Profit 3.419% Sharpe Ratio 69.491 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 15.927 Beta 1.348 Annual Standard Deviation 0.232 Annual Variance 0.054 Information Ratio 104.784 Tracking Error 0.153 Treynor Ratio 11.979 Total Fees $8.09 |
class QInOut(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020,1,1)
self.SetEndDate(2020,1,5)
self.SetCash(100000)
self.SetWarmUp(timedelta(days=400))
#self.SetWarmUp(100,Resolution.Hour)
self.TickerTable = {}
self.InEquity="QQQ"
self.tickers = ["QQQ","TLT"]
for ticker in self.tickers:
# --------- Add Equity
self.AddEquity(ticker, Resolution.Hour)
# --------- Add Equity indicators
rsi = self.RSI(ticker, 14, MovingAverageType.DoubleExponential, Resolution.Daily)
rc = self.RC(ticker,14, 2, Resolution.Daily)
ppo = self.PPO(ticker, 10,12, MovingAverageType.Exponential, Resolution.Daily)
symbolData = SymbolData(ticker, rsi, rc, ppo)
self.TickerTable[ticker] = symbolData
self.Schedule.On(self.DateRules.EveryDay("QQQ"),self.TimeRules.AfterMarketOpen("QQQ",0), self.Trade)
def OnData(self, data):
# Problem 1 -------------------- Indicator not ready
if not not self.TickerTable["QQQ"].Rsi.IsReady:
self.Debug("RSI not ready")
return
if not self.TickerTable["QQQ"].Ppo.IsReady:
self.Debug("PPO not ready")
return
if not self.TickerTable["QQQ"].Rc.IsReady:
self.Debug("RC not ready")
return
def Trade(self):
self.InEquity_RSI = self.TickerTable[self.InEquity].Rsi.Current.Value
self.InEquity_PPO = self.TickerTable[self.InEquity].Ppo.Current.Value
self.InEquity_SLOPE = self.TickerTable[self.InEquity].Rc.Slope.Current.Value
# Problem 2 ------------ if u execute this at Marketclose .... Insufucuuent margin
self.SetHoldings("TLT",1.0,False,"test")
self.SetHoldings("QQQ",1.0,False,"test")
self.SetHoldings("TLT",1.0,False,"test")
# Problem 3 & 4 ------------- If u fetch QQQ on Before MarketOpen at Hour Resolution on Daily resolution... Indicators data shift by 1 day and Data Stale
self.Debug(f"{self.Time} PPO:{round(self.InEquity_PPO,2)} Slope:{round(self.InEquity_SLOPE,2)} RSI:{round(self.InEquity_RSI,2)}")
class SymbolData:
def __init__(self, symbol, rsi, rc, ppo):
self.Symbol = symbol
self.Rsi = rsi
self.Rc = rc
self.Ppo = ppo