| Overall Statistics |
|
Total Trades 14 Average Win 0% Average Loss 0% Compounding Annual Return 36.219% Drawdown 5.400% Expectancy 0 Net Profit 37.844% Sharpe Ratio 2.707 Probabilistic Sharpe Ratio 95.915% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.197 Beta 0.404 Annual Standard Deviation 0.114 Annual Variance 0.013 Information Ratio 0.239 Tracking Error 0.126 Treynor Ratio 0.767 Total Fees $14.00 |
class UncoupledMultidimensionalAutosequencers(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019, 1, 1) # Set Start Date
self.SetCash(100000) # Set Strategy Cash
tickers = ["SPY", "TLT"]
# Dictionary to hold Symbol Data
self.symbolData = {}
for ticker in tickers:
# Add equity data
symbol = self.AddEquity(ticker, Resolution.Daily).Symbol
# Create symbol data for respective symbol
self.symbolData[symbol] = SymbolData(self, symbol)
def OnData(self, data):
# Make sure indicators and rolling windows are ready
if not all([symbol.IsReady for symbol in self.symbolData.values()]):
return
for symbol, value in self.symbolData.items():
# If the ADX today is higher than ADX yesterday
if value.adxWindow[0] > value.adxWindow[1]:
self.MarketOrder(symbol, 100)
class SymbolData:
def __init__(self, algorithm, symbol):
self.algorithm = algorithm
self.symbol = symbol
self.adx = algorithm.ADX(symbol, 14, Resolution.Daily) # Define our indicator
self.adxWindow = RollingWindow[IndicatorDataPoint](2) # Define our rolling window to hold indicator points
self.adx.Updated += self.OnAdxUpdated # Set our event handler
def OnAdxUpdated(self, sender, updated):
if self.adx.IsReady:
self.adxWindow.Add(updated) # Add updated indicator data to rolling window
@property
def IsReady(self):
return self.adx.IsReady and self.adxWindow.IsReady