| Overall Statistics |
|
Total Trades 251 Average Win 2.54% Average Loss -1.29% Compounding Annual Return 14.990% Drawdown 18.000% Expectancy 0.546 Net Profit 149.176% Sharpe Ratio 0.951 Probabilistic Sharpe Ratio 38.332% Loss Rate 48% Win Rate 52% Profit-Loss Ratio 1.97 Alpha 0.133 Beta -0.027 Annual Standard Deviation 0.136 Annual Variance 0.019 Information Ratio 0.007 Tracking Error 0.214 Treynor Ratio -4.747 Total Fees $251.00 Estimated Strategy Capacity $30000000.00 Lowest Capacity Asset QQQ RIWIV7K5Z9LX |
class BootCampTask(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2015, 1, 1)
# self.SetEndDate(2014, 2, 20)
self.SetCash(10000)
self.vix = self.AddFuture(Futures.Indices.VIX)
self.qqq = self.AddEquity('QQQ')
self.tlt = self.AddEquity('TLT')
self.vix.SetFilter(0, 65)
self.Schedule.On(self.DateRules.EveryDay("QQQ"), \
self.TimeRules.BeforeMarketClose("QQQ", 10), \
self.EveryDayBeforeMarketClose)
def OnData(self, slice):
# Loop over each available futures chain from slice.FutureChains data
for chain in slice.FutureChains:
self.nearestContracts = [contract for contract in chain.Value]
# If the length of contracts in this chain is zero, continue to the next chain
if len(self.nearestContracts) == 0:
continue
# Sort our contracts by Expiry
sortedByExpContracts = sorted(self.nearestContracts, key=lambda k : k.Expiry)
#4. Save the contract
self.front = sortedByExpContracts[0]
self.second = sortedByExpContracts[1]
r=self.second.LastPrice
def EveryDayBeforeMarketClose(self):
if (((self.second.LastPrice / self.front.LastPrice - 1) * 100) > 6):
if self.ActiveSecurities["TLT"].Invested:
self.Liquidate("TLT")
self.SetHoldings("QQQ", 1)
if ((self.second.LastPrice / self.front.LastPrice - 1) * 100) < 5:
if self.ActiveSecurities["QQQ"].Invested:
self.Liquidate("QQQ")
self.SetHoldings("TLT", 1)
self.check = (self.second.LastPrice/ self.second.LastPrice - 1) * 100