Overall Statistics Total Trades 2378 Average Win 2.54% Average Loss -1.07% Compounding Annual Return 164.109% Drawdown 26.000% Expectancy 0.547 Net Profit 65215.521% Sharpe Ratio 2.63 Loss Rate 54% Win Rate 46% Profit-Loss Ratio 2.38 Alpha 0.732 Beta 0.319 Annual Standard Deviation 0.324 Annual Variance 0.105 Information Ratio 0.945 Tracking Error 0.499 Treynor Ratio 2.678 Total Fees \$727298.46
```import numpy as np

from System import *
from NodaTime import DateTimeZone
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Brokerages import *
from QuantConnect.Data.Market import *

class BasicTemplateAlgorithm(QCAlgorithm):

def Initialize(self):
# Set the cash we'd like to use for our backtest
# This is ignored in live trading
self.SetCash(37000)

# Start and end dates for the backtest.
# These are ignored in live trading.
self.SetStartDate(2011,06,8)
self.SetEndDate(2018,2,6)

#Assets predetermined
self.svxy = self.AddEquity("SVXY", Resolution.Hour, None, True, 1, True).Symbol
self.spy = self.AddEquity("SPY", Resolution.Minute, None, True, 1, True).Symbol

# Indicators
self.emaBig = self.EMA("SVXY", 5, Resolution.Hour)
self.emaSmall = self.EMA("SVXY", 2, Resolution.Hour)

# Schedules
self.Schedule.On(self.DateRules.EveryDay("SVXY"), self.TimeRules.At(16, 1), Action(self.EveryDayBeforeMarketClose))
self.Schedule.On(self.DateRules.EveryDay("SVXY"), self.TimeRules.At(9, 59), Action(self.EveryDayAfterMarketOpen))
self.Schedule.On(self.DateRules.On(2018, 1, 22), self.TimeRules.At(13, 0), Action(self.SpecificTime))

# Timers
self.w = 1

# Set benchmark
self.SetBenchmark("SVXY")

# Get warmup data so that the Algorithm can start trading
self.SetWarmUp(5)

# Counters
self.case1 = 0
self.case2 = 0

def OnData(self, data):

if self.w == 0:

if not self.Portfolio.Invested:
if self.emaBig < self.emaSmall:
self.case1 += 1
self.SetHoldings(self.svxy, 0.85)

else:
if self.emaBig > self.emaSmall:
self.case2 += 1
self.SetHoldings(self.svxy, 0)

def EveryDayBeforeMarketClose(self):
if self.w == 0:
self.w = 1
#self.Log('Market Close')

def EveryDayAfterMarketOpen(self):
self.w = 0
#self.Log('Market Open')

def SpecificTime(self):
self.Log('Case 1: {}'.format(self.case1))
self.Log('Case 2: {}'.format(self.case2))                        ```