Overall Statistics
Total Trades
420
Average Win
12.06%
Average Loss
-4.08%
Compounding Annual Return
38.353%
Drawdown
37.800%
Expectancy
0.590
Net Profit
4356.196%
Sharpe Ratio
0.992
Probabilistic Sharpe Ratio
28.990%
Loss Rate
60%
Win Rate
40%
Profit-Loss Ratio
2.96
Alpha
0.201
Beta
1.129
Annual Standard Deviation
0.321
Annual Variance
0.103
Information Ratio
0.768
Tracking Error
0.28
Treynor Ratio
0.282
Total Fees
$55686.30
Estimated Strategy Capacity
$720000.00
Lowest Capacity Asset
SVXY V0H08FY38ZFP
Portfolio Turnover
9.60%
#region imports
from AlgorithmImports import *
#endregion
class SleepyFluorescentYellowCat(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2011, 12, 1)
        self.SetCash(100000) 
        self.AddEquity('SVXY',Resolution.Minute)
        res=Resolution.Daily
        self.uvxy=self.AddEquity('UVXY',res).Symbol
        self.bb=self.BB(self.uvxy,10,2,res)
        self.sma=self.SMA(self.uvxy,4,res)
        self.rc=self.RC(self.uvxy,6,0.3,res)
        self.trigger=False
        self.buy=False
        self.hold=False
        self.sell=False

    def OnData(self, data):
        #self.AddRiskManagement(MaximumDrawdownPercentPortfolio(0.10))
        if self.bb.IsReady and self.uvxy in data.Bars and self.sma.IsReady:
            vix=data[self.uvxy].Close
            if self.rc.UpperChannel.Current.Value<vix:
                self.trigger=True

            if self.trigger and self.sma.Current.Value>vix:
                self.buy=True

            if self.hold and (vix<(self.bb.MiddleBand.Current.Value-self.bb.StandardDeviation.Current.Value)):
                self.sell=True
                
            
        if self.buy and data.ContainsKey('SVXY'):
            self.SetHoldings('SVXY',1)
            self.trigger=False
            self.buy=False
            self.hold=True

        if data.ContainsKey('SVXY') and (self.sell or self.Portfolio['SVXY'].UnrealizedProfitPercent<-0.04):
            self.SetHoldings('SVXY',0)
            self.hold=False
            self.sell=False