| Overall Statistics |
|
Total Trades 19 Average Win 35.39% Average Loss 0% Compounding Annual Return 24.415% Drawdown 18.700% Expectancy 0 Net Profit 1781.830% Sharpe Ratio 1.447 Probabilistic Sharpe Ratio 85.411% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.223 Beta 0.299 Annual Standard Deviation 0.18 Annual Variance 0.032 Information Ratio 0.611 Tracking Error 0.221 Treynor Ratio 0.869 Total Fees $467.26 Estimated Strategy Capacity $58000000.00 Lowest Capacity Asset QQQ RIWIV7K5Z9LX |
## SIMON LesFlex June 2021 ##
## Modified by Vladimir
from QuantConnect.Python import PythonQuandl
# -----------------------------------------------
STOCK = 'QQQ'; BOND = 'TLT'; MA = 2; MOM = 1;
# -----------------------------------------------
class LeadingIndicator(QCAlgorithm):
def Initialize(self):
self.quandlCode = "OECD/KEI_LOLITOAA_KOR_ST_M" # LeadInd
## Optional argument - personal token necessary for restricted dataset
Quandl.SetAuthCode("MLNarxdsMU92vk-ZJDvg")
self.SetStartDate(2008,1,1)
self.SetEndDate(2021, 6, 4)
self.SetCash(100000)
self.SetWarmup((MA + MOM)*21, Resolution.Daily)
self.init = True
self.AddData(QuandlCustomColumns, self.quandlCode, Resolution.Daily, TimeZones.NewYork)
self.sma = self.SMA(self.quandlCode, MA)
self.mom = self.MOMP(self.quandlCode, MOM)
self.stock = self.AddEquity(STOCK, Resolution.Hour).Symbol
self.bond = self.AddEquity(BOND, Resolution.Hour).Symbol
self.Schedule.On(self.DateRules.WeekStart(self.stock), self.TimeRules.AfterMarketOpen(self.stock, 31),
self.Rebalance)
def Rebalance(self):
if self.IsWarmingUp or not self.mom.IsReady or not self.sma.IsReady: return
initial_asset = self.stock if self.mom.Current.Value > 0 else self.bond
if self.init:
self.SetHoldings(initial_asset, 1)
self.init = False
if self.mom.Current.Value > 0 and not self.Securities[self.stock].Invested:
self.Liquidate(self.bond)
self.SetHoldings(self.stock, 1)
# self.Debug("Purchased {0} >> {1}".format(self.stock, self.Time))
elif self.mom.Current.Value < 0 and self.sma.Current.Value < 100 and self.Securities[self.stock].Invested:
self.Liquidate(self.stock)
self.SetHoldings(self.bond, 1)
# self.Debug("Liquidated {0} >> {1}".format(self.stock, self.Time))
self.Plot("LeadInd", "SMA(LeadInd)", self.sma.Current.Value)
self.Plot("LeadInd", "THRESHOLD", 100)
self.Plot("MOMP", "MOMP(LeadInd)", self.mom.Current.Value)
self.Plot("MOMP", "THRESHOLD", 0)
class QuandlCustomColumns(PythonQuandl):
def __init__(self):
self.ValueColumnName = "Value"